Title: [278292] trunk/Source/WebCore
Revision
278292
Author
za...@apple.com
Date
2021-05-31 19:41:01 -0700 (Mon, 31 May 2021)

Log Message

[LFC] Tighten the constraint classes (ConstraintsForInFlowContent/ConstraintsForOutOfFlowContent)
https://bugs.webkit.org/show_bug.cgi?id=226435

Reviewed by Antti Koivisto.

While logical height should always be available for out of flow content by design,
the base inflow layout can't necessarily provide it. This height constraint is not even required/used in most of the layout systems,
so let's move it to the derived class(es).

* layout/LayoutContext.cpp:
(WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
* layout/LayoutUnits.h:
* layout/formattingContexts/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry):
* layout/formattingContexts/FormattingGeometry.cpp:
(WebCore::Layout::FormattingGeometry::outOfFlowNonReplacedVerticalGeometry const):
(WebCore::Layout::FormattingGeometry::outOfFlowReplacedVerticalGeometry const):
(WebCore::Layout::FormattingGeometry::inlineReplacedContentHeightAndMargin const):
(WebCore::Layout::FormattingGeometry::inlineReplacedContentWidthAndMargin const):
(WebCore::Layout::FormattingGeometry::constraintsForInFlowContent const):
* layout/formattingContexts/block/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
(WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition):
(WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForBoxAndAncestors):
(WebCore::Layout::BlockFormattingContext::verticalPositionWithMargin const):
* layout/formattingContexts/block/BlockFormattingContext.h:
* layout/formattingContexts/block/BlockFormattingGeometry.cpp:
(WebCore::Layout::BlockFormattingGeometry::staticVerticalPosition const):
(WebCore::Layout::BlockFormattingGeometry::staticPosition const): Deleted.
* layout/formattingContexts/block/BlockFormattingGeometry.h:
* layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp:
(WebCore::Layout::TableWrapperBlockFormattingContext::layoutTableBox):
(WebCore::Layout::TableWrapperBlockFormattingContext::computeHeightAndMarginForTableBox):
* layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::Layout::FlexFormattingContext::sizeAndPlaceFlexItems):
* layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::lineLayout):
* layout/formattingContexts/table/TableFormattingContext.cpp:
(WebCore::Layout::TableFormattingContext::layoutInFlowContent):
(WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
(WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
(WebCore::Layout::TableFormattingContext::layoutCell):
* layout/formattingContexts/table/TableFormattingContext.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::layout):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278291 => 278292)


--- trunk/Source/WebCore/ChangeLog	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/ChangeLog	2021-06-01 02:41:01 UTC (rev 278292)
@@ -1,3 +1,51 @@
+2021-05-31  Alan Bujtas  <za...@apple.com>
+
+        [LFC] Tighten the constraint classes (ConstraintsForInFlowContent/ConstraintsForOutOfFlowContent)
+        https://bugs.webkit.org/show_bug.cgi?id=226435
+
+        Reviewed by Antti Koivisto.
+
+        While logical height should always be available for out of flow content by design,
+        the base inflow layout can't necessarily provide it. This height constraint is not even required/used in most of the layout systems,
+        so let's move it to the derived class(es).
+
+        * layout/LayoutContext.cpp:
+        (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
+        * layout/LayoutUnits.h:
+        * layout/formattingContexts/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry):
+        * layout/formattingContexts/FormattingGeometry.cpp:
+        (WebCore::Layout::FormattingGeometry::outOfFlowNonReplacedVerticalGeometry const):
+        (WebCore::Layout::FormattingGeometry::outOfFlowReplacedVerticalGeometry const):
+        (WebCore::Layout::FormattingGeometry::inlineReplacedContentHeightAndMargin const):
+        (WebCore::Layout::FormattingGeometry::inlineReplacedContentWidthAndMargin const):
+        (WebCore::Layout::FormattingGeometry::constraintsForInFlowContent const):
+        * layout/formattingContexts/block/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+        (WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition):
+        (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForBoxAndAncestors):
+        (WebCore::Layout::BlockFormattingContext::verticalPositionWithMargin const):
+        * layout/formattingContexts/block/BlockFormattingContext.h:
+        * layout/formattingContexts/block/BlockFormattingGeometry.cpp:
+        (WebCore::Layout::BlockFormattingGeometry::staticVerticalPosition const):
+        (WebCore::Layout::BlockFormattingGeometry::staticPosition const): Deleted.
+        * layout/formattingContexts/block/BlockFormattingGeometry.h:
+        * layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+        (WebCore::Layout::TableWrapperBlockFormattingContext::layoutTableBox):
+        (WebCore::Layout::TableWrapperBlockFormattingContext::computeHeightAndMarginForTableBox):
+        * layout/formattingContexts/flex/FlexFormattingContext.cpp:
+        (WebCore::Layout::FlexFormattingContext::sizeAndPlaceFlexItems):
+        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::lineLayout):
+        * layout/formattingContexts/table/TableFormattingContext.cpp:
+        (WebCore::Layout::TableFormattingContext::layoutInFlowContent):
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
+        (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
+        (WebCore::Layout::TableFormattingContext::layoutCell):
+        * layout/formattingContexts/table/TableFormattingContext.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::layout):
+
 2021-05-31  Aakash Jain  <aakash_j...@apple.com>
 
         REGRESSION(r278261): Broke windows build - follow-up fix

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (278291 => 278292)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-06-01 02:41:01 UTC (rev 278292)
@@ -2134,6 +2134,8 @@
 		6F15522126476B5C00E353C6 /* TableWrapperBlockFormattingQuirks.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F15522026476B5B00E353C6 /* TableWrapperBlockFormattingQuirks.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F17264F2470C60B00518C96 /* TableWrapperBlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A52665888C002E9D28 /* FormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26BB6B23343E5B002F2BEA /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		6F26EB48234004A5006906E2 /* InlineLineBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26EB46234004A5006906E2 /* InlineLineBuilder.h */; };
 		6F360E5023999421001512A7 /* InlineSoftLineBreakItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F360E4E23999420001512A7 /* InlineSoftLineBreakItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9993,6 +9995,8 @@
 		6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableWrapperBlockFormattingContext.h; sourceTree = "<group>"; };
 		6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextItem.cpp; sourceTree = "<group>"; };
 		6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineTextItem.h; sourceTree = "<group>"; };
+		6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableFormattingConstraints.h; sourceTree = "<group>"; };
+		6F1E83A52665888C002E9D28 /* FormattingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormattingConstraints.h; sourceTree = "<group>"; };
 		6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
 		6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
 		6F25B200220A85AB0000011B /* InlineLineBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineLineBuilder.cpp; sourceTree = "<group>"; };
@@ -22733,6 +22737,7 @@
 				6FB7D2D5250FD7B5000207AA /* flex */,
 				115CFA9A208BC140001E6991 /* inline */,
 				6FC5CA9122E3593300B13E11 /* table */,
