Title: [112333] trunk
Revision
112333
Author
[email protected]
Date
2012-03-27 16:56:11 -0700 (Tue, 27 Mar 2012)

Log Message

use the correct size when computing flex-pack space
https://bugs.webkit.org/show_bug.cgi?id=82378

Reviewed by Ojan Vafai.

Source/WebCore:

Fix 2 bugs:
- We weren't properly updating available space before computing
  packing space. If a min/max is not hit, we still need to adjust
  the available free space.
- For flex-pack:end, we need to put the overflow in the start edge.

New test cases in css3/flexbox/flex-pack.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::resolveFlexibleLengths):
(WebCore::initialPackingOffset):

LayoutTests:

* css3/flexbox/flex-pack-expected.txt:
* css3/flexbox/flex-pack.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112332 => 112333)


--- trunk/LayoutTests/ChangeLog	2012-03-27 23:49:04 UTC (rev 112332)
+++ trunk/LayoutTests/ChangeLog	2012-03-27 23:56:11 UTC (rev 112333)
@@ -1,3 +1,13 @@
+2012-03-27  Tony Chang  <[email protected]>
+
+        use the correct size when computing flex-pack space
+        https://bugs.webkit.org/show_bug.cgi?id=82378
+
+        Reviewed by Ojan Vafai.
+
+        * css3/flexbox/flex-pack-expected.txt:
+        * css3/flexbox/flex-pack.html:
+
 2012-03-27  Dirk Pranke  <[email protected]>
 
         Remove a bunch of lines that are no longer failing.

Modified: trunk/LayoutTests/css3/flexbox/flex-pack-expected.txt (112332 => 112333)


--- trunk/LayoutTests/css3/flexbox/flex-pack-expected.txt	2012-03-27 23:49:04 UTC (rev 112332)
+++ trunk/LayoutTests/css3/flexbox/flex-pack-expected.txt	2012-03-27 23:56:11 UTC (rev 112333)
@@ -8,3 +8,8 @@
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS
+PASS
+PASS

Modified: trunk/LayoutTests/css3/flexbox/flex-pack.html (112332 => 112333)


--- trunk/LayoutTests/css3/flexbox/flex-pack.html	2012-03-27 23:49:04 UTC (rev 112332)
+++ trunk/LayoutTests/css3/flexbox/flex-pack.html	2012-03-27 23:56:11 UTC (rev 112333)
@@ -49,12 +49,29 @@
   <div data-expected-width="100" data-offset-x="350" style="width: 100px;"></div>
 </div>
 
+<div class="flexbox" style="-webkit-flex-pack: center">
+  <div data-expected-width="200" data-offset-x="0" style="width: -webkit-flex(1 100px);"></div>
+  <div data-expected-width="200" data-offset-x="200" style="width: -webkit-flex(1 100px);"></div>
+  <div data-expected-width="200" data-offset-x="400" style="width: -webkit-flex(1 100px);"></div>
+</div>
+
+<!-- True centering on overflow. -->
+<div class="flexbox" style="-webkit-flex-pack: center">
+  <div data-expected-width="800" data-offset-x="-100" style="width: 800px;"></div>
+</div>
+
 <div class="flexbox" style="-webkit-flex-pack: justify">
   <div data-expected-width="100" data-offset-x="0" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
   <div data-expected-width="100" data-offset-x="250" style="width: 100px;"></div>
   <div data-expected-width="100" data-offset-x="500" style="width: 100px;"></div>
 </div>
 
+<div class="flexbox" style="-webkit-flex-pack: justify">
+  <div data-expected-width="200" data-offset-x="0" style="width: -webkit-flex(1 100px);"></div>
+  <div data-expected-width="200" data-offset-x="200" style="width: -webkit-flex(1 100px);"></div>
+  <div data-expected-width="200" data-offset-x="400" style="width: -webkit-flex(1 100px);"></div>
+</div>
+
 <!-- If there's only one child, we pack start. -->
 <div class="flexbox" style="-webkit-flex-pack: justify">
   <div data-expected-width="100" data-offset-x="0" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
@@ -71,6 +88,11 @@
   <div data-expected-width="100" data-offset-x="250" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
 </div>
 
+<!-- True centering on overflow. -->
+<div class="flexbox" style="-webkit-flex-pack: distribute">
+  <div data-expected-width="800" data-offset-x="-100" style="width: 800px;"></div>
+</div>
+
 <!-- Make sure we don't crash with no children. -->
 <div class="flexbox" style="-webkit-flex-pack: distribute"></div>
 
