Changeset 126468 in webkit


Ignore:
Timestamp:
Aug 23, 2012 12:46:51 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <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.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126465 r126468  
     12012-08-23  Shezan Baig  <shezbaig.wk@gmail.com>
     2
     3        Flexbox doesn't need to compute logical height for stretched items in row flow
     4        https://bugs.webkit.org/show_bug.cgi?id=94807
     5
     6        Reviewed by Tony Chang.
     7
     8        Change logicalHeightConstrainedByMinMax to
     9        constrainLogicalHeightByMinMax. The new method doesn't compute the
     10        MainOrPreferred logical height (that computation has been moved back to
     11        computeLogicalHeight). RenderFlexibleBox now just constrains the
     12        stretchedLogicalHeight by min/max.
     13
     14        No new tests. This is a cleanup of bug 94237.
     15
     16        * rendering/RenderBox.cpp:
     17        (WebCore::RenderBox::constrainLogicalHeightByMinMax): Instead of
     18        computing the MainOrPreferred logical height, just constrain the given
     19        logical height by MinSize and MaxSize.
     20        (WebCore::RenderBox::computeLogicalHeight): Compute the MainOrPreferred
     21        logical height before constraining by min/max.
     22        * rendering/RenderBox.h:
     23        (RenderBox):
     24        * rendering/RenderFlexibleBox.cpp:
     25        (WebCore::RenderFlexibleBox::applyStretchAlignmentToChild): Use
     26        constrainLogicalHeightByMinMax to constrain the stretchedLogicalHeight.
     27
    1282012-08-23  Adam Barth  <abarth@webkit.org>
    229
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r126437 r126468  
    434434}
    435435
    436 LayoutUnit RenderBox::logicalHeightConstrainedByMinMax(LayoutUnit availableHeight)
     436LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight)
    437437{
    438438    RenderStyle* styleToUse = style();
    439     LayoutUnit result = computeLogicalHeightUsing(MainOrPreferredSize, styleToUse->logicalHeight());
    440     if (result == -1)
    441         result = availableHeight;
    442     LayoutUnit minH = computeLogicalHeightUsing(MinSize, styleToUse->logicalMinHeight()); // Leave as -1 if unset.
    443     LayoutUnit maxH = styleToUse->logicalMaxHeight().isUndefined() ? result : computeLogicalHeightUsing(MaxSize, styleToUse->logicalMaxHeight());
    444     if (maxH == -1)
    445         maxH = result;
    446     result = min(maxH, result);
    447     result = max(minH, result);
    448     return result;
     439    if (!styleToUse->logicalMaxHeight().isUndefined()) {
     440        // Constrain by MaxSize.
     441        LayoutUnit maxH = computeLogicalHeightUsing(MaxSize, styleToUse->logicalMaxHeight());
     442        if (maxH != -1)
     443            logicalHeight = min(logicalHeight, maxH);
     444    }
     445    // Constrain by MinSize.
     446    return max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse->logicalMinHeight()));
    449447}
    450448
     
    20142012
    20152013        LayoutUnit heightResult;
    2016         if (checkMinMaxHeight)
    2017             heightResult = logicalHeightConstrainedByMinMax(logicalHeight());
    2018         else {
     2014        if (checkMinMaxHeight) {
     2015            heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style()->logicalHeight());
     2016            if (heightResult == -1)
     2017                heightResult = logicalHeight();
     2018            heightResult = constrainLogicalHeightByMinMax(heightResult);
     2019        } else {
    20192020            // The only times we don't check min/max height are when a fixed length has
    20202021            // been given as an override.  Just use that.  The value has already been adjusted
  • trunk/Source/WebCore/rendering/RenderBox.h

    r126437 r126468  
    7676    LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
    7777
    78     LayoutUnit logicalHeightConstrainedByMinMax(LayoutUnit);
     78    LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit);
    7979
    8080    int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r126257 r126468  
    12341234{
    12351235    if (!isColumnFlow() && child->style()->logicalHeight().isAuto()) {
    1236         // FIXME: If the child has orthogonal flow, then it already has an override height set. How do we stretch?
     1236        // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it.
    12371237        if (!hasOrthogonalFlow(child)) {
    12381238            LayoutUnit stretchedLogicalHeight = child->logicalHeight() + availableAlignmentSpaceForChild(lineCrossAxisExtent, child);
    1239             LayoutUnit desiredLogicalHeight = child->logicalHeightConstrainedByMinMax(stretchedLogicalHeight);
     1239            LayoutUnit desiredLogicalHeight = child->constrainLogicalHeightByMinMax(stretchedLogicalHeight);
    12401240
    12411241            // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905.
Note: See TracChangeset for help on using the changeset viewer.