+				6F1E83A52665888C002E9D28 /* FormattingConstraints.h */,
 				115CFA69208AF7D0001E6991 /* FormattingContext.cpp */,
 				115CFA68208AF7D0001E6991 /* FormattingContext.h */,
 				6FBB860520B464B600DAD938 /* FormattingGeometry.cpp */,
@@ -22770,6 +22775,7 @@
 		6FC5CA9122E3593300B13E11 /* table */ = {
 			isa = PBXGroup;
 			children = (
+				6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */,
 				6FC5CA9422E3599400B13E11 /* TableFormattingContext.cpp */,
 				6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */,
 				11D19C2E23159BAE008F24D3 /* TableFormattingGeometry.cpp */,
@@ -32728,6 +32734,7 @@
 				4A0DA2FF129B241900AB61E1 /* FormAssociatedElement.h in Headers */,
 				D05CED2A0A40BB2C00C5AF38 /* FormatBlockCommand.h in Headers */,
 				7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */,
+				6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */,
 				115CFA6A208AF7D0001E6991 /* FormattingContext.h in Headers */,
 				475C89A42650AC3C00F3B456 /* FormattingGeometry.h in Headers */,
 				6F56B44726479E6200AAE257 /* FormattingQuirks.h in Headers */,
@@ -35648,6 +35655,7 @@
 				E3C04138254CB30D0021D0E6 /* SystemSoundDelegate.h in Headers */,
 				E3C0412F254CA29B0021D0E6 /* SystemSoundManager.h in Headers */,
 				5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
+				6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */,
 				47FA97002650982B00841416 /* TableFormattingGeometry.h in Headers */,
 				6F49C3E726479B3C0051953D /* TableFormattingQuirks.h in Headers */,
 				A8CFF0510A154F09000A4234 /* TableLayout.h in Headers */,

Modified: trunk/Source/WebCore/layout/LayoutContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/LayoutContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/LayoutContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -100,7 +100,7 @@
     auto& boxGeometry = layoutState().geometryForBox(formattingContextRoot);
 
     if (formattingContextRoot.hasInFlowOrFloatingChild()) {
-        auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), { } } };
+        auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() };
         formattingContext->layoutInFlowContent(invalidationState, constraintsForInFlowContent);
     }
 

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (278291 => 278292)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -157,41 +157,6 @@
     ContentHeightAndMargin contentHeightAndMargin;
 };
 
-struct HorizontalConstraints {
-    LayoutUnit logicalRight() const { return logicalLeft + logicalWidth; }
-
-    LayoutUnit logicalLeft;
-    LayoutUnit logicalWidth;
-};
-
-struct VerticalConstraints {
-    LayoutUnit logicalTop;
-    std::optional<LayoutUnit> logicalHeight;
-};
-
-struct ConstraintsForInFlowContent {
-    HorizontalConstraints horizontal;
-    VerticalConstraints vertical;
-};
-
-struct ConstraintsForOutOfFlowContent {
-    HorizontalConstraints horizontal;
-    VerticalConstraints vertical;
-    // Borders and padding are resolved against the containing block's content box as if the box was an in-flow box.
-    LayoutUnit borderAndPaddingConstraints;
-};
-
-struct IntrinsicWidthConstraints {
-    void expand(LayoutUnit horizontalValue);
-    IntrinsicWidthConstraints& operator+=(const IntrinsicWidthConstraints&);
-    IntrinsicWidthConstraints& operator+=(LayoutUnit);
-    IntrinsicWidthConstraints& operator-=(const IntrinsicWidthConstraints&);
-    IntrinsicWidthConstraints& operator-=(LayoutUnit);
-
-    LayoutUnit minimum;
-    LayoutUnit maximum;
-};
-
 struct OverriddenHorizontalValues {
     std::optional<LayoutUnit> width;
     std::optional<UsedHorizontalMargin> margin;
@@ -231,38 +196,6 @@
 #endif
 }
 
