Changeset 138332 in webkit


Ignore:
Timestamp:
Dec 20, 2012, 5:52:05 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Percentage min/max width replaced element may incorrectly rendered
https://bugs.webkit.org/show_bug.cgi?id=105264

Patch by KyungTae Kim <ktf.kim@samsung.com> on 2012-12-20
Reviewed by Tony Chang.

Source/WebCore:

To make do not include percentage min width in preferred logical width calculation,
because we cannot resolve it for preferred width.

Test: fast/css/percent-min-width-img-src-change.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::computeReplacedLogicalWidth):
Modify includeMaxWidth parameter to shouldComputePreferred.
(WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth):
Modify includeMaxWidth parameter to shouldComputePreferred.
If shouldComputePreferred is ComputePreferred,
don't use minLogicalWidth or maxLogicalWidth if they are percent type.

  • rendering/RenderBox.h:

(RenderBox):

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeReplacedLogicalWidth):
Modify includeMaxWidth parameter to shouldComputePreferred.
(WebCore::RenderReplaced::computeMaxPreferredLogicalWidth):
Modify from set includeMaxWidth=false to set shouldComputePreferred=ComputePreferred.

  • rendering/RenderReplaced.h:

(RenderReplaced):

  • rendering/RenderSVGRoot.cpp:

(WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
Modify includeMaxWidth parameter to shouldComputePreferred.

  • rendering/RenderSVGRoot.h:

(RenderSVGRoot):

  • rendering/RenderVideo.cpp:

(WebCore::RenderVideo::computeReplacedLogicalWidth):
Modify includeMaxWidth parameter to shouldComputePreferred.

  • rendering/RenderVideo.h:

(RenderVideo):

LayoutTests:

Add test to check when the source of images with percentage min-width is changed.

  • fast/css/percent-min-width-img-src-change-expected.txt: Added.
  • fast/css/percent-min-width-img-src-change.html: Added.
Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138330 r138332  
     12012-12-20  KyungTae Kim  <ktf.kim@samsung.com>
     2
     3        Percentage min/max width replaced element may incorrectly rendered
     4        https://bugs.webkit.org/show_bug.cgi?id=105264
     5
     6        Reviewed by Tony Chang.
     7
     8        Add test to check when the source of images with percentage min-width is changed.
     9
     10        * fast/css/percent-min-width-img-src-change-expected.txt: Added.
     11        * fast/css/percent-min-width-img-src-change.html: Added.
     12
    1132012-12-20  Ryosuke Niwa  <rniwa@webkit.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r138328 r138332  
     12012-12-20  KyungTae Kim  <ktf.kim@samsung.com>
     2
     3        Percentage min/max width replaced element may incorrectly rendered
     4        https://bugs.webkit.org/show_bug.cgi?id=105264
     5
     6        Reviewed by Tony Chang.
     7
     8        To make do not include percentage min width in preferred logical width calculation,
     9        because we cannot resolve it for preferred width.
     10
     11        Test: fast/css/percent-min-width-img-src-change.html
     12
     13        * rendering/RenderBox.cpp:
     14        (WebCore::RenderBox::computeReplacedLogicalWidth):
     15        Modify includeMaxWidth parameter to shouldComputePreferred.
     16        (WebCore::RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth):
     17        Modify includeMaxWidth parameter to shouldComputePreferred.
     18        If shouldComputePreferred is ComputePreferred,
     19        don't use minLogicalWidth or maxLogicalWidth if they are percent type.
     20        * rendering/RenderBox.h:
     21        (RenderBox):
     22        * rendering/RenderReplaced.cpp:
     23        (WebCore::RenderReplaced::computeReplacedLogicalWidth):
     24        Modify includeMaxWidth parameter to shouldComputePreferred.
     25        (WebCore::RenderReplaced::computeMaxPreferredLogicalWidth):
     26        Modify from set includeMaxWidth=false to set shouldComputePreferred=ComputePreferred.
     27        * rendering/RenderReplaced.h:
     28        (RenderReplaced):
     29        * rendering/RenderSVGRoot.cpp:
     30        (WebCore::RenderSVGRoot::computeReplacedLogicalWidth):
     31        Modify includeMaxWidth parameter to shouldComputePreferred.
     32        * rendering/RenderSVGRoot.h:
     33        (RenderSVGRoot):
     34        * rendering/RenderVideo.cpp:
     35        (WebCore::RenderVideo::computeReplacedLogicalWidth):
     36        Modify includeMaxWidth parameter to shouldComputePreferred.
     37        * rendering/RenderVideo.h:
     38        (RenderVideo):
     39
    1402012-12-20  Alexey Proskuryakov  <ap@apple.com>
    241
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r138317 r138332  
    24162416}
    24172417
    2418 LayoutUnit RenderBox::computeReplacedLogicalWidth(bool includeMaxWidth) const
    2419 {
    2420     return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), includeMaxWidth);
    2421 }
    2422 
    2423 LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth) const
    2424 {
    2425     LayoutUnit minLogicalWidth = computeReplacedLogicalWidthUsing(MinSize, style()->logicalMinWidth());
    2426     LayoutUnit maxLogicalWidth = !includeMaxWidth || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style()->logicalMaxWidth());
     2418LayoutUnit RenderBox::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
     2419{
     2420    return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferred);
     2421}
     2422
     2423LayoutUnit RenderBox::computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred shouldComputePreferred) const
     2424{
     2425    LayoutUnit minLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMinWidth().isPercent()) || style()->logicalMinWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(MinSize, style()->logicalMinWidth());
     2426    LayoutUnit maxLogicalWidth = (shouldComputePreferred == ComputePreferred && style()->logicalMaxWidth().isPercent()) || style()->logicalMaxWidth().isUndefined() ? logicalWidth : computeReplacedLogicalWidthUsing(MaxSize, style()->logicalMaxWidth());
    24272427    return max(minLogicalWidth, min(logicalWidth, maxLogicalWidth));
    24282428}
  • trunk/Source/WebCore/rendering/RenderBox.h

    r137930 r138332  
    4141enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayScrollbarSize };
    4242
     43enum ShouldComputePreferred { ComputeActual, ComputePreferred };
     44
    4345class RenderBox : public RenderBoxModelObject {
    4446public:
     
    415417    LayoutUnit computeContentAndScrollbarLogicalHeightUsing(SizeType, const Length& height) const;
    416418    LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const;
    417     LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth = true) const;
     419    LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, ShouldComputePreferred  = ComputeActual) const;
    418420    LayoutUnit computeReplacedLogicalHeightUsing(SizeType, Length height) const;
    419421    LayoutUnit computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutUnit logicalHeight) const;
    420422
    421     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     423    virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const;
    422424    virtual LayoutUnit computeReplacedLogicalHeight() const;
    423425
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r137169 r138332  
    338338}
    339339
    340 LayoutUnit RenderReplaced::computeReplacedLogicalWidth(bool includeMaxWidth) const
     340LayoutUnit RenderReplaced::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
    341341{
    342342    if (style()->logicalWidth().isSpecified())
    343         return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), includeMaxWidth);
     343        return computeReplacedLogicalWidthRespectingMinMaxWidth(computeReplacedLogicalWidthUsing(MainOrPreferredSize, style()->logicalWidth()), shouldComputePreferred);
    344344
    345345    RenderBox* contentRenderer = embeddedContentBox();
     
    357357        // If 'height' and 'width' both have computed values of 'auto' and the element also has an intrinsic width, then that intrinsic width is the used value of 'width'.
    358358        if (heightIsAuto && hasIntrinsicWidth)
    359             return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedSize.width(), includeMaxWidth);
     359            return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedSize.width(), shouldComputePreferred);
    360360
    361361        bool hasIntrinsicHeight = !isPercentageIntrinsicSize && constrainedSize.height() > 0;
     
    366366            if (intrinsicRatio && ((heightIsAuto && !hasIntrinsicWidth && hasIntrinsicHeight) || !heightIsAuto)) {
    367367                LayoutUnit logicalHeight = computeReplacedLogicalHeight();
    368                 return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)));
     368                return computeReplacedLogicalWidthRespectingMinMaxWidth(roundToInt(round(logicalHeight * intrinsicRatio)), shouldComputePreferred);
    369369            }
    370370
     
    377377                LayoutUnit logicalWidth;
    378378                if (RenderBlock* blockWithWidth = firstContainingBlockWithLogicalWidth(this))
    379                     logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(MainOrPreferredSize, blockWithWidth->style()->logicalWidth()), false);
     379                    logicalWidth = blockWithWidth->computeReplacedLogicalWidthRespectingMinMaxWidth(blockWithWidth->computeReplacedLogicalWidthUsing(MainOrPreferredSize, blockWithWidth->style()->logicalWidth()), shouldComputePreferred);
    380380                else
    381381                    logicalWidth = containingBlock()->availableLogicalWidth();
     
    387387                if (isPercentageIntrinsicSize)
    388388                    logicalWidth = logicalWidth * constrainedSize.width() / 100;
    389                 return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, includeMaxWidth);
     389                return computeReplacedLogicalWidthRespectingMinMaxWidth(logicalWidth, shouldComputePreferred);
    390390            }
    391391        }
     
    393393        // Otherwise, if 'width' has a computed value of 'auto', and the element has an intrinsic width, then that intrinsic width is the used value of 'width'.
    394394        if (hasIntrinsicWidth)
    395             return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedSize.width(), includeMaxWidth);
     395            return computeReplacedLogicalWidthRespectingMinMaxWidth(constrainedSize.width(), shouldComputePreferred);
    396396
    397397        // Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. If 300px is too
     
    402402    }
    403403
    404     return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), includeMaxWidth);
     404    return computeReplacedLogicalWidthRespectingMinMaxWidth(intrinsicLogicalWidth(), shouldComputePreferred);
    405405}
    406406
     
    449449        return intrinsicLogicalWidth();
    450450
    451     // FIXME: We shouldn't be calling a logical width computing function in preferred
    452     // logical widths computation as the layout information is probably invalid.
    453     return computeReplacedLogicalWidth(false);
     451    return computeReplacedLogicalWidth(ComputePreferred);
    454452}
    455453
  • trunk/Source/WebCore/rendering/RenderReplaced.h

    r137169 r138332  
    3333    virtual ~RenderReplaced();
    3434
    35     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     35    virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const OVERRIDE;
    3636    virtual LayoutUnit computeReplacedLogicalHeight() const;
    3737
  • trunk/Source/WebCore/rendering/RenderVideo.cpp

    r133172 r138332  
    263263}
    264264
    265 LayoutUnit RenderVideo::computeReplacedLogicalWidth(bool includeMaxWidth) const
    266 {
    267     return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     265LayoutUnit RenderVideo::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
     266{
     267    return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
    268268}
    269269
  • trunk/Source/WebCore/rendering/RenderVideo.h

    r133172 r138332  
    7171    virtual void layout();
    7272
    73     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     73    virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const OVERRIDE;
    7474    virtual LayoutUnit computeReplacedLogicalHeight() const;
    7575    virtual LayoutUnit minimumReplacedHeight() const OVERRIDE;
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.cpp

    r133845 r138332  
    160160}
    161161
    162 LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(bool includeMaxWidth) const
     162LayoutUnit RenderSVGRoot::computeReplacedLogicalWidth(ShouldComputePreferred shouldComputePreferred) const
    163163{
    164164    SVGSVGElement* svg = static_cast<SVGSVGElement*>(node());
     
    170170
    171171    if (style()->logicalWidth().isSpecified() || style()->logicalMaxWidth().isSpecified())
    172         return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     172        return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
    173173
    174174    if (svg->widthAttributeEstablishesViewport())
     
    180180
    181181    // SVG embedded via SVGImage (background-image/border-image/etc) / Inline SVG.
    182     return RenderReplaced::computeReplacedLogicalWidth(includeMaxWidth);
     182    return RenderReplaced::computeReplacedLogicalWidth(shouldComputePreferred);
    183183}
    184184
  • trunk/Source/WebCore/rendering/svg/RenderSVGRoot.h

    r137847 r138332  
    7979    virtual const char* renderName() const { return "RenderSVGRoot"; }
    8080
    81     virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
     81    virtual LayoutUnit computeReplacedLogicalWidth(ShouldComputePreferred  = ComputeActual) const OVERRIDE;
    8282    virtual LayoutUnit computeReplacedLogicalHeight() const;
    8383    virtual void layout();
Note: See TracChangeset for help on using the changeset viewer.