Diff
Modified: branches/safari-600.5-branch/LayoutTests/ChangeLog (179905 => 179906)
--- branches/safari-600.5-branch/LayoutTests/ChangeLog 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/LayoutTests/ChangeLog 2015-02-11 01:33:24 UTC (rev 179906)
@@ -1,3 +1,22 @@
+2015-02-05 Lucas Forschler <[email protected]>
+
+ Merge r179366
+
+ 2015-01-20 David Hyatt <[email protected]>
+
+ Japanese line breaking rules need to be respected before and after Ruby.
+ https://bugs.webkit.org/show_bug.cgi?id=91588
+ <rdar://problem/17306535>
+
+ Reviewed by Dean Jackson.
+
+ * fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt:
+ * fast/ruby/ruby-block-style-not-updated-with-before-after-content.html:
+ * fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt:
+ * fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html:
+ * fast/ruby/ruby-punctuation-avoid-breaking-expected.html: Added.
+ * fast/ruby/ruby-punctuation-avoid-breaking.html: Added.
+
2015-01-24 David Kilzer <[email protected]>
Merge r176262.
Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt (179905 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content-expected.txt 2015-02-11 01:33:24 UTC (rev 179906)
@@ -4,9 +4,9 @@
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderRuby (block) {RUBY} at (0,0) size 784x384 [color=#0000FF]
- RenderInline (generated) at (0,0) size 512x128 [color=#FFA500]
- RenderText at (0,0) size 512x128
- text run at (0,0) width 512: "1234"
+ RenderInline (generated) at (0,0) size 640x128 [color=#FFA500]
+ RenderText at (0,0) size 640x128
+ text run at (0,0) width 640: "1234 "
RenderRubyRun (anonymous) at (0,128) size 512x128
RenderRubyBase (anonymous) at (0,0) size 512x128
RenderText {#text} at (0,0) size 512x128
Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content.html (179905 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content.html 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-block-style-not-updated-with-before-after-content.html 2015-02-11 01:33:24 UTC (rev 179906)
@@ -4,12 +4,12 @@
<style>
#test::before
{
- content: "1234";
+ content: "1234 ";
color: orange;
}
#test::after
{
- content: "4578";
+ content: " 4578";
color: yellow;
}
</style>
Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt (179905 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content-expected.txt 2015-02-11 01:33:24 UTC (rev 179906)
@@ -4,10 +4,10 @@
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock (anonymous) at (0,0) size 784x384
- RenderRuby (inline) {RUBY} at (0,0) size 512x384 [color=#0000FF]
- RenderInline (generated) at (0,0) size 512x128 [color=#FFA500]
- RenderText at (0,0) size 512x128
- text run at (0,0) width 512: "1234"
+ RenderRuby (inline) {RUBY} at (0,0) size 640x384 [color=#0000FF]
+ RenderInline (generated) at (0,0) size 640x128 [color=#FFA500]
+ RenderText at (0,0) size 640x128
+ text run at (0,0) width 640: "1234 "
RenderRubyRun (anonymous) at (0,128) size 512x128
RenderRubyBase (anonymous) at (0,0) size 512x128
RenderText {#text} at (0,0) size 512x128
Modified: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html (179905 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-inline-style-not-updated-with-before-after-content.html 2015-02-11 01:33:24 UTC (rev 179906)
@@ -4,12 +4,12 @@
<style>
#test::before
{
- content: "1234";
+ content: "1234 ";
color: orange;
}
#test::after
{
- content: "4578";
+ content: " 4578";
color: yellow;
}
</style>
Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking-expected.html (from rev 179722, branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking-expected.html) (0 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking-expected.html (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking-expected.html 2015-02-11 01:33:24 UTC (rev 179906)
@@ -0,0 +1,17 @@
+<html lang="ja">
+<head>
+<meta http-equiv ="content-type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<div>
+<p>Japanese Line breaking rule "Kinsoku" Test Case. We should not break before or after the Ruby.
+<div style="position: absolute; top: 50px; left: 3%; width: 100px;">
+「<ruby>直帰<rt>ちょっき</rt></ruby>」
+</div>
+<div>
+<div style="position: absolute; top: 50px; left: 200px;-webkit-writing-mode: vertical-rl; height: 100px;">
+「<ruby>直帰<rt>ちょっき</rt></ruby>」
+</div>
+
+</body>
+</html>
\ No newline at end of file
Copied: branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking.html (from rev 179722, branches/safari-600.1.4.15-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking.html) (0 => 179906)
--- branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking.html (rev 0)
+++ branches/safari-600.5-branch/LayoutTests/fast/ruby/ruby-punctuation-avoid-breaking.html 2015-02-11 01:33:24 UTC (rev 179906)
@@ -0,0 +1,17 @@
+<html lang="ja">
+<head>
+<meta http-equiv ="content-type" content="text/html; charset=UTF-8">
+</head>
+<body>
+<div>
+<p>Japanese Line breaking rule "Kinsoku" Test Case. We should not break before or after the Ruby.
+<div style="position: absolute; top: 50px; left: 3%; width: 40px;">
+「<ruby>直帰<rt>ちょっき</rt></ruby>」
+</div>
+<div>
+<div style="position: absolute; top: 50px; left: 200px;-webkit-writing-mode: vertical-rl; height: 40px;">
+「<ruby>直帰<rt>ちょっき</rt></ruby>」
+</div>
+
+</body>
+</html>
\ No newline at end of file
Modified: branches/safari-600.5-branch/Source/WebCore/ChangeLog (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/ChangeLog 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/ChangeLog 2015-02-11 01:33:24 UTC (rev 179906)
@@ -1,3 +1,47 @@
+2015-02-05 Lucas Forschler <[email protected]>
+
+ Merge r179366
+
+ 2015-01-20 David Hyatt <[email protected]>
+
+ Japanese line breaking rules need to be respected before and after Ruby.
+ https://bugs.webkit.org/show_bug.cgi?id=91588
+ <rdar://problem/17306535>
+
+ Reviewed by Dean Jackson.
+
+ Added fast/ruby/ruby-punctuation-avoid-breaking.html.
+
+ This patch has to add support for following line breaking rules at both
+ sides of a Ruby boundary. For breaking before a Ruby, unfortunately we
+ just hard-code the rules (and apply this hard-coding only to Ruby and not
+ to other inline replaced elements).
+
+ For breaking after a Ruby we do better. The Ruby run caches its prior characters
+ and line layout is able to obtain them and use them when deciding whether or not
+ to break. This means for the "after" side of a Ruby, we're able to behave the same
+ as if no Ruby was used.
+
+ * rendering/RenderBlockFlow.h:
+ (WebCore::RenderBlockFlow::cachePriorCharactersIfNeeded):
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
+ * rendering/RenderRubyBase.cpp:
+ (WebCore::RenderRubyBase::cachePriorCharactersIfNeeded):
+ * rendering/RenderRubyBase.h:
+ * rendering/RenderRubyRun.cpp:
+ (WebCore::RenderRubyRun::RenderRubyRun):
+ (WebCore::RenderRubyRun::updatePriorContextFromCachedBreakIterator):
+ (WebCore::RenderRubyRun::canBreakBefore):
+ * rendering/RenderRubyRun.h:
+ * rendering/RenderRubyText.cpp:
+ (WebCore::RenderRubyText::canBreakBefore):
+ * rendering/RenderRubyText.h:
+ * rendering/line/BreakingContextInlineHeaders.h:
+ (WebCore::BreakingContext::handleReplaced):
+ (WebCore::BreakingContext::canBreakAtThisPosition):
+ (WebCore::BreakingContext::commitAndUpdateLineBreakIfNeeded):
+
2015-02-10 Lucas Forschler <[email protected]>
Merge r177849
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/InlineBox.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -22,8 +22,10 @@
#define InlineBox_h
#include "RenderBoxModelObject.h"
+#include "TextBreakIterator.h"
#include "TextDirection.h"
+
namespace WebCore {
class HitTestRequest;
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockFlow.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -462,7 +462,9 @@
virtual void computeColumnCountAndWidth();
virtual bool requiresColumns(int) const;
-
+
+ virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) {};
+
private:
bool recomputeLogicalWidthAndColumnWidth();
LayoutUnit columnGap() const;
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderBlockLineLayout.cpp 2015-02-11 01:33:24 UTC (rev 179906)
@@ -1143,6 +1143,7 @@
WordMeasurements wordMeasurements;
end = lineBreaker.nextLineBreak(resolver, layoutState.lineInfo(), renderTextInfo, lastFloatFromPreviousLine, consecutiveHyphenatedLines, wordMeasurements);
+ cachePriorCharactersIfNeeded(renderTextInfo.m_lineBreakIterator);
renderTextInfo.m_lineBreakIterator.resetPriorContext();
if (resolver.position().atEnd()) {
// FIXME: We shouldn't be creating any runs in nextLineBreak to begin with!
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.cpp 2015-02-11 01:33:24 UTC (rev 179906)
@@ -154,4 +154,11 @@
logicalWidth -= inset;
}
+void RenderRubyBase::cachePriorCharactersIfNeeded(const LazyLineBreakIterator& lineBreakIterator)
+{
+ auto* run = rubyRun();
+ if (run)
+ run->setCachedPriorCharacters(lineBreakIterator.lastCharacter(), lineBreakIterator.secondToLastCharacter());
+}
+
} // namespace WebCore
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyBase.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -48,6 +48,8 @@
RenderRubyRun* rubyRun() const;
+ virtual void cachePriorCharactersIfNeeded(const LazyLineBreakIterator&) override;
+
private:
virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const;
virtual ETextAlign textAlignmentForLine(bool endsWithSoftBreak) const;
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.cpp 2015-02-11 01:33:24 UTC (rev 179906)
@@ -43,6 +43,8 @@
RenderRubyRun::RenderRubyRun(Document& document, PassRef<RenderStyle> style)
: RenderBlockFlow(document, WTF::move(style))
+ , m_lastCharacter(0)
+ , m_secondToLastCharacter(0)
{
setReplaced(true);
setInline(true);
@@ -327,4 +329,17 @@
endOverhang = std::min<int>(endOverhang, std::min<int>(toRenderText(endRenderer)->minLogicalWidth(), halfWidthOfFontSize));
}
+void RenderRubyRun::updatePriorContextFromCachedBreakIterator(LazyLineBreakIterator& iterator) const
+{
+ iterator.setPriorContext(m_lastCharacter, m_secondToLastCharacter);
+}
+
+bool RenderRubyRun::canBreakBefore(const LazyLineBreakIterator& iterator) const
+{
+ RenderRubyText* rubyText = this->rubyText();
+ if (!rubyText)
+ return true;
+ return rubyText->canBreakBefore(iterator);
+}
+
} // namespace WebCore
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyRun.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -67,6 +67,14 @@
static RenderRubyRun* staticCreateRubyRun(const RenderObject* parentRuby);
+ void updatePriorContextFromCachedBreakIterator(LazyLineBreakIterator&) const;
+ void setCachedPriorCharacters(UChar last, UChar secondToLast)
+ {
+ m_lastCharacter = last;
+ m_secondToLastCharacter = secondToLast;
+ }
+ bool canBreakBefore(const LazyLineBreakIterator&) const;
+
protected:
RenderRubyBase* createRubyBase() const;
@@ -75,6 +83,10 @@
virtual const char* renderName() const { return "RenderRubyRun (anonymous)"; }
virtual bool createsAnonymousWrapper() const { return true; }
virtual void removeLeftoverAnonymousBlock(RenderBlock*) { }
+
+private:
+ UChar m_lastCharacter;
+ UChar m_secondToLastCharacter;
};
RENDER_OBJECT_TYPE_CASTS(RenderRubyRun, isRubyRun())
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.cpp (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.cpp 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.cpp 2015-02-11 01:33:24 UTC (rev 179906)
@@ -93,4 +93,45 @@
return true;
}
+bool RenderRubyText::canBreakBefore(const LazyLineBreakIterator& iterator) const
+{
+ // FIXME: It would be nice to improve this so that it isn't just hard-coded, but lookahead in this
+ // case is particularly problematic.
+
+ if (!iterator.priorContextLength())
+ return true;
+ UChar ch = iterator.lastCharacter();
+ ULineBreak lineBreak = (ULineBreak)u_getIntPropertyValue(ch, UCHAR_LINE_BREAK);
+ // UNICODE LINE BREAKING ALGORITHM
+ // http://www.unicode.org/reports/tr14/
+ // And Requirements for Japanese Text Layout, 3.1.7 Characters Not Starting a Line
+ // http://www.w3.org/TR/2012/NOTE-jlreq-20120403/#characters_not_starting_a_line
+ switch (lineBreak) {
+ case U_LB_NONSTARTER:
+ case U_LB_CLOSE_PARENTHESIS:
+ case U_LB_CLOSE_PUNCTUATION:
+ case U_LB_EXCLAMATION:
+ case U_LB_BREAK_SYMBOLS:
+ case U_LB_INFIX_NUMERIC:
+ case U_LB_ZWSPACE:
+ case U_LB_WORD_JOINER:
+ return false;
+ default:
+ break;
+ }
+ // Special care for Requirements for Japanese Text Layout
+ switch (ch) {
+ case 0x2019: // RIGHT SINGLE QUOTATION MARK
+ case 0x201D: // RIGHT DOUBLE QUOTATION MARK
+ case 0x00BB: // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ case 0x2010: // HYPHEN
+ case 0x2013: // EN DASH
+ case 0x300C: // LEFT CORNER BRACKET
+ return false;
+ default:
+ break;
+ }
+ return true;
+}
+
} // namespace WebCore
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/RenderRubyText.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -45,7 +45,9 @@
virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
RenderRubyRun* rubyRun() const;
-
+
+ bool canBreakBefore(const LazyLineBreakIterator&) const;
+
private:
virtual const char* renderName() const override { return "RenderRubyText"; }
virtual bool isRubyText() const override { return true; }
Modified: branches/safari-600.5-branch/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h (179905 => 179906)
--- branches/safari-600.5-branch/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h 2015-02-11 01:06:01 UTC (rev 179905)
+++ branches/safari-600.5-branch/Source/WebCore/rendering/line/BreakingContextInlineHeaders.h 2015-02-11 01:33:24 UTC (rev 179906)
@@ -413,7 +413,8 @@
m_width.updateAvailableWidth(replacedBox.logicalHeight());
// Break on replaced elements if either has normal white-space.
- if ((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!m_current.renderer()->isImage() || m_allowImagesToBreak)) {
+ if ((m_autoWrap || RenderStyle::autoWrap(m_lastWS)) && (!m_current.renderer()->isImage() || m_allowImagesToBreak)
+ && (!m_current.renderer()->isRubyRun() || toRenderRubyRun(m_current.renderer())->canBreakBefore(m_renderTextInfo.m_lineBreakIterator))) {
m_width.commit();
m_lineBreak.moveToStartOf(m_current.renderer());
}
@@ -442,10 +443,13 @@
m_width.addUncommittedWidth(replacedLogicalWidth);
} else
m_width.addUncommittedWidth(replacedLogicalWidth);
- if (m_current.renderer()->isRubyRun())
+ if (m_current.renderer()->isRubyRun()) {
m_width.applyOverhang(toRenderRubyRun(m_current.renderer()), m_lastObject, m_nextObject);
- // Update prior line break context characters, using U+FFFD (OBJECT REPLACEMENT CHARACTER) for replaced element.
- m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter);
+ toRenderRubyRun(m_current.renderer())->updatePriorContextFromCachedBreakIterator(m_renderTextInfo.m_lineBreakIterator);
+ } else {
+ // Update prior line break context characters, using U+FFFD (OBJECT REPLACEMENT CHARACTER) for replaced element.
+ m_renderTextInfo.m_lineBreakIterator.updatePriorContext(replacementCharacter);
+ }
}
inline float firstPositiveWidth(const WordMeasurements& wordMeasurements)
@@ -951,7 +955,7 @@
return m_autoWrap;
bool currentIsTextOrEmptyInline = m_current.renderer()->isText() || (m_current.renderer()->isRenderInline() && isEmptyInline(toRenderInline(*m_current.renderer())));
if (!currentIsTextOrEmptyInline)
- return m_autoWrap;
+ return m_autoWrap && !m_current.renderer()->isRubyRun();
bool canBreakHere = !m_currentCharacterIsSpace && textBeginsWithBreakablePosition(m_nextObject);
@@ -998,7 +1002,7 @@
if (!m_current.renderer()->isFloatingOrOutOfFlowPositioned()) {
m_lastObject = m_current.renderer();
- if (m_lastObject->isReplaced() && m_autoWrap && (!m_lastObject->isImage() || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMarker(*m_lastObject).isInside())) {
+ if (m_lastObject->isReplaced() && m_autoWrap && !m_lastObject->isRubyRun() && (!m_lastObject->isImage() || m_allowImagesToBreak) && (!m_lastObject->isListMarker() || toRenderListMarker(*m_lastObject).isInside())) {
m_width.commit();
m_lineBreak.moveToStartOf(m_nextObject);
}