Changeset 128786 in webkit


Ignore:
Timestamp:
Sep 17, 2012 11:44:51 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
https://bugs.webkit.org/show_bug.cgi?id=93547

Patch by Bear Travis <betravis@adobe.com> on 2012-09-17
Reviewed by Levi Weintraub.

Source/WebCore:

Shape-inside needs to be passed the logical size to use when computing percentage
based coordinates. The CSS Regions-specific method computeInitialRegionRangeForBlock
has been generalized to updateRegionsAndExclusionsLogicalSize. This method takes
the pre-child-layout logical width and height, and uses them to compute the logical
width and height that regions and exclusions should use for layout. Regions use a
block's maximum possible logical height to compute a region's maximum extent.
Exclusions use a block's fixed logical width and height, or 0 if one does not exist,
to resolve percentage-based shape lengths. The default logical size used for resolving
percentage based coordinates is tested in shape-inside-percentage-auto.html.

Test: fast/exclusions/shape-inside/shape-inside-percentage.html

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::updateRegionsAndExclusionsLogicalSize): Calculates the logical
height regions and exclusions should use, and updates their layout sizes through
computeExclusionShapeSize and computeRegionRangeForBlock.
(WebCore):
(WebCore::RenderBlock::computeExclusionShapeSize): Pass the appropriate logical size
to exclusion shapes so they can resolve percentage based coordinates.
(WebCore::RenderBlock::layoutBlock): Call the new updateRegionsAndExclusionsLogicalSize
method.

  • rendering/RenderBlock.h:

(RenderBlock):

  • rendering/RenderBox.cpp:

(WebCore::percentageLogicalHeightIsResolvable): Determine if percentage lengths
based on logical height can be resolved.
(WebCore):
(WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock): Added declaration.

  • rendering/RenderBox.h:

(RenderBox):

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::RenderDeprecatedFlexibleBox::layoutBlock): Calling
updateRegionsAndExclusionsLogicalSize rather than computeInitialRegionRangeForBlock.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutBlock): Ditto.

  • rendering/RenderGrid.cpp:

(WebCore::RenderGrid::layoutBlock): Ditto.

LayoutTests:

