Changeset 278292 in webkit
- Timestamp:
- May 31, 2021, 7:41:01 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 20 edited
-
ChangeLog (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
layout/LayoutContext.cpp (modified) (1 diff)
-
layout/LayoutUnits.h (modified) (2 diffs)
-
layout/formattingContexts/FormattingConstraints.h (added)
-
layout/formattingContexts/FormattingContext.cpp (modified) (1 diff)
-
layout/formattingContexts/FormattingContext.h (modified) (2 diffs)
-
layout/formattingContexts/FormattingGeometry.cpp (modified) (7 diffs)
-
layout/formattingContexts/FormattingQuirks.cpp (modified) (1 diff)
-
layout/formattingContexts/block/BlockFormattingContext.cpp (modified) (15 diffs)
-
layout/formattingContexts/block/BlockFormattingContext.h (modified) (2 diffs)
-
layout/formattingContexts/block/BlockFormattingGeometry.cpp (modified) (3 diffs)
-
layout/formattingContexts/block/BlockFormattingGeometry.h (modified) (1 diff)
-
layout/formattingContexts/block/BlockFormattingQuirks.cpp (modified) (1 diff)
-
layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp (modified) (1 diff)
-
layout/formattingContexts/block/tablewrapper/TableWrapperBlockFormattingContext.cpp (modified) (4 diffs)
-
layout/formattingContexts/flex/FlexFormattingContext.cpp (modified) (3 diffs)
-
layout/formattingContexts/inline/InlineFormattingContext.cpp (modified) (6 diffs)
-
layout/formattingContexts/table/TableFormattingConstraints.h (added)
-
layout/formattingContexts/table/TableFormattingContext.cpp (modified) (7 diffs)
-
layout/formattingContexts/table/TableFormattingContext.h (modified) (1 diff)
-
layout/integration/LayoutIntegrationLineLayout.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r278291 r278292 1 2021-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 1 49 2021-05-31 Aakash Jain <aakash_jain@apple.com> 2 50 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r278290 r278292 2135 2135 6F17264F2470C60B00518C96 /* TableWrapperBlockFormattingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F17264E2470C60A00518C96 /* TableWrapperBlockFormattingContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2136 2136 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, ); }; }; 2137 2139 6F26BB6C23343E6F002F2BEA /* LayoutContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26BB6B23343E5B002F2BEA /* LayoutContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2138 2140 6F26EB48234004A5006906E2 /* InlineLineBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F26EB46234004A5006906E2 /* InlineLineBuilder.h */; }; … … 9994 9996 6F1CC1DC225F8B4100720AD2 /* InlineTextItem.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InlineTextItem.cpp; sourceTree = "<group>"; }; 9995 9997 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>"; }; 9996 10000 6F222B741AB52D640094651A /* WebGLVertexArrayObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGLVertexArrayObjectBase.h; sourceTree = "<group>"; }; 9997 10001 6F222B751AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLVertexArrayObjectBase.cpp; sourceTree = "<group>"; }; … … 22734 22738 115CFA9A208BC140001E6991 /* inline */, 22735 22739 6FC5CA9122E3593300B13E11 /* table */, 22740 6F1E83A52665888C002E9D28 /* FormattingConstraints.h */, 22736 22741 115CFA69208AF7D0001E6991 /* FormattingContext.cpp */, 22737 22742 115CFA68208AF7D0001E6991 /* FormattingContext.h */, … … 22771 22776 isa = PBXGroup; 22772 22777 children = ( 22778 6F1E83A02665884C002E9D28 /* TableFormattingConstraints.h */, 22773 22779 6FC5CA9422E3599400B13E11 /* TableFormattingContext.cpp */, 22774 22780 6FC5CA9522E3599400B13E11 /* TableFormattingContext.h */, … … 32729 32735 D05CED2A0A40BB2C00C5AF38 /* FormatBlockCommand.h in Headers */, 32730 32736 7CE6CBFB187F370700D46BF5 /* FormatConverter.h in Headers */, 32737 6F1E83A62665888C002E9D28 /* FormattingConstraints.h in Headers */, 32731 32738 115CFA6A208AF7D0001E6991 /* FormattingContext.h in Headers */, 32732 32739 475C89A42650AC3C00F3B456 /* FormattingGeometry.h in Headers */, … … 35649 35656 E3C0412F254CA29B0021D0E6 /* SystemSoundManager.h in Headers */, 35650 35657 5D5975B319635F1100D00878 /* SystemVersion.h in Headers */, 35658 6F1E83A22665884C002E9D28 /* TableFormattingConstraints.h in Headers */, 35651 35659 47FA97002650982B00841416 /* TableFormattingGeometry.h in Headers */, 35652 35660 6F49C3E726479B3C0051953D /* TableFormattingQuirks.h in Headers */, -
trunk/Source/WebCore/layout/LayoutContext.cpp
r277570 r278292 101 101 102 102 if (formattingContextRoot.hasInFlowOrFloatingChild()) { 103 auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), { } }};103 auto constraintsForInFlowContent = ConstraintsForInFlowContent { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() }; 104 104 formattingContext->layoutInFlowContent(invalidationState, constraintsForInFlowContent); 105 105 } -
trunk/Source/WebCore/layout/LayoutUnits.h
r278253 r278292 158 158 }; 159 159 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 195 160 struct OverriddenHorizontalValues { 196 161 std::optional<LayoutUnit> width; … … 232 197 } 233 198 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 266 199 struct SlotPosition { 267 200 SlotPosition() = default; -
trunk/Source/WebCore/layout/formattingContexts/FormattingContext.cpp
r278253 r278292 107 107 }; 108 108 109 auto containingBlockHeight = *constraints.vertical.logicalHeight;109 auto containingBlockHeight = constraints.vertical.logicalHeight; 110 110 auto verticalGeometry = compute({ }); 111 111 if (auto maxHeight = formattingGeometry().computedMaxHeight(layoutBox, containingBlockHeight)) { -
trunk/Source/WebCore/layout/formattingContexts/FormattingContext.h
r278253 r278292 28 28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 29 30 #include "FormattingConstraints.h" 30 31 #include "LayoutContainerBox.h" 31 32 #include "LayoutUnit.h" … … 43 44 class BoxGeometry; 44 45 class ContainerBox; 46 struct ConstraintsForInFlowContent; 47 struct ConstraintsForOutOfFlowContent; 48 struct HorizontalConstraints; 45 49 class FormattingGeometry; 46 50 class FormattingState; 47 51 class FormattingQuirks; 52 struct IntrinsicWidthConstraints; 48 53 class InvalidationState; 49 54 class LayoutState; -
trunk/Source/WebCore/layout/formattingContexts/FormattingGeometry.cpp
r278253 r278292 325 325 { 326 326 ASSERT(layoutBox.isOutOfFlowPositioned() && !layoutBox.isReplacedBox()); 327 ASSERT(verticalConstraints.logicalHeight);328 327 329 328 // 10.6.4 Absolutely positioned, non-replaced elements … … 354 353 auto& style = layoutBox.style(); 355 354 auto& boxGeometry = formattingContext.geometryForBox(layoutBox); 356 auto containingBlockHeight = *verticalConstraints.logicalHeight;355 auto containingBlockHeight = verticalConstraints.logicalHeight; 357 356 auto containingBlockWidth = horizontalConstraints.logicalWidth; 358 357 … … 587 586 { 588 587 ASSERT(replacedBox.isOutOfFlowPositioned()); 589 ASSERT(verticalConstraints.logicalHeight);590 588 591 589 // 10.6.5 Absolutely positioned, replaced elements … … 602 600 auto& style = replacedBox.style(); 603 601 auto& boxGeometry = formattingContext.geometryForBox(replacedBox); 604 auto containingBlockHeight = *verticalConstraints.logicalHeight;602 auto containingBlockHeight = verticalConstraints.logicalHeight; 605 603 auto containingBlockWidth = horizontalConstraints.logicalWidth; 606 604 … … 922 920 auto& style = replacedBox.style(); 923 921 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); 925 923 auto heightIsAuto = !overriddenVerticalValues.height && isHeightAuto(replacedBox); 926 924 auto widthIsAuto = style.logicalWidth().isAuto(); … … 984 982 auto width = overriddenHorizontalValues.width ? overriddenHorizontalValues.width : computedWidth(replacedBox, horizontalConstraints.logicalWidth); 985 983 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); 987 985 988 986 if (!width && heightIsAuto && replacedBox.hasIntrinsicWidth()) { … … 1169 1167 { 1170 1168 auto& boxGeometry = formattingContext().geometryForBox(containerBox, escapeReason); 1171 return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), computedHeight(containerBox) }};1169 return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, boxGeometry.contentBoxTop() }; 1172 1170 } 1173 1171 -
trunk/Source/WebCore/layout/formattingContexts/FormattingQuirks.cpp
r278185 r278292 59 59 if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) { 60 60 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(); 62 62 auto verticalMargin = formattingGeometry.computedVerticalMargin(*containingBlock, horizontalConstraints); 63 63 -
trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.cpp
r278253 r278292 117 117 auto containingBlockConstraints = constraintsForLayoutBox(layoutBox); 118 118 119 computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal );120 computeStaticVerticalPosition(layoutBox, containingBlockConstraints. vertical);119 computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal()); 120 computeStaticVerticalPosition(layoutBox, containingBlockConstraints.logicalTop()); 121 121 computeWidthAndMargin(floatingContext, layoutBox, { constraints, containingBlockConstraints }); 122 computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal );122 computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal()); 123 123 computePositionToAvoidFloats(floatingContext, layoutBox, { constraints, containingBlockConstraints }); 124 124 … … 133 133 auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState()); 134 134 if (containerBox.isTableWrapperBox()) 135 downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal );135 downcast<TableWrapperBlockFormattingContext>(*formattingContext).setHorizontalConstraintsIgnoringFloats(containingBlockConstraints.horizontal()); 136 136 formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(containerBox)); 137 137 } … … 157 157 auto& formattingState = this->formattingState(); 158 158 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())); 160 160 } 161 161 } … … 169 169 } 170 170 if (!establishesFormattingContext && is<ContainerBox>(layoutBox)) 171 placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal );171 placeInFlowPositionedChildren(downcast<ContainerBox>(layoutBox), containingBlockConstraints.horizontal()); 172 172 173 173 if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling)) … … 176 176 } 177 177 // Place the inflow positioned children. 178 placeInFlowPositionedChildren(formattingRoot, constraints.horizontal );178 placeInFlowPositionedChildren(formattingRoot, constraints.horizontal()); 179 179 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")"); 180 180 } … … 248 248 return { }; 249 249 // 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; 251 251 if (constraints.left) 252 252 availableWidth -= constraints.left->x; 253 253 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); 255 255 return availableWidth; 256 256 } … … 268 268 } 269 269 270 void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints)271 { 272 formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, verticalConstraints));270 void BlockFormattingContext::computeStaticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop) 271 { 272 formattingState().boxGeometry(layoutBox).setLogicalTop(formattingGeometry().staticVerticalPosition(layoutBox, containingBlockContentBoxTop)); 273 273 } 274 274 … … 297 297 }(); 298 298 299 auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal );299 auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal()); 300 300 auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.value_or(0), computedVerticalMargin.after.value_or(0) }; 301 301 auto precomputedMarginBefore = marginCollapse().precomputedMarginBefore(*ancestor, usedNonCollapsedMargin, formattingGeometry); … … 308 308 formattingState().setUsedVerticalMargin(*ancestor, verticalMargin); 309 309 boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) }); 310 boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor. vertical));310 boxGeometry.setLogicalTop(verticalPositionWithMargin(*ancestor, verticalMargin, constraintsForAncestor.logicalTop())); 311 311 #if ASSERT_ENABLED 312 312 setPrecomputedMarginBefore(*ancestor, precomputedMarginBefore); … … 326 326 if (layoutBox.isFloatingPositioned()) { 327 327 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())); 329 329 return; 330 330 } … … 337 337 338 338 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())); 340 340 } 341 341 … … 364 364 availableWidthFloatAvoider = usedAvailableWidthForFloatAvoider(floatingContext, layoutBox, constraintsPair); 365 365 } 366 auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal , availableWidthFloatAvoider);366 auto contentWidthAndMargin = formattingGeometry().computedContentWidthAndMargin(layoutBox, constraintsPair.containingBlock.horizontal(), availableWidthFloatAvoider); 367 367 auto& boxGeometry = formattingState().boxGeometry(layoutBox); 368 368 boxGeometry.setContentBoxWidth(contentWidthAndMargin.contentWidth); … … 374 374 auto compute = [&](std::optional<LayoutUnit> usedHeight) -> ContentHeightAndMargin { 375 375 if (layoutBox.isInFlow()) 376 return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal , { usedHeight });376 return formattingGeometry().inFlowContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight }); 377 377 378 378 if (layoutBox.isFloatingPositioned()) 379 return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal , { usedHeight });379 return formattingGeometry().floatingContentHeightAndMargin(layoutBox, constraints.horizontal(), { usedHeight }); 380 380 381 381 ASSERT_NOT_REACHED(); … … 504 504 } 505 505 506 LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin, const VerticalConstraints& verticalConstraints) const506 LayoutUnit BlockFormattingContext::verticalPositionWithMargin(const Box& layoutBox, const UsedVerticalMargin& verticalMargin, LayoutUnit containingBlockContentBoxTop) const 507 507 { 508 508 ASSERT(!layoutBox.isOutOfFlowPositioned()); … … 533 533 } 534 534 535 auto containingBlockContentBoxTop = verticalConstraints.logicalTop;536 535 // Adjust vertical position depending whether this box directly or indirectly adjoins with its parent. 537 536 auto directlyAdjoinsParent = !layoutBox.previousInFlowSibling(); -
trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingContext.h
r278253 r278292 70 70 71 71 void computeStaticHorizontalPosition(const Box&, const HorizontalConstraints&); 72 void computeStaticVerticalPosition(const Box&, const VerticalConstraints&);72 void computeStaticVerticalPosition(const Box&, LayoutUnit containingBlockContentBoxTop); 73 73 void computePositionToAvoidFloats(const FloatingContext&, const Box&, const ConstraintsPair&); 74 74 void computeVerticalPositionForFloatClear(const FloatingContext&, const Box&); … … 78 78 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override; 79 79 80 LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, const VerticalConstraints&) const;80 LayoutUnit verticalPositionWithMargin(const Box&, const UsedVerticalMargin&, LayoutUnit containingBlockContentBoxTop) const; 81 81 82 82 std::optional<LayoutUnit> usedAvailableWidthForFloatAvoider(const FloatingContext&, const Box&, const ConstraintsPair&); -
trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp
r278253 r278292 238 238 } 239 239 240 LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, const VerticalConstraints& verticalConstraints) const240 LayoutUnit BlockFormattingGeometry::staticVerticalPosition(const Box& layoutBox, LayoutUnit containingBlockContentBoxTop) const 241 241 { 242 242 // https://www.w3.org/TR/CSS22/visuren.html#block-formatting … … 248 248 return BoxGeometry::borderBoxRect(previousInFlowBoxGeometry).bottom() + previousInFlowBoxGeometry.marginAfter(); 249 249 } 250 return verticalConstraints.logicalTop;250 return containingBlockContentBoxTop; 251 251 } 252 252 … … 256 256 // 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). 257 257 return horizontalConstraints.logicalLeft + formattingContext().geometryForBox(layoutBox).marginStart(); 258 }259 260 Point BlockFormattingGeometry::staticPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) const261 {262 return { staticHorizontalPosition(layoutBox, horizontalConstraints), staticVerticalPosition(layoutBox, verticalConstraints) };263 258 } 264 259 -
trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.h
r278253 r278292 45 45 ContentWidthAndMargin inFlowContentWidthAndMargin(const Box&, const HorizontalConstraints&, const OverriddenHorizontalValues&) const; 46 46 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; 49 48 LayoutUnit staticHorizontalPosition(const Box&, const HorizontalConstraints&) const; 50 49 -
trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingQuirks.cpp
r278253 r278292 100 100 if (documentBox.isInFlow()) { 101 101 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()); 103 103 bodyBoxContentHeight -= precomputeDocumentBoxVerticalMargin.before.value_or(0) + precomputeDocumentBoxVerticalMargin.after.value_or(0); 104 104 } -
trunk/Source/WebCore/layout/formattingContexts/block/PrecomputedBlockMarginCollapse.cpp
r278185 r278292 47 47 return blockFormattingState.usedVerticalMargin(layoutBox).positiveAndNegativeValues.before; 48 48 49 auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal ;49 auto horizontalConstraints = formattingGeometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal(); 50 50 auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(layoutBox, horizontalConstraints); 51 51 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 37 37 #include "LayoutContext.h" 38 38 #include "LayoutInitialContainingBlock.h" 39 #include "TableFormattingConstraints.h" 39 40 #include "TableFormattingContext.h" 40 41 #include "TableFormattingState.h" … … 73 74 layoutState().ensureTableFormattingState(tableBox); 74 75 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()); 79 80 80 81 if (tableBox.hasChild()) { 82 auto& formattingGeometry = this->formattingGeometry(); 81 83 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); 83 86 } 84 87 … … 230 233 }(); 231 234 232 auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal , { overriddenTableHeight });235 auto heightAndMargin = formattingGeometry().inFlowContentHeightAndMargin(tableBox, constraints.horizontal(), { overriddenTableHeight }); 233 236 auto verticalMargin = marginCollapse().collapsedVerticalValues(tableBox, heightAndMargin.nonCollapsedMargin); 234 237 // Cache the computed positive and negative margin value pair. … … 236 239 237 240 auto& boxGeometry = formattingState().boxGeometry(tableBox); 238 boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints. vertical));241 boxGeometry.setLogicalTop(verticalPositionWithMargin(tableBox, verticalMargin, constraints.logicalTop())); 239 242 boxGeometry.setContentBoxHeight(heightAndMargin.contentHeight); 240 243 boxGeometry.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) }); -
trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp
r278185 r278292 71 71 auto& formattingState = this->formattingState(); 72 72 auto& formattingGeometry = this->formattingGeometry(); 73 auto flexItemMainAxisStart = constraints.horizontal .logicalLeft;73 auto flexItemMainAxisStart = constraints.horizontal().logicalLeft; 74 74 auto flexItemMainAxisEnd = flexItemMainAxisStart; 75 auto flexItemCrosAxisStart = constraints. vertical.logicalTop;75 auto flexItemCrosAxisStart = constraints.logicalTop(); 76 76 auto flexItemCrosAxisEnd = flexItemCrosAxisStart; 77 77 for (auto& flexItem : childrenOfType<ContainerBox>(root())) { … … 79 79 // FIXME: This is just a simple, let's layout the flex items and place them next to each other setup. 80 80 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); 82 82 auto flexItemConstraints = ConstraintsForInFlowContent { { { }, flexItemLogicalWidth }, { } }; 83 83 … … 91 91 92 92 flexItemGeometry.setBorder(formattingGeometry.computedBorder(flexItem)); 93 flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal .logicalWidth));93 flexItemGeometry.setPadding(formattingGeometry.computedPadding(flexItem, constraints.horizontal().logicalWidth)); 94 94 95 auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal );95 auto computedHorizontalMargin = formattingGeometry.computedHorizontalMargin(flexItem, constraints.horizontal()); 96 96 flexItemGeometry.setHorizontalMargin({ computedHorizontalMargin.start.value_or(0_lu), computedHorizontalMargin.end.value_or(0_lu) }); 97 97 98 auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal );98 auto computedVerticalMargin = formattingGeometry.computedVerticalMargin(flexItem, constraints.horizontal()); 99 99 flexItemGeometry.setVerticalMargin({ computedVerticalMargin.before.value_or(0_lu), computedVerticalMargin.after.value_or(0_lu) }); 100 100 -
trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp
r278253 r278292 99 99 ASSERT(layoutBox->isInlineBlockBox() || layoutBox->isInlineTableBox() || layoutBox->isFloatingPositioned()); 100 100 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()); 103 103 104 104 if (formattingRoot.hasChild()) { … … 106 106 if (formattingRoot.hasInFlowOrFloatingChild()) 107 107 formattingContext->layoutInFlowContent(invalidationState, formattingGeometry().constraintsForInFlowContent(formattingRoot)); 108 computeHeightAndMargin(formattingRoot, constraints.horizontal );108 computeHeightAndMargin(formattingRoot, constraints.horizontal()); 109 109 formattingContext->layoutOutOfFlowContent(invalidationState, formattingGeometry().constraintsForOutOfFlowContent(formattingRoot)); 110 110 } else 111 computeHeightAndMargin(formattingRoot, constraints.horizontal );111 computeHeightAndMargin(formattingRoot, constraints.horizontal()); 112 112 } else { 113 113 // 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()); 117 117 } 118 118 } else if (layoutBox->isLineBreakBox()) { … … 127 127 if (!layoutBox->isInlineTextBox()) { 128 128 // 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()); 131 131 formattingState().boxGeometry(*layoutBox).setVerticalMargin({ }); 132 132 } … … 179 179 auto& formattingState = this->formattingState(); 180 180 formattingState.lineRuns().reserveInitialCapacity(formattingState.inlineItems().size()); 181 InlineLayoutUnit lineLogicalTop = constraints. vertical.logicalTop;181 InlineLayoutUnit lineLogicalTop = constraints.logicalTop(); 182 182 struct PreviousLine { 183 183 LineBuilder::InlineItemRange range; … … 190 190 auto isFirstLine = formattingState.lines().isEmpty(); 191 191 192 auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal , inlineItems };192 auto lineBuilder = LineBuilder { *this, floatingState, constraints.horizontal(), inlineItems }; 193 193 while (!needsLayoutRange.isEmpty()) { 194 194 // Turn previous line's overflow content length into the next line's leading content partial length. … … 201 201 return formattingQuirks().initialLineHeight(); 202 202 }(); 203 auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal .logicalLeft, constraints.horizontal.logicalWidth, initialLineHeight };203 auto initialLineConstraints = InlineRect { lineLogicalTop, constraints.horizontal().logicalLeft, constraints.horizontal().logicalWidth, initialLineHeight }; 204 204 auto lineContent = lineBuilder.layoutInlineContent(needsLayoutRange, partialLeadingContentLength, leadingLogicalWidth, initialLineConstraints, isFirstLine); 205 auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal );205 auto lineLogicalRect = computeGeometryForLineContent(lineContent, constraints.horizontal()); 206 206 207 207 auto lineContentRange = lineContent.inlineItemRange; -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.cpp
r278279 r278292 38 38 #include "LayoutContext.h" 39 39 #include "LayoutInitialContainingBlock.h" 40 #include "TableFormattingConstraints.h" 40 41 #include "TableFormattingState.h" 41 42 #include <wtf/IsoMallocInlines.h> … … 56 57 void TableFormattingContext::layoutInFlowContent(InvalidationState&, const ConstraintsForInFlowContent& constraints) 57 58 { 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(); 60 61 // 1. Compute width and height for the grid. 61 62 computeAndDistributeExtraSpace(availableHorizontalSpace, availableVerticalSpace); … … 100 101 availableVerticalSpace += rowList[rowIndex].logicalHeight(); 101 102 availableVerticalSpace += (cell->rowSpan() - 1) * grid.verticalSpacing(); 102 layoutCell(*cell, availableHorizontalSpace , availableVerticalSpace);103 layoutCell(*cell, availableHorizontalSpace); 103 104 104 105 auto computeIntrinsicVerticalPaddingForCell = [&] { … … 247 248 auto& tableBox = root(); 248 249 auto sectionWidth = grid.columns().logicalWidth() + 2 * grid.horizontalSpacing(); 249 auto logicalTop = constraints. vertical.logicalTop;250 auto logicalTop = constraints.logicalTop(); 250 251 auto verticalSpacing = grid.verticalSpacing(); 251 252 auto paddingBefore = std::optional<LayoutUnit> { verticalSpacing }; … … 271 272 sectionContentHeight += verticalSpacing * (rowCount - 1); 272 273 sectionBoxGeometry.setContentBoxHeight(sectionContentHeight); 273 sectionBoxGeometry.setLogicalLeft(constraints.horizontal .logicalLeft);274 sectionBoxGeometry.setLogicalLeft(constraints.horizontal().logicalLeft); 274 275 sectionBoxGeometry.setLogicalTop(logicalTop); 275 276 … … 278 279 } 279 280 280 void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace , std::optional<LayoutUnit> availableVerticalSpaceForContent)281 void TableFormattingContext::layoutCell(const TableGrid::Cell& cell, LayoutUnit availableHorizontalSpace) 281 282 { 282 283 ASSERT(cell.box().establishesBlockFormattingContext()); … … 306 307 if (cellBox.hasInFlowOrFloatingChild()) { 307 308 auto constraintsForCellContent = formattingGeometry.constraintsForInFlowContent(cellBox); 308 constraintsForCellContent.vertical.logicalHeight = availableVerticalSpaceForContent;309 309 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. 312 311 auto& floatingStateForCellContent = layoutState().ensureBlockFormattingState(cellBox).floatingState(); 313 312 floatingStateForCellContent.clear(); -
trunk/Source/WebCore/layout/formattingContexts/table/TableFormattingContext.h
r278279 r278292 73 73 74 74 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); 76 76 void setUsedGeometryForCells(LayoutUnit availableHorizontalSpace); 77 77 void setUsedGeometryForRows(LayoutUnit availableHorizontalSpace); -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp
r278253 r278292 217 217 auto invalidationState = Layout::InvalidationState { }; 218 218 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() }); 222 221 223 222 constructContent();
Note:
See TracChangeset
for help on using the changeset viewer.