Title: [278659] trunk
Revision
278659
Author
[email protected]
Date
2021-06-09 07:47:55 -0700 (Wed, 09 Jun 2021)

Log Message

[Flexbox] FlexItem stays invisible after initial layout
https://bugs.webkit.org/show_bug.cgi?id=226778

Reviewed by Simon Fraser.

Source/WebCore:

RenderFlexibleBox::layoutAndPlaceChildren() initiates repaint() on newly constructed flex items by checking their everHadLayout bit.
This is similar to what we do for regular block layout when block level boxes appear.
However flexitems are laid out multiple times, first right after they are constructed in constructFlexItem. This initial layout
sets everHadLayout bit to true which makes the check in layoutAndPlaceChildren somewhat late.

Test: fast/flexbox/repaint-issue-when-flex-item-appears.html

* rendering/FlexibleBoxAlgorithm.cpp:
(WebCore::FlexItem::FlexItem):
* rendering/FlexibleBoxAlgorithm.h:
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::constructFlexItem):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):

LayoutTests:

* fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt: Added.
* fast/flexbox/repaint-issue-when-flex-item-appears.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (278658 => 278659)


--- trunk/LayoutTests/ChangeLog	2021-06-09 13:40:41 UTC (rev 278658)
+++ trunk/LayoutTests/ChangeLog	2021-06-09 14:47:55 UTC (rev 278659)
@@ -1,3 +1,13 @@
+2021-06-09  Alan Bujtas  <[email protected]>
+
+        [Flexbox] FlexItem stays invisible after initial layout
+        https://bugs.webkit.org/show_bug.cgi?id=226778
+
+        Reviewed by Simon Fraser.
+
+        * fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt: Added.
+        * fast/flexbox/repaint-issue-when-flex-item-appears.html: Added.
+
 2021-06-09  Diego Pino Garcia  <[email protected]>
 
         [GLIB][GTK] Unreviewed test gardening. Mark flakey tests as timeout only.

Added: trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt (0 => 278659)


--- trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears-expected.txt	2021-06-09 14:47:55 UTC (rev 278659)
@@ -0,0 +1,6 @@
+PASS if the green box is visible below.
+some content here
+(repaint rects
+  (rect 8 28 500 20)
+)
+

Added: trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears.html (0 => 278659)


--- trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears.html	                        (rev 0)
+++ trunk/LayoutTests/fast/flexbox/repaint-issue-when-flex-item-appears.html	2021-06-09 14:47:55 UTC (rev 278659)
@@ -0,0 +1,53 @@
+<style>
+body {
+  width: 1000px;
+  font-family: Ahem;
+  font-size: 20px;
+}
+
+.flexcontainer { 
+  display: flex;
+  flex-direction: column; 
+  height: 100%; 
+}
+
+#flexitem { 
+  display: none;
+  overflow: hidden; 
+
+  width: 500px;
+  background-color: green;
+  color: green;
+}
+
+</style>
+PASS if the green box is visible below.
+<div class=flexcontainer>
+  <div id=flexitem>
+   <div>some content here</div>
+</div>
+<pre id=result></pre>
+<script>
+document.body.offsetHeight;
+
+if (window.testRunner) {
+  testRunner.waitUntilDone();
+  testRunner.dumpAsText();
+}
+
+setTimeout(function() {
+  if (window.internals)
+      window.internals.startTrackingRepaints();
+
+  flexitem.style.display = "block";
+  document.body.offsetHeight;
+
+  if (window.internals) {
+    let repaintRects = window.internals.repaintRectsAsText();
+    window.internals.stopTrackingRepaints();
+    result.innerText = repaintRects;
+  }
+  if (window.testRunner)
+    testRunner.notifyDone();
+}, 0);
+</script>

Modified: trunk/Source/WebCore/ChangeLog (278658 => 278659)


