Changeset 232871 in webkit
- Timestamp:
- Jun 15, 2018 9:00:56 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r232870 r232871 1 2018-06-15 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Align compute functions styles. 4 https://bugs.webkit.org/show_bug.cgi?id=186649 5 6 Reviewed by Antti Koivisto. 7 8 Improve code readability. 9 10 * layout/FormattingContext.h: 11 * layout/FormattingContextGeometry.cpp: 12 (WebCore::Layout::contentHeightForFormattingContextRoot): 13 (WebCore::Layout::FormattingContext::Geometry::computedValueIfNotAuto): 14 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): 15 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): 16 (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): 17 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin): 18 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin): 19 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): 20 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): 21 (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue): 22 (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue): 23 (WebCore::Layout::computedValueIfNotAuto): Deleted. 24 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 25 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 26 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): 27 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin): 28 (WebCore::Layout::BlockFormattingContext::Geometry::staticPosition): 29 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowPositionedPosition): 30 1 31 2018-06-15 Zalan Bujtas <zalan@apple.com> 2 32 -
trunk/Source/WebCore/layout/FormattingContext.h
r232743 r232871 120 120 static Display::Box::VerticalEdges computedNonCollapsedVerticalMarginValue(const LayoutContext&, const Box&); 121 121 122 static std::optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth); 123 122 124 private: 123 125 static VerticalGeometry outOfFlowReplacedVerticalGeometry(LayoutContext&, const Box&); -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r232870 r232871 35 35 { 36 36 ASSERT(layoutBox.style().logicalHeight().isAuto() && layoutBox.establishesFormattingContext()); 37 37 38 // 10.6.7 'Auto' heights for block formatting context roots 38 39 … … 68 69 } 69 70 70 st atic std::optional<LayoutUnit>computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth)71 std::optional<LayoutUnit> FormattingContext::Geometry::computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth) 71 72 { 72 73 if (geometryProperty.isAuto()) … … 336 337 { 337 338 ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); 339 338 340 // 10.6.5 Absolutely positioned, replaced elements 339 341 // … … 404 406 { 405 407 ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); 408 406 409 // 10.3.8 Absolutely positioned, replaced elements 407 410 // In this case, section 10.3.7 applies up through and including the constraint equation, but the rest of section 10.3.7 is replaced by the following rules: … … 536 539 // 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width. 537 540 538 auto& style = layoutBox.style(); 539 auto width = style.logicalWidth(); 541 auto& containingBlock = *layoutBox.containingBlock(); 542 auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); 543 540 544 // #1 541 auto computedNonCollapsedHorizontalMarginValues = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); 542 // #2 543 auto computedWidthValue = width.isAuto() ? shrinkToFitWidth(layoutContext, layoutBox) : LayoutUnit(width.value()); 544 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << computedWidthValue << "px) margin(" << computedNonCollapsedHorizontalMarginValues.left << "px, " << computedNonCollapsedHorizontalMarginValues.right << "px) -> layoutBox(" << &layoutBox << ")"); 545 return FormattingContext::Geometry::WidthAndMargin { computedWidthValue, computedNonCollapsedHorizontalMarginValues }; 545 auto margin = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); 546 // #2 547 auto width = computedValueIfNotAuto(layoutBox.style().logicalWidth(), containingBlockDisplayBox.width()); 548 if (!width) 549 width = shrinkToFitWidth(layoutContext, layoutBox); 550 551 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << margin.left << "px, " << margin.right << "px) -> layoutBox(" << &layoutBox << ")"); 552 return FormattingContext::Geometry::WidthAndMargin { *width, margin }; 546 553 } 547 554 … … 549 556 { 550 557 ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced()); 558 551 559 // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' 552 560 // replaced elements in normal flow and floating replaced elements … … 558 566 { 559 567 ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced()); 568 560 569 // 10.3.6 Floating, replaced elements 561 570 // 562 571 // 1. If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'. 563 572 // 2. The used value of 'width' is determined as for inline replaced elements. 564 auto computedNonCollapsedHorizontalMarginValues = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); 573 auto margin = computedNonCollapsedHorizontalMarginValue(layoutContext, layoutBox); 574 565 575 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced"); 566 return inlineReplacedWidthAndMargin(layoutContext, layoutBox, computedNonCollapsedHorizontalMarginValues.left, computedNonCollapsedHorizontalMarginValues.right);576 return inlineReplacedWidthAndMargin(layoutContext, layoutBox, margin.left, margin.right); 567 577 } 568 578 … … 606 616 { 607 617 ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); 618 608 619 // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements 609 620 // … … 617 628 618 629 // #1 619 auto computedNonCollapsedVerticalMarginValues= computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox);620 621 auto& style = layoutBox.style(); 622 auto height = style.logicalHeight();623 LayoutUnit computedHeightValue;624 if (height.isAuto()) {625 auto width = style.logicalWidth();626 auto replaced = layoutBox.replaced();627 628 if (width.isAuto()&& replaced->hasIntrinsicHeight()) {629 630 computedHeightValue= replaced->intrinsicHeight();631 } else if (replaced->hasIntrinsicRatio()) {632 633 computedHeightValue = width.value()/ replaced->intrinsicRatio();634 } else if (replaced->hasIntrinsicHeight()) {635 636 computedHeightValue= replaced->intrinsicHeight();637 } else{638 639 computedHeightValue = 150;640 641 } else 642 computedHeightValue = height.value();643 644 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow replaced -> height(" << computedHeightValue << "px) margin(" << computedNonCollapsedVerticalMarginValues.top << "px, " << computedNonCollapsedVerticalMarginValues.bottom << "px) -> layoutBox(" << &layoutBox << ")");645 return { computedHeightValue, computedNonCollapsedVerticalMarginValues};630 auto margin = computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox); 631 632 auto& style = layoutBox.style(); 633 auto replaced = layoutBox.replaced(); 634 auto& containingBlock = *layoutBox.containingBlock(); 635 auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); 636 auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockDisplayBox.height()); 637 auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockDisplayBox.width()); 638 639 if (!height && !width && replaced->hasIntrinsicHeight()) { 640 // #2 641 height = replaced->intrinsicHeight(); 642 } else if (!height && replaced->hasIntrinsicRatio()) { 643 // #3 644 height = *width / replaced->intrinsicRatio(); 645 } else if (!height && replaced->hasIntrinsicHeight()) { 646 // #4 647 height = replaced->intrinsicHeight(); 648 } else if (!height) { 649 // #5 650 height = { 150 }; 651 } 652 653 ASSERT(height); 654 655 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow replaced -> height(" << *height << "px) margin(" << margin.top << "px, " << margin.bottom << "px) -> layoutBox(" << &layoutBox << ")"); 656 return { *height, margin }; 646 657 } 647 658 … … 650 661 { 651 662 ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); 663 652 664 // 10.3.2 Inline, replaced elements 653 665 // … … 668 680 // 5. Otherwise, if 'width' has a computed value of 'auto', but none of the conditions above are met, then the used value of 'width' becomes 300px. 669 681 // If 300px is too wide to fit the device, UAs should use the width of the largest rectangle that has a 2:1 ratio and fits the device instead. 670 auto& style = layoutBox.style(); 671 auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); 682 683 auto& style = layoutBox.style(); 684 auto& containingBlock = *layoutBox.containingBlock(); 685 auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); 672 686 673 687 auto computeMarginRight = [&]() { 674 688 if (precomputedMarginRight) 675 689 return precomputedMarginRight.value(); 676 auto marginRight = style.marginRight();677 return marginRight. isAuto() ? LayoutUnit { 0 } : valueForLength(marginRight, containingBlockWidth);690 auto marginRight = computedValueIfNotAuto(style.marginRight(), containingBlockDisplayBox.width()); 691 return marginRight.value_or(LayoutUnit { 0 }); 678 692 }; 679 693 … … 681 695 if (precomputedMarginLeft) 682 696 return precomputedMarginLeft.value(); 683 auto marginLeft = style.marginLeft();684 return marginLeft. isAuto() ? LayoutUnit { 0 } : valueForLength(marginLeft, containingBlockWidth);697 auto marginLeft = computedValueIfNotAuto(style.marginLeft(), containingBlockDisplayBox.width()); 698 return marginLeft.value_or(LayoutUnit { 0 }); 685 699 }; 686 700 687 LayoutUnit computedMarginLeftValue = computeMarginLeft(); 688 LayoutUnit computedMarginRightValue = computeMarginRight(); 689 690 LayoutUnit computedWidthValue; 691 auto width = style.logicalWidth(); 692 auto height = style.logicalHeight(); 701 LayoutUnit marginLeft = computeMarginLeft(); 702 LayoutUnit marginRight = computeMarginRight(); 703 693 704 auto replaced = layoutBox.replaced(); 705 auto height = computedValueIfNotAuto(style.logicalHeight(), containingBlockDisplayBox.height()); 706 auto width = computedValueIfNotAuto(style.logicalWidth(), containingBlockDisplayBox.width()); 707 694 708 ASSERT(replaced); 695 709 696 if ( width.isAuto() && height.isAuto()&& replaced->hasIntrinsicWidth()) {710 if (!width && !height && replaced->hasIntrinsicWidth()) { 697 711 // #1 698 computedWidthValue = replaced->intrinsicWidth(); 699 } else if (width.isAuto() && (height.isCalculated() || replaced->hasIntrinsicHeight()) && replaced->hasIntrinsicRatio()) { 712 width = replaced->intrinsicWidth(); 713 } else if ((!width && !height && !replaced->hasIntrinsicWidth() && replaced->hasIntrinsicHeight() && replaced->hasIntrinsicRatio()) 714 || (!width && height && replaced->hasIntrinsicRatio())) { 700 715 // #2 701 auto usedHeight = height. isCalculated() ? LayoutUnit(height.value()) : replaced->intrinsicHeight();702 computedWidthValue= usedHeight * replaced->intrinsicRatio();703 } else if ( width.isAuto() && height.isAuto() && replaced->hasIntrinsicRatio()) {716 auto usedHeight = height.value_or(replaced->intrinsicHeight()); 717 width = usedHeight * replaced->intrinsicRatio(); 718 } else if (!width && !height && replaced->hasIntrinsicRatio() && !replaced->hasIntrinsicWidth() && !replaced->hasIntrinsicHeight()) { 704 719 // #3 705 720 // FIXME: undefined but surely doable. 706 721 ASSERT_NOT_IMPLEMENTED_YET(); 707 } else if ( width.isAuto()&& replaced->hasIntrinsicWidth()) {722 } else if (!width && replaced->hasIntrinsicWidth()) { 708 723 // #4 709 computedWidthValue= replaced->intrinsicWidth();724 width = replaced->intrinsicWidth(); 710 725 } else { 711 726 // #5 712 computedWidthValue = 300;713 } 714 715 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << computedWidthValue << "px) margin(" << computedMarginLeftValue << "px, " << computedMarginRightValue<< "px) -> layoutBox(" << &layoutBox << ")");716 return { computedWidthValue, { computedMarginLeftValue, computedMarginRightValue} };727 width = { 300 }; 728 } 729 730 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << marginLeft << "px, " << marginRight << "px) -> layoutBox(" << &layoutBox << ")"); 731 return { *width, { marginLeft, marginRight } }; 717 732 } 718 733 … … 744 759 { 745 760 auto& style = layoutBox.style(); 746 auto marginLeft = style.marginLeft();747 auto marginRight = style.marginRight();748 749 761 auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); 750 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed horizontal -> layoutBox: " << &layoutBox); 751 return { 752 marginLeft.isAuto() ? LayoutUnit { 0 } : valueForLength(marginLeft, containingBlockWidth), 753 marginRight.isAuto() ? LayoutUnit { 0 } : valueForLength(marginRight, containingBlockWidth) 754 }; 762 763 auto marginLeft = computedValueIfNotAuto(style.marginLeft(), containingBlockWidth).value_or(LayoutUnit { 0 }); 764 auto marginRight = computedValueIfNotAuto(style.marginRight(), containingBlockWidth).value_or(LayoutUnit { 0 }); 765 766 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed horizontal -> margin(" << marginLeft << "px, " << marginRight << "px) -> layoutBox: " << &layoutBox); 767 return { marginLeft, marginRight }; 755 768 } 756 769 … … 758 771 { 759 772 auto& style = layoutBox.style(); 760 auto marginTop = style.marginTop();761 auto marginBottom = style.marginBottom();762 763 773 auto containingBlockWidth = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->width(); 764 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> layoutBox: " << &layoutBox); 765 return { 766 marginTop.isAuto() ? LayoutUnit { 0 } : valueForLength(marginTop, containingBlockWidth), 767 marginBottom.isAuto() ? LayoutUnit { 0 } : valueForLength(marginBottom, containingBlockWidth) 768 }; 774 775 auto marginTop = computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(LayoutUnit { 0 }); 776 auto marginBottom = computedValueIfNotAuto(style.marginBottom(), containingBlockWidth).value_or(LayoutUnit { 0 }); 777 778 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> margin(" << marginTop << "px, " << marginBottom << "px) -> layoutBox: " << &layoutBox); 779 return { marginTop, marginBottom }; 769 780 } 770 781 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r232870 r232871 74 74 // Only children in the normal flow are taken into account (i.e., floating boxes and absolutely positioned boxes are ignored, 75 75 // and relatively positioned boxes are considered without their offset). Note that the child box may be an anonymous block box. 76 76 77 if (!layoutBox.style().logicalHeight().isAuto()) { 77 78 // FIXME: Only fixed values yet. … … 228 229 }; 229 230 230 auto computedWidthAndMarginValue= compute();231 auto widthAndMargin = compute(); 231 232 if (!isStretchedToViewport(layoutContext, layoutBox)) { 232 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << computedWidthAndMarginValue.width << "px) margin(" << computedWidthAndMarginValue.margin.left << "px, " << computedWidthAndMarginValue.margin.right << "px) -> layoutBox(" << &layoutBox << ")");233 return computedWidthAndMarginValue;233 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")"); 234 return widthAndMargin; 234 235 } 235 236 236 237 auto initialContainingBlockWidth = layoutContext.displayBoxForLayoutBox(initialContainingBlock(layoutBox))->contentBox().width(); 237 auto horizontalMargins = computedWidthAndMarginValue.margin.left + computedWidthAndMarginValue.margin.right;238 auto horizontalMargins = widthAndMargin.margin.left + widthAndMargin.margin.right; 238 239 // Stretch but never overstretch with the margins. 239 if ( computedWidthAndMarginValue.width + horizontalMargins < initialContainingBlockWidth)240 computedWidthAndMarginValue.width = initialContainingBlockWidth - horizontalMargins;241 242 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> streched to viewport-> width(" << computedWidthAndMarginValue.width << "px) margin(" << computedWidthAndMarginValue.margin.left << "px, " << computedWidthAndMarginValue.margin.right << "px) -> layoutBox(" << &layoutBox << ")");243 return { computedWidthAndMarginValue.width, computedWidthAndMarginValue.margin };240 if (widthAndMargin.width + horizontalMargins < initialContainingBlockWidth) 241 widthAndMargin.width = initialContainingBlockWidth - horizontalMargins; 242 243 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> streched to viewport-> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.left << "px, " << widthAndMargin.margin.right << "px) -> layoutBox(" << &layoutBox << ")"); 244 return widthAndMargin; 244 245 } 245 246 … … 254 255 255 256 // #1 256 auto inlineReplacedWidthAndMargin = FormattingContext::Geometry::inlineReplacedWidthAndMargin(layoutContext, layoutBox);257 auto width = FormattingContext::Geometry::inlineReplacedWidthAndMargin(layoutContext, layoutBox).width; 257 258 // #2 258 auto inlineReplacedWidthAndBlockNonReplacedMargin = inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox, inlineReplacedWidthAndMargin.width);259 ASSERT(inlineReplacedWidthAndMargin.width == inlineReplacedWidthAndBlockNonReplacedMargin.width); 260 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << inlineReplacedWidthAndBlockNonReplacedMargin.width << "px) margin(" << inlineReplacedWidthAndBlockNonReplacedMargin.margin.left << "px, " << inlineReplacedWidthAndBlockNonReplacedMargin.margin.left << "px) -> layoutBox(" << &layoutBox << ")");261 return inlineReplacedWidthAndBlockNonReplacedMargin;259 auto margin = inFlowNonReplacedWidthAndMargin(layoutContext, layoutBox, width).margin; 260 261 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << margin.left << "px, " << margin.left << "px) -> layoutBox(" << &layoutBox << ")"); 262 return { width, margin }; 262 263 } 263 264 … … 269 270 // Vertical margins between adjacent block-level boxes in a block formatting context collapse. 270 271 // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch). 272 271 273 auto containingBlockContentBox = layoutContext.displayBoxForLayoutBox(*layoutBox.containingBlock())->contentBox(); 272 274 // Start from the top of the container's content box. … … 284 286 { 285 287 ASSERT(layoutBox.isInFlowPositioned()); 288 286 289 // 9.4.3 Relative positioning 287 290 // … … 292 295 // 2. If one of them is 'auto', it becomes the negative of the other. 293 296 // 3. If neither is 'auto', 'bottom' is ignored (i.e., the used value of 'bottom' will be minus the value of 'top'). 297 298 auto& style = layoutBox.style(); 294 299 auto& displayBox = *layoutContext.displayBoxForLayoutBox(layoutBox); 295 auto& style = layoutBox.style(); 296 297 auto top = style.logicalTop(); 298 auto bottom = style.logicalBottom(); 299 LayoutUnit topDelta; 300 301 if (top.isAuto() && bottom.isAuto()) { 300 auto& containingBlock = *layoutBox.containingBlock(); 301 auto& containingBlockDisplayBox = *layoutContext.displayBoxForLayoutBox(containingBlock); 302 auto containingBlockWidth = containingBlockDisplayBox.width(); 303 304 auto top = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); 305 auto bottom = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); 306 307 if (!top && !bottom) { 302 308 // #1 303 top Delta = 0;304 } else if ( top.isAuto()) {309 top = bottom = { 0 }; 310 } else if (!top) { 305 311 // #2 306 topDelta = -bottom.value(); 307 } else if (bottom.isAuto()) { 308 // #3 #4 309 topDelta = top.value(); 312 top = -*bottom; 313 } else if (!bottom) { 314 // #3 315 bottom = -*top; 316 } else { 317 // #4 318 bottom = std::nullopt; 310 319 } 311 320 … … 320 329 // If the 'direction' property of the containing block is 'ltr', the value of 'left' wins and 'right' becomes -'left'. 321 330 // If 'direction' of the containing block is 'rtl', 'right' wins and 'left' is ignored. 322 // 323 auto left = style.logicalLeft(); 324 auto right = style.logicalRight(); 325 LayoutUnit leftDelta; 326 327 if (left.isAuto() && right.isAuto()) { 331 332 auto left = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); 333 auto right = FormattingContext::Geometry::computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); 334 335 if (!left && !right) { 328 336 // #1 329 left Delta = 0;330 } else if ( left.isAuto()) {337 left = right = { 0 }; 338 } else if (!left) { 331 339 // #2 332 left Delta = -right.value();333 } else if ( right.isAuto()) {340 left = -*right; 341 } else if (!right) { 334 342 // #3 335 leftDelta = left.value();343 right = -*left; 336 344 } else { 337 345 // #4 338 // FIXME: take direction into account 339 leftDelta = left.value(); 340 } 341 342 auto computedLeft = displayBox.left() + leftDelta; 343 auto computedTop = displayBox.top() + topDelta; 344 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position] -> positioned inflow -> top(" << top << "px) left(" << left << "px) layoutBox(" << &layoutBox << ")"); 345 return { computedLeft, computedTop }; 346 auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection(); 347 if (isLeftToRightDirection) 348 right = -*left; 349 else 350 left = std::nullopt; 351 } 352 353 ASSERT(!bottom || *top == -*bottom); 354 ASSERT(!left || *left == -*right); 355 356 auto newTopPosition = displayBox.top() + *top; 357 auto newLeftPosition = displayBox.left() + left.value_or(-*right); 358 359 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position] -> positioned inflow -> top(" << newTopPosition << "px) left(" << newLeftPosition << "px) layoutBox(" << &layoutBox << ")"); 360 return { newTopPosition, newLeftPosition }; 346 361 } 347 362
Note: See TracChangeset
for help on using the changeset viewer.