Changeset 237634 in webkit
- Timestamp:
- Oct 31, 2018, 6:51:56 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContext.cpp (modified) (8 diffs)
-
layout/FormattingContext.h (modified) (4 diffs)
-
layout/FormattingContextGeometry.cpp (modified) (1 diff)
-
layout/LayoutFormattingState.cpp (modified) (1 diff)
-
layout/blockformatting/BlockFormattingContext.cpp (modified) (19 diffs)
-
layout/blockformatting/BlockFormattingContext.h (modified) (1 diff)
-
layout/inlineformatting/InlineFormattingContext.cpp (modified) (15 diffs)
-
layout/inlineformatting/InlineFormattingContext.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r237633 r237634 1 2018-10-31 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Do not pass LayoutState& to compute* and layout* functions 4 https://bugs.webkit.org/show_bug.cgi?id=191100 5 6 Reviewed by Antti Koivisto. 7 8 Reduce noise by removing LayoutState& parameter where possible. 9 10 * layout/FormattingContext.cpp: 11 (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const): 12 (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const): 13 (WebCore::Layout::FormattingContext::computeBorderAndPadding const): 14 (WebCore::Layout::FormattingContext::placeInFlowPositionedChildren const): 15 (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): 16 (WebCore::Layout::FormattingContext::validateGeometryConstraintsAfterLayout const): 17 * layout/FormattingContext.h: 18 * layout/FormattingContextGeometry.cpp: 19 (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth): 20 * layout/LayoutFormattingState.cpp: 21 (WebCore::Layout::LayoutState::layoutFormattingContextSubtree): 22 * layout/blockformatting/BlockFormattingContext.cpp: 23 (WebCore::Layout::BlockFormattingContext::layout const): 24 (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const): 25 (WebCore::Layout::BlockFormattingContext::computeStaticPosition const): 26 (WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTop const): 27 (WebCore::Layout::BlockFormattingContext::computeEstimatedMarginTopForAncestors const): 28 (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForFormattingRootIfNeeded const): 29 (WebCore::Layout::BlockFormattingContext::computeFloatingPosition const): 30 (WebCore::Layout::BlockFormattingContext::computePositionToAvoidFloats const): 31 (WebCore::Layout::BlockFormattingContext::computeVerticalPositionForFloatClear const): 32 (WebCore::Layout::BlockFormattingContext::computeInFlowPositionedPosition const): 33 (WebCore::Layout::BlockFormattingContext::computeWidthAndMargin const): 34 (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const): 35 (WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const): 36 * layout/blockformatting/BlockFormattingContext.h: 37 * layout/inlineformatting/InlineFormattingContext.cpp: 38 (WebCore::Layout::InlineFormattingContext::layout const): 39 (WebCore::Layout::InlineFormattingContext::initializeNewLine const): 40 (WebCore::Layout::InlineFormattingContext::layoutInlineContent const): 41 (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const): 42 (WebCore::Layout::InlineFormattingContext::computeWidthAndHeightForInlineBox const): 43 (WebCore::Layout::InlineFormattingContext::computeFloatPosition const): 44 (WebCore::Layout::InlineFormattingContext::computeStaticPosition const): 45 (WebCore::Layout::InlineFormattingContext::computeInFlowPositionedPosition const): 46 (WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const): 47 * layout/inlineformatting/InlineFormattingContext.h: 48 1 49 2018-10-31 Zalan Bujtas <zalan@apple.com> 2 50 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r237633 r237634 64 64 } 65 65 66 void FormattingContext::computeOutOfFlowHorizontalGeometry(LayoutState& layoutState, const Box& layoutBox) const 67 { 66 void FormattingContext::computeOutOfFlowHorizontalGeometry(const Box& layoutBox) const 67 { 68 auto& layoutState = this->layoutState(); 69 68 70 auto compute = [&](std::optional<LayoutUnit> usedWidth) { 69 71 return Geometry::outOfFlowHorizontalGeometry(layoutState, *this, layoutBox, usedWidth); … … 92 94 } 93 95 94 void FormattingContext::computeOutOfFlowVerticalGeometry(const LayoutState& layoutState, const Box& layoutBox) const 95 { 96 void FormattingContext::computeOutOfFlowVerticalGeometry(const Box& layoutBox) const 97 { 98 auto& layoutState = this->layoutState(); 99 96 100 auto compute = [&](std::optional<LayoutUnit> usedHeight) { 97 101 return Geometry::outOfFlowVerticalGeometry(layoutState, layoutBox, usedHeight); … … 119 123 } 120 124 121 void FormattingContext::computeBorderAndPadding(const LayoutState& layoutState, const Box& layoutBox) const 122 { 125 void FormattingContext::computeBorderAndPadding(const Box& layoutBox) const 126 { 127 auto& layoutState = this->layoutState(); 123 128 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); 124 129 displayBox.setBorder(Geometry::computedBorder(layoutState, layoutBox)); … … 126 131 } 127 132 128 void FormattingContext::placeInFlowPositionedChildren(const LayoutState& layoutState, constContainer& container) const133 void FormattingContext::placeInFlowPositionedChildren(const Container& container) const 129 134 { 130 135 // If this container also establishes a formatting context, then positioning already has happend in that the formatting context. … … 132 137 return; 133 138 134 LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> context: " << &layoutState << "parent: " << &container);139 LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: move in-flow positioned children -> parent: " << &container); 135 140 for (auto& layoutBox : childrenOfType<Box>(container)) { 136 141 if (!layoutBox.isInFlowPositioned()) 137 142 continue; 138 computeInFlowPositionedPosition(layout State, layoutBox);139 } 140 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> context: " << &layoutState << "parent: " << &container);141 } 142 143 void FormattingContext::layoutOutOfFlowDescendants( LayoutState& layoutState,const Box& layoutBox) const143 computeInFlowPositionedPosition(layoutBox); 144 } 145 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: move in-flow positioned children -> parent: " << &container); 146 } 147 148 void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const 144 149 { 145 150 // Initial containing block by definition is a containing block. … … 154 159 return; 155 160 161 auto& layoutState = this->layoutState(); 156 162 LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: layout out-of-flow descendants -> context: " << &layoutState << " root: " << &root()); 157 163 … … 161 167 ASSERT(layoutBox.establishesFormattingContext()); 162 168 163 computeBorderAndPadding(layoutState, layoutBox); 164 computeOutOfFlowHorizontalGeometry(layoutState, layoutBox); 165 166 auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox); 167 formattingState.formattingContext(layoutBox)->layout(layoutState, formattingState); 168 169 computeOutOfFlowVerticalGeometry(layoutState, layoutBox); 170 layoutOutOfFlowDescendants(layoutState, layoutBox); 169 computeBorderAndPadding(layoutBox); 170 computeOutOfFlowHorizontalGeometry(layoutBox); 171 172 layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox).formattingContext(layoutBox)->layout(); 173 174 computeOutOfFlowVerticalGeometry(layoutBox); 175 layoutOutOfFlowDescendants(layoutBox); 171 176 } 172 177 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutState << " root: " << &root()); … … 216 221 217 222 #ifndef NDEBUG 218 void FormattingContext::validateGeometryConstraintsAfterLayout( const LayoutState& layoutState) const223 void FormattingContext::validateGeometryConstraintsAfterLayout() const 219 224 { 220 225 if (!is<Container>(root())) 221 226 return; 222 227 auto& formattingContextRoot = downcast<Container>(root()); 228 auto& layoutState = this->layoutState(); 223 229 // FIXME: add a descendantsOfType<> flavor that stops at nested formatting contexts 224 230 for (auto& layoutBox : descendantsOfType<Box>(formattingContextRoot)) { -
trunk/Source/WebCore/layout/FormattingContext.h
r237633 r237634 50 50 virtual ~FormattingContext(); 51 51 52 virtual void layout( LayoutState&, FormattingState&) const = 0;53 void layoutOutOfFlowDescendants( LayoutState&,const Box&) const;52 virtual void layout() const = 0; 53 void layoutOutOfFlowDescendants(const Box&) const; 54 54 55 55 struct InstrinsicWidthConstraints { … … 57 57 LayoutUnit maximum; 58 58 }; 59 virtual InstrinsicWidthConstraints instrinsicWidthConstraints( LayoutState&,const Box&) const = 0;59 virtual InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const = 0; 60 60 61 61 static Display::Box mapBoxToAncestor(const LayoutState&, const Box&, const Container& ancestor); … … 70 70 const Box& root() const { return *m_root; } 71 71 72 virtual void computeStaticPosition(const LayoutState&, constBox&) const = 0;73 virtual void computeInFlowPositionedPosition(const LayoutState&, constBox&) const = 0;72 virtual void computeStaticPosition(const Box&) const = 0; 73 virtual void computeInFlowPositionedPosition(const Box&) const = 0; 74 74 75 void computeBorderAndPadding(const LayoutState&, constBox&) const;75 void computeBorderAndPadding(const Box&) const; 76 76 77 void placeInFlowPositionedChildren(const LayoutState&, constContainer&) const;77 void placeInFlowPositionedChildren(const Container&) const; 78 78 79 79 #ifndef NDEBUG 80 virtual void validateGeometryConstraintsAfterLayout( const LayoutState&) const;80 virtual void validateGeometryConstraintsAfterLayout() const; 81 81 #endif 82 82 … … 124 124 125 125 private: 126 void computeOutOfFlowVerticalGeometry(const LayoutState&, constBox&) const;127 void computeOutOfFlowHorizontalGeometry( LayoutState&,const Box&) const;126 void computeOutOfFlowVerticalGeometry(const Box&) const; 127 void computeOutOfFlowHorizontalGeometry(const Box&) const; 128 128 129 129 WeakPtr<const Box> m_root; -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r237631 r237634 211 211 // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width). 212 212 auto availableWidth = layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).width(); 213 auto instrinsicWidthConstraints = formattingContext.instrinsicWidthConstraints(layout State, layoutBox);213 auto instrinsicWidthConstraints = formattingContext.instrinsicWidthConstraints(layoutBox); 214 214 return std::min(std::max(instrinsicWidthConstraints.minimum, availableWidth), instrinsicWidthConstraints.maximum); 215 215 } -
trunk/Source/WebCore/layout/LayoutFormattingState.cpp
r237632 r237634 84 84 auto& formattingState = createFormattingStateForFormattingRootIfNeeded(layoutRoot); 85 85 auto formattingContext = formattingState.formattingContext(layoutRoot); 86 formattingContext->layout( *this, formattingState);87 formattingContext->layoutOutOfFlowDescendants( *this,layoutRoot);86 formattingContext->layout(); 87 formattingContext->layoutOutOfFlowDescendants(layoutRoot); 88 88 } 89 89 -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r237633 r237634 50 50 } 51 51 52 void BlockFormattingContext::layout( LayoutState& layoutState, FormattingState& formattingState) const52 void BlockFormattingContext::layout() const 53 53 { 54 54 // 9.4.1 Block formatting contexts … … 59 59 return; 60 60 61 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> block formatting context -> layout context(" << &layoutState << ")formatting root(" << &root() << ")");61 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> block formatting context -> formatting root(" << &root() << ")"); 62 62 63 63 auto& formattingRoot = downcast<Container>(root()); 64 64 LayoutQueue layoutQueue; 65 FloatingContext floatingContext(formattingState .floatingState());65 FloatingContext floatingContext(formattingState().floatingState()); 66 66 // This is a post-order tree traversal layout. 67 67 // The root container layout is done in the formatting context it lives in, not that one it creates, so let's start with the first child. … … 78 78 79 79 if (layoutBox.establishesFormattingContext()) { 80 layoutFormattingContextRoot( layoutState, floatingContext, formattingState, layoutBox);80 layoutFormattingContextRoot(floatingContext, layoutBox); 81 81 layoutQueue.removeLast(); 82 82 // Since this box is a formatting context root, it takes care of its entire subtree. … … 89 89 90 90 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")"); 91 computeStaticPosition(layout State, layoutBox);92 computeBorderAndPadding(layout State, layoutBox);93 computeWidthAndMargin(layout State, layoutBox);91 computeStaticPosition(layoutBox); 92 computeBorderAndPadding(layoutBox); 93 computeWidthAndMargin(layoutBox); 94 94 if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild()) 95 95 break; … … 105 105 // Formatting root boxes are special-cased and they don't come here. 106 106 ASSERT(!layoutBox.establishesFormattingContext()); 107 computeHeightAndMargin(layout State, layoutBox);107 computeHeightAndMargin(layoutBox); 108 108 // Finalize position with clearance. 109 109 if (layoutBox.hasFloatClear()) 110 computeVerticalPositionForFloatClear( layoutState,floatingContext, layoutBox);110 computeVerticalPositionForFloatClear(floatingContext, layoutBox); 111 111 if (!is<Container>(layoutBox)) 112 112 continue; 113 113 auto& container = downcast<Container>(layoutBox); 114 114 // Move in-flow positioned children to their final position. 115 placeInFlowPositionedChildren( layoutState,container);115 placeInFlowPositionedChildren(container); 116 116 if (auto* nextSibling = container.nextInFlowOrFloatingSibling()) { 117 117 layoutQueue.append(nextSibling); … … 121 121 } 122 122 // Place the inflow positioned children. 123 placeInFlowPositionedChildren( layoutState,formattingRoot);124 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> layout context(" << &layoutState << ")formatting root(" << &root() << ")");125 } 126 127 void BlockFormattingContext::layoutFormattingContextRoot( LayoutState& layoutState, FloatingContext& floatingContext, FormattingState&, const Box& layoutBox) const123 placeInFlowPositionedChildren(formattingRoot); 124 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> block formatting context -> formatting root(" << &root() << ")"); 125 } 126 127 void BlockFormattingContext::layoutFormattingContextRoot(FloatingContext& floatingContext, const Box& layoutBox) const 128 128 { 129 129 // Start laying out this formatting root in the formatting contenxt it lives in. 130 130 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &layoutBox << ")"); 131 computeStaticPosition(layout State, layoutBox);132 computeBorderAndPadding(layout State, layoutBox);133 computeWidthAndMargin(layout State, layoutBox);134 135 precomputeVerticalPositionForFormattingRootIfNeeded(layout State, layoutBox);131 computeStaticPosition(layoutBox); 132 computeBorderAndPadding(layoutBox); 133 computeWidthAndMargin(layoutBox); 134 135 precomputeVerticalPositionForFormattingRootIfNeeded(layoutBox); 136 136 // Swich over to the new formatting context (the one that the root creates). 137 auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox); 138 auto formattingContext = formattingState.formattingContext(layoutBox); 139 formattingContext->layout(layoutState, formattingState); 137 auto formattingContext = layoutState().createFormattingStateForFormattingRootIfNeeded(layoutBox).formattingContext(layoutBox); 138 formattingContext->layout(); 140 139 141 140 // Come back and finalize the root's geometry. 142 141 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")"); 143 computeHeightAndMargin(layout State, layoutBox);142 computeHeightAndMargin(layoutBox); 144 143 145 144 // Float related final positioning. 146 145 if (layoutBox.isFloatingPositioned()) { 147 computeFloatingPosition( layoutState,floatingContext, layoutBox);146 computeFloatingPosition(floatingContext, layoutBox); 148 147 floatingContext.floatingState().append(layoutBox); 149 148 } else if (layoutBox.hasFloatClear()) 150 computeVerticalPositionForFloatClear( layoutState,floatingContext, layoutBox);149 computeVerticalPositionForFloatClear(floatingContext, layoutBox); 151 150 else if (layoutBox.establishesBlockFormattingContext()) 152 computePositionToAvoidFloats( layoutState,floatingContext, layoutBox);151 computePositionToAvoidFloats(floatingContext, layoutBox); 153 152 154 153 // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any). 155 formattingContext->layoutOutOfFlowDescendants(layoutState, layoutBox); 156 } 157 158 void BlockFormattingContext::computeStaticPosition(const LayoutState& layoutState, const Box& layoutBox) const 159 { 154 formattingContext->layoutOutOfFlowDescendants(layoutBox); 155 } 156 157 void BlockFormattingContext::computeStaticPosition(const Box& layoutBox) const 158 { 159 auto& layoutState = this->layoutState(); 160 160 layoutState.displayBoxForLayoutBox(layoutBox).setTopLeft(Geometry::staticPosition(layoutState, layoutBox)); 161 161 } 162 162 163 void BlockFormattingContext::computeEstimatedMarginTop(const LayoutState& layoutState, const Box& layoutBox) const 164 { 163 void BlockFormattingContext::computeEstimatedMarginTop(const Box& layoutBox) const 164 { 165 auto& layoutState = this->layoutState(); 165 166 auto estimatedMarginTop = Geometry::estimatedMarginTop(layoutState, layoutBox); 166 167 … … 170 171 } 171 172 172 void BlockFormattingContext::computeEstimatedMarginTopForAncestors(const LayoutState& layoutState, constBox& layoutBox) const173 void BlockFormattingContext::computeEstimatedMarginTopForAncestors(const Box& layoutBox) const 173 174 { 174 175 // We only need to estimate margin top for float related layout (formatting context roots avoid floats). … … 184 185 // 185 186 // The idea here is that as long as we don't cross the block formatting context boundary, we should be able to pre-compute the final top margin. 187 auto& layoutState = this->layoutState(); 186 188 187 189 for (auto* ancestor = layoutBox.containingBlock(); ancestor && !ancestor->establishesBlockFormattingContext(); ancestor = ancestor->containingBlock()) { … … 191 193 return; 192 194 193 computeEstimatedMarginTop( layoutState,*ancestor);194 } 195 } 196 197 void BlockFormattingContext::precomputeVerticalPositionForFormattingRootIfNeeded(const LayoutState& layoutState, constBox& layoutBox) const195 computeEstimatedMarginTop(*ancestor); 196 } 197 } 198 199 void BlockFormattingContext::precomputeVerticalPositionForFormattingRootIfNeeded(const Box& layoutBox) const 198 200 { 199 201 ASSERT(layoutBox.establishesFormattingContext()); … … 201 203 auto avoidsFloats = layoutBox.isFloatingPositioned() || layoutBox.establishesBlockFormattingContext() || layoutBox.hasFloatClear(); 202 204 if (avoidsFloats) 203 computeEstimatedMarginTopForAncestors(layout State, layoutBox);205 computeEstimatedMarginTopForAncestors(layoutBox); 204 206 205 207 // If the inline formatting root is also the root for the floats (happens when the root box also establishes a block formatting context) … … 207 209 auto inlineContextInheritsFloats = layoutBox.establishesInlineFormattingContext() && !layoutBox.establishesBlockFormattingContext(); 208 210 if (inlineContextInheritsFloats) { 209 computeEstimatedMarginTop(layout State, layoutBox);210 computeEstimatedMarginTopForAncestors(layout State, layoutBox);211 computeEstimatedMarginTop(layoutBox); 212 computeEstimatedMarginTopForAncestors(layoutBox); 211 213 } 212 214 } … … 224 226 #endif 225 227 226 void BlockFormattingContext::computeFloatingPosition(const LayoutState& layoutState, const FloatingContext& floatingContext, const Box& layoutBox) const 227 { 228 void BlockFormattingContext::computeFloatingPosition(const FloatingContext& floatingContext, const Box& layoutBox) const 229 { 230 auto& layoutState = this->layoutState(); 228 231 ASSERT(layoutBox.isFloatingPositioned()); 229 232 ASSERT(hasPrecomputedMarginTop(layoutState, layoutBox)); … … 240 243 } 241 244 242 void BlockFormattingContext::computePositionToAvoidFloats(const LayoutState& layoutState, const FloatingContext& floatingContext, const Box& layoutBox) const 243 { 245 void BlockFormattingContext::computePositionToAvoidFloats(const FloatingContext& floatingContext, const Box& layoutBox) const 246 { 247 auto& layoutState = this->layoutState(); 244 248 // Formatting context roots avoid floats. 245 249 ASSERT(layoutBox.establishesBlockFormattingContext()); … … 255 259 } 256 260 257 void BlockFormattingContext::computeVerticalPositionForFloatClear(const LayoutState& layoutState, constFloatingContext& floatingContext, const Box& layoutBox) const261 void BlockFormattingContext::computeVerticalPositionForFloatClear(const FloatingContext& floatingContext, const Box& layoutBox) const 258 262 { 259 263 ASSERT(layoutBox.hasFloatClear()); … … 261 265 return; 262 266 267 auto& layoutState = this->layoutState(); 263 268 // For formatting roots, we already precomputed final position. 264 269 if (!layoutBox.establishesFormattingContext()) 265 computeEstimatedMarginTopForAncestors(layout State, layoutBox);270 computeEstimatedMarginTopForAncestors(layoutBox); 266 271 ASSERT(hasPrecomputedMarginTop(layoutState, layoutBox)); 267 272 … … 270 275 } 271 276 272 void BlockFormattingContext::computeInFlowPositionedPosition(const LayoutState& layoutState, const Box& layoutBox) const 273 { 277 void BlockFormattingContext::computeInFlowPositionedPosition(const Box& layoutBox) const 278 { 279 auto& layoutState = this->layoutState(); 274 280 layoutState.displayBoxForLayoutBox(layoutBox).setTopLeft(Geometry::inFlowPositionedPosition(layoutState, layoutBox)); 275 281 } 276 282 277 void BlockFormattingContext::computeWidthAndMargin(LayoutState& layoutState, const Box& layoutBox) const 278 { 283 void BlockFormattingContext::computeWidthAndMargin(const Box& layoutBox) const 284 { 285 auto& layoutState = this->layoutState(); 286 279 287 auto compute = [&](std::optional<LayoutUnit> usedWidth) -> WidthAndMargin { 280 288 … … 311 319 } 312 320 313 void BlockFormattingContext::computeHeightAndMargin(const LayoutState& layoutState, const Box& layoutBox) const 314 { 321 void BlockFormattingContext::computeHeightAndMargin(const Box& layoutBox) const 322 { 323 auto& layoutState = this->layoutState(); 324 315 325 auto compute = [&](std::optional<LayoutUnit> usedHeight) -> HeightAndMargin { 316 326 … … 348 358 } 349 359 350 FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints(LayoutState& layoutState, const Box& layoutBox) const 351 { 360 FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints(const Box& layoutBox) const 361 { 362 auto& layoutState = this->layoutState(); 352 363 auto& formattingState = layoutState.formattingStateForBox(layoutBox); 353 364 ASSERT(formattingState.isBlockFormattingState()); … … 384 395 // Is it a formatting context root? 385 396 if (!instrinsicWidthConstraints && childBox.establishesFormattingContext()) 386 instrinsicWidthConstraints = formattingStateForChildren.formattingContext(childBox)->instrinsicWidthConstraints( layoutState,childBox);397 instrinsicWidthConstraints = formattingStateForChildren.formattingContext(childBox)->instrinsicWidthConstraints(childBox); 387 398 // Go to the next sibling (and skip the descendants) if this box's min/max width is computed. 388 399 if (instrinsicWidthConstraints) { -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r237633 r237634 48 48 BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState); 49 49 50 void layout( LayoutState&, FormattingState&) const override;50 void layout() const override; 51 51 52 52 private: 53 void layoutFormattingContextRoot( LayoutState&, FloatingContext&, FormattingState&, const Box&) const;53 void layoutFormattingContextRoot(FloatingContext&, const Box&) const; 54 54 55 void computeWidthAndMargin( LayoutState&,const Box&) const;56 void computeHeightAndMargin(const LayoutState&, constBox&) const;55 void computeWidthAndMargin(const Box&) const; 56 void computeHeightAndMargin(const Box&) const; 57 57 58 void computeStaticPosition(const LayoutState&, constBox&) const override;59 void computeFloatingPosition(const LayoutState&, constFloatingContext&, const Box&) const;60 void computePositionToAvoidFloats(const LayoutState&, constFloatingContext&, const Box&) const;61 void computeVerticalPositionForFloatClear(const LayoutState&, constFloatingContext&, const Box&) const;58 void computeStaticPosition(const Box&) const override; 59 void computeFloatingPosition(const FloatingContext&, const Box&) const; 60 void computePositionToAvoidFloats(const FloatingContext&, const Box&) const; 61 void computeVerticalPositionForFloatClear(const FloatingContext&, const Box&) const; 62 62 63 void computeInFlowPositionedPosition(const LayoutState&, constBox&) const override;64 void computeEstimatedMarginTopForAncestors(const LayoutState&, constBox&) const;65 void computeEstimatedMarginTop(const LayoutState&, constBox&) const;63 void computeInFlowPositionedPosition(const Box&) const override; 64 void computeEstimatedMarginTopForAncestors(const Box&) const; 65 void computeEstimatedMarginTop(const Box&) const; 66 66 67 void precomputeVerticalPositionForFormattingRootIfNeeded(const LayoutState&, constBox&) const;67 void precomputeVerticalPositionForFormattingRootIfNeeded(const Box&) const; 68 68 69 InstrinsicWidthConstraints instrinsicWidthConstraints( LayoutState&,const Box&) const override;69 InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const override; 70 70 71 71 // This class implements positioning and sizing for boxes participating in a block formatting context. -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r237633 r237634 52 52 } 53 53 54 void InlineFormattingContext::layout( LayoutState& layoutState, FormattingState& formattingState) const54 void InlineFormattingContext::layout() const 55 55 { 56 56 if (!is<Container>(root())) 57 57 return; 58 58 59 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> layout context(" << &layoutState << ")formatting root(" << &root() << ")");60 61 auto& inlineFormattingState = downcast<InlineFormattingState>(formattingState );59 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")"); 60 61 auto& inlineFormattingState = downcast<InlineFormattingState>(formattingState()); 62 62 InlineRunProvider inlineRunProvider(inlineFormattingState); 63 63 auto& formattingRoot = downcast<Container>(root()); … … 67 67 68 68 if (layoutBox->establishesFormattingContext()) { 69 layoutFormattingContextRoot( layoutState,*layoutBox);69 layoutFormattingContextRoot(*layoutBox); 70 70 // Formatting context roots take care of their entire subtree. Continue with next sibling. 71 71 inlineRunProvider.append(*layoutBox); … … 81 81 82 82 inlineRunProvider.append(*layoutBox); 83 computeWidthAndHeightForInlineBox( layoutState,*layoutBox);83 computeWidthAndHeightForInlineBox(*layoutBox); 84 84 85 85 for (; layoutBox; layoutBox = layoutBox->parent()) { … … 96 96 } 97 97 98 layoutInlineContent( layoutState, inlineFormattingState,inlineRunProvider);99 100 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> layout context(" << &layoutState << ")formatting root(" << &root() << ")");98 layoutInlineContent(inlineRunProvider); 99 100 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> formatting root(" << &root() << ")"); 101 101 } 102 102 … … 106 106 } 107 107 108 void InlineFormattingContext::initializeNewLine( const LayoutState& layoutState, InlineFormattingState& inlineFormattingState,Line& line) const108 void InlineFormattingContext::initializeNewLine(Line& line) const 109 109 { 110 110 auto& formattingRoot = downcast<Container>(root()); 111 auto& formattingRootDisplayBox = layoutState .displayBoxForLayoutBox(formattingRoot);111 auto& formattingRootDisplayBox = layoutState().displayBoxForLayoutBox(formattingRoot); 112 112 113 113 auto lineLogicalLeft = formattingRootDisplayBox.contentBoxLeft(); … … 116 116 117 117 // Check for intruding floats and adjust logical left/available width for this line accordingly. 118 auto& floatingState = inlineFormattingState.floatingState();118 auto& floatingState = formattingState().floatingState(); 119 119 if (!floatingState.isEmpty()) { 120 120 auto floatConstraints = floatingState.constraints(lineLogicalTop, formattingRoot); … … 149 149 } 150 150 151 void InlineFormattingContext::layoutInlineContent(const LayoutState& layoutState, InlineFormattingState& inlineFormattingState, const InlineRunProvider& inlineRunProvider) const 152 { 151 void InlineFormattingContext::layoutInlineContent(const InlineRunProvider& inlineRunProvider) const 152 { 153 auto& layoutState = this->layoutState(); 154 auto& inlineFormattingState = downcast<InlineFormattingState>(formattingState()); 153 155 auto floatingContext = FloatingContext { inlineFormattingState.floatingState() }; 154 156 155 157 Line line(inlineFormattingState, root()); 156 initializeNewLine(l ayoutState, inlineFormattingState, line);158 initializeNewLine(line); 157 159 158 160 InlineLineBreaker lineBreaker(layoutState, inlineFormattingState.inlineContent(), inlineRunProvider.runs()); … … 165 167 if (run->content.isFloat()) { 166 168 auto& floatBox = run->content.inlineItem().layoutBox(); 167 computeFloatPosition( layoutState,floatingContext, line, floatBox);169 computeFloatPosition(floatingContext, line, floatBox); 168 170 inlineFormattingState.floatingState().append(floatBox); 169 171 … … 189 191 if (!line.isClosed()) 190 192 line.close(Line::LastLine::No); 191 initializeNewLine(l ayoutState, inlineFormattingState, line);193 initializeNewLine(line); 192 194 } 193 195 } … … 203 205 } 204 206 205 void InlineFormattingContext::layoutFormattingContextRoot(LayoutState& layoutState, const Box& layoutBox) const 206 { 207 void InlineFormattingContext::layoutFormattingContextRoot(const Box& layoutBox) const 208 { 209 auto& layoutState = this->layoutState(); 210 207 211 ASSERT(layoutBox.isFloatingPositioned() || layoutBox.isInlineBlockBox()); 208 212 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); … … 238 242 }; 239 243 240 computeBorderAndPadding(layout State, layoutBox);244 computeBorderAndPadding(layoutBox); 241 245 computeWidthAndMargin(); 242 246 243 247 // Swich over to the new formatting context (the one that the root creates). 244 auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox); 245 formattingState.formattingContext(layoutBox)->layout(layoutState, formattingState); 248 layoutState.createFormattingStateForFormattingRootIfNeeded(layoutBox).formattingContext(layoutBox)->layout(); 246 249 247 250 // Come back and finalize the root's height and margin. … … 249 252 } 250 253 251 void InlineFormattingContext::computeWidthAndHeightForInlineBox( LayoutState& layoutState,const Box& layoutBox) const254 void InlineFormattingContext::computeWidthAndHeightForInlineBox(const Box& layoutBox) const 252 255 { 253 256 ASSERT(!layoutBox.isContainer()); … … 260 263 } 261 264 265 auto& layoutState = this->layoutState(); 262 266 // This is pretty much only for replaced inline boxes atm. 263 267 ASSERT(layoutBox.replaced()); 264 computeBorderAndPadding(layout State, layoutBox);268 computeBorderAndPadding(layoutBox); 265 269 266 270 auto widthAndMargin = Geometry::inlineReplacedWidthAndMargin(layoutState, layoutBox); … … 277 281 } 278 282 279 void InlineFormattingContext::computeFloatPosition(const LayoutState& layoutState, const FloatingContext& floatingContext, Line& line, const Box& floatBox) const 280 { 283 void InlineFormattingContext::computeFloatPosition(const FloatingContext& floatingContext, Line& line, const Box& floatBox) const 284 { 285 auto& layoutState = this->layoutState(); 281 286 ASSERT(layoutState.hasDisplayBox(floatBox)); 282 287 auto& displayBox = layoutState.displayBoxForLayoutBox(floatBox); … … 288 293 } 289 294 290 void InlineFormattingContext::computeStaticPosition(const LayoutState&, constBox&) const291 { 292 } 293 294 void InlineFormattingContext::computeInFlowPositionedPosition(const LayoutState&, constBox&) const295 { 296 } 297 298 FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsicWidthConstraints( LayoutState&,const Box&) const295 void InlineFormattingContext::computeStaticPosition(const Box&) const 296 { 297 } 298 299 void InlineFormattingContext::computeInFlowPositionedPosition(const Box&) const 300 { 301 } 302 303 FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsicWidthConstraints(const Box&) const 299 304 { 300 305 return { }; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r237633 r237634 46 46 InlineFormattingContext(const Box& formattingContextRoot, FormattingState&); 47 47 48 void layout( LayoutState&, FormattingState&) const override;48 void layout() const override; 49 49 50 50 private: … … 103 103 }; 104 104 105 void layoutInlineContent(const LayoutState&, InlineFormattingState&, constInlineRunProvider&) const;106 void initializeNewLine( const LayoutState&, InlineFormattingState&,Line&) const;105 void layoutInlineContent(const InlineRunProvider&) const; 106 void initializeNewLine(Line&) const; 107 107 108 void layoutFormattingContextRoot( LayoutState&,const Box&) const;109 void computeWidthAndHeightForInlineBox( LayoutState&,const Box&) const;110 void computeFloatPosition(const LayoutState&, constFloatingContext&, Line&, const Box&) const;111 void computeStaticPosition(const LayoutState&, constBox&) const override;112 void computeInFlowPositionedPosition(const LayoutState&, constBox&) const override;108 void layoutFormattingContextRoot(const Box&) const; 109 void computeWidthAndHeightForInlineBox(const Box&) const; 110 void computeFloatPosition(const FloatingContext&, Line&, const Box&) const; 111 void computeStaticPosition(const Box&) const override; 112 void computeInFlowPositionedPosition(const Box&) const override; 113 113 114 InstrinsicWidthConstraints instrinsicWidthConstraints( LayoutState&,const Box&) const override;114 InstrinsicWidthConstraints instrinsicWidthConstraints(const Box&) const override; 115 115 }; 116 116
Note:
See TracChangeset
for help on using the changeset viewer.