--- trunk/Source/WebCore/ChangeLog	2021-06-09 13:40:41 UTC (rev 278658)
+++ trunk/Source/WebCore/ChangeLog	2021-06-09 14:47:55 UTC (rev 278659)
@@ -1,3 +1,24 @@
+2021-06-09  Alan Bujtas  <[email protected]>
+
+        [Flexbox] FlexItem stays invisible after initial layout
+        https://bugs.webkit.org/show_bug.cgi?id=226778
+
+        Reviewed by Simon Fraser.
+
+        RenderFlexibleBox::layoutAndPlaceChildren() initiates repaint() on newly constructed flex items by checking their everHadLayout bit.
+        This is similar to what we do for regular block layout when block level boxes appear.
+        However flexitems are laid out multiple times, first right after they are constructed in constructFlexItem. This initial layout
+        sets everHadLayout bit to true which makes the check in layoutAndPlaceChildren somewhat late.
+
+        Test: fast/flexbox/repaint-issue-when-flex-item-appears.html
+
+        * rendering/FlexibleBoxAlgorithm.cpp:
+        (WebCore::FlexItem::FlexItem):
+        * rendering/FlexibleBoxAlgorithm.h:
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::constructFlexItem):
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+
 2021-06-09  Alexander Mikhaylenko  <[email protected]>
 
         [GTK4] Add support for navigation gestures

Modified: trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp (278658 => 278659)


--- trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp	2021-06-09 13:40:41 UTC (rev 278658)
+++ trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp	2021-06-09 14:47:55 UTC (rev 278659)
@@ -35,13 +35,13 @@
 
 namespace WebCore {
 
-FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin)
+FlexItem::FlexItem(RenderBox& box, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout)
     : box(box)
     , flexBaseContentSize(flexBaseContentSize)
     , hypotheticalMainContentSize(hypotheticalMainContentSize)
     , mainAxisBorderAndPadding(mainAxisBorderAndPadding)
     , mainAxisMargin(mainAxisMargin)
-    , frozen(false)
+    , everHadLayout(everHadLayout)
 {
     ASSERT(!box.isOutOfFlowPositioned());
 }

Modified: trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.h (278658 => 278659)


--- trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.h	2021-06-09 13:40:41 UTC (rev 278658)
+++ trunk/Source/WebCore/rendering/FlexibleBoxAlgorithm.h	2021-06-09 14:47:55 UTC (rev 278659)
@@ -41,7 +41,7 @@
 
 class FlexItem {
 public:
-    FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin);
+    FlexItem(RenderBox&, LayoutUnit flexBaseContentSize, LayoutUnit hypotheticalMainContentSize, LayoutUnit mainAxisBorderAndPadding, LayoutUnit mainAxisMargin, bool everHadLayout);
 
     LayoutUnit hypotheticalMainAxisMarginBoxSize() const
     {
@@ -64,7 +64,8 @@
     const LayoutUnit mainAxisBorderAndPadding;
     const LayoutUnit mainAxisMargin;
     LayoutUnit flexedContentSize;
-    bool frozen;
+    bool frozen { false };
+    bool everHadLayout { false };
 };
 
 class FlexLayoutAlgorithm {

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (278658 => 278659)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-06-09 13:40:41 UTC (rev 278658)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-06-09 14:47:55 UTC (rev 278659)
@@ -1308,6 +1308,7 @@
 
 FlexItem RenderFlexibleBox::constructFlexItem(RenderBox& child, bool relayoutChildren)
 {
+    auto childHadLayout = child.everHadLayout();
     child.clearOverridingContentSize();
     if (childHasIntrinsicMainAxisSize(child)) {
         // If this condition is true, then computeMainAxisExtentForChild will call
@@ -1335,7 +1336,7 @@
     LayoutUnit childInnerFlexBaseSize = computeInnerFlexBaseSizeForChild(child, borderAndPadding);
     LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(child, childInnerFlexBaseSize);
     LayoutUnit margin = isHorizontalFlow() ? child.horizontalMarginExtent() : child.verticalMarginExtent();
-    return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin);
+    return FlexItem(child, childInnerFlexBaseSize, childMinMaxAppliedMainAxisExtent, borderAndPadding, margin, childHadLayout);
 }
     
 void RenderFlexibleBox::freezeViolations(Vector<FlexItem*>& violations, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalFlexShrink, double& totalWeightedFlexShrink)
@@ -1737,7 +1738,6 @@
     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());
 
@@ -1768,7 +1768,7 @@
         if (child.needsLayout())
             m_relaidOutChildren.add(&child);
         child.layoutIfNeeded();
-        if (!childHadLayout && child.checkForRepaintDuringLayout()) {
+        if (!flexItem.everHadLayout && child.checkForRepaintDuringLayout()) {
             child.repaint();
             child.repaintOverhangingFloats(true);
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to