-inline void IntrinsicWidthConstraints::expand(LayoutUnit horizontalValue)
-{
-    minimum += horizontalValue;
-    maximum += horizontalValue;
-}
-
-inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(const IntrinsicWidthConstraints& other)
-{
-    minimum += other.minimum;
-    maximum += other.maximum;
-    return *this;
-}
-
-inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(LayoutUnit value)
-{
-    expand(value);
-    return *this;
-}
-
-inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(const IntrinsicWidthConstraints& other)
-{
-    minimum -= other.minimum;
-    maximum -= other.maximum;
-    return *this;
-}
-
-inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(LayoutUnit value)
-{
-    expand(-value);
-    return *this;
-}
-
 struct SlotPosition {
     SlotPosition() = default;
     SlotPosition(size_t column, size_t row);

Added: trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h (0 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2021 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 "LayoutUnit.h"
+#include <wtf/OptionSet.h>
+
+namespace WebCore {
+namespace Layout {
+
+struct HorizontalConstraints {
+    LayoutUnit logicalRight() const { return logicalLeft + logicalWidth; }
+
+    LayoutUnit logicalLeft;
+    LayoutUnit logicalWidth;
+};
+
+struct VerticalConstraints {
+    LayoutUnit logicalTop;
+    LayoutUnit logicalHeight;
+};
+
+struct ConstraintsForInFlowContent {
+    ConstraintsForInFlowContent(HorizontalConstraints, LayoutUnit logicalTop);
+
+    HorizontalConstraints horizontal() const { return m_horizontal; }
+    LayoutUnit logicalTop() const { return m_logicalTop; }
+
+    enum BaseTypeFlag : uint8_t {
+        GenericContent = 1 << 0,
+        TableContent   = 1 << 1
+    };
+    bool isConstraintsForTableContent() const { return baseTypeFlags().contains(TableContent); }
+
+protected:
+    ConstraintsForInFlowContent(HorizontalConstraints, LayoutUnit logicalTop, OptionSet<BaseTypeFlag>);
+
+private:
+    OptionSet<BaseTypeFlag> baseTypeFlags() const { return OptionSet<BaseTypeFlag>::fromRaw(m_baseTypeFlags); }
+
+    unsigned m_baseTypeFlags : 2; // OptionSet<BaseTypeFlag>
+    HorizontalConstraints m_horizontal;
+    LayoutUnit m_logicalTop;
+};
+
+struct ConstraintsForOutOfFlowContent {
+    HorizontalConstraints horizontal;
+    VerticalConstraints vertical;
+    // Borders and padding are resolved against the containing block's content box as if the box was an in-flow box.
+    LayoutUnit borderAndPaddingConstraints;
+};
+
+inline ConstraintsForInFlowContent::ConstraintsForInFlowContent(HorizontalConstraints horizontal, LayoutUnit logicalTop, OptionSet<BaseTypeFlag> baseTypeFlags)
+    : m_baseTypeFlags(baseTypeFlags.toRaw())
+    , m_horizontal(horizontal)
+    , m_logicalTop(logicalTop)
+{
+}
+
+inline ConstraintsForInFlowContent::ConstraintsForInFlowContent(HorizontalConstraints horizontal, LayoutUnit logicalTop)
+    : ConstraintsForInFlowContent(horizontal, logicalTop, GenericContent)
+{
+}
+
+struct IntrinsicWidthConstraints {
+    void expand(LayoutUnit horizontalValue);
+    IntrinsicWidthConstraints& operator+=(const IntrinsicWidthConstraints&);
+    IntrinsicWidthConstraints& operator+=(LayoutUnit);
+    IntrinsicWidthConstraints& operator-=(const IntrinsicWidthConstraints&);
+    IntrinsicWidthConstraints& operator-=(LayoutUnit);
+
+    LayoutUnit minimum;
+    LayoutUnit maximum;
+};
+
+inline void IntrinsicWidthConstraints::expand(LayoutUnit horizontalValue)
+{
+    minimum += horizontalValue;
+    maximum += horizontalValue;
+}
+
+inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(const IntrinsicWidthConstraints& other)
+{
+    minimum += other.minimum;
+    maximum += other.maximum;
+    return *this;
+}
+
+inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(LayoutUnit value)
+{
+    expand(value);
+    return *this;
+}
+
+inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(const IntrinsicWidthConstraints& other)
+{
+    minimum -= other.minimum;
+    maximum -= other.maximum;
+    return *this;
+}
+
+inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(LayoutUnit value)
+{
+    expand(-value);
+    return *this;
+}
+
+}
+}
+
+#define SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONSTRAINTS(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Layout::ToValueTypeName) \
+    static bool isType(const WebCore::Layout::ConstraintsForInFlowContent& constraints) { return constraints.predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
+#endif

Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -106,7 +106,7 @@
         return formattingGeometry().outOfFlowVerticalGeometry(layoutBox, constraints.horizontal, constraints.vertical, { usedHeight });
     };
 
-    auto containingBlockHeight = *constraints.vertical.logicalHeight;
+    auto containingBlockHeight = constraints.vertical.logicalHeight;
     auto verticalGeometry = compute({ });
     if (auto maxHeight = formattingGeometry().computedMaxHeight(layoutBox, containingBlockHeight)) {
         auto maxVerticalGeometry = compute(maxHeight);

Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -27,6 +27,7 @@
 
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
+#include "FormattingConstraints.h"
 #include "LayoutContainerBox.h"
 #include "LayoutUnit.h"
 #include "LayoutUnits.h"
@@ -42,9 +43,13 @@
 
 class BoxGeometry;
 class ContainerBox;
+struct ConstraintsForInFlowContent;
+struct ConstraintsForOutOfFlowContent;
+struct HorizontalConstraints;
 class FormattingGeometry;
 class FormattingState;
 class FormattingQuirks;
+struct IntrinsicWidthConstraints;
 class InvalidationState;
 class LayoutState;
 

Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -324,7 +324,6 @@
 VerticalGeometry FormattingGeometry::outOfFlowNonReplacedVerticalGeometry(const ContainerBox& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverriddenVerticalValues& overriddenVerticalValues) const
 {
     ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
-    ASSERT(verticalConstraints.logicalHeight);
 
     // 10.6.4 Absolutely positioned, non-replaced elements
     //
@@ -353,7 +352,7 @@
     auto& formattingContext = this->formattingContext();
     auto& style = layoutBox.style();
     auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
-    auto containingBlockHeight = *verticalConstraints.logicalHeight;
+    auto containingBlockHeight = verticalConstraints.logicalHeight;
     auto containingBlockWidth = horizontalConstraints.logicalWidth;
 
     auto top = computedValue(style.logicalTop(), containingBlockWidth);
@@ -586,7 +585,6 @@
 VerticalGeometry FormattingGeometry::outOfFlowReplacedVerticalGeometry(const ReplacedBox& replacedBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints, const OverriddenVerticalValues& overriddenVerticalValues) const
 {
     ASSERT(replacedBox.isOutOfFlowPositioned());
-    ASSERT(verticalConstraints.logicalHeight);
 
     // 10.6.5 Absolutely positioned, replaced elements
     //
@@ -601,7 +599,7 @@
     auto& formattingContext = this->formattingContext();
     auto& style = replacedBox.style();
     auto& boxGeometry = formattingContext.geometryForBox(replacedBox);
-    auto containingBlockHeight = *verticalConstraints.logicalHeight;
+    auto containingBlockHeight = verticalConstraints.logicalHeight;
     auto containingBlockWidth = horizontalConstraints.logicalWidth;
 
     auto top = computedValue(style.logicalTop(), containingBlockWidth);
@@ -921,7 +919,7 @@
     auto usedVerticalMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) };
     auto& style = replacedBox.style();
 
-    auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : std::nullopt);
+    auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(replacedBox, verticalConstraints ? std::optional<LayoutUnit>(verticalConstraints->logicalHeight) : std::nullopt);
     auto heightIsAuto = !overriddenVerticalValues.height && isHeightAuto(replacedBox);
     auto widthIsAuto = style.logicalWidth().isAuto();
 
@@ -983,7 +981,7 @@
 
     auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(replacedBox, horizontalConstraints.logicalWidth);
     auto heightIsAuto = isHeightAuto(replacedBox);
-    auto height = computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : std::nullopt);
+    auto height = computedHeight(replacedBox, verticalConstraints ? std::optional<LayoutUnit>(verticalConstraints->logicalHeight) : std::nullopt);
 
     if (!width && heightIsAuto && replacedBox.hasIntrinsicWidth()) {
         // #1
@@ -1168,7 +1166,7 @@
 ConstraintsForInFlowContent FormattingGeometry::constraintsForInFlowContent(const ContainerBox& containerBox, std::optional<FormattingContext::EscapeReason> escapeReason) const
 {
     auto& boxGeometry = formattingContext().geometryForBox(containerBox, escapeReason);
-    return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), computedHeight(containerBox) } };
+    return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() };
 }
 
 }

Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingQuirks.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/FormattingQuirks.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingQuirks.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -58,7 +58,7 @@
         // -and it's totally insane because now we freely travel across formatting context boundaries and computed margins are nonexistent.
         if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {
             auto& formattingGeometry = formattingContext.formattingGeometry();
-            auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal;
+            auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal();
             auto verticalMargin = formattingGeometry.computedVerticalMargin(*containingBlock, horizontalConstraints);
 
             auto& boxGeometry = formattingContext.geometryForBox(*containingBlock, FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk);

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -116,10 +116,10 @@
             auto& layoutBox = *layoutQueue.last();
             auto containingBlockConstraints = constraintsForLayoutBox(layoutBox);
 
-            computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal);
-            computeStaticVerticalPosition(layoutBox, containingBlockConstraints.vertical);
+            computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal());
+            computeStaticVerticalPosition(layoutBox, containingBlockConstraints.logicalTop());
             computeWidthAndMargin(floatingContext, layoutBox, { constraints, containingBlockConstraints });
