REGRESSION(r136324): Flexbox should relayout flex children when width changes
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 19:21:26 +0000 (19:21 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Jan 2013 19:21:26 +0000 (19:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108231

Reviewed by Ojan Vafai.

Source/WebCore:

If the width of a block changes, we need to set relayoutChildren = true
to relayout the children. This broke when we optimized the layout calls
in layoutAndPlaceChildren.

Test: css3/flexbox/width-change-and-relayout-children.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock): Also reorder the code to match RenderBlock.
The bug fix is to use updateLogicalWidthAndColumnWidth() and its return value to set
relayoutChildren = true.

LayoutTests:

* css3/flexbox/width-change-and-relayout-children-expected.txt: Added.
* css3/flexbox/width-change-and-relayout-children.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/css3/flexbox/width-change-and-relayout-children-expected.txt [new file with mode: 0644]
LayoutTests/css3/flexbox/width-change-and-relayout-children.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlexibleBox.cpp

index 6b520fd..29eeca3 100644 (file)
@@ -1,3 +1,13 @@
+2013-01-30  Tony Chang  <tony@chromium.org>
+
+        REGRESSION(r136324): Flexbox should relayout flex children when width changes
+        https://bugs.webkit.org/show_bug.cgi?id=108231
+
+        Reviewed by Ojan Vafai.
+
+        * css3/flexbox/width-change-and-relayout-children-expected.txt: Added.
+        * css3/flexbox/width-change-and-relayout-children.html: Added.
+
 2013-01-30  Florin Malita  <fmalita@chromium.org>
 
         [Chromium] Unreviewed gardening.
diff --git a/LayoutTests/css3/flexbox/width-change-and-relayout-children-expected.txt b/LayoutTests/css3/flexbox/width-change-and-relayout-children-expected.txt
new file mode 100644 (file)
index 0000000..4544011
--- /dev/null
@@ -0,0 +1,2 @@
+This div should be 200px wide.
+PASS
diff --git a/LayoutTests/css3/flexbox/width-change-and-relayout-children.html b/LayoutTests/css3/flexbox/width-change-and-relayout-children.html
new file mode 100644 (file)
index 0000000..07d61d9
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link href="resources/flexbox.css" rel="stylesheet">
+<style>
+.flexitem {
+    width: 100%;
+    height: 3em;
+    min-height: 3em;
+}
+.child {
+    background-color: salmon;
+}
+</style>
+<script src="../../resources/check-layout.js"></script>
+</head>
+<body>
+<div id="container" style="width: 100px" data-expected-width="200">
+<div class="flexbox column" data-expected-width="200">
+    <div class="flexitem" data-expected-width="200">
+        <div class="child" data-expected-width="200">This div should be 200px wide.</div>
+    </div>
+</div>
+</div>
+<script>
+var container = document.getElementById('container');
+container.offsetWidth;
+container.style.width = "200px";
+window.onload = function()
+{
+    checkLayout("#container");
+};
+</script>
+</body>
+</html>
index e36e34d..186576e 100644 (file)
@@ -1,3 +1,21 @@
+2013-01-30  Tony Chang  <tony@chromium.org>
+
+        REGRESSION(r136324): Flexbox should relayout flex children when width changes
+        https://bugs.webkit.org/show_bug.cgi?id=108231
+
+        Reviewed by Ojan Vafai.
+
+        If the width of a block changes, we need to set relayoutChildren = true
+        to relayout the children. This broke when we optimized the layout calls
+        in layoutAndPlaceChildren.
+
+        Test: css3/flexbox/width-change-and-relayout-children.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock): Also reorder the code to match RenderBlock.
+        The bug fix is to use updateLogicalWidthAndColumnWidth() and its return value to set
+        relayoutChildren = true.
+
 2013-01-30  Tim Horton  <timothy_horton@apple.com>
 
         GraphicsContext3DCG needs to copy image data in paintToCanvas
index 62b33e4..016aefe 100644 (file)
@@ -296,6 +296,15 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
         return;
 
     LayoutRepainter repainter(*this, checkForRepaintDuringLayout());
+
+    if (updateLogicalWidthAndColumnWidth())
+        relayoutChildren = true;
+
+    m_overflow.clear();
+
+    LayoutUnit previousHeight = logicalHeight();
+    setLogicalHeight(0);
+
     LayoutStateMaintainer statePusher(view(), this, locationOffset(), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode());
 
     if (inRenderFlowThread()) {
@@ -305,13 +314,7 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
     }
     updateRegionsAndExclusionsLogicalSize();
 
-    LayoutSize previousSize = size();
-
-    setLogicalHeight(0);
-    updateLogicalWidth();
-
     m_numberOfInFlowChildrenOnFirstLine = -1;
-    m_overflow.clear();
 
     RenderBlock::startDelayUpdateScrollInfo();
 
@@ -330,7 +333,7 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, LayoutUnit)
 
     RenderBlock::finishDelayUpdateScrollInfo();
 
-    if (size() != previousSize)
+    if (logicalHeight() != previousHeight)
         relayoutChildren = true;
 
     layoutPositionedObjects(relayoutChildren || isRoot());