Changeset 143539 in webkit


Ignore:
Timestamp:
Feb 20, 2013 5:07:56 PM (11 years ago)
Author:
ojan@chromium.org
Message:

Positioned, replaced elements with intrinsic width keywords compute the wrong width
https://bugs.webkit.org/show_bug.cgi?id=110393

Reviewed by Emil A Eklund.

Source/WebCore:

Test: fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeReplacedLogicalWidthUsing):
Add the intrinsic size keywords to the switch. Confusingly, we have to
subtract the border and padding since the callers expect the content width.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalWidth):
Don't do the intrinsic ratio calculation if the width is an
intrinsic width keyword, as per, http://dev.w3.org/csswg/css3-sizing/#replaced-intrinsic.

(WebCore::RenderReplaced::computeIntrinsicLogicalWidths):
(WebCore::RenderReplaced::computePreferredLogicalWidths):
The old code was trying to apply the intrinsic ratio calculation to
the intrinsic width, which is wrong per spec.

LayoutTests:

  • fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes-expected.txt: Added.
  • fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r143537 r143539  
     12013-02-20  Ojan Vafai  <ojan@chromium.org>
     2
     3        Positioned, replaced elements with intrinsic width keywords compute the wrong width
     4        https://bugs.webkit.org/show_bug.cgi?id=110393
     5
     6        Reviewed by Emil A Eklund.
     7
     8        * fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes-expected.txt: Added.
     9        * fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes.html: Added.
     10
    1112013-02-20  Simon Fraser  <simon.fraser@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r143538 r143539  
     12013-02-20  Ojan Vafai  <ojan@chromium.org>
     2
     3        Positioned, replaced elements with intrinsic width keywords compute the wrong width
     4        https://bugs.webkit.org/show_bug.cgi?id=110393
     5
     6        Reviewed by Emil A Eklund.
     7
     8        Test: fast/css-intrinsic-dimensions/intrinsic-sized-replaced-absolutes.html
     9
     10        * rendering/RenderBox.cpp:
     11        (WebCore::RenderBox::computeReplacedLogicalWidthUsing):
     12        Add the intrinsic size keywords to the switch. Confusingly, we have to
     13        subtract the border and padding since the callers expect the content width.
     14
     15        * rendering/RenderReplaced.cpp:
     16        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
     17        Don't do the intrinsic ratio calculation if the width is an
     18        intrinsic width keyword, as per, http://dev.w3.org/csswg/css3-sizing/#replaced-intrinsic.
     19
     20        (WebCore::RenderReplaced::computeIntrinsicLogicalWidths):
     21        (WebCore::RenderReplaced::computePreferredLogicalWidths):
     22        The old code was trying to apply the intrinsic ratio calculation to
     23        the intrinsic width, which is wrong per spec.
     24
    1252013-02-20  Alec Flett  <alecflett@chromium.org>
    226
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r143479 r143539  
    25892589        case Fixed:
    25902590            return adjustContentBoxLogicalWidthForBoxSizing(logicalWidth.value());
     2591        case MinContent:
     2592        case MaxContent: {
     2593            // MinContent/MaxContent don't need the availableLogicalWidth argument.
     2594            LayoutUnit availableLogicalWidth = 0;
     2595            return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth) - borderAndPaddingLogicalWidth();
     2596        }
    25912597        case ViewportPercentageWidth:
    25922598        case ViewportPercentageHeight:
     
    25942600        case ViewportPercentageMax:
    25952601            return adjustContentBoxLogicalWidthForBoxSizing(valueForLength(logicalWidth, 0, view()));
     2602        case FitContent:
     2603        case FillAvailable:
    25962604        case Percent:
    25972605        case Calculated: {
     
    26032611            // FIXME: Handle cases when containing block width is calculated or viewport percent.
    26042612            // https://bugs.webkit.org/show_bug.cgi?id=91071
     2613            if (logicalWidth.isIntrinsic())
     2614                return computeIntrinsicLogicalWidthUsing(logicalWidth, cw) - borderAndPaddingLogicalWidth();
    26052615            if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent())))
    26062616                return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForLength(logicalWidth, cw));
    26072617        }
    26082618        // fall through
    2609         default:
     2619        case Intrinsic:
     2620        case MinIntrinsic:
     2621        case Auto:
     2622        case Relative:
     2623        case Undefined:
    26102624            return intrinsicLogicalWidth();
    26112625     }
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r143102 r143539  
    320320LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
    321321{
    322     if (style()->logicalWidth().isSpecified())
     322    if (style()->logicalWidth().isSpecified() || style()->logicalWidth().isIntrinsic())
    323323        return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferred);
    324324
     
    422422void RenderReplaced::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
    423423{
     424    minLogicalWidth = maxLogicalWidth = intrinsicLogicalWidth();
     425}
     426
     427void RenderReplaced::computePreferredLogicalWidths()
     428{
     429    ASSERT(preferredLogicalWidthsDirty());
     430
    424431    // We cannot resolve any percent logical width here as the available logical
    425432    // width may not be set on our containing block.
    426     minLogicalWidth = maxLogicalWidth = style()->logicalWidth().isPercent() ? intrinsicLogicalWidth() : computeReplacedLogicalWidth(ComputePreferred);
    427 }
    428 
    429 void RenderReplaced::computePreferredLogicalWidths()
    430 {
    431     ASSERT(preferredLogicalWidthsDirty());
    432 
    433     computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
     433    if (style()->logicalWidth().isPercent())
     434        computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
     435    else
     436        m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = computeReplacedLogicalWidth(ComputePreferred);
    434437
    435438    RenderStyle* styleToUse = style();
Note: See TracChangeset for help on using the changeset viewer.