Changeset 138770 in webkit


Ignore:
Timestamp:
Jan 3, 2013, 5:21:07 PM (12 years ago)
Author:
tony@chromium.org
Message:

incorrect flexbox relayout with overflow, padding and absolute positioning
https://bugs.webkit.org/show_bug.cgi?id=106022

Reviewed by Ojan Vafai.

Source/WebCore:

The problem was we were entering simplified layout, which doesn't apply the stretch
behavior for flex children. That should be fine if we had kept the override size from
the previous layout. So clear the override size during layout rather than after layout.

Not clearing the override size re-triggers bug 98611. Fix this by always forcing a
layout of an image if it has an override size set. The presence of an override size means
we did some special layout that may not be covered by re-computing the logical width and
height.

Test: css3/flexbox/stretch-simplified-layout.html

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutBlock): Don't clear the override size after layout.
(WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): Clear the override size right before layout.

  • rendering/RenderFlexibleBox.h:

(RenderFlexibleBox): Remove clearChildOverrideSizes() since it's not called anymore.

  • rendering/RenderImage.cpp:

(WebCore::RenderImage::imageDimensionsChanged): If an override size is present, force a relayout.
Also cleaned up the code a bit to avoid computing the width and height unless we need to.

LayoutTests:

  • css3/flexbox/stretch-simplified-layout-expected.txt: Added.
  • css3/flexbox/stretch-simplified-layout.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r138767 r138770  
     12013-01-03  Tony Chang  <tony@chromium.org>
     2
     3        incorrect flexbox relayout with overflow, padding and absolute positioning
     4        https://bugs.webkit.org/show_bug.cgi?id=106022
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css3/flexbox/stretch-simplified-layout-expected.txt: Added.
     9        * css3/flexbox/stretch-simplified-layout.html: Added.
     10
    1112013-01-03  Terry Anderson  <tdanderson@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r138769 r138770  
     12013-01-03  Tony Chang  <tony@chromium.org>
     2
     3        incorrect flexbox relayout with overflow, padding and absolute positioning
     4        https://bugs.webkit.org/show_bug.cgi?id=106022
     5
     6        Reviewed by Ojan Vafai.
     7
     8        The problem was we were entering simplified layout, which doesn't apply the stretch
     9        behavior for flex children. That should be fine if we had kept the override size from
     10        the previous layout. So clear the override size during layout rather than after layout.
     11
     12        Not clearing the override size re-triggers bug 98611. Fix this by always forcing a
     13        layout of an image if it has an override size set. The presence of an override size means
     14        we did some special layout that may not be covered by re-computing the logical width and
     15        height.
     16
     17        Test: css3/flexbox/stretch-simplified-layout.html
     18
     19        * rendering/RenderFlexibleBox.cpp:
     20        (WebCore::RenderFlexibleBox::layoutBlock): Don't clear the override size after layout.
     21        (WebCore::RenderFlexibleBox::computeMainAxisPreferredSizes): Clear the override size right before layout.
     22        * rendering/RenderFlexibleBox.h:
     23        (RenderFlexibleBox): Remove clearChildOverrideSizes() since it's not called anymore.
     24        * rendering/RenderImage.cpp:
     25        (WebCore::RenderImage::imageDimensionsChanged): If an override size is present, force a relayout.
     26        Also cleaned up the code a bit to avoid computing the width and height unless we need to.
     27
    1282013-01-03  Adam Klein  <adamk@chromium.org>
    229
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r138312 r138770  
    343343
    344344    computeRegionRangeForBlock();
    345     clearChildOverrideSizes();
    346345
    347346    repaintChildrenDuringLayoutIfMoved(oldChildRects);
     
    413412    // direction:rtl + flex-direction:column means the cross-axis direction is flipped.
    414413    flipForRightToLeftColumn();
    415 }
    416 
    417 void RenderFlexibleBox::clearChildOverrideSizes()
    418 {
    419     for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox())
    420         child->clearOverrideSize();
    421414}
    422415
     
    858851        if (child->isOutOfFlowPositioned())
    859852            continue;
     853
     854        child->clearOverrideSize();
    860855
    861856        // Only need to layout here if we will need to get the logicalHeight of the child in computeNextFlexLine.
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r138235 r138770  
    140140    bool updateAutoMarginsInCrossAxis(RenderBox* child, LayoutUnit availableAlignmentSpace);
    141141    void repositionLogicalHeightDependentFlexItems(Vector<LineContext>&, LayoutUnit& oldClientAfterEdge);
    142     void clearChildOverrideSizes();
    143142    void appendChildFrameRects(ChildFrameRects&);
    144143    void repaintChildrenDuringLayoutIfMoved(const ChildFrameRects&);
  • trunk/Source/WebCore/rendering/RenderImage.cpp

    r137960 r138770  
    223223        if (!preferredLogicalWidthsDirty())
    224224            setPreferredLogicalWidthsDirty(true);
    225         LogicalExtentComputedValues computedValues;
    226         computeLogicalWidthInRegion(computedValues);
    227         LayoutUnit newWidth = computedValues.m_extent;
    228         computeLogicalHeight(height(), 0, computedValues);
    229         LayoutUnit newHeight = computedValues.m_extent;
     225
     226        bool hasOverrideSize = hasOverrideHeight() || hasOverrideWidth();
     227        if (!hasOverrideSize && !imageSizeChanged) {
     228            LogicalExtentComputedValues computedValues;
     229            computeLogicalWidthInRegion(computedValues);
     230            LayoutUnit newWidth = computedValues.m_extent;
     231            computeLogicalHeight(height(), 0, computedValues);
     232            LayoutUnit newHeight = computedValues.m_extent;
     233
     234            imageSizeChanged = width() != newWidth || height() != newHeight;
     235        }
    230236
    231237        // FIXME: We only need to recompute the containing block's preferred size
     
    233239        // There's no easy way to detect that shrink-to-fit is needed, always force a layout.
    234240        bool containingBlockNeedsToRecomputePreferredSize =
    235             style()->logicalWidth().type() == Percent
    236             || style()->logicalMaxWidth().type() == Percent
    237             || style()->logicalMinWidth().type() == Percent;
    238 
    239         if (imageSizeChanged || width() != newWidth || height() != newHeight || containingBlockNeedsToRecomputePreferredSize) {
     241            style()->logicalWidth().isPercent()
     242            || style()->logicalMaxWidth().isPercent()
     243            || style()->logicalMinWidth().isPercent();
     244
     245        if (imageSizeChanged || hasOverrideSize || containingBlockNeedsToRecomputePreferredSize) {
    240246            shouldRepaint = false;
    241247            if (!selfNeedsLayout())
Note: See TracChangeset for help on using the changeset viewer.