Flexbox doesn't need to compute logical height for stretched items in row flow
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 19:46:51 +0000 (19:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Aug 2012 19:46:51 +0000 (19:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=94807

Patch by Shezan Baig <shezbaig.wk@gmail.com> 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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@126468 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderFlexibleBox.cpp

index 21fe6ff..3a9acb8 100644 (file)
@@ -1,3 +1,30 @@
+2012-08-23  Shezan Baig  <shezbaig.wk@gmail.com>
+
+        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  <abarth@webkit.org>
 
         [V8] V8ScriptInstance is much more complicated than necessary
index 361a5c9..5ec6df9 100644 (file)
@@ -433,19 +433,17 @@ void RenderBox::updateLayerTransform()
         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 @@ void RenderBox::computeLogicalHeight()
         }
 
         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.
index 0bd773f..4affbc0 100644 (file)
@@ -75,7 +75,7 @@ public:
     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(); }
index 448d4da..f40201f 100644 (file)
@@ -1233,10 +1233,10 @@ void RenderFlexibleBox::alignChildren(OrderIterator& iterator, const WTF::Vector
 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()) {