Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (246457 => 246458)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-06-15 14:03:23 UTC (rev 246457)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2019-06-15 14:05:44 UTC (rev 246458)
@@ -201,15 +201,17 @@
}
// Resolve top all the way up to the containing block.
- auto* containingBlock = layoutBox.containingBlock();
+ auto& containingBlock = *layoutBox.containingBlock();
// Start with the parent since we pretend that this box is normal flow.
- for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
+ for (auto* container = layoutBox.parent(); container != &containingBlock; container = container->containingBlock()) {
auto& displayBox = layoutState.displayBoxForLayoutBox(*container);
// Display::Box::top is the border box top position in its containing block's coordinate system.
top += displayBox.top();
ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned());
}
- return top;
+ // Move the static position relative to the padding box. This is very specific to abolutely positioned boxes.
+ auto paddingBoxTop = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxTop();
+ return top - paddingBoxTop;
}
static LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const LayoutState& layoutState, const Box& layoutBox)
@@ -222,15 +224,17 @@
auto left = layoutState.displayBoxForLayoutBox(*layoutBox.parent()).contentBoxLeft();
// Resolve left all the way up to the containing block.
- auto* containingBlock = layoutBox.containingBlock();
+ auto& containingBlock = *layoutBox.containingBlock();
// Start with the parent since we pretend that this box is normal flow.
- for (auto* container = layoutBox.parent(); container != containingBlock; container = container->containingBlock()) {
+ for (auto* container = layoutBox.parent(); container != &containingBlock; container = container->containingBlock()) {
auto& displayBox = layoutState.displayBoxForLayoutBox(*container);
// Display::Box::left is the border box left position in its containing block's coordinate system.
left += displayBox.left();
ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned());
}
- return left;
+ // Move the static position relative to the padding box. This is very specific to abolutely positioned boxes.
+ auto paddingBoxLeft = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxTop();
+ return left - paddingBoxLeft;
}
LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot, UsedHorizontalValues usedValues)
@@ -292,7 +296,6 @@
auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
- auto isStaticallyPositioned = !top && !bottom;
auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);
auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
UsedVerticalMargin::NonCollapsedValues usedVerticalMargin;
@@ -370,12 +373,10 @@
ASSERT(height);
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
- // 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.
- if (!isStaticallyPositioned) {
- auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
- *top += containingBlockPaddingVerticalEdge;
- *bottom += containingBlockPaddingVerticalEdge;
- }
+ // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
+ auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
+ *top += containingBlockPaddingVerticalEdge;
+ *bottom += containingBlockPaddingVerticalEdge;
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 << ")");
return { *top, *bottom, { contentHeight(), usedVerticalMargin } };
@@ -420,7 +421,6 @@
auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
- auto isStaticallyPositioned = !left && !right;
auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth);
auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
UsedHorizontalMargin usedHorizontalMargin;
@@ -524,12 +524,10 @@
ASSERT(width);
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
- // 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.
- if (!isStaticallyPositioned) {
- auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxLeft();
- *left += containingBlockPaddingVerticalEdge;
- *right += containingBlockPaddingVerticalEdge;
- }
+ // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
+ auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxLeft();
+ *left += containingBlockPaddingVerticalEdge;
+ *right += containingBlockPaddingVerticalEdge;
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 << ")");
return { *left, *right, { contentWidth(), usedHorizontalMargin, computedHorizontalMargin } };
@@ -557,7 +555,6 @@
auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth);
auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth);
- auto isStaticallyPositioned = !top && !bottom;
auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues).height;
auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth });
Optional<LayoutUnit> usedMarginBefore = computedVerticalMargin.before;
@@ -604,12 +601,10 @@
bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter);
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
- // 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.
- if (!isStaticallyPositioned) {
- auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
- *top += containingBlockPaddingVerticalEdge;
- *bottom += containingBlockPaddingVerticalEdge;
- }
+ // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
+ auto containingBlockPaddingVerticalEdge = containingBlockDisplayBox.paddingBoxTop();
+ *top += containingBlockPaddingVerticalEdge;
+ *bottom += containingBlockPaddingVerticalEdge;
ASSERT(top);
ASSERT(bottom);
@@ -645,7 +640,6 @@
auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth);
auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth);
- auto isStaticallyPositioned = !left && !right;
auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues);
Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start;
Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end;
@@ -715,12 +709,10 @@
ASSERT(usedMarginEnd);
// For out-of-flow elements the containing block is formed by the padding edge of the ancestor.
- // 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.
- if (!isStaticallyPositioned) {
- auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft();
- *left += containingBlockPaddingVerticalEdge;
- *right += containingBlockPaddingVerticalEdge;
- }
+ // At this point the positioned value is in the coordinate system of the padding box. Let's convert it to border box coordinate system.
+ auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft();
+ *left += containingBlockPaddingVerticalEdge;
+ *right += containingBlockPaddingVerticalEdge;
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 << ")");
return { *left, *right, { width, { *usedMarginStart, *usedMarginEnd }, computedHorizontalMargin } };