-            computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal);
+            computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal());
             computePositionToAvoidFloats(floatingContext, layoutBox, { constraints, containingBlockConstraints });
 
             if (layoutBox.establishesFormattingContext()) {
@@ -132,7 +132,7 @@
                     // Layout the inflow descendants of this formatting context root.
                     auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
                     if (containerBox.isTableWrapperBox())
-                        downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal);
+                        downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal());
                     formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(containerBox));
                 }
                 break;
@@ -156,7 +156,7 @@
                 if (!layoutBox.isFloatAvoider() || floatingContext.isEmpty()) {
                     auto& formattingState = this->formattingState();
                     auto& boxGeometry = formattingState.boxGeometry(layoutBox);
-                    boxGeometry.setLogicalTop(verticalPositionWithMargin(layoutBox, formattingState.usedVerticalMargin(layoutBox), containingBlockConstraints.vertical));
+                    boxGeometry.setLogicalTop(verticalPositionWithMargin(layoutBox, formattingState.usedVerticalMargin(layoutBox), containingBlockConstraints.logicalTop()));
                 }
             }
             auto establishesFormattingContext = layoutBox.establishesFormattingContext(); 
@@ -168,7 +168,7 @@
                 }
             }
             if (!establishesFormattingContext && is<ContainerBox>(layoutBox))
-                placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal);
+                placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal());
 
             if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
                 break;
@@ -175,7 +175,7 @@
         }
     }
     // Place the inflow positioned children.
-    placeInFlowPositionedChildren(formattingRoot, constraints.horizontal);
+    placeInFlowPositionedChildren(formattingRoot, constraints.horizontal());
     LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")");
 }
 
@@ -247,11 +247,11 @@
     if (!constraints.left && !constraints.right)
         return { };
     // Shrink the available space if the floats are actually intruding at this vertical position.
-    auto availableWidth = constraintsPair.containingBlock.horizontal.logicalWidth;
+    auto availableWidth = constraintsPair.containingBlock.horizontal().logicalWidth;
     if (constraints.left)
         availableWidth -= constraints.left->x;
     if (constraints.right)
-        availableWidth -= std::max(0_lu, constraintsPair.containingBlock.horizontal.logicalRight() - constraints.right->x);
+        availableWidth -= std::max(0_lu, constraintsPair.containingBlock.horizontal().logicalRight() - constraints.right->x);
     return availableWidth;
 }
 
@@ -267,9 +267,9 @@
     LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &containerBox);
 }
 
-void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints)
+void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop)
 {
-    formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, verticalConstraints));
+    formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, containingBlockContentBoxTop));
 }
 
 void BlockFormattingContext::computeStaticHorizontalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints)
@@ -296,7 +296,7 @@
             return &containingBlock == &root() ? constraintsPair.formattingContextRoot : formattingGeometry.constraintsForInFlowContent(containingBlock);
         }();
 
