Title: [233767] trunk
Revision
233767
Author
[email protected]
Date
2018-07-12 07:23:45 -0700 (Thu, 12 Jul 2018)

Log Message

Newly added float should trigger full layout on the block.
https://bugs.webkit.org/show_bug.cgi?id=187251
<rdar://problem/41726137>

Reviewed by David Kilzer.

Source/WebCore:

RenderBlockFlow::determineStartPosition() is one of the places where we decide the extent of the line layout for the current block.
In here we try to figure out the first line in the block that requires layout. In certain cases when floats are present,
(due to their intrusive behavior) we just trigger a full layout on the entire block.
One of the special cases is when a new float is added to the block. determineStartPosition() checks for such floats (floats inserted
after the "last known float") and marks the block for full layout. However it missed the case when other, unrelated mutations happened
in addition to this newly inserted float. This patch fixes this case by checking if the floats after the "last know float" actually need layout.

Test: fast/inline/new-float-needs-layout-when-line-is-dirty.html

* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::determineStartPosition):

LayoutTests:

* fast/inline/new-float-needs-layout-when-line-is-dirty-expected.txt: Added.
* fast/inline/new-float-needs-layout-when-line-is-dirty.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (233766 => 233767)


--- trunk/LayoutTests/ChangeLog	2018-07-12 13:19:08 UTC (rev 233766)
+++ trunk/LayoutTests/ChangeLog	2018-07-12 14:23:45 UTC (rev 233767)
@@ -1,3 +1,14 @@
+2018-07-12  Zalan Bujtas  <[email protected]>
+
+        Newly added float should trigger full layout on the block.
+        https://bugs.webkit.org/show_bug.cgi?id=187251
+        <rdar://problem/41726137>
+
+        Reviewed by David Kilzer.
+
+        * fast/inline/new-float-needs-layout-when-line-is-dirty-expected.txt: Added.
+        * fast/inline/new-float-needs-layout-when-line-is-dirty.html: Added.
+
 2018-07-11  Youenn Fablet  <[email protected]>
 
         MediaDevices should derive from EventTarget in its IDL

Added: trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty-expected.txt (0 => 233767)


--- trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty-expected.txt	2018-07-12 14:23:45 UTC (rev 233767)
@@ -0,0 +1 @@
+Pass if no crashfoobar foobar foobar foobar foobar

Added: trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty.html (0 => 233767)


--- trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty.html	                        (rev 0)
+++ trunk/LayoutTests/fast/inline/new-float-needs-layout-when-line-is-dirty.html	2018-07-12 14:23:45 UTC (rev 233767)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+    border: 1px solid green;
+}
+
+#container {
+    width: 100px;
+    height: 200px;
+}
+
+#inlineblock {
+	display: inline-block;
+	width: 10px;
+	height: 10px;
+}
+
+.floatBox {
+	width: 30px;
+	height: 30px;
+	float: left;
+}
+</style>
+</head>
+<body>
+<div id=container>Pass if no crash<div id=inlineblock></div>foobar foobar foobar foobar foobar</div>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+document.body.offsetHeight;
+
+let floatBox = document.createElement("div");
+floatBox.className = "floatBox";
+inlineblock.style.height = "20px";
+container.appendChild(floatBox);
+
+document.body.offsetHeight;
+</script>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (233766 => 233767)


--- trunk/Source/WebCore/ChangeLog	2018-07-12 13:19:08 UTC (rev 233766)
+++ trunk/Source/WebCore/ChangeLog	2018-07-12 14:23:45 UTC (rev 233767)
@@ -1,3 +1,23 @@
+2018-07-12  Zalan Bujtas  <[email protected]>
+
+        Newly added float should trigger full layout on the block.
+        https://bugs.webkit.org/show_bug.cgi?id=187251
+        <rdar://problem/41726137>
+
+        Reviewed by David Kilzer.
+
+        RenderBlockFlow::determineStartPosition() is one of the places where we decide the extent of the line layout for the current block.
+        In here we try to figure out the first line in the block that requires layout. In certain cases when floats are present,
+        (due to their intrusive behavior) we just trigger a full layout on the entire block.
+        One of the special cases is when a new float is added to the block. determineStartPosition() checks for such floats (floats inserted
+        after the "last known float") and marks the block for full layout. However it missed the case when other, unrelated mutations happened
+        in addition to this newly inserted float. This patch fixes this case by checking if the floats after the "last know float" actually need layout.
+
+        Test: fast/inline/new-float-needs-layout-when-line-is-dirty.html
+
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::RenderBlockFlow::determineStartPosition):
+
 2018-07-12  Thibault Saunier  <[email protected]>
 
         [GStreamer] Add pads to the GstFlowCombiner in MediaStreamSrc

Modified: trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp (233766 => 233767)


--- trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2018-07-12 13:19:08 UTC (rev 233766)
+++ trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp	2018-07-12 14:23:45 UTC (rev 233767)
@@ -1834,8 +1834,19 @@
             }
         }
         // Check if a new float has been inserted after the last known float.
-        if (!currentLine && floatsIterator != end)
-            layoutState.markForFullLayout();
+        if (floatsIterator != end) {
+            if (!currentLine)
+                layoutState.markForFullLayout();
+            else {
+                for (; floatsIterator != end; ++floatsIterator) {
+                    auto& floatWithRect = *floatsIterator;
+                    if (!floatWithRect->renderer().needsLayout())
+                        continue;
+                    layoutState.markForFullLayout();
+                    break;
+                }
+            }
+        }
     }
 
     if (layoutState.isFullLayout()) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to