REGRESSION(r182286): Tatechuyoko following ruby is drawn too far to the right
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2015 23:20:12 +0000 (23:20 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Nov 2015 23:20:12 +0000 (23:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150923

Reviewed by Zalan Bujtas.

Source/WebCore:

Ever since r182286, expansion opportunities in justified ruby were moved to their neighboring
elements (thereby forbidding trailing nor leading expansions inside ruby). However, when the
neighboring element is tatechuyoko, we will erroneously honor the expansion opportunity inside
the tatechuyoko, thereby moving it horizontally.

Tatechuyoko should never have expansion opportunities inside it.

Test: fast/text/ruby-justify-tatechuyoko.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::expansionBehaviorForInlineTextBox):

LayoutTests:

* fast/text/ruby-justify-tatechuyoko-expected.html: Added.
* fast/text/ruby-justify-tatechuyoko.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192120 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/text/ruby-justify-tatechuyoko-expected.html [new file with mode: 0755]
LayoutTests/fast/text/ruby-justify-tatechuyoko.html [new file with mode: 0755]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlockLineLayout.cpp

index dad673d..555345f 100644 (file)
@@ -1,3 +1,13 @@
+2015-11-06  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        REGRESSION(r182286): Tatechuyoko following ruby is drawn too far to the right
+        https://bugs.webkit.org/show_bug.cgi?id=150923
+
+        Reviewed by Zalan Bujtas.
+
+        * fast/text/ruby-justify-tatechuyoko-expected.html: Added.
+        * fast/text/ruby-justify-tatechuyoko.html: Added.
+
 2015-11-06  Ryan Haddad  <ryanhaddad@apple.com>
 
         Marking fast/canvas/webgl/oes-texture-half-float-linear.html as flaky on mac
diff --git a/LayoutTests/fast/text/ruby-justify-tatechuyoko-expected.html b/LayoutTests/fast/text/ruby-justify-tatechuyoko-expected.html
new file mode 100755 (executable)
index 0000000..3274532
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+<meta charset="UTF-8">\r
+</head>\r
+<body>\r
+This test makes sure that tatechuyoko which directly follows ruby is properly left-aligned.\r
+<div style="text-align: justify; max-height: 7em; font-size: 40px; -webkit-writing-mode: vertical-rl;" lang="ja">この文章<span style="-webkit-text-combine: horizontal;">99</span>は斜下付サンプルです。</div>\r
+</body>\r
+</html>\r
diff --git a/LayoutTests/fast/text/ruby-justify-tatechuyoko.html b/LayoutTests/fast/text/ruby-justify-tatechuyoko.html
new file mode 100755 (executable)
index 0000000..1a03249
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE html>\r
+<html>\r
+<head>\r
+<meta charset="UTF-8">\r
+</head>\r
+<body>\r
+This test makes sure that tatechuyoko which directly follows ruby is properly left-aligned.\r
+<div style="text-align: justify; max-height: 7em; font-size: 40px; -webkit-writing-mode: vertical-rl;" lang="ja">この<ruby>文章<rt style="color: white;">ルビ</rt></ruby><span style="-webkit-text-combine: horizontal;">99</span>は斜下付サンプルです。</div>\r
+</body>\r
+</html>\r
index 16d59e3..c0f7480 100644 (file)
@@ -1,3 +1,22 @@
+2015-11-06  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        REGRESSION(r182286): Tatechuyoko following ruby is drawn too far to the right
+        https://bugs.webkit.org/show_bug.cgi?id=150923
+
+        Reviewed by Zalan Bujtas.
+
+        Ever since r182286, expansion opportunities in justified ruby were moved to their neighboring
+        elements (thereby forbidding trailing nor leading expansions inside ruby). However, when the
+        neighboring element is tatechuyoko, we will erroneously honor the expansion opportunity inside
+        the tatechuyoko, thereby moving it horizontally.
+
+        Tatechuyoko should never have expansion opportunities inside it.
+
+        Test: fast/text/ruby-justify-tatechuyoko.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::expansionBehaviorForInlineTextBox):
+
 2015-11-06  Mario Sanchez Prada  <mario@endlessm.com>
 
         Layout Test accessibility/win/linked-elements.html is crashing on win debug
index 5381b82..953a8ca 100644 (file)
@@ -717,12 +717,15 @@ void RenderBlockFlow::computeInlineDirectionPositionsForLine(RootInlineBox* line
 
 static inline ExpansionBehavior expansionBehaviorForInlineTextBox(RenderBlockFlow& block, InlineTextBox& textBox, BidiRun* previousRun, BidiRun* nextRun, ETextAlign textAlign, bool isAfterExpansion)
 {
+    // Tatechuyoko is modeled as the Object Replacement Character (U+FFFC), which can never have expansion opportunities inside nor intrinsically adjacent to it.
+    if (textBox.renderer().style().textCombine() == TextCombineHorizontal)
+        return ForbidLeadingExpansion | ForbidTrailingExpansion;
+
     ExpansionBehavior result = 0;
     bool setLeadingExpansion = false;
     bool setTrailingExpansion = false;
     if (textAlign == JUSTIFY) {
-        // If the next box is ruby, and we're justifying, and the first box in the ruby base has a leading expansion, and we are a text box, then
-        // force a trailing expansion.
+        // If the next box is ruby, and we're justifying, and the first box in the ruby base has a leading expansion, and we are a text box, then force a trailing expansion.
         if (nextRun && is<RenderRubyRun>(nextRun->renderer()) && downcast<RenderRubyRun>(nextRun->renderer()).rubyBase() && nextRun->renderer().style().collapseWhiteSpace()) {
             auto& rubyBase = *downcast<RenderRubyRun>(nextRun->renderer()).rubyBase();
             if (rubyBase.firstRootBox() && !rubyBase.firstRootBox()->nextRootBox()) {