Title: [133906] trunk
Revision
133906
Author
[email protected]
Date
2012-11-08 09:26:55 -0800 (Thu, 08 Nov 2012)

Log Message

While absolute positioning is put before the first flexitem, flexitems will move to a new line.
https://bugs.webkit.org/show_bug.cgi?id=101294

Patch by Wei Fanzhe <[email protected]> on 2012-11-08
Reviewed by Ojan Vafai.

Source/WebCore:

This issue has to do with RenderFlexibleBox::computeNextFlexLine. When determing line breaks, the algorithm sees if 1) the total width exceeds lineBreakLength and 2) whether orderedChildren is non-empty.  But then, if the total width exceeds lineBreakLength and there's only absolutely positioned elemments in orderedChildren then the conditions are met and the algorithm mistakenly breaks the line. The solution is to see if orderedChildren collects at least a flex item. If it does, break the line.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeNextFlexLine):

LayoutTests:

Add a case to test flexible layout while absolute positioning is put before the first flexitem.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (133905 => 133906)


--- trunk/LayoutTests/ChangeLog	2012-11-08 17:19:05 UTC (rev 133905)
+++ trunk/LayoutTests/ChangeLog	2012-11-08 17:26:55 UTC (rev 133906)
@@ -1,3 +1,15 @@
+2012-11-08  Wei Fanzhe  <[email protected]>
+
+        While absolute positioning is put before the first flexitem, flexitems will move to a new line.
+        https://bugs.webkit.org/show_bug.cgi?id=101294
+
+        Reviewed by Ojan Vafai.
+
+        Add a case to test flexible layout while absolute positioning is put before the first flexitem.
+
+        * css3/flexbox/flex-algorithm-expected.txt:
+        * css3/flexbox/flex-algorithm.html:
+
 2012-11-08  Yael Aharon  <[email protected]>
 
         Unreviewed. Gardening after r133898.

Modified: trunk/LayoutTests/css3/flexbox/flex-algorithm-expected.txt (133905 => 133906)


--- trunk/LayoutTests/css3/flexbox/flex-algorithm-expected.txt	2012-11-08 17:19:05 UTC (rev 133905)
+++ trunk/LayoutTests/css3/flexbox/flex-algorithm-expected.txt	2012-11-08 17:26:55 UTC (rev 133906)
@@ -23,4 +23,5 @@
 PASS
 PASS
 PASS
+PASS
 

Modified: trunk/LayoutTests/css3/flexbox/flex-algorithm.html (133905 => 133906)


--- trunk/LayoutTests/css3/flexbox/flex-algorithm.html	2012-11-08 17:19:05 UTC (rev 133905)
+++ trunk/LayoutTests/css3/flexbox/flex-algorithm.html	2012-11-08 17:26:55 UTC (rev 133906)
@@ -198,6 +198,11 @@
   </div>
 </div>
 
+<div class="flexbox" style="height: 60px; -webkit-flex-flow: row wrap; position: relative;">
+  <div data-offset-x="0" data-offset-y="0" style="position: absolute;"></div>
+  <div data-offset-x="0" data-offset-y="0" style="width: 700px;"></div>
+</div>
+
 <!-- Test border/padding/margin on the flexbox itself. -->
 <div data-expected-width="830" style="border: 10px solid; display: inline-block;">
     <div data-expected-width="700" style="padding-left: 10px; padding-right: 20px; border-left: 30px solid; border-right: 40px solid; margin-left: 50px; margin-right:60px;" class="flexbox">

Modified: trunk/Source/WebCore/ChangeLog (133905 => 133906)


--- trunk/Source/WebCore/ChangeLog	2012-11-08 17:19:05 UTC (rev 133905)
+++ trunk/Source/WebCore/ChangeLog	2012-11-08 17:26:55 UTC (rev 133906)
@@ -1,3 +1,15 @@
+2012-11-08  Wei Fanzhe  <[email protected]>
+
+        While absolute positioning is put before the first flexitem, flexitems will move to a new line.
+        https://bugs.webkit.org/show_bug.cgi?id=101294
+
+        Reviewed by Ojan Vafai.
+
+        This issue has to do with RenderFlexibleBox::computeNextFlexLine. When determing line breaks, the algorithm sees if 1) the total width exceeds lineBreakLength and 2) whether orderedChildren is non-empty.  But then, if the total width exceeds lineBreakLength and there's only absolutely positioned elemments in orderedChildren then the conditions are met and the algorithm mistakenly breaks the line. The solution is to see if orderedChildren collects at least a flex item. If it does, break the line.  
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::computeNextFlexLine):
+
 2012-11-08  Dimitri Glazkov  <[email protected]>
 
         Unreviewed, rolling out r133429.

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (133905 => 133906)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-11-08 17:19:05 UTC (rev 133905)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-11-08 17:26:55 UTC (rev 133906)
@@ -895,6 +895,7 @@
         return false;
 
     LayoutUnit lineBreakLength = mainAxisContentExtent(LayoutUnit::max());
+    bool lineHasInFlowItem = false;
 
     for (RenderBox* child = iterator.currentChild(); child; child = iterator.next()) {
         if (child->isOutOfFlowPositioned()) {
@@ -906,9 +907,10 @@
         LayoutUnit childMainAxisMarginBoxExtent = mainAxisBorderAndPaddingExtentForChild(child) + childMainAxisExtent;
         childMainAxisMarginBoxExtent += isHorizontalFlow() ? child->marginWidth() : child->marginHeight();
 
-        if (isMultiline() && preferredMainAxisExtent + childMainAxisMarginBoxExtent > lineBreakLength && orderedChildren.size() > 0)
+        if (isMultiline() && preferredMainAxisExtent + childMainAxisMarginBoxExtent > lineBreakLength && lineHasInFlowItem)
             break;
         orderedChildren.append(child);
+        lineHasInFlowItem  = true;
         preferredMainAxisExtent += childMainAxisMarginBoxExtent;
         totalFlexGrow += child->style()->flexGrow();
         totalWeightedFlexShrink += child->style()->flexShrink() * childMainAxisExtent;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to