Title: [110772] trunk
Revision
110772
Author
[email protected]
Date
2012-03-14 15:56:15 -0700 (Wed, 14 Mar 2012)

Log Message

fix negative flexing in auto sized columns
https://bugs.webkit.org/show_bug.cgi?id=80069

Reviewed by Ojan Vafai.

Source/WebCore:

New test cases in css3/flexbox/columns-auto-size.html.

* rendering/RenderFlexibleBox.cpp:
(WebCore):
(WebCore::RenderFlexibleBox::computeAvailableFreeSpace): Properly compute this for auto sizing columns. Previously, we would always return 0.
(WebCore::RenderFlexibleBox::layoutFlexItems):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithm): Drop an unnecessary check against undefined. isSpecified covers this for us.
* rendering/RenderFlexibleBox.h:
(RenderFlexibleBox):

LayoutTests:

* css3/flexbox/columns-auto-size-expected.txt:
* css3/flexbox/columns-auto-size.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110771 => 110772)


--- trunk/LayoutTests/ChangeLog	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/LayoutTests/ChangeLog	2012-03-14 22:56:15 UTC (rev 110772)
@@ -1,3 +1,13 @@
+2012-03-14  Tony Chang  <[email protected]>
+
+        fix negative flexing in auto sized columns
+        https://bugs.webkit.org/show_bug.cgi?id=80069
+
+        Reviewed by Ojan Vafai.
+
+        * css3/flexbox/columns-auto-size-expected.txt:
+        * css3/flexbox/columns-auto-size.html:
+
 2012-03-14  Adam Barth  <[email protected]>
 
         Update baselines for these URL tests.  These tests exist to document

Modified: trunk/LayoutTests/css3/flexbox/columns-auto-size-expected.txt (110771 => 110772)


--- trunk/LayoutTests/css3/flexbox/columns-auto-size-expected.txt	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/LayoutTests/css3/flexbox/columns-auto-size-expected.txt	2012-03-14 22:56:15 UTC (rev 110772)
@@ -4,3 +4,7 @@
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS
+PASS

Modified: trunk/LayoutTests/css3/flexbox/columns-auto-size.html (110771 => 110772)


--- trunk/LayoutTests/css3/flexbox/columns-auto-size.html	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/LayoutTests/css3/flexbox/columns-auto-size.html	2012-03-14 22:56:15 UTC (rev 110772)
@@ -76,6 +76,26 @@
   <div data-expected-height="20" data-offset-y="50" style="padding-top: 10px"><div data-expected-height="10" data-offset-y="60" style="height: 10px"></div></div>
 </div>
 
+<div class="flexbox horizontal" data-expected-height="20">
+  <div data-expected-height="10" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
+  <div data-expected-height="10" data-offset-y="10" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
+</div>
+
+<div class="flexbox horizontal" style="min-height: 10px" data-expected-height="20">
+  <div data-expected-height="10" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
+  <div data-expected-height="10" data-offset-y="10" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
+</div>
+
+<div class="flexbox horizontal" style="min-height: 5px; max-height: 17px;" data-expected-height="17">
+  <div data-expected-height="9" data-offset-y="0" style="height: -webkit-flex(0 1 auto)"><div style="height: 10px"></div></div>
+  <div data-expected-height="8" data-offset-y="9" style="height: -webkit-flex(0 2 auto)"><div style="height: 10px"></div></div>
+</div>
+
+<div class="flexbox horizontal" style="min-height: 5px; max-height: 30px; padding-top: 1px; padding-bottom: 2px;" data-expected-height="33">
+  <div data-expected-height="15" data-offset-y="1" style="height: -webkit-flex(0 1 auto)"><div style="height: 20px"></div></div>
+  <div data-expected-height="15" data-offset-y="16" style="height: -webkit-flex(0 1 auto)"><div style="height: 20px"></div></div>
+</div>
+
 <div class="flexbox vertical">
   <div data-expected-width="10" data-offset-x="20" style="width: -webkit-flex(1 0 10px)"></div>
   <div data-expected-width="10" data-offset-x="10" style="width: 10px;"></div>

Modified: trunk/Source/WebCore/ChangeLog (110771 => 110772)