-        auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal);
+        auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal());
         auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) };
         auto precomputedMarginBefore = marginCollapse().precomputedMarginBefore(*ancestor, usedNonCollapsedMargin, formattingGeometry);
 
@@ -307,7 +307,7 @@
 
         formattingState().setUsedVerticalMargin(*ancestor, verticalMargin);
         boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) });
-        boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor.vertical));
+        boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor.logicalTop()));
 #if ASSERT_ENABLED
         setPrecomputedMarginBefore(*ancestor, precomputedMarginBefore);
         boxGeometry.setHasPrecomputedMarginBefore();
@@ -325,7 +325,7 @@
     // However according to the BFC rules, at this point of the layout flow we don't yet have computed vertical positions for the ancestors.
     if (layoutBox.isFloatingPositioned()) {
         precomputeVerticalPositionForBoxAndAncestors(layoutBox, constraintsPair);
-        formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForFloat(layoutBox, constraintsPair.containingBlock.horizontal));
+        formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForFloat(layoutBox, constraintsPair.containingBlock.horizontal()));
         return;
     }
     // Non-float positioned float avoiders (formatting context roots and clear boxes) should be fine unless there are floats in this context.
@@ -336,7 +336,7 @@
         return computeVerticalPositionForFloatClear(floatingContext, layoutBox);
 
     ASSERT(layoutBox.establishesFormattingContext());
-    formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForNonFloatingFloatAvoider(layoutBox, constraintsPair.containingBlock.horizontal));
+    formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForNonFloatingFloatAvoider(layoutBox, constraintsPair.containingBlock.horizontal()));
 }
 
 void BlockFormattingContext::computeVerticalPositionForFloatClear(const FloatingContext& floatingContext, const Box& layoutBox)
@@ -363,7 +363,7 @@
         // Float avoiders' available width might be shrunk by existing floats in the context.
         availableWidthFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair);
     }
-    auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal, availableWidthFloatAvoider);
+    auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal(), availableWidthFloatAvoider);
     auto& boxGeometry = formattingState().boxGeometry(layoutBox);
     boxGeometry.setContentBoxWidth(contentWidthAndMargin.contentWidth);
     boxGeometry.setHorizontalMargin({ contentWidthAndMargin.usedMargin.start, contentWidthAndMargin.usedMargin.end });
@@ -373,10 +373,10 @@
 {
     auto compute = [&](std::optional<LayoutUnit> usedHeight) -> ContentHeightAndMargin {
         if (layoutBox.isInFlow())
-            return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal, { usedHeight });
+            return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight });
 
         if (layoutBox.isFloatingPositioned())
-            return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal, { usedHeight });
+            return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight });
 
         ASSERT_NOT_REACHED();
         return { };
@@ -503,7 +503,7 @@
     return constraints;
 }
 
-LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin,  const VerticalConstraints& verticalConstraints) const
+LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin, LayoutUnit containingBlockContentBoxTop) const
 {
     ASSERT(!layoutBox.isOutOfFlowPositioned());
     // Now that we've computed the final margin before, let's shift the box's vertical position if needed.
@@ -532,7 +532,6 @@
         currentLayoutBox = &previousInFlowSibling;
     }
 
-    auto containingBlockContentBoxTop = verticalConstraints.logicalTop;
     // Adjust vertical position depending whether this box directly or indirectly adjoins with its parent.
     auto directlyAdjoinsParent = !layoutBox.previousInFlowSibling();
     if (directlyAdjoinsParent) {

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -69,7 +69,7 @@
     void computeHeightAndMargin(const Box&, const ConstraintsForInFlowContent&);
 
     void computeStaticHorizontalPosition(const Box&, const HorizontalConstraints&);
-    void computeStaticVerticalPosition(const Box&, const VerticalConstraints&);
+    void computeStaticVerticalPosition(const Box&, LayoutUnit containingBlockContentBoxTop);
     void computePositionToAvoidFloats(const FloatingContext&, const Box&, const ConstraintsPair&);
     void computeVerticalPositionForFloatClear(const FloatingContext&, const Box&);
 
@@ -77,7 +77,7 @@
 
     IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
 
-    LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, const VerticalConstraints&) const;
+    LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, LayoutUnit containingBlockContentBoxTop) const;
 
     std::optional<LayoutUnit> usedAvailableWidthForFloatAvoider(const FloatingContext&, const Box&, const ConstraintsPair&);
     void updateMarginAfterForPreviousSibling(const Box&);

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -237,7 +237,7 @@
     return { usedWidth, nonReplacedWidthAndMargin.usedMargin };
 }
 
-LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints) const
+LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop) const
 {
     // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
     // In a block formatting context, boxes are laid out one after the other, vertically, beginning at the top of a containing block.
@@ -247,7 +247,7 @@
         auto& previousInFlowBoxGeometry = formattingContext().geometryForBox(*previousInFlowSibling);
         return BoxGeometry::borderBoxRect(previousInFlowBoxGeometry).bottom() + previousInFlowBoxGeometry.marginAfter();
     }
-    return verticalConstraints.logicalTop;
+    return containingBlockContentBoxTop;
 }
 
 LayoutUnit BlockFormattingGeometry::staticHorizontalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints) const
@@ -257,11 +257,6 @@
     return horizontalConstraints.logicalLeft + formattingContext().geometryForBox(layoutBox).marginStart();
 }
 
-Point BlockFormattingGeometry::staticPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) const
-{
-    return { staticHorizontalPosition(layoutBox, horizontalConstraints), staticVerticalPosition(layoutBox, verticalConstraints) };
-}
-
 ContentHeightAndMargin BlockFormattingGeometry::inFlowContentHeightAndMargin(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const OverriddenVerticalValues& overriddenVerticalValues) const
 {
     ASSERT(layoutBox.isInFlow());

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -44,8 +44,7 @@
     ContentHeightAndMargin inFlowContentHeightAndMargin(const Box&, const HorizontalConstraints&, const OverriddenVerticalValues&) const;
     ContentWidthAndMargin inFlowContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&) const;
 
