Changeset 254927 in webkit
- Timestamp:
- Jan 22, 2020 9:07:27 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r254923 r254927 1 2020-01-22 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Do not create a FormattingContext unless there's content to layout. 4 https://bugs.webkit.org/show_bug.cgi?id=206570 5 <rdar://problem/58785735> 6 7 Reviewed by Antti Koivisto. 8 9 We still construct "no-op" FormattingContexts through the computeIntrinsicWidth* codepath (see webkit.org/b/206581). 10 11 * layout/FormattingContext.cpp: 12 (WebCore::Layout::FormattingContext::FormattingContext): 13 (WebCore::Layout::FormattingContext::layoutOutOfFlowContent): 14 * layout/blockformatting/BlockFormattingContext.cpp: 15 (WebCore::Layout::BlockFormattingContext::layoutInFlowContent): 16 * layout/inlineformatting/InlineFormattingContext.cpp: 17 (WebCore::Layout::InlineFormattingContext::layoutInFlowContent): 18 (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot): 19 * layout/tableformatting/TableFormattingContext.cpp: 20 (WebCore::Layout::TableFormattingContext::layoutTableCellBox): 21 1 22 2020-01-22 Antti Koivisto <antti@apple.com> 2 23 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r254407 r254927 164 164 computeBorderAndPadding(*outOfFlowBox, Geometry::horizontalConstraintsForInFlow(outOfFlowRootDisplayBox)); 165 165 computeOutOfFlowHorizontalGeometry(*outOfFlowBox, horizontalConstraints); 166 if (is<Container>(*outOfFlowBox)) { 167 auto& outOfFlowRootContainer = downcast<Container>(*outOfFlowBox); 168 auto formattingContext = LayoutContext::createFormattingContext(outOfFlowRootContainer, layoutState()); 166 if (!is<Container>(*outOfFlowBox) || !downcast<Container>(*outOfFlowBox).hasChild()) { 167 computeOutOfFlowVerticalGeometry(*outOfFlowBox, horizontalConstraints, verticalConstraints); 168 continue; 169 } 170 171 auto& outOfFlowRootContainer = downcast<Container>(*outOfFlowBox); 172 auto formattingContext = LayoutContext::createFormattingContext(outOfFlowRootContainer, layoutState()); 173 if (outOfFlowRootContainer.hasInFlowOrFloatingChild()) 169 174 formattingContext->layoutInFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(outOfFlowRootDisplayBox), Geometry::verticalConstraintsForInFlow(outOfFlowRootDisplayBox)); 170 computeOutOfFlowVerticalGeometry(outOfFlowRootContainer, horizontalConstraints, verticalConstraints); 171 172 formattingContext->layoutOutOfFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(outOfFlowRootDisplayBox), Geometry::verticalConstraintsForInFlow(outOfFlowRootDisplayBox)); 173 } else 174 computeOutOfFlowVerticalGeometry(*outOfFlowBox, horizontalConstraints, verticalConstraints); 175 computeOutOfFlowVerticalGeometry(outOfFlowRootContainer, horizontalConstraints, verticalConstraints); 176 formattingContext->layoutOutOfFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(outOfFlowRootDisplayBox), Geometry::verticalConstraintsForInFlow(outOfFlowRootDisplayBox)); 175 177 } 176 178 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow content -> context: " << &layoutState() << " root: " << &root()); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r254922 r254927 60 60 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> block formatting context -> formatting root(" << &root() << ")"); 61 61 auto& formattingRoot = root(); 62 ASSERT(formattingRoot.hasInFlowOrFloatingChild()); 62 63 auto floatingContext = FloatingContext { formattingRoot, *this, formattingState().floatingState() }; 63 64 … … 149 150 if (layoutBox.establishesFormattingContext()) { 150 151 // Now that we computed the root's height, we can layout the out-of-flow descendants. 151 if (is<Container>(layoutBox) ) {152 if (is<Container>(layoutBox) && downcast<Container>(layoutBox).hasChild()) { 152 153 auto& rootDisplayBox = geometryForBox(layoutBox); 153 154 auto horizontalConstraintsForOutOfFlow = Geometry::horizontalConstraintsForOutOfFlow(rootDisplayBox); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r254837 r254927 69 69 void InlineFormattingContext::layoutInFlowContent(InvalidationState& invalidationState, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints) 70 70 { 71 if (!root().hasInFlowOrFloatingChild())72 return;71 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")"); 72 ASSERT(root().hasInFlowOrFloatingChild()); 73 73 74 74 invalidateFormattingState(invalidationState); 75 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")");76 75 auto* layoutBox = root().firstInFlowOrFloatingChild(); 77 76 // 1. Visit each inline box and partially compute their geometry (margins, paddings and borders). … … 136 135 computeBorderAndPadding(formattingContextRoot, horizontalConstraints); 137 136 computeWidthAndMargin(formattingContextRoot, horizontalConstraints); 137 if (!is<Container>(formattingContextRoot) || !downcast<Container>(formattingContextRoot).hasChild()) { 138 computeHeightAndMargin(formattingContextRoot, horizontalConstraints); 139 return; 140 } 138 141 // Swich over to the new formatting context (the one that the root creates). 139 if (is<Container>(formattingContextRoot)) {140 auto& rootContainer = downcast<Container>(formattingContextRoot);141 auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState());142 auto& rootContainer = downcast<Container>(formattingContextRoot); 143 auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState()); 144 if (rootContainer.hasInFlowOrFloatingChild()) 142 145 formattingContext->layoutInFlowContent(invalidationState, horizontalConstraints, verticalConstraints); 143 // Come back and finalize the root's height and margin. 144 computeHeightAndMargin(rootContainer, horizontalConstraints); 145 // Now that we computed the root's height, we can go back and layout the out-of-flow content. 146 // Come back and finalize the root's height and margin. 147 computeHeightAndMargin(rootContainer, horizontalConstraints); 148 // Now that we computed the root's height, we can go back and layout the out-of-flow content. 149 if (rootContainer.hasChild()) { 146 150 auto& rootContainerDisplayBox = geometryForBox(rootContainer); 147 151 auto horizontalConstraintsForOutOfFlow = Geometry::horizontalConstraintsForOutOfFlow(rootContainerDisplayBox); 148 152 auto verticalConstraintsForOutOfFlow = Geometry::verticalConstraintsForOutOfFlow(rootContainerDisplayBox); 149 153 formattingContext->layoutOutOfFlowContent(invalidationState, horizontalConstraintsForOutOfFlow, verticalConstraintsForOutOfFlow); 150 } else 151 computeHeightAndMargin(formattingContextRoot, horizontalConstraints); 154 } 152 155 } 153 156 -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp
r254666 r254927 112 112 113 113 ASSERT(cellLayoutBox.establishesBlockFormattingContext()); 114 if (is<Container>(cellLayoutBox) )114 if (is<Container>(cellLayoutBox) && downcast<Container>(cellLayoutBox).hasInFlowOrFloatingChild()) 115 115 LayoutContext::createFormattingContext(downcast<Container>(cellLayoutBox), layoutState())->layoutInFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(cellDisplayBox), Geometry::verticalConstraintsForInFlow(cellDisplayBox)); 116 116 cellDisplayBox.setVerticalMargin({ { }, { } });
Note: See TracChangeset
for help on using the changeset viewer.