Changeset 151997 in webkit


Ignore:
Timestamp:
Jun 26, 2013 10:31:26 AM (11 years ago)
Author:
hyatt@apple.com
Message:

Flex boxes (both old and new) don't handle max-height images correctly.
https://bugs.webkit.org/show_bug.cgi?id=118000

Reviewed by Beth Dakin.

Source/WebCore:

Tests: css3/flexbox/image-percent-max-height.html

fast/flexbox/image-percent-max-height.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::dirtyForLayoutFromPercentageHeightDescendants):
(WebCore::RenderBlock::layoutBlockChildren):
Pull the percentage height descendant code that dirties those descendants
out of layoutBlockChildren and into a protected helper function,
dirtyForLayoutFromPercentageHeightDescendants, that can be called from the
flex box code.

Also patch dirtyForLayoutFromPercentageHeightDescendants so that it will dirty
preferred logical widths when a child has an aspect ratio, since we know that
percentage height changes will potentially affect the preferred widths of the image and
its ancestor blocks.

  • rendering/RenderBlock.h:

Declaration of the new dirtyForLayoutFromPercentageHeightDescendants function.

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
Make the old flex box code call dirtyForLayoutFromPercentageHeightDescendants so
that everything is dirtied properly.

(WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
(WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox):
Remove the isReplaced()/percentage height/width dirtying now that the old flexible
box is using the same dirtying mechanism as RenderBlock.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutBlock):
Patch the new flexible box code to use the dirtying mechanism that RenderBlock
uses for percentage heights/widths on replaced descendants.

  • rendering/RenderObject.h:

(WebCore::RenderObject::hasAspectRatio):
Pulled the static helper function from RenderReplaced into a full-blown method
on RenderObject, so that dirtyForLayoutFromPercentageHeightDescendants can call
it to check if an object has an aspect ratio.

  • rendering/RenderReplaced.cpp:

(WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox):
(WebCore::RenderReplaced::computeIntrinsicRatioInformation):
Patch the call sites of the static helper function to use hasAspectRatio instead
and get rid of the static in the cpp file.

LayoutTests:

  • css3/flexbox/image-percent-max-height-expected.html: Added.
  • css3/flexbox/image-percent-max-height.html: Added.
  • css3/flexbox/resources/hero.png: Added.
  • fast/flexbox/image-percent-max-height-expected.html: Added.
  • fast/flexbox/image-percent-max-height.html: Added.
  • fast/flexbox/resources/hero.png: Added.
