⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278292 in webkit


Ignore:
Timestamp:
May 31, 2021, 7:41:01 PM (5 years ago)
Author:
Alan Bujtas
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):

Location:
trunk/Source/WebCore
Files:
2 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r278291 r278292  
     12021-05-31  Alan Bujtas  <zalan@apple.com>
     2
     3        [LFC] Tighten the constraint classes (ConstraintsForInFlowContent/ConstraintsForOutOfFlowContent)
     4        https://bugs.webkit.org/show_bug.cgi?id=226435
     5
     6        Reviewed by Antti Koivisto.
     7
     8        While logical height should always be available for out of flow content by design,
     9        the base inflow layout can't necessarily provide it. This height constraint is not even required/used in most of the layout systems,
     10        so let's move it to the derived class(es).
     11
     12        * layout/LayoutContext.cpp:
     13        (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree):
     14        * layout/LayoutUnits.h:
     15        * layout/formattingContexts/FormattingContext.cpp:
     16        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry):
     17        * layout/formattingContexts/FormattingGeometry.cpp:
     18        (WebCore::Layout::FormattingGeometry::outOfFlowNonReplacedVerticalGeometry const):
     19        (WebCore::Layout::FormattingGeometry::outOfFlowReplacedVerticalGeometry const):
     20        (WebCore::Layout::FormattingGeometry::inlineReplacedContentHeightAndMargin const):
     21        (WebCore::Layout::FormattingGeometry::inlineReplacedContentWidthAndMargin const):
     22        (WebCore::Layout::FormattingGeometry::constraintsForInFlowContent const):
     23        * layout/formattingContexts/block/BlockFormattingContext.cpp:
     24        (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
     25        (WebCore::Layout::BlockFormattingContext::computeStaticVerticalPosition):
     26        (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForBoxAndAncestors):
     27        (WebCore::Layout::BlockFormattingContext::verticalPositionWithMargin const):
     28        * layout/formattingContexts/block/BlockFormattingContext.h:
     29        * layout/formattingContexts/block/BlockFormattingGeometry.cpp:
     30        (WebCore::Layout::BlockFormattingGeometry::staticVerticalPosition const):
     31        (WebCore::Layout::BlockFormattingGeometry::staticPosition const): Deleted.
     32        * layout/formattingContexts/block/BlockFormattingGeometry.h:
     33        * layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp:
     34        (WebCore::Layout::TableWrapperBlockFormattingContext::layoutTableBox):
     35        (WebCore::Layout::TableWrapperBlockFormattingContext::computeHeightAndMarginForTableBox):
     36        * layout/formattingContexts/flex/FlexFormattingContext.cpp:
     37        (WebCore::Layout::FlexFormattingContext::sizeAndPlaceFlexItems):
     38        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
     39        (WebCore::Layout::InlineFormattingContext::lineLayout):
     40        * layout/formattingContexts/table/TableFormattingContext.cpp:
     41        (WebCore::Layout::TableFormattingContext::layoutInFlowContent):
     42        (WebCore::Layout::TableFormattingContext::setUsedGeometryForCells):
     43        (WebCore::Layout::TableFormattingContext::setUsedGeometryForSections):
     44        (WebCore::Layout::TableFormattingContext::layoutCell):
     45        * layout/formattingContexts/table/TableFormattingContext.h:
     46        * layout/integration/LayoutIntegrationLineLayout.cpp:
     47        (WebCore::LayoutIntegration::LineLayout::layout):
     48
    1492021-05-31  Aakash Jain  <aakash_jain@apple.com>
    250
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r278290 r278292  
    21352135                6F17264F2470C60B00518C96 /* TableWrapperBlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21362136                6F1CC1DE225F8B4900720AD2 /* InlineTextItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2137                6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2138                6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F1E83A52665888C002E9D28 /* FormattingConstraints.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21372139                6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26BB6B23343E5B002F2BEA /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21382140                6F26EB48234004A5006906E2 /* InlineLineBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26EB46234004A5006906E2 /* InlineLineBuilder.h */; };
     
    99949996                6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextItem.cpp; sourceTree = "<group>"; };
    99959997                6F1CC1DD225F8B4200720AD2 /* InlineTextItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineTextItem.h; sourceTree = "<group>"; };
     9998                6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableFormattingConstraints.h; sourceTree = "<group>"; };
     9999                6F1E83A52665888C002E9D28 /* FormattingConstraints.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormattingConstraints.h; sourceTree = "<group>"; };
    999610000                6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; };
    999710001                6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; };
     
    2273422738                                115CFA9A208BC140001E6991 /* inline */,
    2273522739                                6FC5CA9122E3593300B13E11 /* table */,
     22740                                6F1E83A52665888C002E9D28 /* FormattingConstraints.h */,
    2273622741                                115CFA69208AF7D0001E6991 /* FormattingContext.cpp */,
    2273722742                                115CFA68208AF7D0001E6991 /* FormattingContext.h */,
     
    2277122776                        isa = PBXGroup;
    2277222777                        children = (
     22778                                6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */,
    2277322779                                6FC5CA9422E3599400B13E11 /* TableFormattingContext.cpp */,
    2277422780                                6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */,
     
    3272932735                                D05CED2A0A40BB2C00C5AF38 /* FormatBlockCommand.h in Headers */,
    3273032736                                7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */,
     32737                                6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */,
    3273132738                                115CFA6A208AF7D0001E6991 /* FormattingContext.h in Headers */,
    3273232739                                475C89A42650AC3C00F3B456 /* FormattingGeometry.h in Headers */,
     
    3564935656                                E3C0412F254CA29B0021D0E6 /* SystemSoundManager.h in Headers */,
    3565035657                                5D5975B319635F1100D00878 /* SystemVersion.h in Headers */,
     35658                                6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */,
    3565135659                                47FA97002650982B00841416 /* TableFormattingGeometry.h in Headers */,
    3565235660                                6F49C3E726479B3C0051953D /* TableFormattingQuirks.h in Headers */,
  • trunk/Source/WebCore/layout/LayoutContext.cpp

    r277570 r278292  
    101101
    102102    if (formattingContextRoot.hasInFlowOrFloatingChild()) {
    103         auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), { } } };
     103        auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() };
    104104        formattingContext->layoutInFlowContent(invalidationState, constraintsForInFlowContent);
    105105    }
  • trunk/Source/WebCore/layout/LayoutUnits.h

    r278253 r278292  
    158158};
    159159
    160 struct HorizontalConstraints {
    161     LayoutUnit logicalRight() const { return logicalLeft + logicalWidth; }
    162 
    163     LayoutUnit logicalLeft;
    164     LayoutUnit logicalWidth;
    165 };
    166 
    167 struct VerticalConstraints {
    168     LayoutUnit logicalTop;
    169     std::optional<LayoutUnit> logicalHeight;
    170 };
    171 
    172 struct ConstraintsForInFlowContent {
    173     HorizontalConstraints horizontal;
    174     VerticalConstraints vertical;
    175 };
    176 
    177 struct ConstraintsForOutOfFlowContent {
    178     HorizontalConstraints horizontal;
    179     VerticalConstraints vertical;
    180     // Borders and padding are resolved against the containing block's content box as if the box was an in-flow box.
    181     LayoutUnit borderAndPaddingConstraints;
    182 };
    183 
    184 struct IntrinsicWidthConstraints {
    185     void expand(LayoutUnit horizontalValue);
    186     IntrinsicWidthConstraints& operator+=(const IntrinsicWidthConstraints&);
    187     IntrinsicWidthConstraints& operator+=(LayoutUnit);
    188     IntrinsicWidthConstraints& operator-=(const IntrinsicWidthConstraints&);
    189     IntrinsicWidthConstraints& operator-=(LayoutUnit);
    190 
    191     LayoutUnit minimum;
    192     LayoutUnit maximum;
    193 };
    194 
    195160struct OverriddenHorizontalValues {
    196161    std::optional<LayoutUnit> width;
     
    232197}
    233198
    234 inline void IntrinsicWidthConstraints::expand(LayoutUnit horizontalValue)
    235 {
    236     minimum += horizontalValue;
    237     maximum += horizontalValue;
    238 }
    239 
    240 inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(const IntrinsicWidthConstraints& other)
    241 {
    242     minimum += other.minimum;
    243     maximum += other.maximum;
    244     return *this;
    245 }
    246 
    247 inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator+=(LayoutUnit value)
    248 {
    249     expand(value);
    250     return *this;
    251 }
    252 
    253 inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(const IntrinsicWidthConstraints& other)
    254 {
    255     minimum -= other.minimum;
    256     maximum -= other.maximum;
    257     return *this;
    258 }
    259 
    260 inline IntrinsicWidthConstraints& IntrinsicWidthConstraints::operator-=(LayoutUnit value)
    261 {
    262     expand(-value);
    263     return *this;
    264 }
    265 
    266199struct SlotPosition {
    267200    SlotPosition() = default;
  • trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp

    r278253 r278292  
    107107    };
    108108
    109     auto containingBlockHeight = *constraints.vertical.logicalHeight;
     109    auto containingBlockHeight = constraints.vertical.logicalHeight;
    110110    auto verticalGeometry = compute({ });
    111111    if (auto maxHeight = formattingGeometry().computedMaxHeight(layoutBox, containingBlockHeight)) {
  • trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h

    r278253 r278292  
    2828#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    2929
     30#include "FormattingConstraints.h"
    3031#include "LayoutContainerBox.h"
    3132#include "LayoutUnit.h"
     
    4344class BoxGeometry;
    4445class ContainerBox;
     46struct ConstraintsForInFlowContent;
     47struct ConstraintsForOutOfFlowContent;
     48struct HorizontalConstraints;
    4549class FormattingGeometry;
    4650class FormattingState;
    4751class FormattingQuirks;
     52struct IntrinsicWidthConstraints;
    4853class InvalidationState;
    4954class LayoutState;
  • trunk/Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp

    r278253 r278292  
    325325{
    326326    ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox());
    327     ASSERT(verticalConstraints.logicalHeight);
    328327
    329328    // 10.6.4 Absolutely positioned, non-replaced elements
     
    354353    auto& style = layoutBox.style();
    355354    auto& boxGeometry = formattingContext.geometryForBox(layoutBox);
    356     auto containingBlockHeight = *verticalConstraints.logicalHeight;
     355    auto containingBlockHeight = verticalConstraints.logicalHeight;
    357356    auto containingBlockWidth = horizontalConstraints.logicalWidth;
    358357
     
    587586{
    588587    ASSERT(replacedBox.isOutOfFlowPositioned());
    589     ASSERT(verticalConstraints.logicalHeight);
    590588
    591589    // 10.6.5 Absolutely positioned, replaced elements
     
    602600    auto& style = replacedBox.style();
    603601    auto& boxGeometry = formattingContext.geometryForBox(replacedBox);
    604     auto containingBlockHeight = *verticalConstraints.logicalHeight;
     602    auto containingBlockHeight = verticalConstraints.logicalHeight;
    605603    auto containingBlockWidth = horizontalConstraints.logicalWidth;
    606604
     
    922920    auto& style = replacedBox.style();
    923921
    924     auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : std::nullopt);
     922    auto height = overriddenVerticalValues.height ? overriddenVerticalValues.height.value() : computedHeight(replacedBox, verticalConstraints ? std::optional<LayoutUnit>(verticalConstraints->logicalHeight) : std::nullopt);
    925923    auto heightIsAuto = !overriddenVerticalValues.height && isHeightAuto(replacedBox);
    926924    auto widthIsAuto = style.logicalWidth().isAuto();
     
    984982    auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(replacedBox, horizontalConstraints.logicalWidth);
    985983    auto heightIsAuto = isHeightAuto(replacedBox);
    986     auto height = computedHeight(replacedBox, verticalConstraints ? verticalConstraints->logicalHeight : std::nullopt);
     984    auto height = computedHeight(replacedBox, verticalConstraints ? std::optional<LayoutUnit>(verticalConstraints->logicalHeight) : std::nullopt);
    987985
    988986    if (!width && heightIsAuto && replacedBox.hasIntrinsicWidth()) {
     
    11691167{
    11701168    auto& boxGeometry = formattingContext().geometryForBox(containerBox, escapeReason);
    1171     return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), computedHeight(containerBox) } };
     1169    return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() };
    11721170}
    11731171
  • trunk/Source/WebCore/layout/formattingContexts/FormattingQuirks.cpp

    r278185 r278292  
    5959        if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {
    6060            auto& formattingGeometry = formattingContext.formattingGeometry();
    61             auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal;
     61            auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal();
    6262            auto verticalMargin = formattingGeometry.computedVerticalMargin(*containingBlock, horizontalConstraints);
    6363
  • trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp

    r278253 r278292  
    117117            auto containingBlockConstraints = constraintsForLayoutBox(layoutBox);
    118118
    119             computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal);
    120             computeStaticVerticalPosition(layoutBox, containingBlockConstraints.vertical);
     119            computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal());
     120            computeStaticVerticalPosition(layoutBox, containingBlockConstraints.logicalTop());
    121121            computeWidthAndMargin(floatingContext, layoutBox, { constraints, containingBlockConstraints });
    122             computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal);
     122            computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal());
    123123            computePositionToAvoidFloats(floatingContext, layoutBox, { constraints, containingBlockConstraints });
    124124
     
    133133                    auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
    134134                    if (containerBox.isTableWrapperBox())
    135                         downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal);
     135                        downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal());
    136136                    formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(containerBox));
    137137                }
     
    157157                    auto& formattingState = this->formattingState();
    158158                    auto& boxGeometry = formattingState.boxGeometry(layoutBox);
    159                     boxGeometry.setLogicalTop(verticalPositionWithMargin(layoutBox, formattingState.usedVerticalMargin(layoutBox), containingBlockConstraints.vertical));
     159                    boxGeometry.setLogicalTop(verticalPositionWithMargin(layoutBox, formattingState.usedVerticalMargin(layoutBox), containingBlockConstraints.logicalTop()));
    160160                }
    161161            }
     
    169169            }
    170170            if (!establishesFormattingContext && is<ContainerBox>(layoutBox))
    171                 placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal);
     171                placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal());
    172172
    173173            if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
     
    176176    }
    177177    // Place the inflow positioned children.
    178     placeInFlowPositionedChildren(formattingRoot, constraints.horizontal);
     178    placeInFlowPositionedChildren(formattingRoot, constraints.horizontal());
    179179    LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")");
    180180}
     
    248248        return { };
    249249    // Shrink the available space if the floats are actually intruding at this vertical position.
    250     auto availableWidth = constraintsPair.containingBlock.horizontal.logicalWidth;
     250    auto availableWidth = constraintsPair.containingBlock.horizontal().logicalWidth;
    251251    if (constraints.left)
    252252        availableWidth -= constraints.left->x;
    253253    if (constraints.right)
    254         availableWidth -= std::max(0_lu, constraintsPair.containingBlock.horizontal.logicalRight() - constraints.right->x);
     254        availableWidth -= std::max(0_lu, constraintsPair.containingBlock.horizontal().logicalRight() - constraints.right->x);
    255255    return availableWidth;
    256256}
     
    268268}
    269269
    270 void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints)
    271 {
    272     formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, verticalConstraints));
     270void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop)
     271{
     272    formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, containingBlockContentBoxTop));
    273273}
    274274
     
    297297        }();
    298298
    299         auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal);
     299        auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal());
    300300        auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) };
    301301        auto precomputedMarginBefore = marginCollapse().precomputedMarginBefore(*ancestor, usedNonCollapsedMargin, formattingGeometry);
     
    308308        formattingState().setUsedVerticalMargin(*ancestor, verticalMargin);
    309309        boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) });
    310         boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor.vertical));
     310        boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor.logicalTop()));
    311311#if ASSERT_ENABLED
    312312        setPrecomputedMarginBefore(*ancestor, precomputedMarginBefore);
     
    326326    if (layoutBox.isFloatingPositioned()) {
    327327        precomputeVerticalPositionForBoxAndAncestors(layoutBox, constraintsPair);
    328         formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForFloat(layoutBox, constraintsPair.containingBlock.horizontal));
     328        formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForFloat(layoutBox, constraintsPair.containingBlock.horizontal()));
    329329        return;
    330330    }
     
    337337
    338338    ASSERT(layoutBox.establishesFormattingContext());
    339     formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForNonFloatingFloatAvoider(layoutBox, constraintsPair.containingBlock.horizontal));
     339    formattingState().boxGeometry(layoutBox).setLogicalTopLeft(floatingContext.positionForNonFloatingFloatAvoider(layoutBox, constraintsPair.containingBlock.horizontal()));
    340340}
    341341
     
    364364        availableWidthFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair);
    365365    }
    366     auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal, availableWidthFloatAvoider);
     366    auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal(), availableWidthFloatAvoider);
    367367    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
    368368    boxGeometry.setContentBoxWidth(contentWidthAndMargin.contentWidth);
     
    374374    auto compute = [&](std::optional<LayoutUnit> usedHeight) -> ContentHeightAndMargin {
    375375        if (layoutBox.isInFlow())
    376             return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal, { usedHeight });
     376            return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight });
    377377
    378378        if (layoutBox.isFloatingPositioned())
    379             return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal, { usedHeight });
     379            return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight });
    380380
    381381        ASSERT_NOT_REACHED();
     
    504504}
    505505
    506 LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin,  const VerticalConstraints& verticalConstraints) const
     506LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin, LayoutUnit containingBlockContentBoxTop) const
    507507{
    508508    ASSERT(!layoutBox.isOutOfFlowPositioned());
     
    533533    }
    534534
    535     auto containingBlockContentBoxTop = verticalConstraints.logicalTop;
    536535    // Adjust vertical position depending whether this box directly or indirectly adjoins with its parent.
    537536    auto directlyAdjoinsParent = !layoutBox.previousInFlowSibling();
  • trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h

    r278253 r278292  
    7070
    7171    void computeStaticHorizontalPosition(const Box&, const HorizontalConstraints&);
    72     void computeStaticVerticalPosition(const Box&, const VerticalConstraints&);
     72    void computeStaticVerticalPosition(const Box&, LayoutUnit containingBlockContentBoxTop);
    7373    void computePositionToAvoidFloats(const FloatingContext&, const Box&, const ConstraintsPair&);
    7474    void computeVerticalPositionForFloatClear(const FloatingContext&, const Box&);
     
    7878    IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
    7979
    80     LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, const VerticalConstraints&) const;
     80    LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, LayoutUnit containingBlockContentBoxTop) const;
    8181
    8282    std::optional<LayoutUnit> usedAvailableWidthForFloatAvoider(const FloatingContext&, const Box&, const ConstraintsPair&);
  • trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp

    r278253 r278292  
    238238}
    239239
    240 LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints) const
     240LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop) const
    241241{
    242242    // https://www.w3.org/TR/CSS22/visuren.html#block-formatting
     
    248248        return BoxGeometry::borderBoxRect(previousInFlowBoxGeometry).bottom() + previousInFlowBoxGeometry.marginAfter();
    249249    }
    250     return verticalConstraints.logicalTop;
     250    return containingBlockContentBoxTop;
    251251}
    252252
     
    256256    // In a block formatting context, each box's left outer edge touches the left edge of the containing block (for right-to-left formatting, right edges touch).
    257257    return horizontalConstraints.logicalLeft + formattingContext().geometryForBox(layoutBox).marginStart();
    258 }
    259 
    260 Point BlockFormattingGeometry::staticPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) const
    261 {
    262     return { staticHorizontalPosition(layoutBox, horizontalConstraints), staticVerticalPosition(layoutBox, verticalConstraints) };
    263258}
    264259
  • trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h

    r278253 r278292  
    4545    ContentWidthAndMargin inFlowContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&) const;
    4646
    47     Point staticPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&) const;
    48     LayoutUnit staticVerticalPosition(const Box&, const VerticalConstraints&) const;
     47    LayoutUnit staticVerticalPosition(const Box&, LayoutUnit containingBlockContentBoxTop) const;
    4948    LayoutUnit staticHorizontalPosition(const Box&, const HorizontalConstraints&) const;
    5049
  • trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp

    r278253 r278292  
    100100    if (documentBox.isInFlow()) {
    101101        auto& formattingGeometry = formattingContext.formattingGeometry();
    102         auto precomputeDocumentBoxVerticalMargin = formattingGeometry.computedVerticalMargin(documentBox, formattingGeometry.constraintsForInFlowContent(initialContainingBlock, FormattingContext::EscapeReason::BodyStretchesToViewportQuirk).horizontal);
     102        auto precomputeDocumentBoxVerticalMargin = formattingGeometry.computedVerticalMargin(documentBox, formattingGeometry.constraintsForInFlowContent(initialContainingBlock, FormattingContext::EscapeReason::BodyStretchesToViewportQuirk).horizontal());
    103103        bodyBoxContentHeight -= precomputeDocumentBoxVerticalMargin.before.value_or(0) + precomputeDocumentBoxVerticalMargin.after.value_or(0);
    104104    }
  • trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp

    r278185 r278292  
    4747        return blockFormattingState.usedVerticalMargin(layoutBox).positiveAndNegativeValues.before;
    4848
    49     auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal;
     49    auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal();
    5050    auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(layoutBox, horizontalConstraints);
    5151    auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) };
  • trunk/Source/WebCore/layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp

    r278253 r278292  
    3737#include "LayoutContext.h"
    3838#include "LayoutInitialContainingBlock.h"
     39#include "TableFormattingConstraints.h"
    3940#include "TableFormattingContext.h"
    4041#include "TableFormattingState.h"
     
    7374    layoutState().ensureTableFormattingState(tableBox);
    7475
    75     computeBorderAndPaddingForTableBox(tableBox, constraints.horizontal);
    76     computeStaticVerticalPosition(tableBox, constraints.vertical);
    77     computeWidthAndMarginForTableBox(tableBox, constraints.horizontal);
    78     computeStaticHorizontalPosition(tableBox, constraints.horizontal);
     76    computeBorderAndPaddingForTableBox(tableBox, constraints.horizontal());
     77    computeStaticVerticalPosition(tableBox, constraints.logicalTop());
     78    computeWidthAndMarginForTableBox(tableBox, constraints.horizontal());
     79    computeStaticHorizontalPosition(tableBox, constraints.horizontal());
    7980
    8081    if (tableBox.hasChild()) {
     82        auto& formattingGeometry = this->formattingGeometry();
    8183        auto invalidationState = InvalidationState { };
    82         LayoutContext::createFormattingContext(tableBox, layoutState())->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(tableBox));
     84        auto constraints = ConstraintsForTableContent { formattingGeometry.constraintsForInFlowContent(tableBox), formattingGeometry.computedHeight(tableBox) };
     85        LayoutContext::createFormattingContext(tableBox, layoutState())->layoutInFlowContent(invalidationState, constraints);
    8386    }
    8487
     
    230233    }();
    231234
    232     auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal, { overriddenTableHeight });
     235    auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal(), { overriddenTableHeight });
    233236    auto verticalMargin = marginCollapse().collapsedVerticalValues(tableBox, heightAndMargin.nonCollapsedMargin);
    234237    // Cache the computed positive and negative margin value pair.
     
    236239
    237240    auto& boxGeometry = formattingState().boxGeometry(tableBox);
    238     boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints.vertical));
     241    boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints.logicalTop()));
    239242    boxGeometry.setContentBoxHeight(heightAndMargin.contentHeight);
    240243    boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) });
  • trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp

    r278185 r278292  
    7171    auto& formattingState = this->formattingState();
    7272    auto& formattingGeometry = this->formattingGeometry();
    73     auto flexItemMainAxisStart = constraints.horizontal.logicalLeft;
     73    auto flexItemMainAxisStart = constraints.horizontal().logicalLeft;
    7474    auto flexItemMainAxisEnd = flexItemMainAxisStart;
    75     auto flexItemCrosAxisStart = constraints.vertical.logicalTop;
     75    auto flexItemCrosAxisStart = constraints.logicalTop();
    7676    auto flexItemCrosAxisEnd = flexItemCrosAxisStart;
    7777    for (auto& flexItem : childrenOfType<ContainerBox>(root())) {
     
    7979        // FIXME: This is just a simple, let's layout the flex items and place them next to each other setup.
    8080        auto intrinsicWidths = formattingState.intrinsicWidthConstraintsForBox(flexItem);
    81         auto flexItemLogicalWidth = std::min(std::max(intrinsicWidths->minimum, constraints.horizontal.logicalWidth), intrinsicWidths->maximum);
     81        auto flexItemLogicalWidth = std::min(std::max(intrinsicWidths->minimum, constraints.horizontal().logicalWidth), intrinsicWidths->maximum);
    8282        auto flexItemConstraints = ConstraintsForInFlowContent { { { }, flexItemLogicalWidth }, { } };
    8383
     
    9191
    9292            flexItemGeometry.setBorder(formattingGeometry.computedBorder(flexItem));
    93             flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal.logicalWidth));
     93            flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal().logicalWidth));
    9494
    95             auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal);
     95            auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal());
    9696            flexItemGeometry.setHorizontalMargin({ computedHorizontalMargin.start.value_or(0_lu), computedHorizontalMargin.end.value_or(0_lu) });
    9797
    98             auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal);
     98            auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal());
    9999            flexItemGeometry.setVerticalMargin({ computedVerticalMargin.before.value_or(0_lu), computedVerticalMargin.after.value_or(0_lu) });
    100100
  • trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp

    r278253 r278292  
    9999                ASSERT(layoutBox->isInlineBlockBox() || layoutBox->isInlineTableBox() || layoutBox->isFloatingPositioned());
    100100                auto& formattingRoot = downcast<ContainerBox>(*layoutBox);
    101                 computeBorderAndPadding(formattingRoot, constraints.horizontal);
    102                 computeWidthAndMargin(formattingRoot, constraints.horizontal);
     101                computeBorderAndPadding(formattingRoot, constraints.horizontal());
     102                computeWidthAndMargin(formattingRoot, constraints.horizontal());
    103103
    104104                if (formattingRoot.hasChild()) {
     
    106106                    if (formattingRoot.hasInFlowOrFloatingChild())
    107107                        formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(formattingRoot));
    108                     computeHeightAndMargin(formattingRoot, constraints.horizontal);
     108                    computeHeightAndMargin(formattingRoot, constraints.horizontal());
    109109                    formattingContext->layoutOutOfFlowContent(invalidationState, formattingGeometry().constraintsForOutOfFlowContent(formattingRoot));
    110110                } else
    111                     computeHeightAndMargin(formattingRoot, constraints.horizontal);
     111                    computeHeightAndMargin(formattingRoot, constraints.horizontal());
    112112            } else {
    113113                // Replaced and other type of leaf atomic inline boxes.
    114                 computeBorderAndPadding(*layoutBox, constraints.horizontal);
    115                 computeWidthAndMargin(*layoutBox, constraints.horizontal);
    116                 computeHeightAndMargin(*layoutBox, constraints.horizontal);
     114                computeBorderAndPadding(*layoutBox, constraints.horizontal());
     115                computeWidthAndMargin(*layoutBox, constraints.horizontal());
     116                computeHeightAndMargin(*layoutBox, constraints.horizontal());
    117117            }
    118118        } else if (layoutBox->isLineBreakBox()) {
     
    127127            if (!layoutBox->isInlineTextBox()) {
    128128                // Inline boxes (<span>) can't get sized/positioned yet. At this point we can only compute their margins, borders and padding.
    129                 computeBorderAndPadding(*layoutBox, constraints.horizontal);
    130                 computeHorizontalMargin(*layoutBox, constraints.horizontal);
     129                computeBorderAndPadding(*layoutBox, constraints.horizontal());
     130                computeHorizontalMargin(*layoutBox, constraints.horizontal());
    131131                formattingState().boxGeometry(*layoutBox).setVerticalMargin({ });
    132132            }
     
    179179    auto& formattingState = this->formattingState();
    180180    formattingState.lineRuns().reserveInitialCapacity(formattingState.inlineItems().size());
    181     InlineLayoutUnit lineLogicalTop = constraints.vertical.logicalTop;
     181    InlineLayoutUnit lineLogicalTop = constraints.logicalTop();
    182182    struct PreviousLine {
    183183        LineBuilder::InlineItemRange range;
     
    190190    auto isFirstLine = formattingState.lines().isEmpty();
    191191
    192     auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal, inlineItems };
     192    auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal(), inlineItems };
    193193    while (!needsLayoutRange.isEmpty()) {
    194194        // Turn previous line's overflow content length into the next line's leading content partial length.
     
    201201            return formattingQuirks().initialLineHeight();
    202202        }();
    203         auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal.logicalLeft, constraints.horizontal.logicalWidth, initialLineHeight };
     203        auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal().logicalLeft, constraints.horizontal().logicalWidth, initialLineHeight };
    204204        auto lineContent = lineBuilder.layoutInlineContent(needsLayoutRange, partialLeadingContentLength, leadingLogicalWidth, initialLineConstraints, isFirstLine);
    205         auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal);
     205        auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal());
    206206
    207207        auto lineContentRange = lineContent.inlineItemRange;
  • trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp

    r278279 r278292  
    3838#include "LayoutContext.h"
    3939#include "LayoutInitialContainingBlock.h"
     40#include "TableFormattingConstraints.h"
    4041#include "TableFormattingState.h"
    4142#include <wtf/IsoMallocInlines.h>
     
    5657void TableFormattingContext::layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent& constraints)
    5758{
    58     auto availableHorizontalSpace = constraints.horizontal.logicalWidth;
    59     auto availableVerticalSpace = constraints.vertical.logicalHeight;
     59    auto availableHorizontalSpace = constraints.horizontal().logicalWidth;
     60    auto availableVerticalSpace = downcast<ConstraintsForTableContent>(constraints).availableVerticalSpaceForContent();
    6061    // 1. Compute width and height for the grid.
    6162    computeAndDistributeExtraSpace(availableHorizontalSpace, availableVerticalSpace);
     
    100101            availableVerticalSpace += rowList[rowIndex].logicalHeight();
    101102        availableVerticalSpace += (cell->rowSpan() - 1) * grid.verticalSpacing();
    102         layoutCell(*cell, availableHorizontalSpace, availableVerticalSpace);
     103        layoutCell(*cell, availableHorizontalSpace);
    103104
    104105        auto computeIntrinsicVerticalPaddingForCell = [&] {
     
    247248    auto& tableBox = root();
    248249    auto sectionWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing();
    249     auto logicalTop = constraints.vertical.logicalTop;
     250    auto logicalTop = constraints.logicalTop();
    250251    auto verticalSpacing = grid.verticalSpacing();
    251252    auto paddingBefore = std::optional<LayoutUnit> { verticalSpacing };
     
    271272        sectionContentHeight += verticalSpacing * (rowCount - 1);
    272273        sectionBoxGeometry.setContentBoxHeight(sectionContentHeight);
    273         sectionBoxGeometry.setLogicalLeft(constraints.horizontal.logicalLeft);
     274        sectionBoxGeometry.setLogicalLeft(constraints.horizontal().logicalLeft);
    274275        sectionBoxGeometry.setLogicalTop(logicalTop);
    275276
     
    278279}
    279280
    280 void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace, std::optional<LayoutUnit> availableVerticalSpaceForContent)
     281void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace)
    281282{
    282283    ASSERT(cell.box().establishesBlockFormattingContext());
     
    306307    if (cellBox.hasInFlowOrFloatingChild()) {
    307308        auto constraintsForCellContent = formattingGeometry.constraintsForInFlowContent(cellBox);
    308         constraintsForCellContent.vertical.logicalHeight = availableVerticalSpaceForContent;
    309309        auto invalidationState = InvalidationState { };
    310         // FIXME: This should probably be part of the invalidation state to indicate when we re-layout the cell
    311         // multiple times as part of the multi-pass table algorithm.
     310        // 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.
    312311        auto& floatingStateForCellContent = layoutState().ensureBlockFormattingState(cellBox).floatingState();
    313312        floatingStateForCellContent.clear();
  • trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h

    r278279 r278292  
    7373
    7474    IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
    75     void layoutCell(const TableGrid::Cell&, LayoutUnit availableHorizontalSpace, std::optional<LayoutUnit> availableVerticalSpaceForContent = std::nullopt);
     75    void layoutCell(const TableGrid::Cell&, LayoutUnit availableHorizontalSpace);
    7676    void setUsedGeometryForCells(LayoutUnit availableHorizontalSpace);
    7777    void setUsedGeometryForRows(LayoutUnit availableHorizontalSpace);
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp

    r278253 r278292  
    217217    auto invalidationState = Layout::InvalidationState { };
    218218    auto horizontalConstraints = Layout::HorizontalConstraints { flow().borderAndPaddingStart(), flow().contentSize().width() };
    219     auto verticalConstraints = Layout::VerticalConstraints { flow().borderAndPaddingBefore(), { } };
    220 
    221     inlineFormattingContext.lineLayoutForIntergration(invalidationState, { horizontalConstraints, verticalConstraints });
     219
     220    inlineFormattingContext.lineLayoutForIntergration(invalidationState, { horizontalConstraints, flow().borderAndPaddingBefore() });
    222221
    223222    constructContent();
Note: See TracChangeset for help on using the changeset viewer.