Changeset 138668 in webkit


Ignore:
Timestamp:
Jan 2, 2013 3:54:21 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
https://bugs.webkit.org/show_bug.cgi?id=26559

Patch by Bem Jones-Bey <Bem Jones-Bey> on 2013-01-02
Reviewed by Tony Chang.

Source/WebCore:

Percentage logical height computation now takes into account the min and max height of the container.

Test: fast/block/min-max-height-percent-height-child.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::constrainContentBoxLogicalHeightByMinMax): Added. Like constrainLogicalHeightByMinMax,

but constrains the content box instead of the border box.

(WebCore):
(WebCore::RenderBox::computeContentLogicalHeight): Make const so it can be called from the const method

constrainContentBoxLogicalHeightByMinMax.

(WebCore::RenderBox::computePercentageLogicalHeight): Use constrainContentBoxLogicalHeightByMinMax to properly

respect min and max height on the containing box when computing the percentage height.

  • rendering/RenderBox.h:

(RenderBox):

LayoutTests:

Add tests to ensure percent heights are correctly determined.

  • fast/block/min-max-height-percent-height-child-expected.txt: Added.
  • fast/block/min-max-height-percent-height-child.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138663 r138668  
     12013-01-02  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=26559
     5
     6        Reviewed by Tony Chang.
     7
     8        Add tests to ensure percent heights are correctly determined.
     9
     10        * fast/block/min-max-height-percent-height-child-expected.txt: Added.
     11        * fast/block/min-max-height-percent-height-child.html: Added.
     12
    1132013-01-02  Ryosuke Niwa  <rniwa@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r138667 r138668  
     12013-01-02  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        When a block's height is determined by min-height/max-height, children with percentage heights are sized incorrectly
     4        https://bugs.webkit.org/show_bug.cgi?id=26559
     5
     6        Reviewed by Tony Chang.
     7
     8        Percentage logical height computation now takes into account the min and max height of the container.
     9
     10        Test: fast/block/min-max-height-percent-height-child.html
     11
     12        * rendering/RenderBox.cpp:
     13        (WebCore::RenderBox::constrainContentBoxLogicalHeightByMinMax): Added. Like constrainLogicalHeightByMinMax,
     14            but constrains the content box instead of the border box.
     15        (WebCore):
     16        (WebCore::RenderBox::computeContentLogicalHeight): Make const so it can be called from the const method
     17            constrainContentBoxLogicalHeightByMinMax.
     18        (WebCore::RenderBox::computePercentageLogicalHeight): Use constrainContentBoxLogicalHeightByMinMax to properly
     19            respect min and max height on the containing box when computing the percentage height.
     20        * rendering/RenderBox.h:
     21        (RenderBox):
     22
    1232013-01-02  Tony Chang  <tony@chromium.org>
    224
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r138332 r138668  
    471471}
    472472
     473LayoutUnit RenderBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logicalHeight) const
     474{
     475    RenderStyle* styleToUse = style();
     476    if (!styleToUse->logicalMaxHeight().isUndefined()) {
     477        LayoutUnit maxH = computeContentLogicalHeight(MaxSize, styleToUse->logicalMaxHeight());
     478        if (maxH != -1)
     479            logicalHeight = min(logicalHeight, maxH);
     480    }
     481    return max(logicalHeight, computeContentLogicalHeight(MinSize, styleToUse->logicalMinHeight()));
     482}
     483
    473484IntRect RenderBox::absoluteContentBox() const
    474485{
     
    22992310}
    23002311
    2301 LayoutUnit RenderBox::computeContentLogicalHeight(SizeType heightType, const Length& height)
     2312LayoutUnit RenderBox::computeContentLogicalHeight(SizeType heightType, const Length& height) const
    23022313{
    23032314    LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(heightType, height);
     
    23822393        }
    23832394    } else if (cbstyle->logicalHeight().isFixed()) {
    2384         LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
    2385         availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
     2395        LayoutUnit contentBoxHeight = cb->adjustContentBoxLogicalHeightForBoxSizing(cbstyle->logicalHeight().value());
     2396        availableHeight = max<LayoutUnit>(0, cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - cb->scrollbarLogicalHeight()));
    23862397    } else if (cbstyle->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight) {
    23872398        // We need to recur and compute the percentage height for our containing block.
     
    23892400        if (heightWithScrollbar != -1) {
    23902401            LayoutUnit contentBoxHeightWithScrollbar = cb->adjustContentBoxLogicalHeightForBoxSizing(heightWithScrollbar);
    2391             availableHeight = max<LayoutUnit>(0, contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
     2402            // We need to adjust for min/max height because this method does not
     2403            // handle the min/max of the current block, its caller does. So the
     2404            // return value from the recursive call will not have been adjusted
     2405            // yet.
     2406            LayoutUnit contentBoxHeight = cb->constrainContentBoxLogicalHeightByMinMax(contentBoxHeightWithScrollbar - cb->scrollbarLogicalHeight());
     2407            availableHeight = max<LayoutUnit>(0, contentBoxHeight);
    23922408        }
    23932409    } else if (cb->isRenderView() || isOutOfFlowPositionedWithSpecifiedHeight) {
  • trunk/Source/WebCore/rendering/RenderBox.h

    r138332 r138668  
    8383    LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
    8484    LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit) const;
     85    LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit) const;
    8586
    8687    int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
     
    414415    LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
    415416    LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height) const;
    416     LayoutUnit computeContentLogicalHeight(SizeType, const Length& height);
     417    LayoutUnit computeContentLogicalHeight(SizeType, const Length& height) const;
    417418    LayoutUnit computeContentAndScrollbarLogicalHeightUsing(SizeType, const Length& height) const;
    418419    LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const;
Note: See TracChangeset for help on using the changeset viewer.