Location:
trunk
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r151993 r151997  
     12013-06-25  David Hyatt  <hyatt@apple.com>
     2
     3        Flex boxes (both old and new) don't handle max-height images correctly.
     4        https://bugs.webkit.org/show_bug.cgi?id=118000
     5
     6        Reviewed by Beth Dakin.
     7
     8        * css3/flexbox/image-percent-max-height-expected.html: Added.
     9        * css3/flexbox/image-percent-max-height.html: Added.
     10        * css3/flexbox/resources/hero.png: Added.
     11        * fast/flexbox/image-percent-max-height-expected.html: Added.
     12        * fast/flexbox/image-percent-max-height.html: Added.
     13        * fast/flexbox/resources/hero.png: Added.
     14
    1152013-06-26  Ryosuke Niwa  <rniwa@webkit.org>
    216
  • trunk/LayoutTests/tables/mozilla_expected_failures/bugs/bug85016-expected.txt

    r142981 r151997  
    1 layer at (0,0) size 982x2059
     1layer at (0,0) size 960x2059
    22  RenderView at (0,0) size 785x585
    33layer at (0,0) size 785x2059
     
    1313      RenderBlock {DIV} at (32,735) size 657x657 [border: (3px dotted #008000)]
    1414        RenderBlock {DIV} at (35,35) size 587x587 [border: (1px solid #FF0000)]
    15           RenderImage {IMG} at (1,1) size 882x585
     15          RenderImage {IMG} at (1,1) size 860x585
    1616          RenderText {#text} at (0,0) size 0x0
    1717      RenderBlock {P} at (0,1424) size 721x18
  • trunk/Source/WebCore/ChangeLog

    r151996 r151997  
     12013-06-25  David Hyatt  <hyatt@apple.com>
     2
     3        Flex boxes (both old and new) don't handle max-height images correctly.
     4        https://bugs.webkit.org/show_bug.cgi?id=118000
     5
     6        Reviewed by Beth Dakin.
     7
     8        Tests: css3/flexbox/image-percent-max-height.html
     9               fast/flexbox/image-percent-max-height.html
     10
     11        * rendering/RenderBlock.cpp:
     12        (WebCore::RenderBlock::dirtyForLayoutFromPercentageHeightDescendants):
     13        (WebCore::RenderBlock::layoutBlockChildren):
     14        Pull the percentage height descendant code that dirties those descendants
     15        out of layoutBlockChildren and into a protected helper function,
     16        dirtyForLayoutFromPercentageHeightDescendants, that can be called from the
     17        flex box code.
     18       
     19        Also patch dirtyForLayoutFromPercentageHeightDescendants so that it will dirty
     20        preferred logical widths when a child has an aspect ratio, since we know that
     21        percentage height changes will potentially affect the preferred widths of the image and
     22        its ancestor blocks.
     23
     24        * rendering/RenderBlock.h:
     25        Declaration of the new dirtyForLayoutFromPercentageHeightDescendants function.
     26
     27        * rendering/RenderDeprecatedFlexibleBox.cpp:
     28        (WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
     29        Make the old flex box code call dirtyForLayoutFromPercentageHeightDescendants so
     30        that everything is dirtied properly.
     31
     32        (WebCore::RenderDeprecatedFlexibleBox::layoutHorizontalBox):
     33        (WebCore::RenderDeprecatedFlexibleBox::layoutVerticalBox):
     34        Remove the isReplaced()/percentage height/width dirtying now that the old flexible
     35        box is using the same dirtying mechanism as RenderBlock.
     36
     37        * rendering/RenderFlexibleBox.cpp:
     38        (WebCore::RenderFlexibleBox::layoutBlock):
     39        Patch the new flexible box code to use the dirtying mechanism that RenderBlock
     40        uses for percentage heights/widths on replaced descendants.
     41
     42        * rendering/RenderObject.h:
     43        (WebCore::RenderObject::hasAspectRatio):
     44        Pulled the static helper function from RenderReplaced into a full-blown method
     45        on RenderObject, so that dirtyForLayoutFromPercentageHeightDescendants can call
     46        it to check if an object has an aspect ratio.
     47
     48        * rendering/RenderReplaced.cpp:
     49        (WebCore::RenderReplaced::computeAspectRatioInformationForRenderBox):
     50        (WebCore::RenderReplaced::computeIntrinsicRatioInformation):
     51        Patch the call sites of the static helper function to use hasAspectRatio instead
     52        and get rid of the static in the cpp file.
     53
    1542013-06-26  Kangil Han  <kangil.han@samsung.com>
    255
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r151946 r151997  
    25202520}
    25212521
     2522void RenderBlock::dirtyForLayoutFromPercentageHeightDescendants()
     2523{
     2524    if (!gPercentHeightDescendantsMap)
     2525        return;
     2526
     2527    TrackedRendererListHashSet* descendants = gPercentHeightDescendantsMap->get(this);
     2528    if (!descendants)
     2529        return;
     2530   
     2531    TrackedRendererListHashSet::iterator end = descendants->end();
     2532    for (TrackedRendererListHashSet::iterator it = descendants->begin(); it != end; ++it) {
     2533        RenderBox* box = *it;
     2534        while (box != this) {
     2535            if (box->normalChildNeedsLayout())
     2536                break;
     2537            box->setChildNeedsLayout(true, MarkOnlyThis);
     2538           
     2539            // If the width of an image is affected by the height of a child (e.g., an image with an aspect ratio),
     2540            // then we have to dirty preferred widths, since even enclosing blocks can become dirty as a result.
     2541            // (A horizontal flexbox that contains an inline image wrapped in an anonymous block for example.)
     2542            if (box->hasAspectRatio())
     2543                box->setPreferredLogicalWidthsDirty(true);
     2544           
     2545            box = box->containingBlock();
     2546            ASSERT(box);
     2547            if (!box)
     2548                break;
     2549        }
     2550    }
     2551}
     2552
    25222553void RenderBlock::layoutBlockChildren(bool relayoutChildren, LayoutUnit& maxFloatLogicalBottom)
    25232554{
    2524     if (gPercentHeightDescendantsMap) {
    2525         if (TrackedRendererListHashSet* descendants = gPercentHeightDescendantsMap->get(this)) {
    2526             TrackedRendererListHashSet::iterator end = descendants->end();
    2527             for (TrackedRendererListHashSet::iterator it = descendants->begin(); it != end; ++it) {
    2528                 RenderBox* box = *it;
    2529                 while (box != this) {
    2530                     if (box->normalChildNeedsLayout())
    2531                         break;
    2532                     box->setChildNeedsLayout(true, MarkOnlyThis);
    2533                     box = box->containingBlock();
    2534                     ASSERT(box);
    2535                     if (!box)
    2536                         break;
    2537                 }
    2538             }
    2539         }
    2540     }
     2555    dirtyForLayoutFromPercentageHeightDescendants();
    25412556
    25422557    LayoutUnit beforeEdge = borderAndPaddingBefore();
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r151750 r151997  
    10951095
    10961096protected:
     1097    void dirtyForLayoutFromPercentageHeightDescendants();
     1098   
    10971099    void determineLogicalLeftPositionForChild(RenderBox* child, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
    10981100
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r151750 r151997  
    332332    appendChildFrameRects(this, oldChildRects);
    333333   
     334    dirtyForLayoutFromPercentageHeightDescendants();
     335
    334336    if (isHorizontal())
    335337        layoutHorizontalBox(relayoutChildren);
     
    457459        LayoutUnit maxAscent = 0, maxDescent = 0;
    458460        for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
    459             if (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent())))
     461            if (relayoutChildren)
    460462                child->setChildNeedsLayout(true, MarkOnlyThis);
    461463
     
    759761        for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
    760762            // Make sure we relayout children if we need it.
    761             if (!haveLineClamp && (relayoutChildren || (child->isReplaced() && (child->style()->width().isPercent() || child->style()->height().isPercent()))))
     763            if (!haveLineClamp && relayoutChildren)
    762764                child->setChildNeedsLayout(true, MarkOnlyThis);
    763765
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r151750 r151997  
    350350    RenderBlock::startDelayUpdateScrollInfo();
    351351
     352    dirtyForLayoutFromPercentageHeightDescendants();
     353
    352354    Vector<LineContext> lineContexts;
    353355    OrderHashSet orderValues;
  • trunk/Source/WebCore/rendering/RenderObject.h

    r151622 r151997  
    479479    virtual bool isSVGResourceFilterPrimitive() const { return false; }
    480480
     481    bool hasAspectRatio() const { return isReplaced() && (isImage() || isVideo() || isCanvas()); }
     482   
    481483    virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
    482484
  • trunk/Source/WebCore/rendering/RenderReplaced.cpp

    r148921 r151997  
    249249}
    250250
    251 static inline bool rendererHasAspectRatio(const RenderObject* renderer)
    252 {
    253     ASSERT(renderer);
    254     return renderer->isImage() || renderer->isCanvas() || renderer->isVideo();
    255 }
    256 
    257251void RenderReplaced::computeAspectRatioInformationForRenderBox(RenderBox* contentRenderer, FloatSize& constrainedSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
    258252{
     
    267261            intrinsicSize.scale(style()->effectiveZoom());
    268262
    269         if (rendererHasAspectRatio(this) && isPercentageIntrinsicSize)
     263        if (hasAspectRatio() && isPercentageIntrinsicSize)
    270264            intrinsicRatio = 1;
    271265           
     
    313307
    314308    // Figure out if we need to compute an intrinsic ratio.
    315     if (intrinsicSize.isEmpty() || !rendererHasAspectRatio(this))
     309    if (intrinsicSize.isEmpty() || !hasAspectRatio())
    316310        return;
    317311
Note: See TracChangeset for help on using the changeset viewer.