-    Point staticPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&) const;
-    LayoutUnit staticVerticalPosition(const Box&, const VerticalConstraints&) const;
+    LayoutUnit staticVerticalPosition(const Box&, LayoutUnit containingBlockContentBoxTop) const;
     LayoutUnit staticHorizontalPosition(const Box&, const HorizontalConstraints&) const;
 
     IntrinsicWidthConstraints intrinsicWidthConstraints(const Box&) const;

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -99,7 +99,7 @@
     // However the non-in-flow document box's vertical margins are ignored. They don't affect the body box's content height.
     if (documentBox.isInFlow()) {
         auto& formattingGeometry = formattingContext.formattingGeometry();
-        auto precomputeDocumentBoxVerticalMargin = formattingGeometry.computedVerticalMargin(documentBox, formattingGeometry.constraintsForInFlowContent(initialContainingBlock, FormattingContext::EscapeReason::BodyStretchesToViewportQuirk).horizontal);
+        auto precomputeDocumentBoxVerticalMargin = formattingGeometry.computedVerticalMargin(documentBox, formattingGeometry.constraintsForInFlowContent(initialContainingBlock, FormattingContext::EscapeReason::BodyStretchesToViewportQuirk).horizontal());
         bodyBoxContentHeight -= precomputeDocumentBoxVerticalMargin.before.value_or(0) + precomputeDocumentBoxVerticalMargin.after.value_or(0);
     }
     return std::max(contentHeightAndMargin.contentHeight,  bodyBoxContentHeight);

Modified: trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -46,7 +46,7 @@
     if (blockFormattingState.hasUsedVerticalMargin(layoutBox))
         return blockFormattingState.usedVerticalMargin(layoutBox).positiveAndNegativeValues.before;
 
-    auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal;
+    auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal();
     auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(layoutBox, horizontalConstraints);
     auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) };
     return precomputedPositiveNegativeMarginBefore(layoutBox, nonCollapsedMargin, formattingGeometry);

Modified: trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -36,6 +36,7 @@
 #include "LayoutChildIterator.h"
 #include "LayoutContext.h"
 #include "LayoutInitialContainingBlock.h"
+#include "TableFormattingConstraints.h"
 #include "TableFormattingContext.h"
 #include "TableFormattingState.h"
 #include "TableWrapperBlockFormattingQuirks.h"
@@ -72,14 +73,16 @@
 {
     layoutState().ensureTableFormattingState(tableBox);
 
-    computeBorderAndPaddingForTableBox(tableBox, constraints.horizontal);
-    computeStaticVerticalPosition(tableBox, constraints.vertical);
-    computeWidthAndMarginForTableBox(tableBox, constraints.horizontal);
-    computeStaticHorizontalPosition(tableBox, constraints.horizontal);
+    computeBorderAndPaddingForTableBox(tableBox, constraints.horizontal());
+    computeStaticVerticalPosition(tableBox, constraints.logicalTop());
+    computeWidthAndMarginForTableBox(tableBox, constraints.horizontal());
+    computeStaticHorizontalPosition(tableBox, constraints.horizontal());
 
     if (tableBox.hasChild()) {
+        auto& formattingGeometry = this->formattingGeometry();
         auto invalidationState = InvalidationState { };
-        LayoutContext::createFormattingContext(tableBox, layoutState())->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(tableBox));
+        auto constraints = ConstraintsForTableContent { formattingGeometry.constraintsForInFlowContent(tableBox), formattingGeometry.computedHeight(tableBox) };
+        LayoutContext::createFormattingContext(tableBox, layoutState())->layoutInFlowContent(invalidationState, constraints);
     }
 
     computeHeightAndMarginForTableBox(tableBox, constraints);
@@ -229,13 +232,13 @@
         return { };
     }();
 
-    auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal, { overriddenTableHeight });
+    auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal(), { overriddenTableHeight });
     auto verticalMargin = marginCollapse().collapsedVerticalValues(tableBox, heightAndMargin.nonCollapsedMargin);
     // Cache the computed positive and negative margin value pair.
     formattingState().setUsedVerticalMargin(tableBox, verticalMargin);
 
     auto& boxGeometry = formattingState().boxGeometry(tableBox);
-    boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints.vertical));
+    boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints.logicalTop()));
     boxGeometry.setContentBoxHeight(heightAndMargin.contentHeight);
     boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) });
     // Adjust the previous sibling's margin bottom now that this box's vertical margin is computed.

Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -70,15 +70,15 @@
 {
     auto& formattingState = this->formattingState();
     auto& formattingGeometry = this->formattingGeometry();
-    auto flexItemMainAxisStart = constraints.horizontal.logicalLeft;
+    auto flexItemMainAxisStart = constraints.horizontal().logicalLeft;
     auto flexItemMainAxisEnd = flexItemMainAxisStart;
-    auto flexItemCrosAxisStart = constraints.vertical.logicalTop;
+    auto flexItemCrosAxisStart = constraints.logicalTop();
     auto flexItemCrosAxisEnd = flexItemCrosAxisStart;
     for (auto& flexItem : childrenOfType<ContainerBox>(root())) {
         ASSERT(flexItem.establishesFormattingContext());
         // FIXME: This is just a simple, let's layout the flex items and place them next to each other setup.
         auto intrinsicWidths = formattingState.intrinsicWidthConstraintsForBox(flexItem);
-        auto flexItemLogicalWidth = std::min(std::max(intrinsicWidths->minimum, constraints.horizontal.logicalWidth), intrinsicWidths->maximum);
+        auto flexItemLogicalWidth = std::min(std::max(intrinsicWidths->minimum, constraints.horizontal().logicalWidth), intrinsicWidths->maximum);
         auto flexItemConstraints = ConstraintsForInFlowContent { { { }, flexItemLogicalWidth }, { } };
 
         auto invalidationState = InvalidationState { };
@@ -90,12 +90,12 @@
             flexItemGeometry.setLogicalTopLeft(LayoutPoint { flexItemMainAxisEnd, flexItemCrosAxisStart });
 
             flexItemGeometry.setBorder(formattingGeometry.computedBorder(flexItem));
-            flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal.logicalWidth));
+            flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal().logicalWidth));
 
