Changeset 246458 in webkit
- Timestamp:
- Jun 15, 2019, 7:05:44 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContextGeometry.cpp (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r246457 r246458 1 2019-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 1 20 2019-06-15 Zalan Bujtas <zalan@apple.com> 2 21 -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r245776 r246458 202 202 203 203 // Resolve top all the way up to the containing block. 204 auto * containingBlock =layoutBox.containingBlock();204 auto& containingBlock = *layoutBox.containingBlock(); 205 205 // 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()) { 207 207 auto& displayBox = layoutState.displayBoxForLayoutBox(*container); 208 208 // Display::Box::top is the border box top position in its containing block's coordinate system. … … 210 210 ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned()); 211 211 } 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; 213 215 } 214 216 … … 223 225 224 226 // Resolve left all the way up to the containing block. 225 auto * containingBlock =layoutBox.containingBlock();227 auto& containingBlock = *layoutBox.containingBlock(); 226 228 // 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()) { 228 230 auto& displayBox = layoutState.displayBoxForLayoutBox(*container); 229 231 // Display::Box::left is the border box left position in its containing block's coordinate system. … … 231 233 ASSERT(!container->isPositioned() || layoutBox.isFixedPositioned()); 232 234 } 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; 234 238 } 235 239 … … 293 297 auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); 294 298 auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); 295 auto isStaticallyPositioned = !top && !bottom;296 299 auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); 297 300 auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth }); … … 371 374 372 375 // 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; 379 380 380 381 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 << ")"); … … 421 422 auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); 422 423 auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); 423 auto isStaticallyPositioned = !left && !right;424 424 auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth); 425 425 auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); … … 525 525 526 526 // 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; 533 531 534 532 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 << ")"); … … 558 556 auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); 559 557 auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); 560 auto isStaticallyPositioned = !top && !bottom;561 558 auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues).height; 562 559 auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutBox, UsedHorizontalValues { containingBlockWidth }); … … 605 602 606 603 // 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; 613 608 614 609 ASSERT(top); … … 646 641 auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); 647 642 auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); 648 auto isStaticallyPositioned = !left && !right;649 643 auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); 650 644 Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start; … … 716 710 717 711 // 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; 724 716 725 717 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.