Title: [136660] trunk
Revision
136660
Author
[email protected]
Date
2012-12-05 02:24:55 -0800 (Wed, 05 Dec 2012)

Log Message

Flex item auto margins in the cross direction should safe center
https://bugs.webkit.org/show_bug.cgi?id=103919

Reviewed by Ojan Vafai.

Source/WebCore:

Do not apply auto margins for cross axis if there's no alignment
space available.

Test: css3/flexbox/flex-flow-auto-margins-no-available-space.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::alignChildren): Make sure we pass a
positive value for availableAlignmentSpace to
updateAutoMarginsInCrossAxis().

LayoutTests:

* css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt: Added.
* css3/flexbox/flex-flow-auto-margins-no-available-space.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136659 => 136660)


--- trunk/LayoutTests/ChangeLog	2012-12-05 10:22:52 UTC (rev 136659)
+++ trunk/LayoutTests/ChangeLog	2012-12-05 10:24:55 UTC (rev 136660)
@@ -1,3 +1,13 @@
+2012-12-05  Carlos Garcia Campos  <[email protected]>
+
+        Flex item auto margins in the cross direction should safe center
+        https://bugs.webkit.org/show_bug.cgi?id=103919
+
+        Reviewed by Ojan Vafai.
+
+        * css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt: Added.
+        * css3/flexbox/flex-flow-auto-margins-no-available-space.html: Added.
+
 2012-12-05  Mike West  <[email protected]>
 
         [mac][gtk] Unreviewed gardening.

Added: trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt (0 => 136660)


--- trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space-expected.txt	2012-12-05 10:24:55 UTC (rev 136660)
@@ -0,0 +1,5 @@
+PASS
+ PASS
+ PASS
+ PASS
+

Added: trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space.html (0 => 136660)


--- trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space.html	                        (rev 0)
+++ trunk/LayoutTests/css3/flexbox/flex-flow-auto-margins-no-available-space.html	2012-12-05 10:24:55 UTC (rev 136660)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<link href="" rel="stylesheet">
+<style>
+.container {
+    position: relative;
+    background-color: pink;
+    outline: 1px solid black;
+    display: inline-block;
+}
+.flexbox {
+    background-color: grey;
+    width: 100px;
+    height: 100px;
+    margin: 20px;
+}
+.flexbox > * {
+    -webkit-flex: none;
+    -moz-flex: none;
+}
+.flexbox > :nth-child(1) {
+    background-color: blue;
+    margin: auto;
+}
+</style>
+<script src=""
+<body _onload_="checkLayout('.flexbox')">
+
+<div class="container">
+  <div class="flexbox row">
+    <div data-offset-x=60 data-offset-y=20 style="width: 20px; height: 120px"></div>
+  </div>
+</div>
+
+<div class="container">
+  <div class="flexbox row-reverse">
+    <div data-offset-x=60 data-offset-y=20 style="width: 20px; height: 120px"></div>
+  </div>
+</div>
+
+<div class="container">
+  <div class="flexbox column">
+    <div data-offset-x=20 data-offset-y=60 style="width: 120px; height: 20px"></div>
+  </div>
+</div>
+
+<div class="container">
+  <div class="flexbox column-reverse">
+    <div data-offset-x=20 data-offset-y=60 style="width: 120px; height: 20px"></div>
+  </div>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136659 => 136660)


--- trunk/Source/WebCore/ChangeLog	2012-12-05 10:22:52 UTC (rev 136659)
+++ trunk/Source/WebCore/ChangeLog	2012-12-05 10:24:55 UTC (rev 136660)
@@ -1,3 +1,20 @@
+2012-12-05  Carlos Garcia Campos  <[email protected]>
+
+        Flex item auto margins in the cross direction should safe center
+        https://bugs.webkit.org/show_bug.cgi?id=103919
+
+        Reviewed by Ojan Vafai.
+
+        Do not apply auto margins for cross axis if there's no alignment
+        space available.
+
+        Test: css3/flexbox/flex-flow-auto-margins-no-available-space.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::alignChildren): Make sure we pass a
+        positive value for availableAlignmentSpace to
+        updateAutoMarginsInCrossAxis().
+
 2012-12-05  Mike West  <[email protected]>
 
         Web Inspector: Autogenerate stack traces and line numbers when possible.

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (136659 => 136660)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-12-05 10:22:52 UTC (rev 136659)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-12-05 10:24:55 UTC (rev 136660)
@@ -780,6 +780,8 @@
 
 void RenderFlexibleBox::updateAutoMarginsInMainAxis(RenderBox* child, LayoutUnit autoMarginOffset)
 {
+    ASSERT(autoMarginOffset >= 0);
+
     if (isHorizontalFlow()) {
         if (child->style()->marginLeft().isAuto())
             child->setMarginLeft(autoMarginOffset);
@@ -810,6 +812,7 @@
 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUnit availableAlignmentSpace)
 {
     ASSERT(!child->isOutOfFlowPositioned());
+    ASSERT(availableAlignmentSpace >= 0);
 
     bool isHorizontal = isHorizontalFlow();
     Length start = isHorizontal ? child->style()->marginTop() : child->style()->marginLeft();
@@ -1295,7 +1298,7 @@
                 continue;
             }
 
-            if (updateAutoMarginsInCrossAxis(child, availableAlignmentSpaceForChild(lineCrossAxisExtent, child)))
+            if (updateAutoMarginsInCrossAxis(child, std::max(LayoutUnit(0), availableAlignmentSpaceForChild(lineCrossAxisExtent, child))))
                 continue;
 
             switch (alignmentForChild(child)) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to