-            auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal);
+            auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal());
             flexItemGeometry.setHorizontalMargin({ computedHorizontalMargin.start.value_or(0_lu), computedHorizontalMargin.end.value_or(0_lu) });
 
-            auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal);
+            auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal());
             flexItemGeometry.setVerticalMargin({ computedVerticalMargin.before.value_or(0_lu), computedVerticalMargin.after.value_or(0_lu) });
 
             flexItemGeometry.setContentBoxHeight(formattingGeometry.contentHeightForFormattingContextRoot(flexItem));

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -98,22 +98,22 @@
             if (is<ContainerBox>(layoutBox) && layoutBox->establishesFormattingContext()) {
                 ASSERT(layoutBox->isInlineBlockBox() || layoutBox->isInlineTableBox() || layoutBox->isFloatingPositioned());
                 auto& formattingRoot = downcast<ContainerBox>(*layoutBox);
-                computeBorderAndPadding(formattingRoot, constraints.horizontal);
-                computeWidthAndMargin(formattingRoot, constraints.horizontal);
+                computeBorderAndPadding(formattingRoot, constraints.horizontal());
+                computeWidthAndMargin(formattingRoot, constraints.horizontal());
 
                 if (formattingRoot.hasChild()) {
                     auto formattingContext = LayoutContext::createFormattingContext(formattingRoot, layoutState());
                     if (formattingRoot.hasInFlowOrFloatingChild())
                         formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(formattingRoot));
-                    computeHeightAndMargin(formattingRoot, constraints.horizontal);
+                    computeHeightAndMargin(formattingRoot, constraints.horizontal());
                     formattingContext->layoutOutOfFlowContent(invalidationState, formattingGeometry().constraintsForOutOfFlowContent(formattingRoot));
                 } else
-                    computeHeightAndMargin(formattingRoot, constraints.horizontal);
+                    computeHeightAndMargin(formattingRoot, constraints.horizontal());
             } else {
                 // Replaced and other type of leaf atomic inline boxes.
-                computeBorderAndPadding(*layoutBox, constraints.horizontal);
-                computeWidthAndMargin(*layoutBox, constraints.horizontal);
-                computeHeightAndMargin(*layoutBox, constraints.horizontal);
+                computeBorderAndPadding(*layoutBox, constraints.horizontal());
+                computeWidthAndMargin(*layoutBox, constraints.horizontal());
+                computeHeightAndMargin(*layoutBox, constraints.horizontal());
             }
         } else if (layoutBox->isLineBreakBox()) {
             auto& boxGeometry = formattingState().boxGeometry(*layoutBox);
@@ -126,8 +126,8 @@
             // Text wrapper boxes (anonymous inline level boxes) don't have box geometries (they only generate runs).
             if (!layoutBox->isInlineTextBox()) {
                 // Inline boxes (<span>) can't get sized/positioned yet. At this point we can only compute their margins, borders and padding.
-                computeBorderAndPadding(*layoutBox, constraints.horizontal);
-                computeHorizontalMargin(*layoutBox, constraints.horizontal);
+                computeBorderAndPadding(*layoutBox, constraints.horizontal());
+                computeHorizontalMargin(*layoutBox, constraints.horizontal());
                 formattingState().boxGeometry(*layoutBox).setVerticalMargin({ });
             }
         } else
@@ -178,7 +178,7 @@
 {
     auto& formattingState = this->formattingState();
     formattingState.lineRuns().reserveInitialCapacity(formattingState.inlineItems().size());
-    InlineLayoutUnit lineLogicalTop = constraints.vertical.logicalTop;
+    InlineLayoutUnit lineLogicalTop = constraints.logicalTop();
     struct PreviousLine {
         LineBuilder::InlineItemRange range;
         size_t overflowContentLength { 0 };
@@ -189,7 +189,7 @@
     auto floatingContext = FloatingContext { *this, floatingState };
     auto isFirstLine = formattingState.lines().isEmpty();
 
-    auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal, inlineItems };
+    auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal(), inlineItems };
     while (!needsLayoutRange.isEmpty()) {
         // Turn previous line's overflow content length into the next line's leading content partial length.
         // "sp[<-line break->]lit_content" -> overflow length: 11 -> leading partial content length: 11.
@@ -200,9 +200,9 @@
                 return root().style().computedLineHeight();
             return formattingQuirks().initialLineHeight();
         }();
-        auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal.logicalLeft, constraints.horizontal.logicalWidth, initialLineHeight };
+        auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal().logicalLeft, constraints.horizontal().logicalWidth, initialLineHeight };
         auto lineContent = lineBuilder.layoutInlineContent(needsLayoutRange, partialLeadingContentLength, leadingLogicalWidth, initialLineConstraints, isFirstLine);
