WebKit Bugzilla
Attachment 358299 Details for
Bug 193059
: [LFC][BFC] Use computedValue and usedValue consistently
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193059-20190103182200.patch (text/plain), 57.33 KB, created by
zalan
on 2019-01-03 18:22:06 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2019-01-03 18:22:06 PST
Size:
57.33 KB
patch
obsolete
>Subversion Revision: 239603 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7e30263dfc9d552c13d7dd3b43a729590c1b982d..7e3275a9b0cb4c4e837c668ed7805d55fc83f2bb 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,57 @@ >+2019-01-03 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][BFC] Use computedValue and usedValue consistently >+ https://bugs.webkit.org/show_bug.cgi?id=193059 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ https://www.w3.org/TR/CSS22/cascade.html#value-stages >+ >+ 6.1.2 Computed values >+ Specified values are resolved to computed values during the cascade; for example URIs are made absolute and 'em' and 'ex' units >+ are computed to pixel or absolute lengths. Computing a value never requires the user agent to render the document... >+ >+ 6.1.3 Used values >+ Computed values are processed as far as possible without formatting the document. Some values, however, can only be determined when the document >+ is being laid out. For example, if the width of an element is set to be a certain percentage of its containing block, the width cannot be determined >+ until the width of the containing block has been determined. The used value is the result of taking the computed value and resolving any remaining >+ dependencies into an absolute value. >+ >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const): >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::complicatedCases): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedWidthAndMargin): >+ * layout/LayoutState.cpp: >+ (WebCore::Layout::LayoutState::LayoutState): >+ * layout/LayoutUnits.h: >+ * layout/Verification.cpp: >+ (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const): >+ * layout/blockformatting/BlockFormattingContextGeometry.cpp: >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin): >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin): >+ * layout/displaytree/DisplayBox.cpp: >+ (WebCore::Display::Box::Box): >+ * layout/displaytree/DisplayBox.h: >+ (WebCore::Display::Box::setHasValidHorizontalComputedMargin): >+ (WebCore::Display::Box::setHorizontalComputedMargin): >+ (WebCore::Display::Box::computedMarginStart const): >+ (WebCore::Display::Box::computedMarginEnd const): >+ (WebCore::Display::Box::setHasValidHorizontalNonComputedMargin): Deleted. >+ (WebCore::Display::Box::setHorizontalNonComputedMargin): Deleted. >+ (WebCore::Display::Box::nonComputedMarginStart const): Deleted. >+ (WebCore::Display::Box::nonComputedMarginEnd const): Deleted. >+ * layout/floats/FloatAvoider.h: >+ (WebCore::Layout::FloatAvoider::marginStart const): >+ (WebCore::Layout::FloatAvoider::marginEnd const): >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::InlineFormattingContext::computeWidthAndMargin const): >+ > 2019-01-03 David Kilzer <ddkilzer@apple.com> > > Leak of WebCore::LibWebRTCCertificateGenerator::RTCCertificateGeneratorCallback (48 bytes) in com.apple.WebKit.WebContent running WebKit layout tests >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index 11efc4618b91aa8f61ff0325ca76480e48c95926..5e536a8bae7351c35d3a2fa438539c06745818ad 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -87,10 +87,10 @@ void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox) > } > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); >- displayBox.setLeft(horizontalGeometry.left + horizontalGeometry.widthAndMargin.margin.start); >+ displayBox.setLeft(horizontalGeometry.left + horizontalGeometry.widthAndMargin.usedMargin.start); > displayBox.setContentBoxWidth(horizontalGeometry.widthAndMargin.width); >- displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.margin); >- displayBox.setHorizontalNonComputedMargin(horizontalGeometry.widthAndMargin.nonComputedMargin); >+ displayBox.setHorizontalMargin(horizontalGeometry.widthAndMargin.usedMargin); >+ displayBox.setHorizontalComputedMargin(horizontalGeometry.widthAndMargin.computedMargin); > } > > void FormattingContext::computeOutOfFlowVerticalGeometry(const Box& layoutBox) const >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index c339f9780fc40eff608f92579cc4700d911e4e3e..cf2e377f3d8d862955db0f8375abe5b811ae388e 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -280,8 +280,10 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeomet > auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); > auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); > auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); >- auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >- auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); >+ auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >+ auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); >+ auto usedMarginBefore = computedMarginBefore; >+ auto usedMarginAfter = computedMarginAfter; > auto paddingTop = displayBox.paddingTop().valueOr(0); > auto paddingBottom = displayBox.paddingBottom().valueOr(0); > auto borderTop = displayBox.borderTop(); >@@ -291,72 +293,72 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeomet > top = staticVerticalPositionForOutOfFlowPositioned(layoutState, layoutBox); > > if (top && height && bottom) { >- if (!marginBefore && !marginAfter) { >+ if (!usedMarginBefore && !usedMarginAfter) { > auto marginBeforeAndAfter = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom); >- marginBefore = marginAfter = marginBeforeAndAfter / 2; >- } else if (!marginBefore) >- marginBefore = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom); >+ usedMarginBefore = usedMarginAfter = marginBeforeAndAfter / 2; >+ } else if (!usedMarginBefore) >+ usedMarginBefore = containingBlockHeight - (*top + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > else >- marginAfter = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom); >+ usedMarginAfter = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *bottom); > // Over-constrained? >- auto boxHeight = *top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom; >+ auto boxHeight = *top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom; > if (boxHeight > containingBlockHeight) >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); > } > > if (!top && !height && bottom) { > // #1 > height = contentHeightForFormattingContextRoot(layoutState, layoutBox); >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > } > > if (!top && !bottom && height) { > // #2 > top = staticVerticalPositionForOutOfFlowPositioned(layoutState, layoutBox); >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); > } > > if (!height && !bottom && top) { > // #3 > height = contentHeightForFormattingContextRoot(layoutState, layoutBox); >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); > } > > if (!top && height && bottom) { > // #4 >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter + *bottom); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > } > > if (!height && top && bottom) { > // #5 >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- height = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + paddingBottom + borderBottom + *marginAfter + *bottom); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ height = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > } > > if (!bottom && top && height) { > // #6 >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *marginAfter); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + *height + paddingBottom + borderBottom + *usedMarginAfter); > } > > ASSERT(top); > ASSERT(bottom); > ASSERT(height); >- ASSERT(marginBefore); >- ASSERT(marginAfter); >+ ASSERT(usedMarginBefore); >+ ASSERT(usedMarginAfter); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << *height << "px) margin(" << *marginBefore << "px, " << *marginAfter << "px) layoutBox(" << &layoutBox << ")"); >- return { *top, *bottom, { *height, { { *marginBefore, *marginAfter }, { } } } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << *height << "px) margin(" << *usedMarginBefore << "px, " << *usedMarginAfter << "px) layoutBox(" << &layoutBox << ")"); >+ return { *top, *bottom, { *height, { { *usedMarginBefore, *usedMarginAfter }, { } } } }; > } > > HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth) >@@ -398,10 +400,10 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); > auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); > auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth); >- auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >- auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >- auto nonComputedMarginStart = marginStart.valueOr(0); >- auto nonComputedMarginEnd = marginEnd.valueOr(0); >+ auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >+ auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >+ auto usedMarginStart = computedMarginStart; >+ auto usedMarginEnd = computedMarginEnd; > auto paddingLeft = displayBox.paddingLeft().valueOr(0); > auto paddingRight = displayBox.paddingRight().valueOr(0); > auto borderLeft = displayBox.borderLeft(); >@@ -411,8 +413,8 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. > // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static > // position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. >- marginStart = marginStart.valueOr(0); >- marginEnd = marginEnd.valueOr(0); >+ usedMarginStart = usedMarginStart.valueOr(0); >+ usedMarginEnd = usedMarginEnd.valueOr(0); > > auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutState, layoutBox); > if (isLeftToRightDirection) >@@ -425,84 +427,84 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGe > // solve for 'margin-right' ('margin-left'). If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that value. > // If the values are over-constrained, ignore the value for 'left' (in case the 'direction' property of the containing block is 'rtl') or 'right' > // (in case 'direction' is 'ltr') and solve for that value. >- if (!marginStart && !marginEnd) { >+ if (!usedMarginStart && !usedMarginEnd) { > auto marginStartAndEnd = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); > if (marginStartAndEnd >= 0) >- marginStart = marginEnd = marginStartAndEnd / 2; >+ usedMarginStart = usedMarginEnd = marginStartAndEnd / 2; > else { > if (isLeftToRightDirection) { >- marginStart = 0_lu; >- marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); >+ usedMarginStart = 0_lu; >+ usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); > } else { >- marginEnd = 0_lu; >- marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ usedMarginEnd = 0_lu; >+ usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > } > } >- } else if (!marginStart) { >- marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ } else if (!usedMarginStart) { >+ usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > // Overconstrained? Ignore right (left). >- if (*marginStart < 0) { >+ if (*usedMarginStart < 0) { > if (isLeftToRightDirection) >- marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >+ usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); > else >- marginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > } >- } else if (!marginEnd) { >- marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); >+ } else if (!usedMarginEnd) { >+ usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); > // Overconstrained? Ignore right (left). >- if (*marginEnd < 0) { >+ if (*usedMarginEnd < 0) { > if (isLeftToRightDirection) >- marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); >+ usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); > else >- marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); >+ usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *right); > } > } > } else { > // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' to 0, and pick the one of the following six rules that applies. >- marginStart = marginStart.valueOr(0); >- marginEnd = marginEnd.valueOr(0); >+ usedMarginStart = usedMarginStart.valueOr(0); >+ usedMarginEnd = usedMarginEnd.valueOr(0); > } > >- ASSERT(marginStart); >- ASSERT(marginEnd); >+ ASSERT(usedMarginStart); >+ ASSERT(usedMarginEnd); > > if (!left && !width && right) { > // #1 > width = shrinkToFitWidth(layoutState, layoutBox); >- left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > } else if (!left && !right && width) { > // #2 > auto staticHorizontalPosition = staticHorizontalPositionForOutOfFlowPositioned(layoutState, layoutBox); > if (isLeftToRightDirection) { > left = staticHorizontalPosition; >- right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >+ right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); > } else { > right = staticHorizontalPosition; >- left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > } > } else if (!width && !right && left) { > // #3 > width = shrinkToFitWidth(layoutState, layoutBox); >- right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >+ right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); > } else if (!left && width && right) { > // #4 >- left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd + *right); >+ left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd + *right); > } else if (!width && left && right) { > // #5 >- width = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + paddingRight + borderRight + *marginEnd + *right); >+ width = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + paddingRight + borderRight + *usedMarginEnd + *right); > } else if (!right && left && width) { > // #6 >- right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >+ right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); > } > > ASSERT(left); > ASSERT(right); > ASSERT(width); >- ASSERT(marginStart); >- ASSERT(marginEnd); >+ ASSERT(usedMarginStart); >+ ASSERT(usedMarginEnd); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow non-replaced -> left(" << *left << "px) right(" << *right << "px) width(" << *width << "px) margin(" << *marginStart << "px, " << *marginEnd << "px) layoutBox(" << &layoutBox << ")"); >- return { *left, *right, { *width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow non-replaced -> left(" << *left << "px) right(" << *right << "px) width(" << *width << "px) margin(" << *usedMarginStart << "px, " << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")"); >+ return { *left, *right, { *width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } } }; > } > > VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight) >@@ -528,8 +530,10 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry( > auto top = computedValueIfNotAuto(style.logicalTop(), containingBlockWidth); > auto bottom = computedValueIfNotAuto(style.logicalBottom(), containingBlockWidth); > auto height = inlineReplacedHeightAndMargin(layoutState, layoutBox, usedHeight).height; >- auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >- auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); >+ auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >+ auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); >+ auto usedMarginBefore = computedMarginBefore; >+ auto usedMarginAfter = computedMarginAfter; > auto paddingTop = displayBox.paddingTop().valueOr(0); > auto paddingBottom = displayBox.paddingBottom().valueOr(0); > auto borderTop = displayBox.borderTop(); >@@ -542,36 +546,36 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry( > > if (!bottom) { > // #2 >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >+ usedMarginBefore = usedMarginBefore.valueOr(0); >+ usedMarginAfter = usedMarginAfter.valueOr(0); > } > >- if (!marginBefore && !marginAfter) { >+ if (!usedMarginBefore && !usedMarginAfter) { > // #3 > auto marginBeforeAndAfter = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom); >- marginBefore = marginAfter = marginBeforeAndAfter / 2; >+ usedMarginBefore = usedMarginAfter = marginBeforeAndAfter / 2; > } > > // #4 > if (!top) >- top = containingBlockHeight - (*marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom); >+ top = containingBlockHeight - (*usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > > if (!bottom) >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter); > >- if (!marginBefore) >- marginBefore = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom); >+ if (!usedMarginBefore) >+ usedMarginBefore = containingBlockHeight - (*top + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom); > >- if (!marginAfter) >- marginAfter = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom); >+ if (!usedMarginAfter) >+ usedMarginAfter = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *bottom); > > // #5 >- auto boxHeight = *top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter + *bottom; >+ auto boxHeight = *top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter + *bottom; > if (boxHeight > containingBlockHeight) >- bottom = containingBlockHeight - (*top + *marginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginAfter); >+ bottom = containingBlockHeight - (*top + *usedMarginBefore + borderTop + paddingTop + height + paddingBottom + borderBottom + *usedMarginAfter); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << height << "px) margin(" << *marginBefore << "px, " << *marginAfter << "px) layoutBox(" << &layoutBox << ")"); >- return { *top, *bottom, { height, { { *marginBefore, *marginAfter }, { } } } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << height << "px) margin(" << *usedMarginBefore << "px, " << *usedMarginAfter << "px) layoutBox(" << &layoutBox << ")"); >+ return { *top, *bottom, { height, { { *usedMarginBefore, *usedMarginAfter }, { } } } }; > } > > HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth) >@@ -600,10 +604,10 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeome > > auto left = computedValueIfNotAuto(style.logicalLeft(), containingBlockWidth); > auto right = computedValueIfNotAuto(style.logicalRight(), containingBlockWidth); >- auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >- auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >- auto nonComputedMarginStart = marginStart.valueOr(0); >- auto nonComputedMarginEnd = marginEnd.valueOr(0); >+ auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >+ auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >+ auto usedMarginStart = computedMarginStart; >+ auto usedMarginEnd = computedMarginEnd; > auto width = inlineReplacedWidthAndMargin(layoutState, layoutBox, usedWidth).width; > auto paddingLeft = displayBox.paddingLeft().valueOr(0); > auto paddingRight = displayBox.paddingRight().valueOr(0); >@@ -621,55 +625,55 @@ HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeome > > if (!left || !right) { > // #2 >- marginStart = marginStart.valueOr(0); >- marginEnd = marginEnd.valueOr(0); >+ usedMarginStart = usedMarginStart.valueOr(0); >+ usedMarginEnd = usedMarginEnd.valueOr(0); > } > >- if (!marginStart && !marginEnd) { >+ if (!usedMarginStart && !usedMarginEnd) { > // #3 > auto marginStartAndEnd = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *right); > if (marginStartAndEnd >= 0) >- marginStart = marginEnd = marginStartAndEnd / 2; >+ usedMarginStart = usedMarginEnd = marginStartAndEnd / 2; > else { > if (isLeftToRightDirection) { >- marginStart = 0_lu; >- marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right); >+ usedMarginStart = 0_lu; >+ usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right); > } else { >- marginEnd = 0_lu; >- marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right); >+ usedMarginEnd = 0_lu; >+ usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right); > } > } > } > > // #4 > if (!left) >- left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right); >+ left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right); > > if (!right) >- right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd); >+ right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd); > >- if (!marginStart) >- marginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right); >+ if (!usedMarginStart) >+ usedMarginStart = containingBlockWidth - (*left + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right); > >- if (!marginEnd) >- marginEnd = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right); >+ if (!usedMarginEnd) >+ usedMarginEnd = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *right); > >- auto boxWidth = (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right); >+ auto boxWidth = (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right); > if (boxWidth > containingBlockWidth) { > // #5 Over-constrained? > if (isLeftToRightDirection) >- right = containingBlockWidth - (*left + *marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd); >+ right = containingBlockWidth - (*left + *usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd); > else >- left = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *marginEnd + *right); >+ left = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + width + paddingRight + borderRight + *usedMarginEnd + *right); > } > > ASSERT(left); > ASSERT(right); >- ASSERT(marginStart); >- ASSERT(marginEnd); >+ ASSERT(usedMarginStart); >+ ASSERT(usedMarginEnd); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right(" << *right << "px) width(" << width << "px) margin(" << *marginStart << "px, " << *marginEnd << "px) layoutBox(" << &layoutBox << ")"); >- return { *left, *right, { width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Width][Margin] -> out-of-flow replaced -> left(" << *left << "px) right(" << *right << "px) width(" << width << "px) margin(" << *usedMarginStart << "px, " << *usedMarginEnd << "px) layoutBox(" << &layoutBox << ")"); >+ return { *left, *right, { width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } } }; > } > > HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedHeight) >@@ -693,12 +697,13 @@ HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& > auto containingBlockWidth = containingBlockDisplayBox.contentBoxWidth(); > > auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); >- auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >- auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); >+ auto computedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth); >+ auto computedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth); > > // #1 >- marginBefore = marginBefore.valueOr(0); >- marginAfter = marginAfter.valueOr(0); >+ auto usedMarginBefore = computedMarginBefore.valueOr(0); >+ auto usedMarginAfter = computedMarginAfter.valueOr(0); >+ > // #2 > if (!height) { > ASSERT(isHeightAuto(layoutBox)); >@@ -706,11 +711,9 @@ HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& > } > > ASSERT(height); >- ASSERT(marginBefore); >- ASSERT(marginAfter); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << *marginBefore << "px, " << *marginAfter << "px) -> layoutBox(" << &layoutBox << ")"); >- return HeightAndMargin { *height, { { *marginBefore, *marginAfter }, { } } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << usedMarginBefore << "px, " << usedMarginAfter << "px) -> layoutBox(" << &layoutBox << ")"); >+ return HeightAndMargin { *height, { { usedMarginBefore, usedMarginAfter }, { } } }; > } > > WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, Optional<LayoutUnit> usedWidth) >@@ -869,29 +872,24 @@ WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const L > auto& containingBlockDisplayBox = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()); > auto containingBlockWidth = containingBlockDisplayBox.width(); > >- auto computeMarginEnd = [&]() { >- if (precomputedMarginEnd) >- return precomputedMarginEnd.value(); >- auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >- return marginEnd.valueOr(0_lu); >- }; >- >- auto computeMarginStart = [&]() { >+ auto usedMarginStart = [&] { > if (precomputedMarginStart) > return precomputedMarginStart.value(); > auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); > return marginStart.valueOr(0_lu); > }; > >+ auto usedMarginEnd = [&] { >+ if (precomputedMarginEnd) >+ return precomputedMarginEnd.value(); >+ auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >+ return marginEnd.valueOr(0_lu); >+ }; >+ > auto replaced = layoutBox.replaced(); > ASSERT(replaced); > >- auto marginStart = computeMarginStart(); >- auto marginEnd = computeMarginEnd(); >- auto nonComputedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth).valueOr(0); >- auto nonComputedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth).valueOr(0); > auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth); >- > auto heightIsAuto = isHeightAuto(layoutBox); > auto height = computedHeightValue(layoutState, layoutBox, HeightType::Normal); > >@@ -916,8 +914,10 @@ WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const L > > ASSERT(width); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << marginStart << "px, " << marginEnd << "px) -> layoutBox(" << &layoutBox << ")"); >- return { *width, { marginStart, marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << *width << "px) margin(" << usedMarginStart() << "px, " << usedMarginEnd() << "px) -> layoutBox(" << &layoutBox << ")"); >+ auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >+ auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >+ return { *width, { usedMarginStart(), usedMarginEnd() }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } }; > } > > LayoutSize FormattingContext::Geometry::inFlowPositionedPositionOffset(const LayoutState& layoutState, const Box& layoutBox) >@@ -1037,11 +1037,11 @@ VerticalMargin::ComputedValues FormattingContext::Geometry::computedNonCollapsed > auto& style = layoutBox.style(); > auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > >- auto marginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth).valueOr(0_lu); >- auto marginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth).valueOr(0_lu); >+ auto usedMarginBefore = computedValueIfNotAuto(style.marginBefore(), containingBlockWidth).valueOr(0_lu); >+ auto usedMarginAfter = computedValueIfNotAuto(style.marginAfter(), containingBlockWidth).valueOr(0_lu); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> margin(" << marginBefore << "px, " << marginAfter << "px) -> layoutBox: " << &layoutBox); >- return { marginBefore, marginAfter }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Margin] -> non collapsed vertical -> margin(" << usedMarginBefore << "px, " << usedMarginAfter << "px) -> layoutBox: " << &layoutBox); >+ return { usedMarginBefore, usedMarginAfter }; > } > > } >diff --git a/Source/WebCore/layout/LayoutState.cpp b/Source/WebCore/layout/LayoutState.cpp >index cc1dbc034ee8b97760e6869eb872f9e2cc976e73..fb644e72ff51782921d39f52f27930b3e31243eb 100644 >--- a/Source/WebCore/layout/LayoutState.cpp >+++ b/Source/WebCore/layout/LayoutState.cpp >@@ -54,7 +54,7 @@ LayoutState::LayoutState(const Container& initialContainingBlock, const LayoutSi > > auto& displayBox = displayBoxForLayoutBox(initialContainingBlock); > displayBox.setHorizontalMargin({ }); >- displayBox.setHorizontalNonComputedMargin({ }); >+ displayBox.setHorizontalComputedMargin({ }); > displayBox.setVerticalMargin({ }); > displayBox.setBorder({ }); > displayBox.setPadding({ }); >diff --git a/Source/WebCore/layout/LayoutUnits.h b/Source/WebCore/layout/LayoutUnits.h >index d76b6a38565ef34aff44f9f810ab66e2f9e11422..70ae2bc4112d3a2538fea6c477d06014557bedcd 100644 >--- a/Source/WebCore/layout/LayoutUnits.h >+++ b/Source/WebCore/layout/LayoutUnits.h >@@ -103,9 +103,8 @@ struct Edges { > > struct WidthAndMargin { > LayoutUnit width; >- HorizontalMargin margin; >- // FIXME: Figure out if we really really need this. >- HorizontalMargin nonComputedMargin; >+ HorizontalMargin usedMargin; >+ HorizontalMargin computedMargin; > }; > > struct HeightAndMargin { >diff --git a/Source/WebCore/layout/Verification.cpp b/Source/WebCore/layout/Verification.cpp >index 8eb054743afa0ec5a8f2b834694c4e58719fc2f7..494157a9ee75b75f44c2536222aca82e7d00fc56 100644 >--- a/Source/WebCore/layout/Verification.cpp >+++ b/Source/WebCore/layout/Verification.cpp >@@ -247,8 +247,8 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con > > return Display::Box::Rect { > borderBox.top() - displayBox.nonCollapsedMarginBefore(), >- borderBox.left() - displayBox.nonComputedMarginStart(), >- displayBox.nonComputedMarginStart() + borderBox.width() + displayBox.nonComputedMarginEnd(), >+ borderBox.left() - displayBox.computedMarginStart(), >+ displayBox.computedMarginStart() + borderBox.width() + displayBox.computedMarginEnd(), > displayBox.nonCollapsedMarginBefore() + borderBox.height() + displayBox.nonCollapsedMarginAfter() > }; > }; >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index 429c0a9811a48dbf4551a4be92130f250143a38b..b8bfa9918af527e91ee1a9b9a2c289f385dea502 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -331,9 +331,9 @@ void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > displayBox.setContentBoxWidth(widthAndMargin.width); >- displayBox.moveHorizontally(widthAndMargin.margin.start); >- displayBox.setHorizontalMargin(widthAndMargin.margin); >- displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin); >+ displayBox.moveHorizontally(widthAndMargin.usedMargin.start); >+ displayBox.setHorizontalMargin(widthAndMargin.usedMargin); >+ displayBox.setHorizontalComputedMargin(widthAndMargin.computedMargin); > } > > void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >index ee43872eab6e500be8ac72b15af9010beebf8106..64a77584960c94ce57b6e07d651569186bdf0ba2 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >@@ -141,10 +141,10 @@ WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > > auto width = computedValueIfNotAuto(usedWidth ? Length { usedWidth.value(), Fixed } : style.logicalWidth(), containingBlockWidth); >- auto marginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >- auto marginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >- auto nonComputedMarginStart = marginStart.valueOr(0); >- auto nonComputedMarginEnd = marginEnd.valueOr(0); >+ auto computedMarginStart = computedValueIfNotAuto(style.marginStart(), containingBlockWidth); >+ auto computedMarginEnd = computedValueIfNotAuto(style.marginEnd(), containingBlockWidth); >+ auto usedMarginStart = computedMarginStart; >+ auto usedMarginEnd = computedMarginEnd; > auto borderLeft = displayBox.borderLeft(); > auto borderRight = displayBox.borderRight(); > auto paddingLeft = displayBox.paddingLeft().valueOr(0); >@@ -152,51 +152,51 @@ WidthAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedWidthAndMargin > > // #1 > if (width) { >- auto horizontalSpaceForMargin = containingBlockWidth - (marginStart.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + marginEnd.valueOr(0)); >+ auto horizontalSpaceForMargin = containingBlockWidth - (usedMarginStart.valueOr(0) + borderLeft + paddingLeft + *width + paddingRight + borderRight + usedMarginEnd.valueOr(0)); > if (horizontalSpaceForMargin < 0) { >- marginStart = marginStart.valueOr(0); >- marginEnd = marginEnd.valueOr(0); >+ usedMarginStart = usedMarginStart.valueOr(0); >+ usedMarginEnd = usedMarginEnd.valueOr(0); > } > } > > // #2 >- if (width && marginStart && marginEnd) { >+ if (width && usedMarginStart && usedMarginEnd) { > if (containingBlock->style().isLeftToRightDirection()) >- marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); >+ usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); > else >- marginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >+ usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); > } > > // #3 >- if (!marginStart && width && marginEnd) >- marginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *marginEnd); >- else if (marginStart && !width && marginEnd) >- width = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + paddingRight + borderRight + *marginEnd); >- else if (marginStart && width && !marginEnd) >- marginEnd = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); >+ if (!usedMarginStart && width && usedMarginEnd) >+ usedMarginStart = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight + *usedMarginEnd); >+ else if (usedMarginStart && !width && usedMarginEnd) >+ width = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + paddingRight + borderRight + *usedMarginEnd); >+ else if (usedMarginStart && width && !usedMarginEnd) >+ usedMarginEnd = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + *width + paddingRight + borderRight); > > // #4 > if (!width) { >- marginStart = marginStart.valueOr(0); >- marginEnd = marginEnd.valueOr(0); >- width = containingBlockWidth - (*marginStart + borderLeft + paddingLeft + paddingRight + borderRight + *marginEnd); >+ usedMarginStart = usedMarginStart.valueOr(0); >+ usedMarginEnd = usedMarginEnd.valueOr(0); >+ width = containingBlockWidth - (*usedMarginStart + borderLeft + paddingLeft + paddingRight + borderRight + *usedMarginEnd); > } > > // #5 >- if (!marginStart && !marginEnd) { >+ if (!usedMarginStart && !usedMarginEnd) { > auto horizontalSpaceForMargin = containingBlockWidth - (borderLeft + paddingLeft + *width + paddingRight + borderRight); >- marginStart = marginEnd = horizontalSpaceForMargin / 2; >+ usedMarginStart = usedMarginEnd = horizontalSpaceForMargin / 2; > } > > ASSERT(width); >- ASSERT(marginStart); >- ASSERT(marginEnd); >+ ASSERT(usedMarginStart); >+ ASSERT(usedMarginEnd); > >- return WidthAndMargin { *width, { *marginStart, *marginEnd }, { nonComputedMarginStart, nonComputedMarginEnd } }; >+ return WidthAndMargin { *width, { *usedMarginStart, *usedMarginEnd }, { computedMarginStart.valueOr(0), computedMarginEnd.valueOr(0) } }; > }; > > auto widthAndMargin = compute(); >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.margin.start << "px, " << widthAndMargin.margin.end << "px) -> layoutBox(" << &layoutBox << ")"); >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow non-replaced -> width(" << widthAndMargin.width << "px) margin(" << widthAndMargin.usedMargin.start << "px, " << widthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")"); > return widthAndMargin; > } > >@@ -214,8 +214,8 @@ WidthAndMargin BlockFormattingContext::Geometry::inFlowReplacedWidthAndMargin(co > // #2 > auto nonReplacedWidthAndMargin = inFlowNonReplacedWidthAndMargin(layoutState, layoutBox, width); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << nonReplacedWidthAndMargin.margin.start << "px, " << nonReplacedWidthAndMargin.margin.end << "px) -> layoutBox(" << &layoutBox << ")"); >- return { width, nonReplacedWidthAndMargin.margin, nonReplacedWidthAndMargin.nonComputedMargin }; >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width][Margin] -> inflow replaced -> width(" << width << "px) margin(" << nonReplacedWidthAndMargin.usedMargin.start << "px, " << nonReplacedWidthAndMargin.usedMargin.end << "px) -> layoutBox(" << &layoutBox << ")"); >+ return { width, nonReplacedWidthAndMargin.usedMargin, nonReplacedWidthAndMargin.computedMargin }; > } > > Point BlockFormattingContext::Geometry::staticPosition(const LayoutState& layoutState, const Box& layoutBox) >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.cpp b/Source/WebCore/layout/displaytree/DisplayBox.cpp >index 027b434bbc6d4c2f5510afce9c507839e649e244..3140a55afab4cf12b3f55ffb7b1261f1d796f1ae 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.cpp >+++ b/Source/WebCore/layout/displaytree/DisplayBox.cpp >@@ -59,7 +59,7 @@ Box::Box(const Box& other) > , m_contentHeight(other.m_contentHeight) > , m_horizontalMargin(other.m_horizontalMargin) > , m_verticalMargin(other.m_verticalMargin) >- , m_horizontalNonComputedMargin(other.m_horizontalNonComputedMargin) >+ , m_horizontalComputedMargin(other.m_horizontalComputedMargin) > , m_estimatedMarginBefore(other.m_estimatedMarginBefore) > , m_border(other.m_border) > , m_padding(other.m_padding) >@@ -69,7 +69,7 @@ Box::Box(const Box& other) > , m_hasValidHorizontalMargin(other.m_hasValidHorizontalMargin) > , m_hasValidVerticalMargin(other.m_hasValidVerticalMargin) > , m_hasValidVerticalNonCollapsedMargin(other.m_hasValidVerticalNonCollapsedMargin) >- , m_hasValidHorizontalNonComputedMargin(other.m_hasValidHorizontalNonComputedMargin) >+ , m_hasValidHorizontalComputedMargin(other.m_hasValidHorizontalComputedMargin) > , m_hasValidBorder(other.m_hasValidBorder) > , m_hasValidPadding(other.m_hasValidPadding) > , m_hasValidContentHeight(other.m_hasValidContentHeight) >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.h b/Source/WebCore/layout/displaytree/DisplayBox.h >index 56392f47ee79e30d3f0e21894d3f14bb875d7e89..75ec77187a46ec2ffdf81e5ba71187634a73637e 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.h >+++ b/Source/WebCore/layout/displaytree/DisplayBox.h >@@ -146,8 +146,8 @@ public: > > LayoutUnit nonCollapsedMarginBefore() const; > LayoutUnit nonCollapsedMarginAfter() const; >- LayoutUnit nonComputedMarginStart() const; >- LayoutUnit nonComputedMarginEnd() const; >+ LayoutUnit computedMarginStart() const; >+ LayoutUnit computedMarginEnd() const; > > Optional<LayoutUnit> estimatedMarginBefore() const { return m_estimatedMarginBefore; } > >@@ -193,7 +193,7 @@ private: > > void setHorizontalMargin(Layout::HorizontalMargin); > void setVerticalMargin(Layout::VerticalMargin); >- void setHorizontalNonComputedMargin(Layout::HorizontalMargin); >+ void setHorizontalComputedMargin(Layout::HorizontalMargin); > void setEstimatedMarginBefore(LayoutUnit marginBefore) { m_estimatedMarginBefore = marginBefore; } > > void setBorder(Layout::Edges); >@@ -208,7 +208,7 @@ private: > void setHasValidLeft() { m_hasValidLeft = true; } > void setHasValidVerticalMargin() { m_hasValidVerticalMargin = true; } > void setHasValidVerticalNonCollapsedMargin() { m_hasValidVerticalNonCollapsedMargin = true; } >- void setHasValidHorizontalNonComputedMargin() { m_hasValidHorizontalNonComputedMargin = true; } >+ void setHasValidHorizontalComputedMargin() { m_hasValidHorizontalComputedMargin = true; } > void setHasValidHorizontalMargin() { m_hasValidHorizontalMargin = true; } > > void setHasValidBorder() { m_hasValidBorder = true; } >@@ -226,7 +226,7 @@ private: > > Layout::HorizontalMargin m_horizontalMargin; > Layout::VerticalMargin m_verticalMargin; >- Layout::HorizontalMargin m_horizontalNonComputedMargin; >+ Layout::HorizontalMargin m_horizontalComputedMargin; > Optional<LayoutUnit> m_estimatedMarginBefore; > > Layout::Edges m_border; >@@ -238,7 +238,7 @@ private: > bool m_hasValidHorizontalMargin { false }; > bool m_hasValidVerticalMargin { false }; > bool m_hasValidVerticalNonCollapsedMargin { false }; >- bool m_hasValidHorizontalNonComputedMargin { false }; >+ bool m_hasValidHorizontalComputedMargin { false }; > bool m_hasValidBorder { false }; > bool m_hasValidPadding { false }; > bool m_hasValidContentHeight { false }; >@@ -525,12 +525,12 @@ inline void Box::setVerticalMargin(Layout::VerticalMargin margin) > m_verticalMargin = margin; > } > >-inline void Box::setHorizontalNonComputedMargin(Layout::HorizontalMargin margin) >+inline void Box::setHorizontalComputedMargin(Layout::HorizontalMargin margin) > { > #if !ASSERT_DISABLED >- setHasValidHorizontalNonComputedMargin(); >+ setHasValidHorizontalComputedMargin(); > #endif >- m_horizontalNonComputedMargin = margin; >+ m_horizontalComputedMargin = margin; > } > > inline void Box::setBorder(Layout::Edges border) >@@ -591,16 +591,16 @@ inline LayoutUnit Box::nonCollapsedMarginAfter() const > return m_verticalMargin.nonCollapsedValues().after; > } > >-inline LayoutUnit Box::nonComputedMarginStart() const >+inline LayoutUnit Box::computedMarginStart() const > { >- ASSERT(m_hasValidHorizontalNonComputedMargin); >- return m_horizontalNonComputedMargin.start; >+ ASSERT(m_hasValidHorizontalComputedMargin); >+ return m_horizontalComputedMargin.start; > } > >-inline LayoutUnit Box::nonComputedMarginEnd() const >+inline LayoutUnit Box::computedMarginEnd() const > { >- ASSERT(m_hasValidHorizontalNonComputedMargin); >- return m_horizontalNonComputedMargin.end; >+ ASSERT(m_hasValidHorizontalComputedMargin); >+ return m_horizontalComputedMargin.end; > } > > inline Optional<LayoutUnit> Box::paddingTop() const >diff --git a/Source/WebCore/layout/floats/FloatAvoider.h b/Source/WebCore/layout/floats/FloatAvoider.h >index 7d46690494d4ee6b81c183c28a2de3b4b2fda662..8b5cd884058477131395b4a9e5a0e81a6c1a629c 100644 >--- a/Source/WebCore/layout/floats/FloatAvoider.h >+++ b/Source/WebCore/layout/floats/FloatAvoider.h >@@ -72,8 +72,9 @@ protected: > > LayoutUnit marginBefore() const { return displayBox().marginBefore(); } > LayoutUnit marginAfter() const { return displayBox().marginAfter(); } >- LayoutUnit marginStart() const { return displayBox().nonComputedMarginStart(); } >- LayoutUnit marginEnd() const { return displayBox().nonComputedMarginEnd(); } >+ // Do not use the used values here because they computed as if this box was not a float avoider. >+ LayoutUnit marginStart() const { return displayBox().computedMarginStart(); } >+ LayoutUnit marginEnd() const { return displayBox().computedMarginEnd(); } > > LayoutUnit marginBoxWidth() const { return marginStart() + displayBox().width() + marginEnd(); } > >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index e21b874072756ade164bb8f70605759805069743..5c5f3edb723b3a26c1e760e16c9be000dbd00f75 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -342,8 +342,8 @@ void InlineFormattingContext::computeWidthAndMargin(const Box& layoutBox) const > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > displayBox.setContentBoxWidth(widthAndMargin.width); >- displayBox.setHorizontalMargin(widthAndMargin.margin); >- displayBox.setHorizontalNonComputedMargin(widthAndMargin.nonComputedMargin); >+ displayBox.setHorizontalMargin(widthAndMargin.usedMargin); >+ displayBox.setHorizontalComputedMargin(widthAndMargin.computedMargin); > } > > void InlineFormattingContext::computeHeightAndMargin(const Box& layoutBox) const
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
Flags:
koivisto
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193059
:
358145
|
358258
| 358299