Flex child does not get repainted when it is inserted back to the render tree.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2018 19:31:15 +0000 (19:31 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Apr 2018 19:31:15 +0000 (19:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184361
<rdar://problem/34528716>

Reviewed by Antti Koivisto.

Source/WebCore:

As with any regular block children, we should issue full repaint for flexbox items on their
first layout (see RenderBlockFlow::layoutBlockChild()).

Test: fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):

LayoutTests:

* fast/flexbox/missing-repaint-when-flext-item-never-had-layout-expected.txt: Added.
* fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout-expected.txt [new file with mode: 0644]
LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlexibleBox.cpp

index 927fe4a..443a86e 100644 (file)
@@ -1,3 +1,14 @@
+2018-04-06  Zalan Bujtas  <zalan@apple.com>
+
+        Flex child does not get repainted when it is inserted back to the render tree.
+        https://bugs.webkit.org/show_bug.cgi?id=184361
+        <rdar://problem/34528716>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/flexbox/missing-repaint-when-flext-item-never-had-layout-expected.txt: Added.
+        * fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html: Added.
+
 2018-04-06  Daniel Bates  <dabates@apple.com>
 
         Emit a more informative message when a script is blocked due to "X-Content-Type: nosniff"
diff --git a/LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout-expected.txt b/LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout-expected.txt
new file mode 100644 (file)
index 0000000..6051996
--- /dev/null
@@ -0,0 +1,6 @@
+PASS if visible
+(repaint rects
+  (rect 8 8 200 18)
+  (rect 8 8 200 200)
+)
+
diff --git a/LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html b/LayoutTests/fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html
new file mode 100644 (file)
index 0000000..47767f8
--- /dev/null
@@ -0,0 +1,45 @@
+<style>
+  .parent {
+    width: 200px;
+    height: 200px;
+    background: red;
+    display: flex;
+  }
+
+  .child {
+    display: inline;
+    width: 200px;
+    height: 200px;
+    background: green;
+    border: 0;
+  }
+</style>
+
+
+<div class=parent><span class=child id=foobar>PASS if visible</span></div>
+<pre id=repaintRects></pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+setTimeout(function() {
+    foobar.style.display = "none";
+    document.body.offsetWidth;
+    setTimeout(function() {
+        if (window.internals)
+            internals.startTrackingRepaints();
+        
+        foobar.style.display = "inline";
+        document.body.offsetWidth;
+        
+        if (window.testRunner) {
+            if (window.internals) {
+                repaintRects.innerText = internals.repaintRectsAsText();
+                internals.stopTrackingRepaints();
+            }
+            testRunner.notifyDone();
+        }
+    }, 0);
+}, 0);
+</script>
index 1f8d8ae..7486e00 100644 (file)
@@ -1,3 +1,19 @@
+2018-04-06  Zalan Bujtas  <zalan@apple.com>
+
+        Flex child does not get repainted when it is inserted back to the render tree.
+        https://bugs.webkit.org/show_bug.cgi?id=184361
+        <rdar://problem/34528716>
+
+        Reviewed by Antti Koivisto.
+
+        As with any regular block children, we should issue full repaint for flexbox items on their
+        first layout (see RenderBlockFlow::layoutBlockChild()).
+
+        Test: fast/flexbox/missing-repaint-when-flext-item-never-had-layout.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+
 2018-04-06  Ms2ger  <Ms2ger@igalia.com>
 
         Support transferring ImageBitmap objects
index efb9a27..7b4013b 100644 (file)
@@ -1552,6 +1552,7 @@ void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, Vect
     for (size_t i = 0; i < children.size(); ++i) {
         const auto& flexItem = children[i];
         auto& child = flexItem.box;
+        bool childHadLayout = child.everHadLayout();
 
         ASSERT(!flexItem.box.isOutOfFlowPositioned());
 
@@ -1582,6 +1583,10 @@ void RenderFlexibleBox::layoutAndPlaceChildren(LayoutUnit& crossAxisOffset, Vect
         if (child.needsLayout())
             m_relaidOutChildren.add(&child);
         child.layoutIfNeeded();
+        if (!childHadLayout && child.checkForRepaintDuringLayout()) {
+            child.repaint();
+            child.repaintOverhangingFloats(true);
+        }
 
         updateAutoMarginsInMainAxis(child, autoMarginOffset);