Title: [126468] trunk/Source/WebCore
Revision
126468
Author
[email protected]
Date
2012-08-23 12:46:51 -0700 (Thu, 23 Aug 2012)

Log Message

Flexbox doesn't need to compute logical height for stretched items in row flow
https://bugs.webkit.org/show_bug.cgi?id=94807

Patch by Shezan Baig <[email protected]> on 2012-08-23
Reviewed by Tony Chang.

Change logicalHeightConstrainedByMinMax to
constrainLogicalHeightByMinMax. The new method doesn't compute the
MainOrPreferred logical height (that computation has been moved back to
computeLogicalHeight). RenderFlexibleBox now just constrains the
stretchedLogicalHeight by min/max.

No new tests. This is a cleanup of bug 94237.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::constrainLogicalHeightByMinMax): Instead of
computing the MainOrPreferred logical height, just constrain the given
logical height by MinSize and MaxSize.
(WebCore::RenderBox::computeLogicalHeight): Compute the MainOrPreferred
logical height before constraining by min/max.
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::applyStretchAlignmentToChild): Use
constrainLogicalHeightByMinMax to constrain the stretchedLogicalHeight.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126467 => 126468)


--- trunk/Source/WebCore/ChangeLog	2012-08-23 19:43:32 UTC (rev 126467)
+++ trunk/Source/WebCore/ChangeLog	2012-08-23 19:46:51 UTC (rev 126468)
@@ -1,3 +1,30 @@
+2012-08-23  Shezan Baig  <[email protected]>
+
+        Flexbox doesn't need to compute logical height for stretched items in row flow
+        https://bugs.webkit.org/show_bug.cgi?id=94807
+
+        Reviewed by Tony Chang.
+
+        Change logicalHeightConstrainedByMinMax to
+        constrainLogicalHeightByMinMax. The new method doesn't compute the
+        MainOrPreferred logical height (that computation has been moved back to
+        computeLogicalHeight). RenderFlexibleBox now just constrains the
+        stretchedLogicalHeight by min/max.
+
+        No new tests. This is a cleanup of bug 94237.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::constrainLogicalHeightByMinMax): Instead of
+        computing the MainOrPreferred logical height, just constrain the given
+        logical height by MinSize and MaxSize.
+        (WebCore::RenderBox::computeLogicalHeight): Compute the MainOrPreferred
+        logical height before constraining by min/max.
+        * rendering/RenderBox.h:
+        (RenderBox):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::applyStretchAlignmentToChild): Use
+        constrainLogicalHeightByMinMax to constrain the stretchedLogicalHeight.
+
 2012-08-23  Adam Barth  <[email protected]>
 
         [V8] V8ScriptInstance is much more complicated than necessary

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (126467 => 126468)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2012-08-23 19:43:32 UTC (rev 126467)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2012-08-23 19:46:51 UTC (rev 126468)
@@ -433,19 +433,17 @@
         layer()->updateTransform();
 }
 
-LayoutUnit RenderBox::logicalHeightConstrainedByMinMax(LayoutUnit availableHeight)
+LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight)
 {
     RenderStyle* styleToUse = style();
-    LayoutUnit result = computeLogicalHeightUsing(MainOrPreferredSize, styleToUse->logicalHeight());
-    if (result == -1)
-        result = availableHeight;
-    LayoutUnit minH = computeLogicalHeightUsing(MinSize, styleToUse->logicalMinHeight()); // Leave as -1 if unset.
-    LayoutUnit maxH = styleToUse->logicalMaxHeight().isUndefined() ? result : computeLogicalHeightUsing(MaxSize, styleToUse->logicalMaxHeight());
-    if (maxH == -1)
-        maxH = result;
-    result = min(maxH, result);
-    result = max(minH, result);
-    return result;
+    if (!styleToUse->logicalMaxHeight().isUndefined()) {
+        // Constrain by MaxSize.
+        LayoutUnit maxH = computeLogicalHeightUsing(MaxSize, styleToUse->logicalMaxHeight());
+        if (maxH != -1)
+            logicalHeight = min(logicalHeight, maxH);
+    }
+    // Constrain by MinSize.
+    return max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse->logicalMinHeight()));
 }
 
 IntRect RenderBox::absoluteContentBox() const
@@ -2013,9 +2011,12 @@
         }
 
         LayoutUnit heightResult;
-        if (checkMinMaxHeight)
-            heightResult = logicalHeightConstrainedByMinMax(logicalHeight());
-        else {
+        if (checkMinMaxHeight) {
+            heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight());
+            if (heightResult == -1)
+                heightResult = logicalHeight();
+            heightResult = constrainLogicalHeightByMinMax(heightResult);
+        } else {
             // The only times we don't check min/max height are when a fixed length has
             // been given as an override.  Just use that.  The value has already been adjusted
             // for box-sizing.

Modified: trunk/Source/WebCore/rendering/RenderBox.h (126467 => 126468)


--- trunk/Source/WebCore/rendering/RenderBox.h	2012-08-23 19:43:32 UTC (rev 126467)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2012-08-23 19:46:51 UTC (rev 126468)
@@ -75,7 +75,7 @@
     LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
     LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
 
-    LayoutUnit logicalHeightConstrainedByMinMax(LayoutUnit);
+    LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit);
 
     int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
     int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMode() ? pixelSnappedWidth() : pixelSnappedHeight(); }

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (126467 => 126468)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-23 19:43:32 UTC (rev 126467)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-23 19:46:51 UTC (rev 126468)
@@ -1233,10 +1233,10 @@
 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox* child, LayoutUnit lineCrossAxisExtent)
 {
     if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) {
-        // FIXME: If the child has orthogonal flow, then it already has an override height set. How do we stretch?
+        // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it.
         if (!hasOrthogonalFlow(child)) {
             LayoutUnit stretchedLogicalHeight = child->logicalHeight() + availableAlignmentSpaceForChild(lineCrossAxisExtent, child);
-            LayoutUnit desiredLogicalHeight = child->logicalHeightConstrainedByMinMax(stretchedLogicalHeight);
+            LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMinMax(stretchedLogicalHeight);
 
             // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905.
             if (desiredLogicalHeight != child->logicalHeight()) {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to