-        auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal);
+        auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal());
 
         auto lineContentRange = lineContent.inlineItemRange;
         if (!lineContentRange.isEmpty()) {

Added: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingConstraints.h (0 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingConstraints.h	                        (rev 0)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingConstraints.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 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 "FormattingConstraints.h"
+
+namespace WebCore {
+namespace Layout {
+
+struct ConstraintsForTableContent : public ConstraintsForInFlowContent {
+    ConstraintsForTableContent(const ConstraintsForInFlowContent&, std::optional<LayoutUnit> availableVerticalSpaceForContent);
+
+    std::optional<LayoutUnit> availableVerticalSpaceForContent() const { return m_availableVerticalSpaceForContent; }
+
+private:
+    std::optional<LayoutUnit> m_availableVerticalSpaceForContent;
+};
+
+inline ConstraintsForTableContent::ConstraintsForTableContent(const ConstraintsForInFlowContent& inFlowContraints, std::optional<LayoutUnit> availableVerticalSpaceForContent)
+    : ConstraintsForInFlowContent(inFlowContraints.horizontal(), inFlowContraints.logicalTop(), TableContent)
+    , m_availableVerticalSpaceForContent(availableVerticalSpaceForContent)
+{
+}
+
+}
+}
+
+SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONSTRAINTS(ConstraintsForTableContent, isConstraintsForTableContent())
+
+#endif

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -37,6 +37,7 @@
 #include "LayoutChildIterator.h"
 #include "LayoutContext.h"
 #include "LayoutInitialContainingBlock.h"
+#include "TableFormattingConstraints.h"
 #include "TableFormattingState.h"
 #include <wtf/IsoMallocInlines.h>
 
@@ -55,8 +56,8 @@
 
 void TableFormattingContext::layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent& constraints)
 {
-    auto availableHorizontalSpace = constraints.horizontal.logicalWidth;
-    auto availableVerticalSpace = constraints.vertical.logicalHeight;
+    auto availableHorizontalSpace = constraints.horizontal().logicalWidth;
+    auto availableVerticalSpace = downcast<ConstraintsForTableContent>(constraints).availableVerticalSpaceForContent();
     // 1. Compute width and height for the grid.
     computeAndDistributeExtraSpace(availableHorizontalSpace, availableVerticalSpace);
     // 2. Finalize cells.
@@ -99,7 +100,7 @@
         for (size_t rowIndex = cell->startRow() + 1; rowIndex < cell->endRow(); ++rowIndex)
             availableVerticalSpace += rowList[rowIndex].logicalHeight();
         availableVerticalSpace += (cell->rowSpan() - 1) * grid.verticalSpacing();
-        layoutCell(*cell, availableHorizontalSpace, availableVerticalSpace);
+        layoutCell(*cell, availableHorizontalSpace);
 
         auto computeIntrinsicVerticalPaddingForCell = [&] {
             // Intrinsic padding is the extra padding for the cell box when it is shorter than the row. Cell boxes have to
@@ -246,7 +247,7 @@
     auto& grid = formattingState().tableGrid();
     auto& tableBox = root();
     auto sectionWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
-    auto logicalTop = constraints.vertical.logicalTop;
+    auto logicalTop = constraints.logicalTop();
     auto verticalSpacing = grid.verticalSpacing();
     auto paddingBefore = std::optional<LayoutUnit> { verticalSpacing };
     auto paddingAfter = verticalSpacing;
@@ -270,7 +271,7 @@
         }
         sectionContentHeight += verticalSpacing * (rowCount - 1);
         sectionBoxGeometry.setContentBoxHeight(sectionContentHeight);
-        sectionBoxGeometry.setLogicalLeft(constraints.horizontal.logicalLeft);
+        sectionBoxGeometry.setLogicalLeft(constraints.horizontal().logicalLeft);
         sectionBoxGeometry.setLogicalTop(logicalTop);
 
         logicalTop += sectionBoxGeometry.borderBoxHeight();
@@ -277,7 +278,7 @@
     }
 }
 
-void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace, std::optional<LayoutUnit> availableVerticalSpaceForContent)
+void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace)
 {
     ASSERT(cell.box().establishesBlockFormattingContext());
 
@@ -305,10 +306,8 @@
 
     if (cellBox.hasInFlowOrFloatingChild()) {
         auto constraintsForCellContent = formattingGeometry.constraintsForInFlowContent(cellBox);
-        constraintsForCellContent.vertical.logicalHeight = availableVerticalSpaceForContent;
         auto invalidationState = InvalidationState { };
-        // FIXME: This should probably be part of the invalidation state to indicate when we re-layout the cell
-        // multiple times as part of the multi-pass table algorithm.
+        // FIXME: This should probably be part of the invalidation state to indicate when we re-layout the cell multiple times as part of the multi-pass table algorithm.
         auto& floatingStateForCellContent = layoutState().ensureBlockFormattingState(cellBox).floatingState();
         floatingStateForCellContent.clear();
         LayoutContext::createFormattingContext(cellBox, layoutState())->layoutInFlowContent(invalidationState, constraintsForCellContent);

Modified: trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h (278291 => 278292)


--- trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h	2021-06-01 02:41:01 UTC (rev 278292)
@@ -72,7 +72,7 @@
     TableFormattingContext::TableLayout tableLayout() const { return TableLayout(*this, formattingState().tableGrid()); }
 
     IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
-    void layoutCell(const TableGrid::Cell&, LayoutUnit availableHorizontalSpace, std::optional<LayoutUnit> availableVerticalSpaceForContent = std::nullopt);
+    void layoutCell(const TableGrid::Cell&, LayoutUnit availableHorizontalSpace);
     void setUsedGeometryForCells(LayoutUnit availableHorizontalSpace);
     void setUsedGeometryForRows(LayoutUnit availableHorizontalSpace);
     void setUsedGeometryForSections(const ConstraintsForInFlowContent&);

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (278291 => 278292)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-06-01 01:35:29 UTC (rev 278291)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-06-01 02:41:01 UTC (rev 278292)
@@ -216,9 +216,8 @@
 
     auto invalidationState = Layout::InvalidationState { };
     auto horizontalConstraints = Layout::HorizontalConstraints { flow().borderAndPaddingStart(), flow().contentSize().width() };
-    auto verticalConstraints = Layout::VerticalConstraints { flow().borderAndPaddingBefore(), { } };
 
-    inlineFormattingContext.lineLayoutForIntergration(invalidationState, { horizontalConstraints, verticalConstraints });
+    inlineFormattingContext.lineLayoutForIntergration(invalidationState, { horizontalConstraints, flow().borderAndPaddingBefore() });
 
     constructContent();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to