@@ -88,5 +110,12 @@
   <div data-expected-width="200" data-offset-x="400" style="width: 200px;"></div>
 </div>
 
+<!-- We overflow the flexbox (no negative flexing) and align the end. The overflow is to the left. -->
+<div class="flexbox" style="-webkit-flex-pack: end">
+  <div data-expected-width="300" data-offset-x="-100" style="width: -webkit-flex(1 300px);"></div>
+  <div data-expected-width="200" data-offset-x="200" style="width: 200px;"></div>
+  <div data-expected-width="200" data-offset-x="400" style="width: 200px;"></div>
+</div>
+
 </body>
 </html>

Modified: trunk/Source/WebCore/ChangeLog (112332 => 112333)


--- trunk/Source/WebCore/ChangeLog	2012-03-27 23:49:04 UTC (rev 112332)
+++ trunk/Source/WebCore/ChangeLog	2012-03-27 23:56:11 UTC (rev 112333)
@@ -1,3 +1,22 @@
+2012-03-27  Tony Chang  <[email protected]>
+
+        use the correct size when computing flex-pack space
+        https://bugs.webkit.org/show_bug.cgi?id=82378
+
+        Reviewed by Ojan Vafai.
+
+        Fix 2 bugs:
+        - We weren't properly updating available space before computing
+          packing space. If a min/max is not hit, we still need to adjust
+          the available free space.
+        - For flex-pack:end, we need to put the overflow in the start edge.
+
+        New test cases in css3/flexbox/flex-pack.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::resolveFlexibleLengths):
+        (WebCore::initialPackingOffset):
+
 2012-03-27  Dana Jansens  <[email protected]>
 
         [chromium] Unknown transforms should be treated as non-axis aligned on main thread

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (112332 => 112333)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-27 23:49:04 UTC (rev 112332)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-27 23:56:11 UTC (rev 112333)
@@ -769,6 +769,7 @@
     childSizes.clear();
     LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent();
     LayoutUnit totalViolation = 0;
+    LayoutUnit usedFreeSpace = 0;
     WTF::Vector<Violation> minViolations;
     WTF::Vector<Violation> maxViolations;
     for (size_t i = 0; i < children.size(); ++i) {
@@ -781,7 +782,8 @@
         if (inflexibleItems.contains(child))
             childSizes.append(inflexibleItems.get(child));
         else {
-            LayoutUnit childSize = preferredMainAxisContentExtentForChild(child);
+            LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(child);
+            LayoutUnit childSize = preferredChildSize;
             if (availableFreeSpace > 0 && totalPositiveFlexibility > 0 && flexSign == PositiveFlexibility)
                 childSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility);
             else if (availableFreeSpace < 0 && totalNegativeFlexibility > 0  && flexSign == NegativeFlexibility)
@@ -789,6 +791,7 @@
 
             LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(child, childSize, flexboxAvailableContentExtent);
             childSizes.append(adjustedChildSize);
+            usedFreeSpace += adjustedChildSize - preferredChildSize;
 
             LayoutUnit violation = adjustedChildSize - childSize;
             if (violation > 0)
@@ -801,20 +804,22 @@
 
     if (totalViolation)
         freezeViolations(totalViolation < 0 ? maxViolations : minViolations, availableFreeSpace, totalPositiveFlexibility, totalNegativeFlexibility, inflexibleItems);
+    else
+        availableFreeSpace -= usedFreeSpace;
+
     return !totalViolation;
 }
 
 static LayoutUnit initialPackingOffset(LayoutUnit availableFreeSpace, EFlexPack flexPack, size_t numberOfChildren)
 {
-    if (availableFreeSpace > 0) {
-        if (flexPack == PackEnd)
-            return availableFreeSpace;
-        if (flexPack == PackCenter)
-            return availableFreeSpace / 2;
-        if (flexPack == PackDistribute && numberOfChildren)
+    if (flexPack == PackEnd)
+        return availableFreeSpace;
+    if (flexPack == PackCenter)
+        return availableFreeSpace / 2;
+    if (flexPack == PackDistribute) {
+        if (availableFreeSpace > 0 && numberOfChildren)
             return availableFreeSpace / (2 * numberOfChildren);
-    } else if (availableFreeSpace < 0) {
-        if (flexPack == PackCenter || flexPack == PackDistribute)
+        if (availableFreeSpace < 0)
             return availableFreeSpace / 2;
     }
     return 0;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to