Test that shape percentage-based measurements resolve correctly. Some testing is
already covered by shape-inside-percentage-auto.html.

  • fast/exclusions/shape-inside/shape-inside-percentage-expected.html: Added.
  • fast/exclusions/shape-inside/shape-inside-percentage.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r128783 r128786  
     12012-09-17  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
     4        https://bugs.webkit.org/show_bug.cgi?id=93547
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Test that shape percentage-based measurements resolve correctly. Some testing is
     9        already covered by shape-inside-percentage-auto.html.
     10
     11        * fast/exclusions/shape-inside/shape-inside-percentage-expected.html: Added.
     12        * fast/exclusions/shape-inside/shape-inside-percentage.html: Added.
     13
    1142012-09-17  Ojan Vafai  <ojan@chromium.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r128785 r128786  
     12012-09-17  Bear Travis  <betravis@adobe.com>
     2
     3        [CSS Exclusions] Enable shape-inside for percentage lengths based on logical height
     4        https://bugs.webkit.org/show_bug.cgi?id=93547
     5
     6        Reviewed by Levi Weintraub.
     7
     8        Shape-inside needs to be passed the logical size to use when computing percentage
     9        based coordinates. The CSS Regions-specific method computeInitialRegionRangeForBlock
     10        has been generalized to updateRegionsAndExclusionsLogicalSize. This method takes
     11        the pre-child-layout logical width and height, and uses them to compute the logical
     12        width and height that regions and exclusions should use for layout. Regions use a
     13        block's maximum possible logical height to compute a region's maximum extent.
     14        Exclusions use a block's fixed logical width and height, or 0 if one does not exist,
     15        to resolve percentage-based shape lengths. The default logical size used for resolving
     16        percentage based coordinates is tested in shape-inside-percentage-auto.html.
     17
     18        Test: fast/exclusions/shape-inside/shape-inside-percentage.html
     19
     20        * rendering/RenderBlock.cpp:
     21        (WebCore::RenderBlock::updateRegionsAndExclusionsLogicalSize): Calculates the logical
     22        height regions and exclusions should use, and updates their layout sizes through
     23        computeExclusionShapeSize and computeRegionRangeForBlock.
     24        (WebCore):
     25        (WebCore::RenderBlock::computeExclusionShapeSize): Pass the appropriate logical size
     26        to exclusion shapes so they can resolve percentage based coordinates.
     27        (WebCore::RenderBlock::layoutBlock): Call the new updateRegionsAndExclusionsLogicalSize
     28        method.
     29        * rendering/RenderBlock.h:
     30        (RenderBlock):
     31        * rendering/RenderBox.cpp:
     32        (WebCore::percentageLogicalHeightIsResolvable): Determine if percentage lengths
     33        based on logical height can be resolved.
     34        (WebCore):
     35        (WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock): Added declaration.
     36        * rendering/RenderBox.h:
     37        (RenderBox):
     38        * rendering/RenderDeprecatedFlexibleBox.cpp:
     39        (WebCore::RenderDeprecatedFlexibleBox::layoutBlock): Calling
     40        updateRegionsAndExclusionsLogicalSize rather than computeInitialRegionRangeForBlock.
     41        * rendering/RenderFlexibleBox.cpp:
     42        (WebCore::RenderFlexibleBox::layoutBlock): Ditto.
     43        * rendering/RenderGrid.cpp:
     44        (WebCore::RenderGrid::layoutBlock): Ditto.
     45
    1462012-09-17  Vangelis Kokkevis  <vangelis@chromium.org>
    247
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r128416 r128786  
    13951395#endif
    13961396
    1397 void RenderBlock::computeInitialRegionRangeForBlock()
    1398 {
    1399     if (inRenderFlowThread()) {
    1400         // Set our start and end regions. No regions above or below us will be considered by our children. They are
    1401         // effectively clamped to our region range.
    1402         LayoutUnit oldHeight =  logicalHeight();
    1403         LayoutUnit oldLogicalTop = logicalTop();
    1404         setLogicalHeight(MAX_LAYOUT_UNIT / 2);
    1405         updateLogicalHeight();
    1406         enclosingRenderFlowThread()->setRegionRangeForBox(this, offsetFromLogicalTopOfFirstPage());
    1407         setLogicalHeight(oldHeight);
    1408         setLogicalTop(oldLogicalTop);
    1409     }
    1410 }
     1397void RenderBlock::updateRegionsAndExclusionsLogicalSize()
     1398{
     1399#if ENABLE(CSS_EXCLUSIONS)
     1400    if (!inRenderFlowThread() && !wrapShapeInfo())
     1401#else
     1402    if (!inRenderFlowThread())
     1403#endif
     1404        return;
     1405
     1406    LayoutUnit oldHeight = logicalHeight();
     1407    LayoutUnit oldTop = logicalTop();
     1408
     1409    // Compute the maximum logical height content may cause this block to expand to
     1410    // FIXME: These should eventually use the const computeLogicalHeight rather than updateLogicalHeight
     1411    setLogicalHeight(MAX_LAYOUT_UNIT / 2);
     1412    updateLogicalHeight();
     1413
     1414#if ENABLE(CSS_EXCLUSIONS)
     1415    computeExclusionShapeSize();
     1416#endif
     1417
     1418    // Set our start and end regions. No regions above or below us will be considered by our children. They are
     1419    // effectively clamped to our region range.
     1420    computeRegionRangeForBlock();
     1421
     1422    setLogicalHeight(oldHeight);
     1423    setLogicalTop(oldTop);
     1424}
     1425
     1426#if ENABLE(CSS_EXCLUSIONS)
     1427void RenderBlock::computeExclusionShapeSize()
     1428{
     1429    WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo();
     1430    if (wrapShapeInfo) {
     1431        bool percentageLogicalHeightResolvable = percentageLogicalHeightIsResolvableFromBlock(this, false);
     1432        wrapShapeInfo->computeShapeSize(logicalWidth(), percentageLogicalHeightResolvable ? logicalHeight() : ZERO_LAYOUT_UNIT);
     1433    }
     1434}
     1435#endif
    14111436
    14121437void RenderBlock::computeRegionRangeForBlock()
     
    14921517            relayoutChildren = true;
    14931518    }
    1494     computeInitialRegionRangeForBlock();
    1495 #if ENABLE(CSS_EXCLUSIONS)
    1496     // FIXME: Bug 93547: Resolve logical height for percentage based vertical lengths
    1497     if (WrapShapeInfo* wrapShapeInfo = this->wrapShapeInfo())
    1498         wrapShapeInfo->computeShapeSize(logicalWidth(), 0);
    1499 #endif
     1519    updateRegionsAndExclusionsLogicalSize();
    15001520
    15011521    // We use four values, maxTopPos, maxTopNeg, maxBottomPos, and maxBottomNeg, to track
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r128713 r128786  
    492492#endif
    493493
    494     void computeInitialRegionRangeForBlock();
     494    void updateRegionsAndExclusionsLogicalSize();
    495495    void computeRegionRangeForBlock();
    496496
     
    499499private:
    500500#if ENABLE(CSS_EXCLUSIONS)
     501    void computeExclusionShapeSize();
    501502    void updateWrapShapeInfoAfterStyleChange(const BasicShape*, const BasicShape* oldWrapShape);
    502503#endif
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r128633 r128786  
    37273727}
    37283728
    3729 static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
     3729inline static bool percentageLogicalHeightIsResolvable(const RenderBox* box)
     3730{
     3731    return RenderBox::percentageLogicalHeightIsResolvableFromBlock(box->containingBlock(), box->isOutOfFlowPositioned());
     3732}
     3733
     3734bool RenderBox::percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool isOutOfFlowPositioned)
    37303735{
    37313736    // In quirks mode, blocks with auto height are skipped, and we keep looking for an enclosing
     
    37343739    // block has an auto height. We still skip anonymous containing blocks in both modes, though, and look
    37353740    // only at explicit containers.
    3736     const RenderBlock* cb = box->containingBlock();
     3741    const RenderBlock* cb = containingBlock;
     3742    bool inQuirksMode = cb->document()->inQuirksMode();
    37373743    while (!cb->isRenderView() && !cb->isBody() && !cb->isTableCell() && !cb->isOutOfFlowPositioned() && cb->style()->logicalHeight().isAuto()) {
    3738         if (!box->document()->inQuirksMode() && !cb->isAnonymousBlock())
     3744        if (!inQuirksMode && !cb->isAnonymousBlock())
    37393745            break;
    37403746        cb = cb->containingBlock();
     
    37583764        return true;
    37593765    if (cb->style()->logicalHeight().isPercent() && !isOutOfFlowPositionedWithSpecifiedHeight)
    3760         return percentageLogicalHeightIsResolvable(cb);
    3761     if (cb->isRenderView() || (cb->isBody() && box->document()->inQuirksMode()) || isOutOfFlowPositionedWithSpecifiedHeight)
     3766        return percentageLogicalHeightIsResolvableFromBlock(cb->containingBlock(), cb->isOutOfFlowPositioned());
     3767    if (cb->isRenderView() || inQuirksMode || isOutOfFlowPositionedWithSpecifiedHeight)
    37623768        return true;
    3763     if (cb->isRoot() && box->isOutOfFlowPositioned()) {
     3769    if (cb->isRoot() && isOutOfFlowPositioned) {
    37643770        // Match the positioned objects behavior, which is that positioned objects will fill their viewport
    37653771        // always.  Note we could only hit this case by recurring into computePercentageLogicalHeight on a positioned containing block.
  • trunk/Source/WebCore/rendering/RenderBox.h

    r128633 r128786  
    400400    virtual LayoutUnit computeReplacedLogicalHeight() const;
    401401
     402    static bool percentageLogicalHeightIsResolvableFromBlock(const RenderBlock* containingBlock, bool outOfFlowPositioned);
    402403    LayoutUnit computePercentageLogicalHeight(const Length& height) const;
    403404
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r128201 r128786  
    244244            relayoutChildren = true;
    245245    }
    246     computeInitialRegionRangeForBlock();
     246    updateRegionsAndExclusionsLogicalSize();
    247247
    248248    LayoutSize previousSize = size();
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r128494 r128786  
    250250            relayoutChildren = true;
    251251    }
    252     computeInitialRegionRangeForBlock();
     252    updateRegionsAndExclusionsLogicalSize();
    253253
    254254    LayoutSize previousSize = size();
  • trunk/Source/WebCore/rendering/RenderGrid.cpp

    r128201 r128786  
    7272            relayoutChildren = true;
    7373    }
    74     computeInitialRegionRangeForBlock();
     74    updateRegionsAndExclusionsLogicalSize();
    7575
    7676    LayoutSize previousSize = size();
Note: See TracChangeset for help on using the changeset viewer.