Changeset 241122 in webkit
- Timestamp:
- Feb 7, 2019 8:33:07 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r241121 r241122 1 2019-02-07 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Use dedicated data structures for optional used values (input to geometry functions) 4 https://bugs.webkit.org/show_bug.cgi?id=194376 5 6 Reviewed by Antti Koivisto. 7 8 This is in preparation for being able to pass in the containing block's width as an optional used value. 9 During layout we always have a valid width for the containing block, however it's not the case while computing the preferred width. 10 11 * layout/FormattingContext.cpp: 12 (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const): 13 (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const): 14 * layout/FormattingContext.h: 15 (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry): Deleted. 16 (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry): Deleted. 17 (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin): Deleted. 18 (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin): Deleted. 19 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): Deleted. 20 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): Deleted. 21 (): Deleted. 22 (WebCore::Layout::FormattingContext::Geometry::complicatedCases): Deleted. 23 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): Deleted. 24 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): Deleted. 25 (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry): Deleted. 26 (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry): Deleted. 27 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin): Deleted. 28 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin): Deleted. 29 (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): Deleted. 30 * layout/FormattingContextGeometry.cpp: 31 (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry): 32 (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry): 33 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): 34 (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): 35 (WebCore::Layout::FormattingContext::Geometry::complicatedCases): 36 (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): 37 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedHeightAndMargin): 38 (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin): 39 (WebCore::Layout::FormattingContext::Geometry::outOfFlowVerticalGeometry): 40 (WebCore::Layout::FormattingContext::Geometry::outOfFlowHorizontalGeometry): 41 (WebCore::Layout::FormattingContext::Geometry::floatingHeightAndMargin): 42 (WebCore::Layout::FormattingContext::Geometry::floatingWidthAndMargin): 43 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): 44 (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): 45 * layout/LayoutUnits.h: 46 * layout/blockformatting/BlockFormattingContext.cpp: 47 (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const): 48 (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const): 49 * layout/blockformatting/BlockFormattingContext.h: 50 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin): Deleted. 51 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin): Deleted. 52 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): Deleted. 53 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): Deleted. 54 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin): Deleted. 55 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 56 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 57 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): 58 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin): 59 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin): 60 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowWidthAndMargin): 61 * layout/inlineformatting/InlineFormattingContext.cpp: 62 (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const): 63 (WebCore::Layout::InlineFormattingContext::computeHeightAndMargin const): 64 * layout/inlineformatting/InlineFormattingContextGeometry.cpp: 65 (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin): 66 (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockHeightAndMargin): 67 * page/FrameViewLayoutContext.cpp: 68 (WebCore::layoutUsingFormattingContext): 69 1 70 2019-02-07 Antti Koivisto <antti@apple.com> 2 71 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r240253 r241122 69 69 auto& layoutState = this->layoutState(); 70 70 71 auto compute = [&]( Optional<LayoutUnit> usedWidth) {72 return Geometry::outOfFlowHorizontalGeometry(layoutState, layoutBox, used Width);71 auto compute = [&](UsedHorizontalValues usedValues) { 72 return Geometry::outOfFlowHorizontalGeometry(layoutState, layoutBox, usedValues); 73 73 }; 74 74 … … 77 77 78 78 if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) { 79 auto maxHorizontalGeometry = compute( maxWidth);79 auto maxHorizontalGeometry = compute({ *maxWidth, { } }); 80 80 if (horizontalGeometry.widthAndMargin.width > maxHorizontalGeometry.widthAndMargin.width) 81 81 horizontalGeometry = maxHorizontalGeometry; … … 83 83 84 84 if (auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth)) { 85 auto minHorizontalGeometry = compute( minWidth);85 auto minHorizontalGeometry = compute({ *minWidth, { } }); 86 86 if (horizontalGeometry.widthAndMargin.width < minHorizontalGeometry.widthAndMargin.width) 87 87 horizontalGeometry = minHorizontalGeometry; … … 99 99 auto& layoutState = this->layoutState(); 100 100 101 auto compute = [&]( Optional<LayoutUnit> usedHeight) {102 return Geometry::outOfFlowVerticalGeometry(layoutState, layoutBox, used Height);101 auto compute = [&](UsedVerticalValues usedValues) { 102 return Geometry::outOfFlowVerticalGeometry(layoutState, layoutBox, usedValues); 103 103 }; 104 104 105 105 auto verticalGeometry = compute({ }); 106 106 if (auto maxHeight = Geometry::computedMaxHeight(layoutState, layoutBox)) { 107 auto maxVerticalGeometry = compute( maxHeight);107 auto maxVerticalGeometry = compute({ *maxHeight }); 108 108 if (verticalGeometry.heightAndMargin.height > maxVerticalGeometry.heightAndMargin.height) 109 109 verticalGeometry = maxVerticalGeometry; … … 111 111 112 112 if (auto minHeight = Geometry::computedMinHeight(layoutState, layoutBox)) { 113 auto minVerticalGeometry = compute( minHeight);113 auto minVerticalGeometry = compute({ *minHeight }); 114 114 if (verticalGeometry.heightAndMargin.height < minVerticalGeometry.heightAndMargin.height) 115 115 verticalGeometry = minVerticalGeometry; -
trunk/Source/WebCore/layout/FormattingContext.h
r240253 r241122 79 79 class Geometry { 80 80 public: 81 static VerticalGeometry outOfFlowVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });82 static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });81 static VerticalGeometry outOfFlowVerticalGeometry(const LayoutState&, const Box&, UsedVerticalValues); 82 static HorizontalGeometry outOfFlowHorizontalGeometry(LayoutState&, const Box&, UsedHorizontalValues); 83 83 84 static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });85 static WidthAndMargin floatingWidthAndMargin(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });84 static HeightAndMargin floatingHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 85 static WidthAndMargin floatingWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues); 86 86 87 static HeightAndMargin inlineReplacedHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { }); 88 static WidthAndMargin inlineReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { }, 89 Optional<LayoutUnit> precomputedMarginStart = { }, Optional<LayoutUnit> precomputedMarginEnd = { }); 87 static HeightAndMargin inlineReplacedHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 88 static WidthAndMargin inlineReplacedWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues); 90 89 91 90 static LayoutSize inFlowPositionedPositionOffset(const LayoutState&, const Box&); 92 91 93 static HeightAndMargin complicatedCases(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });92 static HeightAndMargin complicatedCases(const LayoutState&, const Box&, UsedVerticalValues); 94 93 static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&); 95 94 … … 111 110 112 111 private: 113 static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });114 static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });112 static VerticalGeometry outOfFlowReplacedVerticalGeometry(const LayoutState&, const Box&, UsedVerticalValues); 113 static HorizontalGeometry outOfFlowReplacedHorizontalGeometry(const LayoutState&, const Box&, UsedHorizontalValues); 115 114 116 static VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });117 static HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });115 static VerticalGeometry outOfFlowNonReplacedVerticalGeometry(const LayoutState&, const Box&, UsedVerticalValues); 116 static HorizontalGeometry outOfFlowNonReplacedHorizontalGeometry(LayoutState&, const Box&, UsedHorizontalValues); 118 117 119 static HeightAndMargin floatingReplacedHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });120 static WidthAndMargin floatingReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });118 static HeightAndMargin floatingReplacedHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 119 static WidthAndMargin floatingReplacedWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues); 121 120 122 static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });121 static WidthAndMargin floatingNonReplacedWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues); 123 122 }; 124 123 -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r240894 r241122 252 252 } 253 253 254 VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)254 VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 255 255 { 256 256 ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced()); … … 289 289 auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); 290 290 auto isStaticallyPositioned = !top && !bottom; 291 auto height = used Height ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);291 auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); 292 292 auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox); 293 293 UsedVerticalMargin::NonCollapsedValues usedVerticalMargin; … … 377 377 } 378 378 379 HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)379 HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 380 380 { 381 381 ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.replaced()); … … 417 417 auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); 418 418 auto isStaticallyPositioned = !left && !right; 419 auto width = computedValueIfNotAuto(used Width ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);419 auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth); 420 420 auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); 421 421 UsedHorizontalMargin usedHorizontalMargin; … … 531 531 } 532 532 533 VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)533 VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 534 534 { 535 535 ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); … … 554 554 auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); 555 555 auto isStaticallyPositioned = !top && !bottom; 556 auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, used Height).height;556 auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues).height; 557 557 auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox); 558 558 Optional<LayoutUnit> usedMarginBefore = computedVerticalMargin.before; … … 615 615 } 616 616 617 HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)617 HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 618 618 { 619 619 ASSERT(layoutBox.isOutOfFlowPositioned() && layoutBox.replaced()); … … 646 646 Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start; 647 647 Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end; 648 auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, used Width).width;648 auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues).width; 649 649 auto paddingLeft = displayBox.paddingLeft().valueOr(0); 650 650 auto paddingRight = displayBox.paddingRight().valueOr(0); … … 723 723 } 724 724 725 HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)725 HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 726 726 { 727 727 ASSERT(!layoutBox.replaced()); … … 738 738 // 2. If 'height' is 'auto', the height depends on the element's descendants per 10.6.7. 739 739 740 auto height = used Height ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);740 auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); 741 741 auto computedVerticalMargin = Geometry::computedVerticalMargin(layoutState, layoutBox); 742 742 // #1 … … 754 754 } 755 755 756 WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)756 WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 757 757 { 758 758 ASSERT(layoutBox.isFloatingPositioned() && !layoutBox.replaced()); … … 770 770 auto usedHorizontallMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) }; 771 771 // #2 772 auto width = computedValueIfNotAuto(used Width ? Length { usedWidth.value(), Fixed } : layoutBox.style().logicalWidth(), containingBlockWidth);772 auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), containingBlockWidth); 773 773 if (!width) 774 774 width = shrinkToFitWidth(layoutState, layoutBox); … … 778 778 } 779 779 780 HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)780 HeightAndMargin FormattingContext::Geometry::floatingReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 781 781 { 782 782 ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced()); … … 785 785 // replaced elements in normal flow and floating replaced elements 786 786 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced"); 787 return inlineReplacedHeightAndMargin(layoutState, layoutBox, used Height);788 } 789 790 WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)787 return inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues); 788 } 789 790 WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 791 791 { 792 792 ASSERT(layoutBox.isFloatingPositioned() && layoutBox.replaced()); … … 799 799 800 800 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced"); 801 return inlineReplacedWidthAndMargin(layoutState, layoutBox, usedWidth, computedHorizontalMargin.start, computedHorizontalMargin.end);802 } 803 804 VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)801 return inlineReplacedWidthAndMargin(layoutState, layoutBox, { usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } }); 802 } 803 804 VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 805 805 { 806 806 ASSERT(layoutBox.isOutOfFlowPositioned()); 807 807 808 808 if (!layoutBox.replaced()) 809 return outOfFlowNonReplacedVerticalGeometry(layoutState, layoutBox, used Height);810 return outOfFlowReplacedVerticalGeometry(layoutState, layoutBox, used Height);811 } 812 813 HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)809 return outOfFlowNonReplacedVerticalGeometry(layoutState, layoutBox, usedValues); 810 return outOfFlowReplacedVerticalGeometry(layoutState, layoutBox, usedValues); 811 } 812 813 HorizontalGeometry FormattingContext::Geometry::outOfFlowHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 814 814 { 815 815 ASSERT(layoutBox.isOutOfFlowPositioned()); 816 816 817 817 if (!layoutBox.replaced()) 818 return outOfFlowNonReplacedHorizontalGeometry(layoutState, layoutBox, used Width);819 return outOfFlowReplacedHorizontalGeometry(layoutState, layoutBox, used Width);820 } 821 822 HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)818 return outOfFlowNonReplacedHorizontalGeometry(layoutState, layoutBox, usedValues); 819 return outOfFlowReplacedHorizontalGeometry(layoutState, layoutBox, usedValues); 820 } 821 822 HeightAndMargin FormattingContext::Geometry::floatingHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 823 823 { 824 824 ASSERT(layoutBox.isFloatingPositioned()); 825 825 826 826 if (!layoutBox.replaced()) 827 return complicatedCases(layoutState, layoutBox, used Height);828 return floatingReplacedHeightAndMargin(layoutState, layoutBox, used Height);829 } 830 831 WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)827 return complicatedCases(layoutState, layoutBox, usedValues); 828 return floatingReplacedHeightAndMargin(layoutState, layoutBox, usedValues); 829 } 830 831 WidthAndMargin FormattingContext::Geometry::floatingWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 832 832 { 833 833 ASSERT(layoutBox.isFloatingPositioned()); 834 834 835 835 if (!layoutBox.replaced()) 836 return floatingNonReplacedWidthAndMargin(layoutState, layoutBox, used Width);837 return floatingReplacedWidthAndMargin(layoutState, layoutBox, used Width);838 } 839 840 HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)836 return floatingNonReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 837 return floatingReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 838 } 839 840 HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 841 841 { 842 842 ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); … … 858 858 auto replaced = layoutBox.replaced(); 859 859 860 auto height = used Height ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);861 auto heightIsAuto = !used Height && isHeightAuto(layoutBox);860 auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); 861 auto heightIsAuto = !usedValues.height && isHeightAuto(layoutBox); 862 862 auto widthIsAuto = style.logicalWidth().isAuto(); 863 863 … … 883 883 } 884 884 885 WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, 886 Optional<LayoutUnit> usedWidth, Optional<LayoutUnit> precomputedMarginStart, Optional<LayoutUnit> precomputedMarginEnd) 885 WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 887 886 { 888 887 ASSERT((layoutBox.isOutOfFlowPositioned() || layoutBox.isFloatingPositioned() || layoutBox.isInFlow()) && layoutBox.replaced()); … … 913 912 914 913 auto usedMarginStart = [&] { 915 return precomputedMarginStart.valueOr(computedHorizontalMargin.start.valueOr(0_lu)); 914 if (usedValues.margin) 915 return usedValues.margin->start; 916 return computedHorizontalMargin.start.valueOr(0_lu); 916 917 }; 917 918 918 919 auto usedMarginEnd = [&] { 919 return precomputedMarginEnd.valueOr(computedHorizontalMargin.end.valueOr(0_lu)); 920 if (usedValues.margin) 921 return usedValues.margin->end; 922 return computedHorizontalMargin.end.valueOr(0_lu); 920 923 }; 921 924 … … 923 926 ASSERT(replaced); 924 927 925 auto width = computedValueIfNotAuto(used Width ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);928 auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth); 926 929 auto heightIsAuto = isHeightAuto(layoutBox); 927 930 auto height = computedHeightValue(layoutState, layoutBox, HeightType::Normal); -
trunk/Source/WebCore/layout/LayoutUnits.h
r239675 r241122 125 125 }; 126 126 127 struct UsedHorizontalValues { 128 Optional<LayoutUnit> width; 129 Optional<UsedHorizontalMargin> margin; 130 }; 131 132 struct UsedVerticalValues { 133 Optional<LayoutUnit> height; 134 }; 135 127 136 } 128 137 } -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r240656 r241122 300 300 auto& layoutState = this->layoutState(); 301 301 302 auto compute = [&]( Optional<LayoutUnit> usedWidth) -> WidthAndMargin {302 auto compute = [&](UsedHorizontalValues usedValues) -> WidthAndMargin { 303 303 304 304 if (layoutBox.isInFlow()) 305 return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, used Width);305 return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, usedValues); 306 306 307 307 if (layoutBox.isFloatingPositioned()) 308 return Geometry::floatingWidthAndMargin(layoutState, layoutBox, used Width);308 return Geometry::floatingWidthAndMargin(layoutState, layoutBox, usedValues); 309 309 310 310 ASSERT_NOT_REACHED(); … … 316 316 317 317 if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) { 318 auto maxWidthAndMargin = compute( maxWidth);318 auto maxWidthAndMargin = compute({ *maxWidth, { } }); 319 319 if (widthAndMargin.width > maxWidthAndMargin.width) 320 320 widthAndMargin = maxWidthAndMargin; … … 322 322 323 323 auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth).valueOr(0); 324 auto minWidthAndMargin = compute( minWidth);324 auto minWidthAndMargin = compute({ minWidth, { } }); 325 325 if (widthAndMargin.width < minWidthAndMargin.width) 326 326 widthAndMargin = minWidthAndMargin; … … 336 336 auto& layoutState = this->layoutState(); 337 337 338 auto compute = [&]( Optional<LayoutUnit> usedHeight) -> HeightAndMargin {338 auto compute = [&](UsedVerticalValues usedValues) -> HeightAndMargin { 339 339 340 340 if (layoutBox.isInFlow()) 341 return Geometry::inFlowHeightAndMargin(layoutState, layoutBox, used Height);341 return Geometry::inFlowHeightAndMargin(layoutState, layoutBox, usedValues); 342 342 343 343 if (layoutBox.isFloatingPositioned()) 344 return Geometry::floatingHeightAndMargin(layoutState, layoutBox, used Height);344 return Geometry::floatingHeightAndMargin(layoutState, layoutBox, usedValues); 345 345 346 346 ASSERT_NOT_REACHED(); … … 351 351 if (auto maxHeight = Geometry::computedMaxHeight(layoutState, layoutBox)) { 352 352 if (heightAndMargin.height > *maxHeight) { 353 auto maxHeightAndMargin = compute( maxHeight);353 auto maxHeightAndMargin = compute({ *maxHeight }); 354 354 // Used height should remain the same. 355 355 ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || maxHeightAndMargin.height == *maxHeight); … … 360 360 if (auto minHeight = Geometry::computedMinHeight(layoutState, layoutBox)) { 361 361 if (heightAndMargin.height < *minHeight) { 362 auto minHeightAndMargin = compute( minHeight);362 auto minHeightAndMargin = compute({ *minHeight }); 363 363 // Used height should remain the same. 364 364 ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || minHeightAndMargin.height == *minHeight); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r240654 r241122 74 74 class Geometry : public FormattingContext::Geometry { 75 75 public: 76 static HeightAndMargin inFlowHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });77 static WidthAndMargin inFlowWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });76 static HeightAndMargin inFlowHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 77 static WidthAndMargin inFlowWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues); 78 78 79 79 static Point staticPosition(const LayoutState&, const Box&); … … 83 83 84 84 private: 85 static HeightAndMargin inFlowNonReplacedHeightAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedHeight = { });86 static WidthAndMargin inFlowNonReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });87 static WidthAndMargin inFlowReplacedWidthAndMargin(const LayoutState&, const Box&, Optional<LayoutUnit> usedWidth = { });85 static HeightAndMargin inFlowNonReplacedHeightAndMargin(const LayoutState&, const Box&, UsedVerticalValues); 86 static WidthAndMargin inFlowNonReplacedWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues); 87 static WidthAndMargin inFlowReplacedWidthAndMargin(const LayoutState&, const Box&, UsedHorizontalValues); 88 88 static Point staticPositionForOutOfFlowPositioned(const LayoutState&, const Box&); 89 89 }; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r240654 r241122 38 38 namespace Layout { 39 39 40 HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)40 HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 41 41 { 42 42 ASSERT(layoutBox.isInFlow() && !layoutBox.replaced()); … … 62 62 auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) }; 63 63 auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop().valueOr(0); 64 auto height = used Height ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal);64 auto height = usedValues.height ? usedValues.height.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); 65 65 66 66 if (height) { … … 108 108 } 109 109 110 WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)110 WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 111 111 { 112 112 ASSERT(layoutBox.isInFlow()); … … 140 140 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); 141 141 142 auto width = computedValueIfNotAuto(used Width ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth);142 auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth); 143 143 auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); 144 144 UsedHorizontalMargin usedHorizontalMargin; … … 204 204 } 205 205 206 WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)206 WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 207 207 { 208 208 ASSERT(layoutBox.isInFlow() && layoutBox.replaced()); … … 214 214 215 215 // #1 216 auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedWidth).width;216 usedValues.width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues).width; 217 217 // #2 218 auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, width);219 220 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")");221 return { width, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin };218 auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 219 220 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *usedValues.width << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")"); 221 return { *usedValues.width, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin }; 222 222 } 223 223 … … 243 243 } 244 244 245 HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight)245 HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) 246 246 { 247 247 ASSERT(layoutBox.isInFlow()); … … 250 250 // replaced elements in normal flow and floating replaced elements 251 251 if (layoutBox.replaced()) 252 return inlineReplacedHeightAndMargin(layoutState, layoutBox, used Height);252 return inlineReplacedHeightAndMargin(layoutState, layoutBox, usedValues); 253 253 254 254 HeightAndMargin heightAndMargin; 255 255 // TODO: Figure out the case for the document element. Let's just complicated-case it for now. 256 256 if (layoutBox.isOverflowVisible() && !layoutBox.isDocumentBox()) 257 heightAndMargin = inFlowNonReplacedHeightAndMargin(layoutState, layoutBox, used Height);257 heightAndMargin = inFlowNonReplacedHeightAndMargin(layoutState, layoutBox, usedValues); 258 258 else { 259 259 // 10.6.6 Complicated cases 260 260 // Block-level, non-replaced elements in normal flow when 'overflow' does not compute to 'visible' (except if the 'overflow' property's value has been propagated to the viewport). 261 heightAndMargin = complicatedCases(layoutState, layoutBox, used Height);261 heightAndMargin = complicatedCases(layoutState, layoutBox, usedValues); 262 262 } 263 263 … … 271 271 } 272 272 273 WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth)273 WidthAndMargin BlockFormattingContext::Geometry::inFlowWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, UsedHorizontalValues usedValues) 274 274 { 275 275 ASSERT(layoutBox.isInFlow()); 276 276 277 277 if (!layoutBox.replaced()) 278 return inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, used Width);279 return inFlowReplacedWidthAndMargin(layoutState, layoutBox, used Width);278 return inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 279 return inFlowReplacedWidthAndMargin(layoutState, layoutBox, usedValues); 280 280 } 281 281 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r241023 r241122 109 109 WidthAndMargin widthAndMargin; 110 110 if (layoutBox.isFloatingPositioned()) 111 widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox );111 widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox, { }); 112 112 else if (layoutBox.isInlineBlockBox()) 113 113 widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox); 114 114 else if (layoutBox.replaced()) 115 widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox );115 widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox, { }); 116 116 else 117 117 ASSERT_NOT_REACHED(); … … 129 129 HeightAndMargin heightAndMargin; 130 130 if (layoutBox.isFloatingPositioned()) 131 heightAndMargin = Geometry::floatingHeightAndMargin(layoutState, layoutBox );131 heightAndMargin = Geometry::floatingHeightAndMargin(layoutState, layoutBox, { }); 132 132 else if (layoutBox.isInlineBlockBox()) 133 133 heightAndMargin = Geometry::inlineBlockHeightAndMargin(layoutState, layoutBox); 134 134 else if (layoutBox.replaced()) 135 heightAndMargin = Geometry::inlineReplacedHeightAndMargin(layoutState, layoutBox );135 heightAndMargin = Geometry::inlineReplacedHeightAndMargin(layoutState, layoutBox, { }); 136 136 else 137 137 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp
r241023 r241122 47 47 // Exactly as inline replaced elements. 48 48 if (formattingContextRoot.replaced()) 49 return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot );49 return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot, { }); 50 50 51 51 // 10.3.9 'Inline-block', non-replaced elements in normal flow … … 72 72 // 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements 73 73 if (layoutBox.replaced()) 74 return inlineReplacedHeightAndMargin(layoutState, layoutBox );74 return inlineReplacedHeightAndMargin(layoutState, layoutBox, { }); 75 75 76 76 // 10.6.6 Complicated cases 77 77 // - 'Inline-block', non-replaced elements. 78 return complicatedCases(layoutState, layoutBox );78 return complicatedCases(layoutState, layoutBox, { }); 79 79 } 80 80
Note: See TracChangeset
for help on using the changeset viewer.