Changeset 96139 in webkit


Ignore:
Timestamp:
Sep 27, 2011 12:31:31 PM (13 years ago)
Author:
robert@webkit.org
Message:

Reviewed by David Hyatt.

Replaced elements squeezed when width is specified as percentage inside a table with Auto layout
https://bugs.webkit.org/show_bug.cgi?id=29447

Source/WebCore:

If inserting a 'replaced' element (e.g. image, plugin) in a table cell that is not descendant from
a block with fixed layout then do not squeeze the element, let it use its intrinsic width and height.

Test: fast/replaced/table-percent-width.html

  • rendering/RenderBox.cpp:

(WebCore::avoidSqueezingWidth):
(WebCore::avoidSqueezingHeight):
(WebCore::RenderBox::containingBlockReplacedLogicalWidthForContent):
(WebCore::RenderBox::computeReplacedLogicalWidthUsing):
(WebCore::RenderBox::computeReplacedLogicalHeightUsing):

  • rendering/RenderBox.h:

LayoutTests:

  • fast/replaced/table-percent-width.html: Added.
  • fast/replaced/table-percent-width-expected.txt: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96138 r96139  
     12011-06-28  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Replaced elements squeezed when width is specified as percentage inside a table with Auto layout
     6        https://bugs.webkit.org/show_bug.cgi?id=29447
     7
     8        * fast/replaced/table-percent-width.html: Added.
     9        * fast/replaced/table-percent-width-expected.txt: Added.
     10
    1112011-09-27  Simon Fraser  <simon.fraser@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r96138 r96139  
     12011-06-28  Robert Hogan  <robert@webkit.org>
     2
     3        Reviewed by David Hyatt.
     4
     5        Replaced elements squeezed when width is specified as percentage inside a table with Auto layout
     6        https://bugs.webkit.org/show_bug.cgi?id=29447
     7
     8        If inserting a 'replaced' element (e.g. image, plugin) in a table cell that is not descendant from
     9        a block with fixed layout then do not squeeze the element, let it use its intrinsic width and height.
     10
     11        Test: fast/replaced/table-percent-width.html
     12
     13        * rendering/RenderBox.cpp:
     14        (WebCore::avoidSqueezingWidth):
     15        (WebCore::avoidSqueezingHeight):
     16        (WebCore::RenderBox::containingBlockReplacedLogicalWidthForContent):
     17        (WebCore::RenderBox::computeReplacedLogicalWidthUsing):
     18        (WebCore::RenderBox::computeReplacedLogicalHeightUsing):
     19        * rendering/RenderBox.h:
     20
    1212011-09-27  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r95737 r96139  
    12171217}
    12181218
     1219static bool avoidSqueezingWidth(RenderBlock* cb)
     1220{
     1221    while (cb && !cb->isRenderView()) {
     1222        if (!cb->style()->logicalWidth().isAuto() && !cb->style()->logicalWidth().isPercent())
     1223            return false;
     1224        cb = cb->containingBlock();
     1225    }
     1226    return true;
     1227}
     1228
     1229static bool avoidSqueezingHeight(RenderBlock* cb)
     1230{
     1231    while (cb && !cb->isRenderView()) {
     1232        if (!cb->style()->logicalHeight().isAuto() && !cb->style()->logicalHeight().isPercent())
     1233            return false;
     1234        cb = cb->containingBlock();
     1235    }
     1236    return true;
     1237}
     1238
     1239int RenderBox::containingBlockReplacedLogicalWidthForContent() const
     1240{
     1241    RenderBlock* cb = containingBlock();
     1242    // Don't let table cells squeeze percent-height replaced elements
     1243    // <http://bugs.webkit.org/show_bug.cgi?id=29447>
     1244    if (cb->isTableCell() && avoidSqueezingWidth(cb))
     1245        return max(shrinkToAvoidFloats() ? cb->availableLogicalWidthForLine(y(), false) : cb->availableLogicalWidth(), intrinsicLogicalWidth());
     1246
     1247    return containingBlockLogicalWidthForContent();
     1248}
     1249
    12191250LayoutUnit RenderBox::containingBlockLogicalWidthForContent() const
    12201251{
     
    20152046            // containing block's block-flow.
    20162047            // https://bugs.webkit.org/show_bug.cgi?id=46496
    2017             const LayoutUnit cw = isPositioned() ? containingBlockLogicalWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockLogicalWidthForContent();
     2048            const LayoutUnit cw = isPositioned() ? containingBlockLogicalWidthForPositioned(toRenderBoxModelObject(container())) : containingBlockReplacedLogicalWidthForContent();
    20182049            if (cw > 0)
    20192050                return computeContentBoxLogicalWidth(logicalWidth.calcMinValue(cw));
     
    20752106                // FIXME: This needs to be made block-flow-aware.  If the cell and image are perpendicular block-flows, this isn't right.
    20762107                // https://bugs.webkit.org/show_bug.cgi?id=46997
    2077                 while (cb && !cb->isRenderView() && (cb->style()->logicalHeight().isAuto() || cb->style()->logicalHeight().isPercent())) {
    2078                     if (cb->isTableCell()) {
    2079                         // Don't let table cells squeeze percent-height replaced elements
    2080                         // <http://bugs.webkit.org/show_bug.cgi?id=15359>
    2081                         availableHeight = max(availableHeight, intrinsicLogicalHeight());
    2082                         return logicalHeight.calcValue(availableHeight - borderAndPaddingLogicalHeight());
    2083                     }
    2084                     cb = cb->containingBlock();
     2108                if (cb->isTableCell() && avoidSqueezingHeight(toRenderBlock(cb))) {
     2109                    // Don't let table cells squeeze percent-height replaced elements
     2110                    // <http://bugs.webkit.org/show_bug.cgi?id=15359>
     2111                    availableHeight = max(availableHeight, intrinsicLogicalHeight());
     2112                    return logicalHeight.calcValue(availableHeight - borderAndPaddingLogicalHeight());
    20852113                }
    20862114            }
  • trunk/Source/WebCore/rendering/RenderBox.h

    r94912 r96139  
    286286    virtual LayoutUnit containingBlockLogicalWidthForContent() const;
    287287    LayoutUnit perpendicularContainingBlockLogicalHeight() const;
     288    int containingBlockReplacedLogicalWidthForContent() const;
    288289   
    289290    virtual void computeLogicalWidth();
Note: See TracChangeset for help on using the changeset viewer.