Title: [207275] trunk
Revision
207275
Author
za...@apple.com
Date
2016-10-12 20:48:54 -0700 (Wed, 12 Oct 2016)

Log Message

RenderRubyRun should not mark child renderers dirty at the end of layout.
https://bugs.webkit.org/show_bug.cgi?id=163359
<rdar://problem/28711840>

Reviewed by David Hyatt.

Source/WebCore:

The current layout logic does not support marking renderers dirty for subsequent layouts.
Layout needs to exit with a clean tree.
Should relayoutChild be insufficient, we could also mark the base/text dirty for the justified content.

Test: fast/ruby/rubyrun-has-bad-child.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::updateRubyForJustifiedText):
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::layout):
(WebCore::RenderRubyRun::layoutBlock):
* rendering/RenderRubyRun.h:

LayoutTests:

* fast/ruby/rubyrun-has-bad-child-expected.txt: Added.
* fast/ruby/rubyrun-has-bad-child.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207274 => 207275)


--- trunk/LayoutTests/ChangeLog	2016-10-13 03:16:15 UTC (rev 207274)
+++ trunk/LayoutTests/ChangeLog	2016-10-13 03:48:54 UTC (rev 207275)
@@ -1,3 +1,14 @@
+2016-10-12  Zalan Bujtas  <za...@apple.com>
+
+        RenderRubyRun should not mark child renderers dirty at the end of layout.
+        https://bugs.webkit.org/show_bug.cgi?id=163359
+        <rdar://problem/28711840>
+
+        Reviewed by David Hyatt.
+
+        * fast/ruby/rubyrun-has-bad-child-expected.txt: Added.
+        * fast/ruby/rubyrun-has-bad-child.html: Added.
+
 2016-10-12  Simon Fraser  <simon.fra...@apple.com>
 
         polygonPathFromPoints calls uncheckedAppend, but assertion size() < capacity() fails

Added: trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child-expected.txt (0 => 207275)


--- trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child-expected.txt	2016-10-13 03:48:54 UTC (rev 207275)
@@ -0,0 +1,2 @@
+PASS if no crash or assert in debug. r foobarfoobar
+

Added: trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child.html (0 => 207275)


--- trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child.html	                        (rev 0)
+++ trunk/LayoutTests/fast/ruby/rubyrun-has-bad-child.html	2016-10-13 03:48:54 UTC (rev 207275)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that we can rendere ruby with text-align justified properly.</title>
+<style>
+body {
+  text-align: justify;
+  font: 150px Litherum;
+}
+</style>
+</head>
+<body>
+PASS if no crash or assert in debug.
+<ruby><rb>r</rb>
+ <canvas id=canvasId></canvas></ruby>
+foobarfoobar<ruby><rt id=rtId></rt></ruby><div id=divId></div>
+</body>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+var rt = document.getElementById("rtId");
+var canvas = document.getElementById("canvasId");
+rt.parentNode.removeChild(rt);
+canvas.parentNode.insertBefore(rt, canvas);
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (207274 => 207275)


--- trunk/Source/WebCore/ChangeLog	2016-10-13 03:16:15 UTC (rev 207274)
+++ trunk/Source/WebCore/ChangeLog	2016-10-13 03:48:54 UTC (rev 207275)
@@ -1,3 +1,24 @@
+2016-10-12  Zalan Bujtas  <za...@apple.com>
+
+        RenderRubyRun should not mark child renderers dirty at the end of layout.
+        https://bugs.webkit.org/show_bug.cgi?id=163359
+        <rdar://problem/28711840>
+
+        Reviewed by David Hyatt.
+
+        The current layout logic does not support marking renderers dirty for subsequent layouts.
+        Layout needs to exit with a clean tree.
+        Should relayoutChild be insufficient, we could also mark the base/text dirty for the justified content.
+
+        Test: fast/ruby/rubyrun-has-bad-child.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::updateRubyForJustifiedText):
+        * rendering/RenderRubyRun.cpp:
+        (WebCore::RenderRubyRun::layout):
+        (WebCore::RenderRubyRun::layoutBlock):
+        * rendering/RenderRubyRun.h:
+
 2016-10-12  Simon Fraser  <simon.fra...@apple.com>
 
         Crash when using megaplan.ru

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (207274 => 207275)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2016-10-13 03:16:15 UTC (rev 207274)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2016-10-13 03:48:54 UTC (rev 207275)
@@ -580,12 +580,6 @@
     rubyRun.clearOverrideLogicalContentWidth();
     r.box()->setExpansion(newRubyRunWidth - r.box()->logicalWidth());
 
-    // This relayout caused the size of the RenderRubyText and the RenderRubyBase to change, dependent on the line's current expansion. Next time we relayout the
-    // RenderRubyRun, make sure that we relayout the RenderRubyBase and RenderRubyText as well.
-    rubyBase.setNeedsLayout(MarkOnlyThis);
-    if (RenderRubyText* rubyText = rubyRun.rubyText())
-        rubyText->setNeedsLayout(MarkOnlyThis);
-
     totalLogicalWidth += totalExpansion;
     expansionOpportunityCount -= totalOpportunitiesInRun;
 }

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.cpp (207274 => 207275)


--- trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2016-10-13 03:16:15 UTC (rev 207274)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.cpp	2016-10-13 03:48:54 UTC (rev 207275)
@@ -230,15 +230,26 @@
 {
     if (RenderRubyBase* base = rubyBase())
         base->reset();
+    RenderBlockFlow::layout();
+}
 
-    RenderBlockFlow::layout();
-    
+void RenderRubyRun::layoutBlock(bool relayoutChildren, LayoutUnit pageHeight)
+{
+    if (!relayoutChildren) {
+        // Since the extra relayout in RenderBlockFlow::updateRubyForJustifiedText() causes the size of the RenderRubyText/RenderRubyBase
+        // dependent on the line's current expansion, whenever we relayout the RenderRubyRun, we need to relayout the RenderRubyBase/RenderRubyText as well.
+        // FIXME: We should take the expansion opportunities into account if possible.
+        relayoutChildren = style().textAlign() == JUSTIFY;
+    }
+
+    RenderBlockFlow::layoutBlock(relayoutChildren, pageHeight);
+
     RenderRubyText* rt = rubyText();
     if (!rt)
         return;
 
     rt->setLogicalLeft(0);
-    
+
     // Place the RenderRubyText such that its bottom is flush with the lineTop of the first line of the RenderRubyBase.
     LayoutUnit lastLineRubyTextBottom = rt->logicalHeight();
     LayoutUnit firstLineRubyTextTop = 0;

Modified: trunk/Source/WebCore/rendering/RenderRubyRun.h (207274 => 207275)


--- trunk/Source/WebCore/rendering/RenderRubyRun.h	2016-10-13 03:16:15 UTC (rev 207274)
+++ trunk/Source/WebCore/rendering/RenderRubyRun.h	2016-10-13 03:48:54 UTC (rev 207275)
@@ -54,6 +54,7 @@
 
     RenderObject* layoutSpecialExcludedChild(bool relayoutChildren) override;
     void layout() override;
+    void layoutBlock(bool relayoutChildren, LayoutUnit pageHeight = 0) override;
 
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
     void addChild(RenderObject* child, RenderObject* beforeChild = 0) override;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to