Title: [124987] trunk
Revision
124987
Author
[email protected]
Date
2012-08-07 22:25:34 -0700 (Tue, 07 Aug 2012)

Log Message

percentage margins + flex incorrectly overflows the flexbox
https://bugs.webkit.org/show_bug.cgi?id=93411

Reviewed by Tony Chang.

Source/WebCore:

Percent margins should always be computed with respect to the containing
block's width, not it's height. We were getting this wrong in column flows.

Test: css3/flexbox/percent-margins.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeMarginValue):
(WebCore):
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
* rendering/RenderFlexibleBox.h:

LayoutTests:

* css3/flexbox/percent-margins-expected.txt: Added.
* css3/flexbox/percent-margins.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124986 => 124987)


--- trunk/LayoutTests/ChangeLog	2012-08-08 05:22:46 UTC (rev 124986)
+++ trunk/LayoutTests/ChangeLog	2012-08-08 05:25:34 UTC (rev 124987)
@@ -1,3 +1,13 @@
+2012-08-07  Ojan Vafai  <[email protected]>
+
+        percentage margins + flex incorrectly overflows the flexbox
+        https://bugs.webkit.org/show_bug.cgi?id=93411
+
+        Reviewed by Tony Chang.
+
+        * css3/flexbox/percent-margins-expected.txt: Added.
+        * css3/flexbox/percent-margins.html: Added.
+
 2012-08-07  Eric Carlson  <[email protected]>
 
         REGRESSION (r124710-r124713): media/video-seek-past-end-paused.html failing on Apple Lion Debug WK1 (Tests)

Added: trunk/LayoutTests/css3/flexbox/percent-margins-expected.txt (0 => 124987)


--- trunk/LayoutTests/css3/flexbox/percent-margins-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/percent-margins-expected.txt	2012-08-08 05:25:34 UTC (rev 124987)
@@ -0,0 +1,2 @@
+PASS
+PASS

Added: trunk/LayoutTests/css3/flexbox/percent-margins.html (0 => 124987)


--- trunk/LayoutTests/css3/flexbox/percent-margins.html	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/percent-margins.html	2012-08-08 05:25:34 UTC (rev 124987)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+</script>
+<script src=""
+<body _onload_="checkLayout('.flexbox')">
+
+<div class="flexbox" style="display:-webkit-flex; -webkit-flex-direction: column; background-color: salmon; height: 300px; width: 400px;">
+    <div style="margin: 10%; background-color: orange; height: 5px; -webkit-flex: 1" data-expected-width=320 data-expected-height=135></div>
+    <div style="margin: 10%; background-color: orange; height: 5px;" data-expected-width=320 data-expected-height=5></div>
+</div>
+
+<div class="flexbox" style="display:-webkit-flex; background-color: salmon; height: 300px; width: 400px;">
+    <div style="margin: 10%; background-color: orange; height: 5px; -webkit-flex: 1 5px" data-expected-width=235 data-expected-height=5></div>
+    <div style="margin: 10%; background-color: orange; height: 5px; width: 5px" data-expected-width=5 data-expected-height=5></div>
+</div>
+
+</body>

Modified: trunk/Source/WebCore/ChangeLog (124986 => 124987)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 05:22:46 UTC (rev 124986)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 05:25:34 UTC (rev 124987)
@@ -1,3 +1,22 @@
+2012-08-07  Ojan Vafai  <[email protected]>
+
+        percentage margins + flex incorrectly overflows the flexbox
+        https://bugs.webkit.org/show_bug.cgi?id=93411
+
+        Reviewed by Tony Chang.
+
+        Percent margins should always be computed with respect to the containing
+        block's width, not it's height. We were getting this wrong in column flows.
+
+        Test: css3/flexbox/percent-margins.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::computeMarginValue):
+        (WebCore):
+        (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes):
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+        * rendering/RenderFlexibleBox.h:
+
 2012-08-07  Kentaro Hara  <[email protected]>
 
         [V8] Replace throwError(ExceptionCode, Isolate*) with setDOMException(ExceptionCode, Isolate*) in v8/* and v8/custom/*

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (124986 => 124987)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-08 05:22:46 UTC (rev 124986)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-08 05:25:34 UTC (rev 124987)
@@ -758,6 +758,14 @@
     return ascent + flowAwareMarginBeforeForChild(child);
 }
 
+LayoutUnit RenderFlexibleBox::computeMarginValue(Length margin, LayoutUnit availableSize, RenderView* view)
+{
+    // CSS always computes percent margins with respect to the containing block's width, even for margin-top/margin-bottom.
+    if (margin.isPercent())
+        availableSize = logicalWidth();
+    return minimumValueForLength(margin, availableSize, view);
+}
+
 void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet& orderValues)
 {
     LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
@@ -780,11 +788,11 @@
         // Before running the flex algorithm, 'auto' has a margin of 0.
         // Also, if we're not auto sizing, we don't do a layout that computes the start/end margins.
         if (isHorizontalFlow()) {
-            child->setMarginLeft(minimumValueForLength(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView));
-            child->setMarginRight(minimumValueForLength(child->style()->marginRight(), flexboxAvailableContentExtent, renderView));
+            child->setMarginLeft(computeMarginValue(child->style()->marginLeft(), flexboxAvailableContentExtent, renderView));
+            child->setMarginRight(computeMarginValue(child->style()->marginRight(), flexboxAvailableContentExtent, renderView));
         } else {
-            child->setMarginTop(minimumValueForLength(child->style()->marginTop(), flexboxAvailableContentExtent, renderView));
-            child->setMarginBottom(minimumValueForLength(child->style()->marginBottom(), flexboxAvailableContentExtent, renderView));
+            child->setMarginTop(computeMarginValue(child->style()->marginTop(), flexboxAvailableContentExtent, renderView));
+            child->setMarginBottom(computeMarginValue(child->style()->marginBottom(), flexboxAvailableContentExtent, renderView));
         }
     }
 }

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (124986 => 124987)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-08-08 05:22:46 UTC (rev 124986)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-08-08 05:25:34 UTC (rev 124987)
@@ -119,6 +119,7 @@
     LayoutUnit availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox*);
     LayoutUnit marginBoxAscentForChild(RenderBox*);
 
+    LayoutUnit computeMarginValue(Length margin, LayoutUnit availableSize, RenderView*);
     void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&);
     LayoutUnit lineBreakLength();
     LayoutUnit adjustChildSizeForMinAndMax(RenderBox*, LayoutUnit childSize, LayoutUnit flexboxAvailableContentExtent);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to