Changeset 125055 in webkit


Ignore:
Timestamp:
Aug 8, 2012 11:29:02 AM (12 years ago)
Author:
ojan@chromium.org
Message:

percentage height/width values in quirks mode are incorrectly resolved in flexbox children
https://bugs.webkit.org/show_bug.cgi?id=81809

Reviewed by Tony Chang.

Source/WebCore:

When computing percentage logical heights we need to use the RenderBox helper methods
to make sure we handle all the edge cases correctly (e.g. walk up the containing block
ancestor chain in quirks mode until we find a definite size).

For widths, the containing block always has a definite size, so all we need to do
is call computeContentBoxLogicalWidth(valueForLength(...)), although I'm not sure
this does the right thing for the intrinsic sizing keywords.

Tests: css3/flexbox/box-sizing-min-max-sizes.html

css3/flexbox/percentage-sizes-quirks.html
css3/flexbox/percentage-sizes.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeLogicalClientHeight):
(WebCore):

  • rendering/RenderBox.h:

(RenderBox):

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeMainAxisSizeForChild):
(WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForChild):
(WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax):

  • rendering/RenderFlexibleBox.h:

LayoutTests:

  • css3/flexbox/box-sizing-min-max-sizes-expected.txt: Added.
  • css3/flexbox/box-sizing-min-max-sizes.html: Added.
  • css3/flexbox/percentage-sizes-expected.txt: Added.
  • css3/flexbox/percentage-sizes-quirks-expected.txt: Added.
  • css3/flexbox/percentage-sizes-quirks.html: Added.
  • css3/flexbox/percentage-sizes.html: Added.