--- trunk/Source/WebCore/ChangeLog	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/Source/WebCore/ChangeLog	2012-03-14 22:56:15 UTC (rev 110772)
@@ -1,3 +1,20 @@
+2012-03-14  Tony Chang  <[email protected]>
+
+        fix negative flexing in auto sized columns
+        https://bugs.webkit.org/show_bug.cgi?id=80069
+
+        Reviewed by Ojan Vafai.
+
+        New test cases in css3/flexbox/columns-auto-size.html.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore):
+        (WebCore::RenderFlexibleBox::computeAvailableFreeSpace): Properly compute this for auto sizing columns. Previously, we would always return 0.
+        (WebCore::RenderFlexibleBox::layoutFlexItems):
+        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithm): Drop an unnecessary check against undefined. isSpecified covers this for us.
+        * rendering/RenderFlexibleBox.h:
+        (RenderFlexibleBox):
+
 2012-03-14  Grace Ku  <[email protected]>
 
         Incorrect handling of sizes in "em" when first-line changes font size

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (110771 => 110772)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-03-14 22:56:15 UTC (rev 110772)
@@ -576,6 +576,27 @@
     return mainAxisLength.calcMinValue(mainAxisContentExtent());
 }
 
+LayoutUnit RenderFlexibleBox::computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent)
+{
+    if (!isColumnFlow())
+        return mainAxisContentExtent() - preferredMainAxisExtent;
+
+    if (hasOverrideHeight())
+        return overrideHeight();
+
+    LayoutUnit heightResult = computeContentLogicalHeightUsing(style()->logicalHeight());
+    if (heightResult == -1)
+        heightResult = preferredMainAxisExtent;
+    LayoutUnit minHeight = computeContentLogicalHeightUsing(style()->logicalMinHeight()); // Leave as -1 if unset.
+    LayoutUnit maxHeight = style()->logicalMaxHeight().isUndefined() ? heightResult : computeContentLogicalHeightUsing(style()->logicalMaxHeight());
+    if (maxHeight == -1)
+        maxHeight = heightResult;
+    heightResult = std::min(maxHeight, heightResult);
+    heightResult = std::max(minHeight, heightResult);
+
+    return heightResult - preferredMainAxisExtent;
+}
+
 void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren)
 {
     FlexOrderHashSet flexOrderValues;
@@ -592,9 +613,8 @@
     WrapReverseContext wrapReverseContext(style()->flexWrap());
 
     LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
-    LayoutUnit mainAxisFlexibleSpace = mainAxisContentExtent();
     while (computeNextFlexLine(flexIterator, orderedChildren, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility)) {
-        LayoutUnit availableFreeSpace = mainAxisFlexibleSpace - preferredMainAxisExtent;
+        LayoutUnit availableFreeSpace = computeAvailableFreeSpace(preferredMainAxisExtent);
         InflexibleFlexItemSize inflexibleItems;
         WTF::Vector<LayoutUnit> childSizes;
         while (!runFreeSpaceAllocationAlgorithm(orderedChildren, availableFreeSpace, totalPositiveFlexibility, totalNegativeFlexibility, inflexibleItems, childSizes)) {
@@ -738,7 +758,7 @@
                 childPreferredSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility);
 
                 Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
-                if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) {
+                if (childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) {
                     childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent);
                     availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForChild(child);
                     totalPositiveFlexibility -= positiveFlexForChild(child);
@@ -750,7 +770,7 @@
                 childPreferredSize += lroundf(availableFreeSpace * negativeFlexForChild(child) / totalNegativeFlexibility);
 
                 Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
-                if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) {
+                if (childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) {
                     childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableContentExtent);
                     availableFreeSpace += preferredMainAxisContentExtentForChild(child) - childPreferredSize;
                     totalNegativeFlexibility -= negativeFlexForChild(child);

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (110771 => 110772)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-03-14 22:44:28 UTC (rev 110771)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-03-14 22:56:15 UTC (rev 110772)
@@ -105,6 +105,7 @@
     void computeMainAxisPreferredSizes(bool relayoutChildren, FlexOrderHashSet&);
     LayoutUnit lineBreakLength();
     bool computeNextFlexLine(FlexOrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
+    LayoutUnit computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent);
     bool runFreeSpaceAllocationAlgorithm(const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
     void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
     void prepareChildForPositionedLayout(RenderBox* child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to