WebKit Bugzilla
Attachment 357297 Details for
Bug 192692
: [LFC][BFC] Introduce VerticalMargin and HorizontalMargin types.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192692-20181213210738.patch (text/plain), 35.65 KB, created by
zalan
on 2018-12-13 21:07:39 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
zalan
Created:
2018-12-13 21:07:39 PST
Size:
35.65 KB
patch
obsolete
>Subversion Revision: 239116 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f1f419e30d93243aa9dc5037767d73922b34dfb6..28dd4e0684cb5dbc2ceb3e67495eb8ef98d7759f 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,59 @@ >+2018-12-13 Zalan Bujtas <zalan@apple.com> >+ >+ [LFC][BFC] Introduce VerticalMargin and HorizontalMargin types. >+ https://bugs.webkit.org/show_bug.cgi?id=192692 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is in preparation for completing block margin collapsing. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * layout/FormattingContext.cpp: >+ (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const): >+ * layout/FormattingContext.h: >+ * layout/FormattingContextGeometry.cpp: >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry): >+ (WebCore::Layout::FormattingContext::Geometry::complicatedCases): >+ (WebCore::Layout::FormattingContext::Geometry::inlineReplacedHeightAndMargin): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue): >+ (WebCore::Layout::FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue): >+ * layout/LayoutState.cpp: >+ (WebCore::Layout::LayoutState::LayoutState): >+ * layout/LayoutUnits.h: >+ (WebCore::Layout::HeightAndMargin::usedMarginValues const): Deleted. >+ * layout/MarginTypes.h: Added. >+ (WebCore::Layout::VerticalMargin::nonCollapsedValues const): >+ (WebCore::Layout::VerticalMargin::collapsedValues const): >+ (WebCore::Layout::VerticalMargin::setCollapsedValues): >+ (WebCore::Layout::VerticalMargin::VerticalMargin): >+ (WebCore::Layout::VerticalMargin::usedValues const): >+ * layout/blockformatting/BlockFormattingContext.cpp: >+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const): >+ * layout/blockformatting/BlockFormattingContextGeometry.cpp: >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): >+ (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin): >+ * layout/blockformatting/BlockFormattingContextQuirks.cpp: >+ (WebCore::Layout::BlockFormattingContext::Quirks::stretchedHeight): >+ * layout/displaytree/DisplayBox.cpp: >+ (WebCore::Display::Box::Box): >+ * layout/displaytree/DisplayBox.h: >+ (WebCore::Display::Box::setHorizontalMargin): >+ (WebCore::Display::Box::setVerticalMargin): >+ (WebCore::Display::Box::setHorizontalNonComputedMargin): >+ (WebCore::Display::Box::verticalMargin const): >+ (WebCore::Display::Box::marginTop const): >+ (WebCore::Display::Box::marginLeft const): >+ (WebCore::Display::Box::marginBottom const): >+ (WebCore::Display::Box::marginRight const): >+ (WebCore::Display::Box::nonCollapsedMarginTop const): >+ (WebCore::Display::Box::nonCollapsedMarginBottom const): >+ (WebCore::Display::Box::setVerticalNonCollapsedMargin): Deleted. >+ * layout/floats/FloatingContext.cpp: >+ (WebCore::Layout::FloatingContext::verticalPositionWithClearance const): >+ * layout/inlineformatting/InlineFormattingContext.cpp: >+ (WebCore::Layout::InlineFormattingContext::computeHeightAndMargin const): >+ > 2018-12-12 Chris Dumez <cdumez@apple.com> > > Unreviewed attempt to fix Windows Cairo build after r239100. >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index dbcb4a7ee2e67cf0c3bfca958d35c8b1e4f60150..c21328ae073537dd7acac7cddc0503b0c3412e2e 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -9106,6 +9106,7 @@ > 6F3E1F612136141700A65A08 /* FloatBox.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; }; > 6F5217C42177F5A6006583BB /* InlineRunProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InlineRunProvider.h; sourceTree = "<group>"; }; > 6F5217C62177F5A6006583BB /* InlineRunProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InlineRunProvider.cpp; sourceTree = "<group>"; }; >+ 6F675D4321C21BD100324F1D /* MarginTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MarginTypes.h; sourceTree = "<group>"; }; > 6F73918C2106CEDD006AF262 /* LayoutUnits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutUnits.h; sourceTree = "<group>"; }; > 6F7CA3C4208C2956002F29AB /* LayoutState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; }; > 6F7CA3C5208C2956002F29AB /* LayoutState.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; }; >@@ -16116,6 +16117,7 @@ > 6F7CA3C5208C2956002F29AB /* LayoutState.cpp */, > 6F7CA3C4208C2956002F29AB /* LayoutState.h */, > 6F73918C2106CEDD006AF262 /* LayoutUnits.h */, >+ 6F675D4321C21BD100324F1D /* MarginTypes.h */, > 11FF02D520BA3C810083F25B /* Verification.cpp */, > ); > path = layout; >@@ -25515,6 +25517,8 @@ > D0D8648E21B70676003C983C /* WebGPUBuffer.idl */, > D0D8648221B61727003C983C /* WebGPUBufferDescriptor.h */, > D0D8648321B61727003C983C /* WebGPUBufferDescriptor.idl */, >+ D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */, >+ D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */, > D001D9AC21B0C81A0023B9BC /* WebGPUColor.h */, > D001D9AD21B0C81A0023B9BC /* WebGPUColor.idl */, > D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */, >@@ -25566,8 +25570,6 @@ > D0EACF882193EE4E000FA75C /* WebGPUTextureView.cpp */, > D0EACF872193EE4E000FA75C /* WebGPUTextureView.h */, > D0EACF892193EE4E000FA75C /* WebGPUTextureView.idl */, >- D063AE4C21C07AB5000E6A35 /* WebGPUBufferUsage.idl */, >- D063AE4E21C0810A000E6A35 /* WebGPUBufferUsage.h */, > ); > path = webgpu; > sourceTree = "<group>"; >diff --git a/Source/WebCore/layout/FormattingContext.cpp b/Source/WebCore/layout/FormattingContext.cpp >index d33d37e5cd71c5dddb4aac05fe25850e6a2fa5cf..81dda8c62395077f7be624d54af7a2679cf58638 100644 >--- a/Source/WebCore/layout/FormattingContext.cpp >+++ b/Source/WebCore/layout/FormattingContext.cpp >@@ -116,12 +116,11 @@ void FormattingContext::computeOutOfFlowVerticalGeometry(const Box& layoutBox) c > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > // Margins of absolutely positioned boxes do not collapse >- ASSERT(!verticalGeometry.heightAndMargin.collapsedMargin); >- auto nonCollapsedVerticalMargins = verticalGeometry.heightAndMargin.usedMarginValues(); >+ ASSERT(!verticalGeometry.heightAndMargin.margin.collapsedValues()); >+ auto nonCollapsedVerticalMargins = verticalGeometry.heightAndMargin.margin.nonCollapsedValues(); > displayBox.setTop(verticalGeometry.top + nonCollapsedVerticalMargins.top); > displayBox.setContentBoxHeight(verticalGeometry.heightAndMargin.height); >- displayBox.setVerticalMargin(nonCollapsedVerticalMargins); >- displayBox.setVerticalNonCollapsedMargin(nonCollapsedVerticalMargins); >+ displayBox.setVerticalMargin(verticalGeometry.heightAndMargin.margin); > } > > void FormattingContext::computeBorderAndPadding(const Box& layoutBox) const >diff --git a/Source/WebCore/layout/FormattingContext.h b/Source/WebCore/layout/FormattingContext.h >index 4f65e56e9189c8dcbe2f04c7fca4c37dba41c278..50b3863ec5337e41181b681bcfd30e2d0f24a33a 100644 >--- a/Source/WebCore/layout/FormattingContext.h >+++ b/Source/WebCore/layout/FormattingContext.h >@@ -96,8 +96,8 @@ protected: > static Edges computedBorder(const LayoutState&, const Box&); > static std::optional<Edges> computedPadding(const LayoutState&, const Box&); > >- static HorizontalEdges computedNonCollapsedHorizontalMarginValue(const LayoutState&, const Box&); >- static VerticalEdges computedNonCollapsedVerticalMarginValue(const LayoutState&, const Box&); >+ static HorizontalMargin computedNonCollapsedHorizontalMarginValue(const LayoutState&, const Box&); >+ static VerticalMargin::ComputedValues computedNonCollapsedVerticalMarginValue(const LayoutState&, const Box&); > > static std::optional<LayoutUnit> computedValueIfNotAuto(const Length& geometryProperty, LayoutUnit containingBlockWidth); > static std::optional<LayoutUnit> fixedValue(const Length& geometryProperty); >diff --git a/Source/WebCore/layout/FormattingContextGeometry.cpp b/Source/WebCore/layout/FormattingContextGeometry.cpp >index c99071ebb85763ae979c187f4e42fc2a89f7abd9..d1fe88e013433f74cb803bd9680bbef5b6bb5140 100644 >--- a/Source/WebCore/layout/FormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/FormattingContextGeometry.cpp >@@ -356,7 +356,7 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowNonReplacedVerticalGeomet > ASSERT(marginBottom); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow non-replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << *height << "px) margin(" << *marginTop << "px, " << *marginBottom << "px) layoutBox(" << &layoutBox << ")"); >- return { *top, *bottom, { *height, { *marginTop, *marginBottom }, { } } }; >+ return { *top, *bottom, { *height, { { *marginTop, *marginBottom }, { } } } }; > } > > HorizontalGeometry FormattingContext::Geometry::outOfFlowNonReplacedHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth) >@@ -571,7 +571,7 @@ VerticalGeometry FormattingContext::Geometry::outOfFlowReplacedVerticalGeometry( > bottom = containingBlockHeight - (*top + *marginTop + borderTop + paddingTop + height + paddingBottom + borderBottom + *marginBottom); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Position][Height][Margin] -> out-of-flow replaced -> top(" << *top << "px) bottom(" << *bottom << "px) height(" << height << "px) margin(" << *marginTop << "px, " << *marginBottom << "px) layoutBox(" << &layoutBox << ")"); >- return { *top, *bottom, { height, { *marginTop, *marginBottom }, { } } }; >+ return { *top, *bottom, { height, { { *marginTop, *marginBottom }, { } } } }; > } > > HorizontalGeometry FormattingContext::Geometry::outOfFlowReplacedHorizontalGeometry(const LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth) >@@ -710,7 +710,7 @@ HeightAndMargin FormattingContext::Geometry::complicatedCases(const LayoutState& > ASSERT(marginBottom); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> floating non-replaced -> height(" << *height << "px) margin(" << *marginTop << "px, " << *marginBottom << "px) -> layoutBox(" << &layoutBox << ")"); >- return HeightAndMargin { *height, { *marginTop, *marginBottom }, { } }; >+ return HeightAndMargin { *height, { { *marginTop, *marginBottom }, { } } }; > } > > WidthAndMargin FormattingContext::Geometry::floatingNonReplacedWidthAndMargin(LayoutState& layoutState, const Box& layoutBox, std::optional<LayoutUnit> usedWidth) >@@ -838,7 +838,7 @@ HeightAndMargin FormattingContext::Geometry::inlineReplacedHeightAndMargin(const > ASSERT(height); > > LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow replaced -> height(" << *height << "px) margin(" << margin.top << "px, " << margin.bottom << "px) -> layoutBox(" << &layoutBox << ")"); >- return { *height, margin, { } }; >+ return { *height, { margin, { } } }; > } > > WidthAndMargin FormattingContext::Geometry::inlineReplacedWidthAndMargin(const LayoutState& layoutState, const Box& layoutBox, >@@ -1020,7 +1020,7 @@ std::optional<Edges> FormattingContext::Geometry::computedPadding(const LayoutSt > }; > } > >-HorizontalEdges FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue(const LayoutState& layoutState, const Box& layoutBox) >+HorizontalMargin FormattingContext::Geometry::computedNonCollapsedHorizontalMarginValue(const LayoutState& layoutState, const Box& layoutBox) > { > auto& style = layoutBox.style(); > auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); >@@ -1032,7 +1032,7 @@ HorizontalEdges FormattingContext::Geometry::computedNonCollapsedHorizontalMargi > return { marginLeft, marginRight }; > } > >-VerticalEdges FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutState& layoutState, const Box& layoutBox) >+VerticalMargin::ComputedValues FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(const LayoutState& layoutState, const Box& layoutBox) > { > auto& style = layoutBox.style(); > auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); >diff --git a/Source/WebCore/layout/LayoutState.cpp b/Source/WebCore/layout/LayoutState.cpp >index 832f4e82ee777407742ec68461a080042e0b776f..cc1dbc034ee8b97760e6869eb872f9e2cc976e73 100644 >--- a/Source/WebCore/layout/LayoutState.cpp >+++ b/Source/WebCore/layout/LayoutState.cpp >@@ -56,7 +56,6 @@ LayoutState::LayoutState(const Container& initialContainingBlock, const LayoutSi > displayBox.setHorizontalMargin({ }); > displayBox.setHorizontalNonComputedMargin({ }); > displayBox.setVerticalMargin({ }); >- displayBox.setVerticalNonCollapsedMargin({ }); > displayBox.setBorder({ }); > displayBox.setPadding({ }); > displayBox.setTopLeft({ }); >diff --git a/Source/WebCore/layout/LayoutUnits.h b/Source/WebCore/layout/LayoutUnits.h >index 3e1d8446f75c81693158b82fc39a63bdeafdb881..d76b6a38565ef34aff44f9f810ab66e2f9e11422 100644 >--- a/Source/WebCore/layout/LayoutUnits.h >+++ b/Source/WebCore/layout/LayoutUnits.h >@@ -30,6 +30,7 @@ > #include "LayoutUnit.h" > #include "LayoutPoint.h" > #include "LayoutRect.h" >+#include "MarginTypes.h" > #include <wtf/Optional.h> > > namespace WebCore { >@@ -102,16 +103,14 @@ struct Edges { > > struct WidthAndMargin { > LayoutUnit width; >- HorizontalEdges margin; >- HorizontalEdges nonComputedMargin; >+ HorizontalMargin margin; >+ // FIXME: Figure out if we really really need this. >+ HorizontalMargin nonComputedMargin; > }; > > struct HeightAndMargin { >- VerticalEdges usedMarginValues() const { return collapsedMargin.value_or(nonCollapsedMargin); } >- > LayoutUnit height; >- VerticalEdges nonCollapsedMargin; >- std::optional<VerticalEdges> collapsedMargin; >+ VerticalMargin margin; > }; > > struct HorizontalGeometry { >diff --git a/Source/WebCore/layout/MarginTypes.h b/Source/WebCore/layout/MarginTypes.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7146e2291607c84068b72179bd553399a91526fd >--- /dev/null >+++ b/Source/WebCore/layout/MarginTypes.h >@@ -0,0 +1,89 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#if ENABLE(LAYOUT_FORMATTING_CONTEXT) >+ >+#include <wtf/Optional.h> >+ >+namespace WebCore { >+namespace Layout { >+ >+struct VerticalMargin { >+ struct ComputedValues { >+ LayoutUnit top; >+ LayoutUnit bottom; >+ }; >+ ComputedValues usedValues() const; >+ ComputedValues nonCollapsedValues() const { return m_nonCollapsed; } >+ >+ struct CollapsedValues { >+ std::optional<LayoutUnit> top; >+ std::optional<LayoutUnit> bottom; >+ }; >+ std::optional<CollapsedValues> collapsedValues() const { return m_collapsed; } >+ void setCollapsedValues(CollapsedValues collapsedValues) { m_collapsed = collapsedValues; } >+ >+ VerticalMargin(ComputedValues nonCollapsed, std::optional<CollapsedValues>); >+ >+ VerticalMargin() = default; >+ ~VerticalMargin() = default; >+private: >+ ComputedValues m_nonCollapsed; >+ std::optional<CollapsedValues> m_collapsed; >+}; >+ >+struct HorizontalMargin { >+ LayoutUnit left; >+ LayoutUnit right; >+}; >+ >+struct PositiveAndNegativeVerticalMargin { >+ struct Values { >+ std::optional<LayoutUnit> positive; >+ std::optional<LayoutUnit> negative; >+ }; >+ Values top; >+ Values bottom; >+}; >+ >+inline VerticalMargin::VerticalMargin(VerticalMargin::ComputedValues nonCollapsed, std::optional<VerticalMargin::CollapsedValues> collapsed) >+ : m_nonCollapsed(nonCollapsed) >+ , m_collapsed(collapsed) >+{ >+} >+ >+inline VerticalMargin::ComputedValues VerticalMargin::usedValues() const >+{ >+ if (!m_collapsed) >+ return m_nonCollapsed; >+ return { m_collapsed->top.value_or(m_nonCollapsed.top), >+ m_collapsed->bottom.value_or(m_nonCollapsed.bottom) }; >+} >+ >+} >+} >+#endif >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >index a12d10f65c8a166105d16a547f9750ae2ccce52e..1e36cba67589f875e6a6787f3e21b9d9c00e900b 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp >@@ -358,7 +358,7 @@ void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const > auto maxHeightAndMargin = compute(maxHeight); > // Used height should remain the same. > ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || maxHeightAndMargin.height == *maxHeight); >- heightAndMargin = { *maxHeight, maxHeightAndMargin.nonCollapsedMargin, maxHeightAndMargin.collapsedMargin }; >+ heightAndMargin = { *maxHeight, maxHeightAndMargin.margin }; > } > } > >@@ -367,18 +367,17 @@ void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const > auto minHeightAndMargin = compute(minHeight); > // Used height should remain the same. > ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || minHeightAndMargin.height == *minHeight); >- heightAndMargin = { *minHeight, minHeightAndMargin.nonCollapsedMargin, minHeightAndMargin.collapsedMargin }; >+ heightAndMargin = { *minHeight, minHeightAndMargin.margin }; > } > } > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > displayBox.setContentBoxHeight(heightAndMargin.height); >- displayBox.setVerticalNonCollapsedMargin(heightAndMargin.nonCollapsedMargin); >- displayBox.setVerticalMargin(heightAndMargin.usedMarginValues()); >+ displayBox.setVerticalMargin(heightAndMargin.margin); > > // If this box has already been moved by the estimated vertical margin, no need to move it again. > if (layoutBox.isFloatingPositioned() || !displayBox.estimatedMarginTop()) >- displayBox.moveVertically(heightAndMargin.usedMarginValues().top); >+ displayBox.moveVertically(heightAndMargin.margin.usedValues().top); > } > > FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints() const >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >index 3b09f30cf1b69c837adbe3b8183802eca86408c4..ebe1a2270b8981f16e9ea13b1ecb6f97ba87a065 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp >@@ -61,24 +61,24 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg > auto containingBlockWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth(); > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > >- VerticalEdges nonCollapsedMargin = { computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(0), >+ auto nonCollapsedMargin = VerticalMargin::ComputedValues { computedValueIfNotAuto(style.marginTop(), containingBlockWidth).value_or(0), > computedValueIfNotAuto(style.marginBottom(), containingBlockWidth).value_or(0) }; >- VerticalEdges collapsedMargin = { MarginCollapse::marginTop(layoutState, layoutBox), MarginCollapse::marginBottom(layoutState, layoutBox) }; >+ auto collapsedMargin = VerticalMargin::CollapsedValues { MarginCollapse::marginTop(layoutState, layoutBox), MarginCollapse::marginBottom(layoutState, layoutBox) }; > auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop().value_or(0); >- >+ > auto height = usedHeight ? usedHeight.value() : computedHeightValue(layoutState, layoutBox, HeightType::Normal); > if (height) >- return { height.value(), nonCollapsedMargin, collapsedMargin }; >+ return { height.value(), { nonCollapsedMargin, collapsedMargin } }; > > if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild()) >- return { 0, nonCollapsedMargin, collapsedMargin }; >+ return { 0, { nonCollapsedMargin, collapsedMargin } }; > > // 1. the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines > if (layoutBox.establishesInlineFormattingContext()) { > // This is temp and will be replaced by the correct display box once inline runs move over to the display tree. > auto& inlineRuns = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox)).inlineRuns(); > auto bottomEdge = inlineRuns.isEmpty() ? LayoutUnit() : inlineRuns.last().logicalBottom(); >- return { bottomEdge, nonCollapsedMargin, collapsedMargin }; >+ return { bottomEdge, { nonCollapsedMargin, collapsedMargin } }; > } > > // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin... >@@ -86,7 +86,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg > ASSERT(lastInFlowChild); > if (!MarginCollapse::isMarginBottomCollapsedWithParent(*lastInFlowChild)) { > auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild); >- return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginBottom() - borderAndPaddingTop, nonCollapsedMargin, collapsedMargin }; >+ return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginBottom() - borderAndPaddingTop, { nonCollapsedMargin, collapsedMargin } }; > } > > // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin >@@ -95,16 +95,16 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMarg > inFlowChild = inFlowChild->previousInFlowSibling(); > if (inFlowChild) { > auto& inFlowDisplayBox = layoutState.displayBoxForLayoutBox(*inFlowChild); >- return { inFlowDisplayBox.top() + inFlowDisplayBox.borderBox().height() - borderAndPaddingTop, nonCollapsedMargin, collapsedMargin }; >+ return { inFlowDisplayBox.top() + inFlowDisplayBox.borderBox().height() - borderAndPaddingTop, { nonCollapsedMargin, collapsedMargin } }; > } > > // 4. zero, otherwise >- return { 0, nonCollapsedMargin, collapsedMargin }; >+ return { 0, { nonCollapsedMargin, collapsedMargin } }; > }; > > auto heightAndMargin = compute(); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.usedMarginValues().top << "px, " << heightAndMargin.usedMarginValues().bottom << "px) -> layoutBox(" << &layoutBox << ")"); >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.usedValues().top << "px, " << heightAndMargin.margin.usedValues().bottom << "px) -> layoutBox(" << &layoutBox << ")"); > return heightAndMargin; > } > >@@ -263,7 +263,7 @@ HeightAndMargin BlockFormattingContext::Geometry::inFlowHeightAndMargin(const La > > heightAndMargin = Quirks::stretchedHeight(layoutState, layoutBox, heightAndMargin); > >- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.usedMarginValues().top << "px, " << heightAndMargin.usedMarginValues().bottom << "px) -> layoutBox(" << &layoutBox << ")"); >+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.usedValues().top << "px, " << heightAndMargin.margin.usedValues().bottom << "px) -> layoutBox(" << &layoutBox << ")"); > return heightAndMargin; > } > >diff --git a/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp b/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp >index b8f018ac1d21fa481d0dd08ecdf4ef887c124d25..a19a60839a8eb5a9091a78702d67a29ff1832fea 100644 >--- a/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp >+++ b/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp >@@ -80,9 +80,9 @@ HeightAndMargin BlockFormattingContext::Quirks::stretchedHeight(const LayoutStat > > LayoutUnit totalVerticalMargins; > if (layoutBox.isDocumentBox()) { >- auto verticalMargins = heightAndMargin.usedMarginValues(); >+ auto verticalMargins = heightAndMargin.margin.usedValues(); > // Document box's margins do not collapse. >- ASSERT(!heightAndMargin.collapsedMargin); >+ ASSERT(!heightAndMargin.margin.collapsedValues()); > totalVerticalMargins = verticalMargins.top + verticalMargins.bottom; > } else if (layoutBox.isBodyBox()) { > // Here is the quirky part for body box: >@@ -93,7 +93,7 @@ HeightAndMargin BlockFormattingContext::Quirks::stretchedHeight(const LayoutStat > > // This quirk happens when the body height is 0 which means its vertical margins collapse through (top and bottom margins are adjoining). > // However now that we stretch the body they don't collapse through anymore, so we need to use the non-collapsed values instead. >- auto bodyBoxVerticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.nonCollapsedMargin; >+ auto bodyBoxVerticalMargins = heightAndMargin.height ? heightAndMargin.margin.usedValues() : heightAndMargin.margin.nonCollapsedValues(); > totalVerticalMargins = bodyBoxVerticalMargins.top + bodyBoxVerticalMargins.bottom; > } > >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.cpp b/Source/WebCore/layout/displaytree/DisplayBox.cpp >index 1534793b78bba3ed23b60a5d82bac60acbd1bd03..65bc0f070ae7056ae655f1992a3abdfc9f3d29b2 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.cpp >+++ b/Source/WebCore/layout/displaytree/DisplayBox.cpp >@@ -57,8 +57,8 @@ Box::Box(const Box& other) > , m_topLeft(other.m_topLeft) > , m_contentWidth(other.m_contentWidth) > , m_contentHeight(other.m_contentHeight) >- , m_margin(other.m_margin) >- , m_verticalNonCollapsedMargin(other.m_verticalNonCollapsedMargin) >+ , m_horizontalMargin(other.m_horizontalMargin) >+ , m_verticalMargin(other.m_verticalMargin) > , m_horizontalNonComputedMargin(other.m_horizontalNonComputedMargin) > , m_estimatedMarginTop(other.m_estimatedMarginTop) > , m_border(other.m_border) >diff --git a/Source/WebCore/layout/displaytree/DisplayBox.h b/Source/WebCore/layout/displaytree/DisplayBox.h >index 62a3992cada3a017958c40c838e5a0542eb3b402..e49de3c36ae8522beae40e70dfd94c3bbab53d42 100644 >--- a/Source/WebCore/layout/displaytree/DisplayBox.h >+++ b/Source/WebCore/layout/displaytree/DisplayBox.h >@@ -138,6 +138,7 @@ public: > Rect rect() const { return { top(), left(), width(), height() }; } > Rect rectWithMargin() const { return { top() - marginTop(), left() - marginLeft(), marginLeft() + width() + marginRight(), marginTop() + height() + marginBottom() }; } > >+ Layout::VerticalMargin verticalMargin() const; > LayoutUnit marginTop() const; > LayoutUnit marginLeft() const; > LayoutUnit marginBottom() const; >@@ -190,10 +191,9 @@ private: > void setContentBoxHeight(LayoutUnit); > void setContentBoxWidth(LayoutUnit); > >- void setHorizontalMargin(Layout::HorizontalEdges); >- void setVerticalMargin(Layout::VerticalEdges); >- void setVerticalNonCollapsedMargin(Layout::VerticalEdges); >- void setHorizontalNonComputedMargin(Layout::HorizontalEdges); >+ void setHorizontalMargin(Layout::HorizontalMargin); >+ void setVerticalMargin(Layout::VerticalMargin); >+ void setHorizontalNonComputedMargin(Layout::HorizontalMargin); > void setEstimatedMarginTop(LayoutUnit marginTop) { m_estimatedMarginTop = marginTop; } > > void setBorder(Layout::Edges); >@@ -224,9 +224,9 @@ private: > LayoutUnit m_contentWidth; > LayoutUnit m_contentHeight; > >- Layout::Edges m_margin; >- Layout::VerticalEdges m_verticalNonCollapsedMargin; >- Layout::HorizontalEdges m_horizontalNonComputedMargin; >+ Layout::HorizontalMargin m_horizontalMargin; >+ Layout::VerticalMargin m_verticalMargin; >+ Layout::HorizontalMargin m_horizontalNonComputedMargin; > std::optional<LayoutUnit> m_estimatedMarginTop; > > Layout::Edges m_border; >@@ -507,32 +507,25 @@ inline LayoutUnit Box::contentBoxWidth() const > return m_contentWidth; > } > >-inline void Box::setHorizontalMargin(Layout::HorizontalEdges margin) >+inline void Box::setHorizontalMargin(Layout::HorizontalMargin margin) > { > #if !ASSERT_DISABLED > setHasValidHorizontalMargin(); > #endif >- m_margin.horizontal = margin; >+ m_horizontalMargin = margin; > } > >-inline void Box::setVerticalMargin(Layout::VerticalEdges margin) >+inline void Box::setVerticalMargin(Layout::VerticalMargin margin) > { > #if !ASSERT_DISABLED > setHasValidVerticalMargin(); >-#endif >- ASSERT(!m_estimatedMarginTop || *m_estimatedMarginTop == margin.top); >- m_margin.vertical = margin; >-} >- >-inline void Box::setVerticalNonCollapsedMargin(Layout::VerticalEdges margin) >-{ >-#if !ASSERT_DISABLED > setHasValidVerticalNonCollapsedMargin(); > #endif >- m_verticalNonCollapsedMargin = margin; >+ ASSERT(!m_estimatedMarginTop || *m_estimatedMarginTop == margin.usedValues().top); >+ m_verticalMargin = margin; > } > >-inline void Box::setHorizontalNonComputedMargin(Layout::HorizontalEdges margin) >+inline void Box::setHorizontalNonComputedMargin(Layout::HorizontalMargin margin) > { > #if !ASSERT_DISABLED > setHasValidHorizontalNonComputedMargin(); >@@ -556,40 +549,46 @@ inline void Box::setPadding(std::optional<Layout::Edges> padding) > m_padding = padding; > } > >+inline Layout::VerticalMargin Box::verticalMargin() const >+{ >+ ASSERT(m_hasValidVerticalMargin); >+ return m_verticalMargin; >+} >+ > inline LayoutUnit Box::marginTop() const > { > ASSERT(m_hasValidVerticalMargin); >- return m_margin.vertical.top; >+ return m_verticalMargin.usedValues().top; > } > > inline LayoutUnit Box::marginLeft() const > { > ASSERT(m_hasValidHorizontalMargin); >- return m_margin.horizontal.left; >+ return m_horizontalMargin.left; > } > > inline LayoutUnit Box::marginBottom() const > { > ASSERT(m_hasValidVerticalMargin); >- return m_margin.vertical.bottom; >+ return m_verticalMargin.usedValues().bottom; > } > > inline LayoutUnit Box::marginRight() const > { > ASSERT(m_hasValidHorizontalMargin); >- return m_margin.horizontal.right; >+ return m_horizontalMargin.right; > } > > inline LayoutUnit Box::nonCollapsedMarginTop() const > { > ASSERT(m_hasValidVerticalNonCollapsedMargin); >- return m_verticalNonCollapsedMargin.top; >+ return m_verticalMargin.nonCollapsedValues().top; > } > > inline LayoutUnit Box::nonCollapsedMarginBottom() const > { > ASSERT(m_hasValidVerticalNonCollapsedMargin); >- return m_verticalNonCollapsedMargin.bottom; >+ return m_verticalMargin.nonCollapsedValues().bottom; > } > > inline LayoutUnit Box::nonComputedMarginLeft() const >diff --git a/Source/WebCore/layout/floats/FloatingContext.cpp b/Source/WebCore/layout/floats/FloatingContext.cpp >index 814234230eadce03052965f0358151c9ea60b886..2753194038a986a07ceb69d0a2d3a501d67d06b8 100644 >--- a/Source/WebCore/layout/floats/FloatingContext.cpp >+++ b/Source/WebCore/layout/floats/FloatingContext.cpp >@@ -192,8 +192,17 @@ std::optional<Position> FloatingContext::verticalPositionWithClearance(const Box > auto collapsedMargin = displayBox.marginTop(); > > // Reset previous bottom and current top margins to non-collapsing. >- previousInFlowDisplayBox.setVerticalMargin({ previousInFlowDisplayBox.marginTop(), previousInFlowDisplayBox.nonCollapsedMarginBottom() }); >- displayBox.setVerticalMargin({ displayBox.nonCollapsedMarginTop(), displayBox.marginBottom() }); >+ auto previousVerticalMargin = previousInFlowDisplayBox.verticalMargin(); >+ if (previousVerticalMargin.collapsedValues() && previousVerticalMargin.collapsedValues()->bottom) { >+ previousVerticalMargin.setCollapsedValues({ previousVerticalMargin.collapsedValues()->top, { } }); >+ previousInFlowDisplayBox.setVerticalMargin(previousVerticalMargin); >+ } >+ // FIXME: check if collapsing through has anything to do with this. >+ auto verticalMargin = displayBox.verticalMargin(); >+ if (verticalMargin.collapsedValues() && verticalMargin.collapsedValues()->top) { >+ verticalMargin.setCollapsedValues({ { }, verticalMargin.collapsedValues()->bottom }); >+ displayBox.setVerticalMargin(verticalMargin); >+ } > > auto nonCollapsedMargin = previousInFlowDisplayBox.marginBottom() + displayBox.marginTop(); > auto marginOffset = nonCollapsedMargin - collapsedMargin; >diff --git a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >index f87252720307423c9947193887e93967253831be..c7ad9c5c9d11705feb5778ad40863d6384c726e7 100644 >--- a/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >+++ b/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp >@@ -362,8 +362,7 @@ void InlineFormattingContext::computeHeightAndMargin(const Box& layoutBox) const > > auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); > displayBox.setContentBoxHeight(heightAndMargin.height); >- displayBox.setVerticalNonCollapsedMargin(heightAndMargin.nonCollapsedMargin); >- displayBox.setVerticalMargin(heightAndMargin.usedMarginValues()); >+ displayBox.setVerticalMargin(heightAndMargin.margin); > } > > void InlineFormattingContext::layoutFormattingContextRoot(const Box& root) 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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192692
:
357297
|
357300