Location:
trunk
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r125054 r125055  
     12012-08-07  Ojan Vafai  <ojan@chromium.org>
     2
     3        percentage height/width values in quirks mode are incorrectly resolved in flexbox children
     4        https://bugs.webkit.org/show_bug.cgi?id=81809
     5
     6        Reviewed by Tony Chang.
     7
     8        * css3/flexbox/box-sizing-min-max-sizes-expected.txt: Added.
     9        * css3/flexbox/box-sizing-min-max-sizes.html: Added.
     10        * css3/flexbox/percentage-sizes-expected.txt: Added.
     11        * css3/flexbox/percentage-sizes-quirks-expected.txt: Added.
     12        * css3/flexbox/percentage-sizes-quirks.html: Added.
     13        * css3/flexbox/percentage-sizes.html: Added.
     14
    1152012-08-08  Andrew Scherkus  <scherkus@chromium.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r125054 r125055  
     12012-08-07  Ojan Vafai  <ojan@chromium.org>
     2
     3        percentage height/width values in quirks mode are incorrectly resolved in flexbox children
     4        https://bugs.webkit.org/show_bug.cgi?id=81809
     5
     6        Reviewed by Tony Chang.
     7
     8        When computing percentage logical heights we need to use the RenderBox helper methods
     9        to make sure we handle all the edge cases correctly (e.g. walk up the containing block
     10        ancestor chain in quirks mode until we find a definite size).
     11
     12        For widths, the containing block always has a definite size, so all we need to do
     13        is call computeContentBoxLogicalWidth(valueForLength(...)), although I'm not sure
     14        this does the right thing for the intrinsic sizing keywords.
     15
     16        Tests: css3/flexbox/box-sizing-min-max-sizes.html
     17               css3/flexbox/percentage-sizes-quirks.html
     18               css3/flexbox/percentage-sizes.html
     19
     20        * rendering/RenderBox.cpp:
     21        (WebCore::RenderBox::computeLogicalClientHeight):
     22        (WebCore):
     23        * rendering/RenderBox.h:
     24        (RenderBox):
     25        * rendering/RenderFlexibleBox.cpp:
     26        (WebCore::RenderFlexibleBox::computeMainAxisSizeForChild):
     27        (WebCore::RenderFlexibleBox::preferredMainAxisContentExtentForChild):
     28        (WebCore::RenderFlexibleBox::adjustChildSizeForMinAndMax):
     29        * rendering/RenderFlexibleBox.h:
     30
    1312012-08-08  Andrew Scherkus  <scherkus@chromium.org>
    232
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r124773 r125055  
    20602060        logicalHeight = computeBorderBoxLogicalHeight(logicalHeight);
    20612061    return logicalHeight;
     2062}
     2063
     2064LayoutUnit RenderBox::computeLogicalClientHeight(SizeType heightType, const Length& height)
     2065{
     2066    LayoutUnit heightIncludingScrollbar = computeContentLogicalHeightUsing(heightType, height);
     2067    if (heightIncludingScrollbar == -1)
     2068        return -1;
     2069    return std::max(LayoutUnit(0), computeContentBoxLogicalHeight(heightIncludingScrollbar) - scrollbarLogicalHeight());
    20622070}
    20632071
  • trunk/Source/WebCore/rendering/RenderBox.h

    r124662 r125055  
    343343    LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage);
    344344    LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height);
     345    LayoutUnit computeLogicalClientHeight(SizeType, const Length& height);
    345346    LayoutUnit computeContentLogicalHeightUsing(SizeType, const Length& height);
    346347    LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const;
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r124987 r125055  
    401401}
    402402
    403 LayoutUnit RenderFlexibleBox::computeLogicalClientHeight(SizeType heightType, const Length& height)
    404 {
    405     LayoutUnit heightIncludingScrollbar = computeContentLogicalHeightUsing(heightType, height);
    406     if (heightIncludingScrollbar == -1)
    407         return -1;
    408     return std::max(LayoutUnit(0), computeContentBoxLogicalHeight(heightIncludingScrollbar) - scrollbarLogicalHeight());
     403LayoutUnit RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox* child, SizeType sizeType, const Length& size, LayoutUnit maximumValue)
     404{
     405    // FIXME: This is wrong for orthogonal flows. It should use the flexbox's writing-mode, not the child's in order
     406    // to figure out the logical height/width.
     407    if (isColumnFlow())
     408        return child->computeLogicalClientHeight(sizeType, size);
     409    return child->computeContentBoxLogicalWidth(valueForLength(size, maximumValue, view()));
    409410}
    410411
     
    605606        return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child);
    606607    }
    607     LayoutUnit extent = minimumValueForLength(flexBasis, mainAxisContentExtent(), view());
    608     extent = isColumnFlow() ? child->computeContentBoxLogicalHeight(extent) : child->computeContentBoxLogicalWidth(extent);
    609     return std::max(LayoutUnit(0), extent);
     608    return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis, mainAxisContentExtent()));
    610609}
    611610
     
    814813LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, LayoutUnit childSize, LayoutUnit flexboxAvailableContentExtent)
    815814{
     815    // FIXME: Support intrinsic min/max lengths.
    816816    Length max = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
     817    if (max.isSpecified()) {
     818        LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max, flexboxAvailableContentExtent);
     819        if (maxExtent != -1 && childSize > maxExtent)
     820            childSize = maxExtent;
     821    }
     822
    817823    Length min = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
    818     RenderView* renderView = view();
    819     // FIXME: valueForLength isn't quite right in quirks mode: percentage heights should check parents until a value is found.
    820     // https://bugs.webkit.org/show_bug.cgi?id=81809
    821     if (max.isSpecified() && childSize > valueForLength(max, flexboxAvailableContentExtent, renderView))
    822         childSize = valueForLength(max, flexboxAvailableContentExtent, renderView);
    823 
    824     if (min.isSpecified() && childSize < valueForLength(min, flexboxAvailableContentExtent, renderView))
    825         return valueForLength(min, flexboxAvailableContentExtent, renderView);
    826 
    827     // FIXME: Support min/max sizes of fit-content, max-content and fill-available.
    828     if (min.isAuto()) {
    829         LayoutUnit minContent = hasOrthogonalFlow(child) ? child->logicalHeight() : child->minPreferredLogicalWidth();
    830         minContent -= mainAxisBorderAndPaddingExtentForChild(child);
    831         return std::max(childSize, minContent);
    832     }
    833 
    834     return childSize;
     824    LayoutUnit minExtent = 0;
     825    if (min.isSpecified())
     826        minExtent = computeMainAxisExtentForChild(child, MinSize, min, flexboxAvailableContentExtent);
     827    else if (min.isAuto()) {
     828        minExtent = hasOrthogonalFlow(child) ? child->logicalHeight() : child->minPreferredLogicalWidth();
     829        minExtent -= mainAxisBorderAndPaddingExtentForChild(child);
     830    }
     831    return std::max(childSize, minExtent);
    835832}
    836833
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r124987 r125055  
    8686    LayoutUnit crossAxisContentExtent() const;
    8787    LayoutUnit mainAxisContentExtent();
    88     LayoutUnit computeLogicalClientHeight(SizeType, const Length& height);
     88    LayoutUnit computeMainAxisExtentForChild(RenderBox* child, SizeType, const Length& size, LayoutUnit maximumValue);
    8989    WritingMode transformedWritingMode() const;
    9090    LayoutUnit flowAwareBorderStart() const;
Note: See TracChangeset for help on using the changeset viewer.