Title: [130714] trunk
Revision
130714
Author
t...@chromium.org
Date
2012-10-08 18:52:21 -0700 (Mon, 08 Oct 2012)

Log Message

image not displayed in flexbox
https://bugs.webkit.org/show_bug.cgi?id=98611

Reviewed by Ojan Vafai.

Source/WebCore:

Flexbox will override the width of a child and when stretching, will override the height of the child.
When this happens, when an image loads, it checks to see if it's width/height has
changed, and if so, does a relayout.  The overridden width/height was preventing this
relayout from happening.

To fix, we clear all the override sizes when we're done laying out the flex children.

Test: css3/flexbox/relayout-image-load.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutBlock): Clear child override sizes.
(WebCore::RenderFlexibleBox::clearChildOverrideSizes):
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): No longer need to clear the override size
here since it should have already been cleared.
* rendering/RenderFlexibleBox.h:

LayoutTests:

Load an image after flexbox layout has happened.

* css3/flexbox/relayout-image-load-expected.txt: Added.
* css3/flexbox/relayout-image-load.html: Added.
* platform/chromium/TestExpectations: Remove css3/flexbox/flexitem-stretch-image.html
since it should no longer be flaky.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (130713 => 130714)


--- trunk/LayoutTests/ChangeLog	2012-10-09 01:48:12 UTC (rev 130713)
+++ trunk/LayoutTests/ChangeLog	2012-10-09 01:52:21 UTC (rev 130714)
@@ -1,3 +1,17 @@
+2012-10-08  Tony Chang  <t...@chromium.org>
+
+        image not displayed in flexbox
+        https://bugs.webkit.org/show_bug.cgi?id=98611
+
+        Reviewed by Ojan Vafai.
+
+        Load an image after flexbox layout has happened.
+
+        * css3/flexbox/relayout-image-load-expected.txt: Added.
+        * css3/flexbox/relayout-image-load.html: Added.
+        * platform/chromium/TestExpectations: Remove css3/flexbox/flexitem-stretch-image.html
+        since it should no longer be flaky.
+
 2012-10-08  Dirk Pranke  <dpra...@chromium.org>
 
         results.html and garden-o-matic are ignoring IMAGE failures when expected to FAIL

Added: trunk/LayoutTests/css3/flexbox/relayout-image-load-expected.txt (0 => 130714)


--- trunk/LayoutTests/css3/flexbox/relayout-image-load-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/relayout-image-load-expected.txt	2012-10-09 01:52:21 UTC (rev 130714)
@@ -0,0 +1,5 @@
+Test to make sure that we properly relayout when an image loads. You should see a green 100x100 image.
+
+ 
+
+PASS

Added: trunk/LayoutTests/css3/flexbox/relayout-image-load.html (0 => 130714)


--- trunk/LayoutTests/css3/flexbox/relayout-image-load.html	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/relayout-image-load.html	2012-10-09 01:52:21 UTC (rev 130714)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link href="" rel="stylesheet">
+<style>
+</style>
+<script src=""
+</head>
+<body>
+<p>Test to make sure that we properly relayout when an image loads. You
+should see a green 100x100 image.</p>
+<div id="test" class="flexbox">
+    &nbsp;
+    <div class="flexbox">
+        <img data-expected-width=100 data-expected-height=100 id="image" _onload_="imageLoaded()">
+    </div>
+</div>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function changeImage()
+{
+    document.getElementById("image").src = ""
+}
+setTimeout(changeImage, 0);
+
+function imageLoaded()
+{
+    checkLayout('#test')
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/chromium/TestExpectations (130713 => 130714)


--- trunk/LayoutTests/platform/chromium/TestExpectations	2012-10-09 01:48:12 UTC (rev 130713)
+++ trunk/LayoutTests/platform/chromium/TestExpectations	2012-10-09 01:52:21 UTC (rev 130714)
@@ -3412,7 +3412,6 @@
 webkit.org/b/94532 [ Linux ] fast/forms/formmethod-attribute-button-html.html [ Missing Pass ]
 
 webkit.org/b/94660 fast/js/create-lots-of-workers.html [ Crash Pass Timeout ]
-webkit.org/b/95366 [ Debug ] css3/flexbox/flexitem-stretch-image.html [ Failure Pass ]
 
 crbug.com/67540 webkit.org/b/94735 [ Linux ] fast/text/emphasis-overlap.html [ Failure ImageOnlyFailure ]
 

Modified: trunk/Source/WebCore/ChangeLog (130713 => 130714)


--- trunk/Source/WebCore/ChangeLog	2012-10-09 01:48:12 UTC (rev 130713)
+++ trunk/Source/WebCore/ChangeLog	2012-10-09 01:52:21 UTC (rev 130714)
@@ -1,3 +1,26 @@
+2012-10-08  Tony Chang  <t...@chromium.org>
+
+        image not displayed in flexbox
+        https://bugs.webkit.org/show_bug.cgi?id=98611
+
+        Reviewed by Ojan Vafai.
+
+        Flexbox will override the width of a child and when stretching, will override the height of the child.
+        When this happens, when an image loads, it checks to see if it's width/height has
+        changed, and if so, does a relayout.  The overridden width/height was preventing this
+        relayout from happening.
+
+        To fix, we clear all the override sizes when we're done laying out the flex children.
+
+        Test: css3/flexbox/relayout-image-load.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutBlock): Clear child override sizes.
+        (WebCore::RenderFlexibleBox::clearChildOverrideSizes):
+        (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): No longer need to clear the override size
+        here since it should have already been cleared.
+        * rendering/RenderFlexibleBox.h:
+
 2012-10-08  Andreas Kling  <kl...@webkit.org>
 
         REGRESSION(r130643): editing/pasteboard/data-transfer-item is failing on chromium.

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (130713 => 130714)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-10-09 01:48:12 UTC (rev 130713)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-10-09 01:52:21 UTC (rev 130714)
@@ -324,6 +324,7 @@
     layoutPositionedObjects(relayoutChildren || isRoot());
 
     computeRegionRangeForBlock();
+    clearChildOverrideSizes();
 
     // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflow than it needs to.
     computeOverflow(oldClientAfterEdge);
@@ -373,6 +374,12 @@
     flipForRightToLeftColumn(iterator);
 }
 
+void RenderFlexibleBox::clearChildOverrideSizes()
+{
+    for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
+        child->clearOverrideSize();
+}
+
 bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox* child) const
 {
     // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow.
@@ -806,7 +813,6 @@
         if (child->isOutOfFlowPositioned())
             continue;
 
-        child->clearOverrideSize();
         // Only need to layout here if we will need to get the logicalHeight of the child in computeNextFlexLine.
         Length childMainAxisMin = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
         if (hasOrthogonalFlow(child) && (flexBasisForChild(child).isAuto() || childMainAxisMin.isAuto())) {

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (130713 => 130714)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-10-09 01:48:12 UTC (rev 130713)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-10-09 01:52:21 UTC (rev 130714)
@@ -120,6 +120,7 @@
     bool hasAutoMarginsInCrossAxis(RenderBox* child) const;
     bool updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUnit availableAlignmentSpace);
     void repositionLogicalHeightDependentFlexItems(OrderIterator&, WTF::Vector<LineContext>&, LayoutUnit& oldClientAfterEdge);
+    void clearChildOverrideSizes();
 
     LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox*);
     LayoutUnit marginBoxAscentForChild(RenderBox*);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to