⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 246458 in webkit


Ignore:
Timestamp:
Jun 15, 2019, 7:05:44 AM (7 years ago)
Author:
Alan Bujtas
Message:

[LFC] Convert both the absolutely and statically positioned out-of-flow block level boxes positions relative to the containing block's padding box
https://bugs.webkit.org/show_bug.cgi?id=198878
<rdar://problem/51772882>

Reviewed by Antti Koivisto.

This patch ensures that while we compute the vertical/horizontal geometry for an out-of-flow block level box,
the static and the absolute positioned values are in the same coordinate system (relative to the containing block's padding box).

  • layout/FormattingContextGeometry.cpp:

(WebCore::Layout::staticVerticalPositionForOutOfFlowPositioned):
(WebCore::Layout::staticHorizontalPositionForOutOfFlowPositioned):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
(WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r246457 r246458  
     12019-06-15  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Convert both the absolutely and statically positioned out-of-flow block level boxes positions relative to the containing block's padding box
     4        https://bugs.webkit.org/show_bug.cgi?id=198878
     5        <rdar://problem/51772882>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        This patch ensures that while we compute the vertical/horizontal geometry for an out-of-flow block level box,
     10        the static and the absolute positioned values are in the same coordinate system (relative to the containing block's padding box).
     11
     12        * layout/FormattingContextGeometry.cpp:
     13        (WebCore::Layout::staticVerticalPositionForOutOfFlowPositioned):
     14        (WebCore::Layout::staticHorizontalPositionForOutOfFlowPositioned):
     15        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry):
     16        (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry):
     17        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry):
     18        (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry):
     19
    1202019-06-15  Zalan Bujtas  <zalan@apple.com>
    221
  • trunk/Source/WebCore/layout/FormattingContextGeometry.cpp

    r245776 r246458  
    202202
    203203    // Resolve top all the way up to the containing block.
    204     auto* containingBlock = layoutBox.containingBlock();
     204    auto& containingBlock = *layoutBox.containingBlock();
    205205    // Start with the parent since we pretend that this box is normal flow.
    206     for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
     206    for (auto* container = layoutBox.parent(); container != &containingBlock; container = container->containingBlock()) {
    207207        auto& displayBox = layoutState.displayBoxForLayoutBox(*container);
    208208        // Display::Box::top is the border box top position in its containing block's coordinate system.
     
    210210        ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned());
    211211    }
    212     return top;
     212    // Move the static position relative to the padding box. This is very specific to abolutely positioned boxes.
     213    auto paddingBoxTop = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxTop();
     214    return top - paddingBoxTop;
    213215}
    214216
     
    223225
    224226    // Resolve left all the way up to the containing block.
    225     auto* containingBlock = layoutBox.containingBlock();
     227    auto& containingBlock = *layoutBox.containingBlock();
    226228    // Start with the parent since we pretend that this box is normal flow.
    227     for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
     229    for (auto* container = layoutBox.parent(); container != &containingBlock; container = container->containingBlock()) {
    228230        auto& displayBox = layoutState.displayBoxForLayoutBox(*container);
    229231        // Display::Box::left is the border box left position in its containing block's coordinate system.
     
    231233        ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned());
    232234    }
    233     return left;
     235    // Move the static position relative to the padding box. This is very specific to abolutely positioned boxes.
     236    auto paddingBoxLeft = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxTop();
     237    return left - paddingBoxLeft;
    234238}
    235239
     
    293297    auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
    294298    auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
    295     auto isStaticallyPositioned = !top && !bottom;
    296299    auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
    297300    auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
     
    371374
    372375    // For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
    373     // At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
    374     if (!isStaticallyPositioned) {
    375         auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
    376         *top += containingBlockPaddingVerticalEdge;
    377         *bottom += containingBlockPaddingVerticalEdge;
    378     }
     376    // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
     377    auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
     378    *top += containingBlockPaddingVerticalEdge;
     379    *bottom += containingBlockPaddingVerticalEdge;
    379380
    380381    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom("  << *bottom << "px) height(" << *height << "px) margin(" << usedVerticalMargin.before << "px, "  << usedVerticalMargin.after << "px) layoutBox(" << &layoutBox << ")");
     
    421422    auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
    422423    auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
    423     auto isStaticallyPositioned = !left && !right;
    424424    auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
    425425    auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
     
    525525
    526526    // For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
    527     // At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
    528     if (!isStaticallyPositioned) {
    529         auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxLeft();
    530         *left += containingBlockPaddingVerticalEdge;
    531         *right += containingBlockPaddingVerticalEdge;
    532     }
     527    // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
     528    auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxLeft();
     529    *left += containingBlockPaddingVerticalEdge;
     530    *right += containingBlockPaddingVerticalEdge;
    533531
    534532    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow non-replaced -> left(" << *left << "px) right("  << *right << "px) width(" << *width << "px) margin(" << usedHorizontalMargin.start << "px, "  << usedHorizontalMargin.end << "px) layoutBox(" << &layoutBox << ")");
     
    558556    auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
    559557    auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
    560     auto isStaticallyPositioned = !top && !bottom;
    561558    auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues).height;
    562559    auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
     
    605602
    606603    // For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
    607     // At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
    608     if (!isStaticallyPositioned) {
    609         auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
    610         *top += containingBlockPaddingVerticalEdge;
    611         *bottom += containingBlockPaddingVerticalEdge;
    612     }
     604    // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
     605    auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
     606    *top += containingBlockPaddingVerticalEdge;
     607    *bottom += containingBlockPaddingVerticalEdge;
    613608
    614609    ASSERT(top);
     
    646641    auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
    647642    auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
    648     auto isStaticallyPositioned = !left && !right;
    649643    auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
    650644    Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start;
     
    716710
    717711    // For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
    718     // At this point the non-statically positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
    719     if (!isStaticallyPositioned) {
    720         auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft();
    721         *left += containingBlockPaddingVerticalEdge;
    722         *right += containingBlockPaddingVerticalEdge;
    723     }
     712    // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
     713    auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft();
     714    *left += containingBlockPaddingVerticalEdge;
     715    *right += containingBlockPaddingVerticalEdge;
    724716
    725717    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right("  << *right << "px) width(" << width << "px) margin(" << *usedMarginStart << "px, "  << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")");
Note: See TracChangeset for help on using the changeset viewer.