WebKit Bugzilla
Attachment 361489 Details for
Bug 194424
: [LFC] Horizontal geometry compute functions should take the containing block's width as a used value
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194424-20190207203034.patch (text/plain), 28.30 KB, created by
zalan
on 2019-02-07 20:30:35 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-02-07 20:30:35 PST
Size:
28.30 KB
patch
obsolete
>Subversion Revision: 241135 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6922c0089356d3fc32c051f8ea44db9e1a064fe3..4841395f8fc77efb1ebae09110a3fcc3223578d5 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,39 @@ >+2019-02-07 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC] Horizontal geometry compute functions should take the containing block's width as a used value >+ https://bugs.webkit.org/show_bug.cgi?id=194424 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is in preparation for passing optional containing block width for the preferred with codepath. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const): >+ (WebCore::Layout::FormattingContext::computeBorderAndPadding const): >+ * layout/FormattingContext.h: >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::floatingNonReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::floatingReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::computedBorder): >+ (WebCore::Layout::FormattingContext::Geometry::computedPadding): >+ (WebCore::Layout::FormattingContext::Geometry::computedHorizontalMargin): >+ * layout/LayoutUnits.h: >+ (WebCore::Layout::UsedHorizontalValues::UsedHorizontalValues): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const): >+ * layout/blockformatting/BlockFormattingContextGeometry.cpp: >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::InlineFormattingContext::computeMarginBorderAndPadding const): >+ (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const): >+ * layout/inlineformatting/InlineFormattingContext.h: >+ * layout/inlineformatting/InlineFormattingContextGeometry.cpp: >+ (WebCore::Layout::InlineFormattingContext::Geometry::inlineBlockWidthAndMargin): >+ > 2019-02-07 Youenn Fablet <youenn@apple.com> > > Make to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index dc186975d6037005bc42aac0b8e7c88bdb29b0e2..cd94e251ded3e6511f15dee55b99fd66bc196c29 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -67,22 +67,22 @@ LayoutState& FormattingContext::layoutState() const > void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox) const > { > auto& layoutState = this->layoutState(); >+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).paddingBoxWidth(); > >- auto compute = [&](UsedHorizontalValues usedValues) { >+ auto compute = [&](Optional<LayoutUnit> usedWidth) { >+ auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } }; > return Geometry::outOfFlowHorizontalGeometry(layoutState, layoutBox, usedValues); > }; > > auto horizontalGeometry = compute({ }); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).paddingBoxWidth(); >- > if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) { >- auto maxHorizontalGeometry = compute({ *maxWidth, { } }); >+ auto maxHorizontalGeometry = compute(maxWidth); > if (horizontalGeometry.widthAndMargin.width > maxHorizontalGeometry.widthAndMargin.width) > horizontalGeometry = maxHorizontalGeometry; > } > > if (auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth)) { >- auto minHorizontalGeometry = compute({ *minWidth, { } }); >+ auto minHorizontalGeometry = compute(minWidth); > if (horizontalGeometry.widthAndMargin.width < minHorizontalGeometry.widthAndMargin.width) > horizontalGeometry = minHorizontalGeometry; > } >@@ -127,8 +127,9 @@ void FormattingContext::computeBorderAndPadding(const Box& layoutBox) const > { > auto& layoutState = this->layoutState(); > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); >- displayBox.setBorder(Geometry::computedBorder(layoutState, layoutBox)); >- displayBox.setPadding(Geometry::computedPadding(layoutState, layoutBox)); >+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); >+ displayBox.setBorder(Geometry::computedBorder(layoutBox)); >+ displayBox.setPadding(Geometry::computedPadding(layoutBox, UsedHorizontalValues { containingBlockWidth, { }, { } })); > } > > void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 8270da8cc4ae7bafbc64bdddd949520afbeff268..62530a3fde0d17e468873acea0e3c46991d5359c 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -90,12 +90,12 @@ protected: > static LayoutSize inFlowPositionedPositionOffset(const LayoutState&, const Box&); > > static HeightAndMargin complicatedCases(const LayoutState&, const Box&, UsedVerticalValues); >- static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&); >+ static LayoutUnit shrinkToFitWidth(LayoutState&, const Box&, UsedHorizontalValues); > >- static Edges computedBorder(const LayoutState&, const Box&); >- static Optional<Edges> computedPadding(const LayoutState&, const Box&); >+ static Edges computedBorder(const Box&); >+ static Optional<Edges> computedPadding(const Box&, UsedHorizontalValues); > >- static ComputedHorizontalMargin computedHorizontalMargin(const LayoutState&, const Box&); >+ static ComputedHorizontalMargin computedHorizontalMargin(const Box&, UsedHorizontalValues); > static ComputedVerticalMargin computedVerticalMargin(const LayoutState&, const Box&); > > static Optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth); >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index c8461228f41039cdb958206f6e8f95d9ea18c7d9..809b017582b3820585766cb2f72cb8e7dd4788d4 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -234,7 +234,7 @@ static LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const LayoutSta > return left; > } > >-LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot) >+LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutState, const Box& formattingRoot, UsedHorizontalValues usedValues) > { > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingRoot << ")"); > ASSERT(formattingRoot.establishesFormattingContext()); >@@ -246,7 +246,7 @@ LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(LayoutState& layoutStat > // 'padding-left', 'padding-right', 'border-right-width', 'margin-right', and the widths of any relevant scroll bars. > > // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width). >- auto availableWidth = layoutState.displayBoxForLayoutBox(*formattingRoot.containingBlock()).width(); >+ auto availableWidth = usedValues.containingBlockWidth; > auto instrinsicWidthConstraints = layoutState.createFormattingContext(formattingRoot)->instrinsicWidthConstraints(); > return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum); > } >@@ -410,14 +410,14 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > auto& containingBlock = *layoutBox.containingBlock(); > auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(containingBlock); >- auto containingBlockWidth = containingBlockDisplayBox.paddingBoxWidth(); >+ auto containingBlockWidth = usedValues.containingBlockWidth; > auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection(); > > 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(layoutState, layoutBox); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > UsedHorizontalMargin usedHorizontalMargin; > auto paddingLeft = displayBox.paddingLeft().valueOr(0); > auto paddingRight = displayBox.paddingRight().valueOr(0); >@@ -487,7 +487,7 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > > if (!left && !width && right) { > // #1 >- width = shrinkToFitWidth(layoutState, layoutBox); >+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues); > left = containingBlockWidth - (usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end + *right); > } else if (!left && !right && width) { > // #2 >@@ -501,7 +501,7 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > } > } else if (!width && !right && left) { > // #3 >- width = shrinkToFitWidth(layoutState, layoutBox); >+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues); > right = containingBlockWidth - (*left + usedHorizontalMargin.start + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedHorizontalMargin.end); > } else if (!left && width && right) { > // #4 >@@ -635,14 +635,13 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeome > auto& style = layoutBox.style(); > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > auto& containingBlock = *layoutBox.containingBlock(); >- auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(containingBlock); >- auto containingBlockWidth = containingBlockDisplayBox.paddingBoxWidth(); >+ auto containingBlockWidth = usedValues.containingBlockWidth; > auto isLeftToRightDirection = containingBlock.style().isLeftToRightDirection(); > > auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); > auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); > auto isStaticallyPositioned = !left && !right; >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > Optional<LayoutUnit> usedMarginStart = computedHorizontalMargin.start; > Optional<LayoutUnit> usedMarginEnd = computedHorizontalMargin.end; > auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues).width; >@@ -713,7 +712,7 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeome > // 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(); >+ auto containingBlockPaddingVerticalEdge = layoutState.displayBoxForLayoutBox(containingBlock).paddingBoxLeft(); > *left += containingBlockPaddingVerticalEdge; > *right += containingBlockPaddingVerticalEdge; > } >@@ -762,16 +761,14 @@ WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(La > // 1. If 'margin-left', or 'margin-right' are computed as 'auto', their used value is '0'. > // 2. If 'width' is computed as 'auto', the used value is the "shrink-to-fit" width. > >- auto& containingBlock = *layoutBox.containingBlock(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth(); >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > > // #1 > auto usedHorizontallMargin = UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) }; > // #2 >- auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), containingBlockWidth); >+ auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : layoutBox.style().logicalWidth(), usedValues.containingBlockWidth); > if (!width) >- width = shrinkToFitWidth(layoutState, layoutBox); >+ width = shrinkToFitWidth(layoutState, layoutBox, usedValues); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> floating non-replaced -> width(" << *width << "px) margin(" << usedHorizontallMargin.start << "px, " << usedHorizontallMargin.end << "px) -> layoutBox(" << &layoutBox << ")"); > return WidthAndMargin { *width, usedHorizontallMargin, computedHorizontalMargin }; >@@ -795,10 +792,10 @@ WidthAndMargin FormattingContext::Geometry::floatingReplacedWidthAndMargin(const > // > // 1. If 'margin-left' or 'margin-right' are computed as 'auto', their used value is '0'. > // 2. The used value of 'width' is determined as for inline replaced elements. >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating replaced -> redirected to inline replaced"); >- return inlineReplacedWidthAndMargin(layoutState, layoutBox, { usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } }); >+ return inlineReplacedWidthAndMargin(layoutState, layoutBox, UsedHorizontalValues { usedValues.containingBlockWidth, usedValues.width, UsedHorizontalMargin { computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) } }); > } > > VerticalGeometry FormattingContext::Geometry::outOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, UsedVerticalValues usedValues) >@@ -906,9 +903,8 @@ WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const L > // 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. > > auto& style = layoutBox.style(); >- auto& containingBlock = *layoutBox.containingBlock(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth(); >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); >+ auto containingBlockWidth = usedValues.containingBlockWidth; >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > > auto usedMarginStart = [&] { > if (usedValues.margin) >@@ -1030,7 +1026,7 @@ LayoutSize FormattingContext::Geometry::inFlowPositionedPositionOffset(const Lay > return { leftPositionOffset, topPositionOffset }; > } > >-Edges FormattingContext::Geometry::computedBorder(const LayoutState&, const Box& layoutBox) >+Edges FormattingContext::Geometry::computedBorder(const Box& layoutBox) > { > auto& style = layoutBox.style(); > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Border] -> layoutBox: " << &layoutBox); >@@ -1040,25 +1036,23 @@ Edges FormattingContext::Geometry::computedBorder(const LayoutState&, const Box& > }; > } > >-Optional<Edges> FormattingContext::Geometry::computedPadding(const LayoutState& layoutState, const Box& layoutBox) >+Optional<Edges> FormattingContext::Geometry::computedPadding(const Box& layoutBox, UsedHorizontalValues usedValues) > { > if (!layoutBox.isPaddingApplicable()) > return WTF::nullopt; > > auto& style = layoutBox.style(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Padding] -> layoutBox: " << &layoutBox); > return Edges { >- { valueForLength(style.paddingLeft(), containingBlockWidth), valueForLength(style.paddingRight(), containingBlockWidth) }, >- { valueForLength(style.paddingTop(), containingBlockWidth), valueForLength(style.paddingBottom(), containingBlockWidth) } >+ { valueForLength(style.paddingLeft(), usedValues.containingBlockWidth), valueForLength(style.paddingRight(), usedValues.containingBlockWidth) }, >+ { valueForLength(style.paddingTop(), usedValues.containingBlockWidth), valueForLength(style.paddingBottom(), usedValues.containingBlockWidth) } > }; > } > >-ComputedHorizontalMargin FormattingContext::Geometry::computedHorizontalMargin(const LayoutState& layoutState, const Box& layoutBox) >+ComputedHorizontalMargin FormattingContext::Geometry::computedHorizontalMargin(const Box& layoutBox, UsedHorizontalValues usedValues) > { > auto& style = layoutBox.style(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); >- return { computedValueIfNotAuto(style.marginStart(), containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), containingBlockWidth) }; >+ return { computedValueIfNotAuto(style.marginStart(), usedValues.containingBlockWidth), computedValueIfNotAuto(style.marginEnd(), usedValues.containingBlockWidth) }; > } > > ComputedVerticalMargin FormattingContext::Geometry::computedVerticalMargin(const LayoutState& layoutState, const Box& layoutBox) >diff --git a/Source/WebCore/layout/LayoutUnits.h b/Source/WebCore/layout/LayoutUnits.h >index 83c1b6eb3d4fa1205c32c248ff55b810524f91e2..61bae2492467fc773db7acfb22c69f07b5bb7e50 100644 >--- a/Source/WebCore/layout/LayoutUnits.h >+++ b/Source/WebCore/layout/LayoutUnits.h >@@ -125,6 +125,14 @@ struct VerticalGeometry { > }; > > struct UsedHorizontalValues { >+ explicit UsedHorizontalValues(LayoutUnit containingBlockWidth, Optional<LayoutUnit> width, Optional<UsedHorizontalMargin> margin) >+ : containingBlockWidth(containingBlockWidth) >+ , width(width) >+ , margin(margin) >+ { >+ } >+ >+ LayoutUnit containingBlockWidth; > Optional<LayoutUnit> width; > Optional<UsedHorizontalMargin> margin; > }; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 8aac4925a32400ad813066c66dc6b9d0a0a27091..557d1ea3cbbbef300b8f2aba16c93292a4dd5f6c 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -298,9 +298,10 @@ void BlockFormattingContext::computePositionToAvoidFloats(const FloatingContext& > void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > { > auto& layoutState = this->layoutState(); >+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > >- auto compute = [&](UsedHorizontalValues usedValues) -> WidthAndMargin { >- >+ auto compute = [&](Optional<LayoutUnit> usedWidth) -> WidthAndMargin { >+ auto usedValues = UsedHorizontalValues { containingBlockWidth, usedWidth, { } }; > if (layoutBox.isInFlow()) > return Geometry::inFlowWidthAndMargin(layoutState, layoutBox, usedValues); > >@@ -312,16 +313,15 @@ void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > }; > > auto widthAndMargin = compute({ }); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > > if (auto maxWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMaxWidth(), containingBlockWidth)) { >- auto maxWidthAndMargin = compute({ *maxWidth, { } }); >+ auto maxWidthAndMargin = compute(maxWidth); > if (widthAndMargin.width > maxWidthAndMargin.width) > widthAndMargin = maxWidthAndMargin; > } > > auto minWidth = Geometry::computedValueIfNotAuto(layoutBox.style().logicalMinWidth(), containingBlockWidth).valueOr(0); >- auto minWidthAndMargin = compute({ minWidth, { } }); >+ auto minWidthAndMargin = compute(minWidth); > if (widthAndMargin.width < minWidthAndMargin.width) > widthAndMargin = minWidthAndMargin; > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >index 3442c0ce75d260180f4263774f3d138be078aae4..3d97b03e9f0482a7dae0d2ac432f565fccdd2f34 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >@@ -136,11 +136,11 @@ WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin > > auto& style = layoutBox.style(); > auto* containingBlock = layoutBox.containingBlock(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*containingBlock).contentBoxWidth(); >+ auto containingBlockWidth = usedValues.containingBlockWidth; > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > > auto width = computedValueIfNotAuto(usedValues.width ? Length { usedValues.width.value(), Fixed } : style.logicalWidth(), containingBlockWidth); >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, layoutBox); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutBox, usedValues); > UsedHorizontalMargin usedHorizontalMargin; > auto borderLeft = displayBox.borderLeft(); > auto borderRight = displayBox.borderRight(); >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index 6e4131bc388abbc46e2fb4e2b8caaa6f80749300..0280838710845efebcc6721493f5bbae1b320137 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -97,7 +97,8 @@ void InlineFormattingContext::computeMarginBorderAndPadding(const InlineContaine > > computeBorderAndPadding(inlineContainer); > auto& displayBox = layoutState().displayBoxForLayoutBox(inlineContainer); >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState(), inlineContainer); >+ auto containingBlockWidth = layoutState().displayBoxForLayoutBox(*inlineContainer.containingBlock()).contentBoxWidth(); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(inlineContainer, UsedHorizontalValues { containingBlockWidth, { }, { } }); > displayBox.setHorizontalComputedMargin(computedHorizontalMargin); > displayBox.setHorizontalMargin({ computedHorizontalMargin.start.valueOr(0), computedHorizontalMargin.end.valueOr(0) }); > } >@@ -105,14 +106,16 @@ void InlineFormattingContext::computeMarginBorderAndPadding(const InlineContaine > void InlineFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > { > auto& layoutState = this->layoutState(); >+ auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > > WidthAndMargin widthAndMargin; >+ auto usedValues = UsedHorizontalValues { containingBlockWidth, { }, { } }; > if (layoutBox.isFloatingPositioned()) >- widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox, { }); >+ widthAndMargin = Geometry::floatingWidthAndMargin(layoutState, layoutBox, usedValues); > else if (layoutBox.isInlineBlockBox()) >- widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox); >+ widthAndMargin = Geometry::inlineBlockWidthAndMargin(layoutState, layoutBox, usedValues); > else if (layoutBox.replaced()) >- widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox, { }); >+ widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox, usedValues); > else > ASSERT_NOT_REACHED(); > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >index d4e10c2691f166feff618c933fd2cd325ddf1753..1df58602fe2fc4fd5063a5d5143c19cad4eaab24 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h >@@ -82,7 +82,7 @@ private: > class Geometry : public FormattingContext::Geometry { > public: > static HeightAndMargin inlineBlockHeightAndMargin(const LayoutState&, const Box&); >- static WidthAndMargin inlineBlockWidthAndMargin(LayoutState&, const Box&); >+ static WidthAndMargin inlineBlockWidthAndMargin(LayoutState&, const Box&, UsedHorizontalValues); > }; > > void layoutFormattingContextRoot(const Box&) const; >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp >index 757a921f2046310b625904f1b0de93e342e575c4..e777864ec92c464a2df7fb25ac8dfd57bebe43ea 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp >@@ -38,7 +38,7 @@ > namespace WebCore { > namespace Layout { > >-WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(LayoutState& layoutState, const Box& formattingContextRoot) >+WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(LayoutState& layoutState, const Box& formattingContextRoot, UsedHorizontalValues usedValues) > { > ASSERT(formattingContextRoot.isInFlow()); > >@@ -46,21 +46,19 @@ WidthAndMargin InlineFormattingContext::Geometry::inlineBlockWidthAndMargin(Layo > > // Exactly as inline replaced elements. > if (formattingContextRoot.replaced()) >- return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot, { }); >+ return inlineReplacedWidthAndMargin(layoutState, formattingContextRoot, usedValues); > > // 10.3.9 'Inline-block', non-replaced elements in normal flow > > // If 'width' is 'auto', the used value is the shrink-to-fit width as for floating elements. > // A computed value of 'auto' for 'margin-left' or 'margin-right' becomes a used value of '0'. >- auto& containingBlock = *formattingContextRoot.containingBlock(); >- auto containingBlockWidth = layoutState.displayBoxForLayoutBox(containingBlock).contentBoxWidth(); > // #1 >- auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), containingBlockWidth); >+ auto width = computedValueIfNotAuto(formattingContextRoot.style().logicalWidth(), usedValues.containingBlockWidth); > if (!width) >- width = shrinkToFitWidth(layoutState, formattingContextRoot); >+ width = shrinkToFitWidth(layoutState, formattingContextRoot, usedValues); > > // #2 >- auto computedHorizontalMargin = Geometry::computedHorizontalMargin(layoutState, formattingContextRoot); >+ auto computedHorizontalMargin = Geometry::computedHorizontalMargin(formattingContextRoot, usedValues); > > return WidthAndMargin { *width, { computedHorizontalMargin.start.valueOr(0_lu), computedHorizontalMargin.end.valueOr(0_lu) }, computedHorizontalMargin }; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194424
: 361489