Changeset 143476 in webkit


Ignore:
Timestamp:
Feb 20, 2013 10:37:06 AM (11 years ago)
Author:
ojan@chromium.org
Message:

Make intrinsic width values work for positioned elements
https://bugs.webkit.org/show_bug.cgi?id=110264

Reviewed by Tony Chang.

Source/WebCore:

Tests: fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html

fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeIntrinsicLogicalWidthUsing):
(WebCore::RenderBox::computeLogicalWidthInRegionUsing):
Move the computation of intrinsic widths out into a helper function so that
computePositionedLogicalWidthUsing can use it. As per the current spec,
fill-available measures shrink to avoid floats. http://dev.w3.org/csswg/css3-sizing/

(WebCore::RenderBox::computePositionedLogicalWidth):
Compute intrinsic min-widths in addition to non-zero ones. Intrinsic widths
return true for isZero. width and max-width don't need modifying since they already
call computePositionedLogicalWidthUsing for intrinsic widths.

(WebCore::RenderBox::computePositionedLogicalWidthUsing):
Compute intrinsic widths and use a Fixed length for the rest of the positioned width
computation. Doesn't include bordersPlusPadding because the caller, expected the content
width and adds in the bordersPlusPadding later.

  • rendering/RenderBox.h:

LayoutTests:

  • fast/css-intrinsic-dimensions/intrinsic-sized-absolutes-expected.txt: Added.
  • fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html: Added.
  • fast/css-intrinsic-dimensions/width-shrinks-avoid-floats-expected.txt: Added.
  • fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html: Added.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143475 r143476  
     12013-02-20  Ojan Vafai  <ojan@chromium.org>
     2
     3        Make intrinsic width values work for positioned elements
     4        https://bugs.webkit.org/show_bug.cgi?id=110264
     5
     6        Reviewed by Tony Chang.
     7
     8        * fast/css-intrinsic-dimensions/intrinsic-sized-absolutes-expected.txt: Added.
     9        * fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html: Added.
     10        * fast/css-intrinsic-dimensions/width-shrinks-avoid-floats-expected.txt: Added.
     11        * fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html: Added.
     12
    1132013-02-20  Robert Hogan  <robert@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r143475 r143476  
     12013-02-20  Ojan Vafai  <ojan@chromium.org>
     2
     3        Make intrinsic width values work for positioned elements
     4        https://bugs.webkit.org/show_bug.cgi?id=110264
     5
     6        Reviewed by Tony Chang.
     7
     8        Tests: fast/css-intrinsic-dimensions/intrinsic-sized-absolutes.html
     9               fast/css-intrinsic-dimensions/width-shrinks-avoid-floats.html
     10
     11        * rendering/RenderBox.cpp:
     12        (WebCore::RenderBox::computeIntrinsicLogicalWidthUsing):
     13        (WebCore::RenderBox::computeLogicalWidthInRegionUsing):
     14        Move the computation of intrinsic widths out into a helper function so that
     15        computePositionedLogicalWidthUsing can use it. As per the current spec,
     16        fill-available measures shrink to avoid floats. http://dev.w3.org/csswg/css3-sizing/
     17
     18        (WebCore::RenderBox::computePositionedLogicalWidth):
     19        Compute intrinsic min-widths in addition to non-zero ones. Intrinsic widths
     20        return true for isZero. width and max-width don't need modifying since they already
     21        call computePositionedLogicalWidthUsing for intrinsic widths.
     22
     23        (WebCore::RenderBox::computePositionedLogicalWidthUsing):
     24        Compute intrinsic widths and use a Fixed length for the rest of the positioned width
     25        computation. Doesn't include bordersPlusPadding because the caller, expected the content
     26        width and adds in the bordersPlusPadding later.
     27
     28        * rendering/RenderBox.h:
     29
    1302013-02-20  Robert Hogan  <robert@webkit.org>
    231
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r143313 r143476  
    20392039}
    20402040
     2041LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const
     2042{
     2043    if (logicalWidthLength.type() == MinContent)
     2044        return minIntrinsicLogicalWidth();
     2045    if (logicalWidthLength.type() == MaxContent)
     2046        return maxIntrinsicLogicalWidth();
     2047
     2048    RenderView* renderView = view();
     2049    LayoutUnit marginStart = minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView);
     2050    LayoutUnit marginEnd = minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView);
     2051    LayoutUnit fillAvailableMeasure = availableLogicalWidth - marginStart - marginEnd;
     2052
     2053    if (logicalWidthLength.type() == FillAvailable)
     2054        return fillAvailableMeasure;
     2055    if (logicalWidthLength.type() == FitContent) {
     2056        LayoutUnit minLogicalWidth = 0;
     2057        LayoutUnit maxLogicalWidth = 0;
     2058        computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
     2059        minLogicalWidth += borderAndPaddingLogicalWidth();
     2060        maxLogicalWidth += borderAndPaddingLogicalWidth();
     2061        return max(minLogicalWidth, min(maxLogicalWidth, fillAvailableMeasure));
     2062    }
     2063    ASSERT_NOT_REACHED();
     2064    return 0;
     2065}
     2066
    20412067LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, LayoutUnit availableLogicalWidth,
    20422068    const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     
    20612087    }
    20622088
    2063     if (logicalWidth.type() == MinContent)
    2064         return minIntrinsicLogicalWidth();
    2065     if (logicalWidth.type() == MaxContent)
    2066         return maxIntrinsicLogicalWidth();
     2089    if (logicalWidth.isIntrinsic())
     2090        return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth);
    20672091
    20682092    RenderView* renderView = view();
     
    20712095    LayoutUnit logicalWidthResult = availableLogicalWidth - marginStart - marginEnd;
    20722096
    2073     // shrinkToAvoidFloats() is only true for width: auto so the below code works correctly for
    2074     // width: fill-available since no case matches and it returns the logicalWidthResult from above.
    20752097    if (shrinkToAvoidFloats() && cb->containsFloats())
    20762098        logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region, offsetFromLogicalTopOfFirstPage));
    2077 
    2078     if (logicalWidth.type() == FitContent) {
    2079         LayoutUnit minLogicalWidth = 0;
    2080         LayoutUnit maxLogicalWidth = 0;
    2081         computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
    2082         minLogicalWidth += borderAndPaddingLogicalWidth();
    2083         maxLogicalWidth += borderAndPaddingLogicalWidth();
    2084         return max(minLogicalWidth, min(maxLogicalWidth, logicalWidthResult));
    2085     }
    2086 
    2087     if (logicalWidth.type() == FillAvailable)
    2088         return logicalWidthResult;
    20892099
    20902100    if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthType))
     
    30013011
    30023012    // Calculate constraint equation values for 'min-width' case.
    3003     if (!style()->logicalMinWidth().isZero()) {
     3013    if (!style()->logicalMinWidth().isZero() || style()->logicalMinWidth().isIntrinsic()) {
    30043014        LogicalExtentComputedValues minValues;
    30053015
     
    30633073    if (widthSizeType == MinSize && logicalWidth.isAuto())
    30643074        logicalWidth = Length(0, Fixed);
     3075    else if (logicalWidth.isIntrinsic())
     3076        logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth) - bordersPlusPadding, Fixed);
    30653077
    30663078    // 'left' and 'right' cannot both be 'auto' because one would of been
  • trunk/Source/WebCore/rendering/RenderBox.h

    r142816 r143476  
    659659    void computePositionedLogicalWidthReplaced(LogicalExtentComputedValues&) const;
    660660
     661    LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const;
     662
    661663    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
    662664
Note: See TracChangeset for help on using the changeset viewer.