Changeset 249349 in webkit
- Timestamp:
- Aug 30, 2019 3:45:49 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249344 r249349 1 2019-08-30 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Pass FormattingContext to Geometry/Quirks/BlockMarginCollapsing classes 4 https://bugs.webkit.org/show_bug.cgi?id=201355 5 <rdar://problem/54895959> 6 7 Reviewed by Antti Koivisto. 8 9 This is in preparation for enforcing LFC to not call outside of the formatting context. 10 LayoutState::displayBoxForLayoutBox calls will be forced to go through the FormattingContext class to 11 check LFC escaping. 12 13 14 * layout/FormattingContext.h: 15 (WebCore::Layout::FormattingContext::isBlockFormattingContext const): 16 (WebCore::Layout::FormattingContext::isInlineFormattingContext const): 17 (WebCore::Layout::FormattingContext::isTableFormattingContext const): 18 (WebCore::Layout::FormattingContext::Geometry::layoutState const): 19 (WebCore::Layout::FormattingContext::Geometry::layoutState): 20 (WebCore::Layout::FormattingContext::Geometry::formattingContext const): 21 (WebCore::Layout::FormattingContext::geometry const): 22 (WebCore::Layout::FormattingContext::Quirks::layoutState const): 23 (WebCore::Layout::FormattingContext::Quirks::layoutState): 24 (WebCore::Layout::FormattingContext::Quirks::formattingContext const): 25 (WebCore::Layout::FormattingContext::quirks const): 26 (WebCore::Layout::FormattingContext::Geometry::Geometry): 27 (WebCore::Layout::FormattingContext::Quirks::Quirks): 28 * layout/FormattingContextGeometry.cpp: 29 (WebCore::Layout::FormattingContext::Geometry::computedHeightValue const): 30 * layout/FormattingContextQuirks.cpp: 31 (WebCore::Layout::FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight): 32 * layout/blockformatting/BlockFormattingContext.h: 33 (WebCore::Layout::BlockFormattingContext::Geometry::formattingContext const): 34 (WebCore::Layout::BlockFormattingContext::geometry const): 35 (WebCore::Layout::BlockFormattingContext::MarginCollapse::layoutState): 36 (WebCore::Layout::BlockFormattingContext::MarginCollapse::layoutState const): 37 (WebCore::Layout::BlockFormattingContext::MarginCollapse::formattingContext const): 38 (WebCore::Layout::BlockFormattingContext::marginCollapse const): 39 (WebCore::Layout::BlockFormattingContext::Quirks::formattingContext const): 40 (WebCore::Layout::BlockFormattingContext::quirks const): 41 (WebCore::Layout::BlockFormattingContext::Geometry::Geometry): 42 (WebCore::Layout::BlockFormattingContext::Quirks::Quirks): 43 (WebCore::Layout::BlockFormattingContext::MarginCollapse::MarginCollapse): 44 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 45 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 46 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin): 47 * layout/blockformatting/BlockFormattingContextQuirks.cpp: 48 (WebCore::Layout::BlockFormattingContext::Quirks::stretchedInFlowHeight): 49 * layout/blockformatting/BlockMarginCollapse.cpp: 50 (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues): 51 (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore): 52 (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore): 53 * layout/inlineformatting/InlineFormattingContext.h: 54 (WebCore::Layout::InlineFormattingContext::InlineLayout::layoutState const): 55 (WebCore::Layout::InlineFormattingContext::InlineLayout::formattingContext const): 56 (WebCore::Layout::InlineFormattingContext::InlineLayout::formattingRoot const): 57 (WebCore::Layout::InlineFormattingContext::Quirks::formattingContext const): 58 (WebCore::Layout::InlineFormattingContext::quirks const): 59 (WebCore::Layout::InlineFormattingContext::Geometry::formattingContext const): 60 (WebCore::Layout::InlineFormattingContext::geometry const): 61 (WebCore::Layout::InlineFormattingContext::Geometry::Geometry): 62 (WebCore::Layout::InlineFormattingContext::Quirks::Quirks): 63 * layout/inlineformatting/InlineFormattingContextLineLayout.cpp: 64 (WebCore::Layout::LineLayout::LineLayout): 65 (WebCore::Layout::InlineFormattingContext::InlineLayout::InlineLayout): 66 (WebCore::Layout::InlineFormattingContext::InlineLayout::layout const): 67 (WebCore::Layout::InlineFormattingContext::InlineLayout::computedIntrinsicWidth const): 68 (WebCore::Layout::InlineFormattingContext::InlineLayout::createDisplayRuns const): 69 * layout/inlineformatting/InlineLine.cpp: 70 (WebCore::Layout::Line::Line): 71 (WebCore::Layout::Line::isVisuallyEmpty const): 72 (WebCore::Layout::Line::close): 73 (WebCore::Layout::Line::appendNonReplacedInlineBox): 74 (WebCore::Layout::Line::adjustBaselineAndLineHeight): 75 (WebCore::Layout::Line::inlineItemContentHeight const): 76 (WebCore::Layout::Line::layoutState const): 77 (WebCore::Layout::Line::formattingContext const): 78 * layout/inlineformatting/InlineLine.h: 79 * layout/tableformatting/TableFormattingContext.h: 80 (WebCore::Layout::TableFormattingContext::Geometry::formattingContext const): 81 (WebCore::Layout::TableFormattingContext::geometry const): 82 (WebCore::Layout::TableFormattingContext::Geometry::Geometry): 83 * page/FrameViewLayoutContext.cpp: 84 (WebCore::layoutUsingFormattingContext): 85 1 86 2019-08-30 Ryan Haddad <ryanhaddad@apple.com> 2 87 -
trunk/Source/WebCore/layout/FormattingContext.h
r249331 r249349 29 29 30 30 #include "DisplayBox.h" 31 #include "LayoutBox.h" 31 32 #include <wtf/IsoMalloc.h> 32 33 #include <wtf/WeakPtr.h> … … 39 40 namespace Layout { 40 41 41 class Box;42 42 class Container; 43 43 class FormattingState; … … 69 69 static Point mapPointToDescendent(const LayoutState&, Point, const Container& from, const Container& to); 70 70 71 bool isBlockFormattingContext() const { return root().establishesBlockFormattingContext(); } 72 bool isInlineFormattingContext() const { return root().establishesInlineFormattingContext(); } 73 bool isTableFormattingContext() const { return root().establishesTableFormattingContext(); } 74 71 75 protected: 72 76 using LayoutQueue = Vector<const Box*>; … … 85 89 class Geometry { 86 90 public: 87 Geometry( LayoutState&);91 Geometry(const FormattingContext&); 88 92 89 93 VerticalGeometry outOfFlowVerticalGeometry(const Box&, UsedVerticalValues) const; … … 121 125 Optional<LayoutUnit> computedHeightValue(const Box&, HeightType) const; 122 126 123 const LayoutState& layoutState() const { return m_layoutState; } 124 LayoutState& layoutState() { return m_layoutState; } 127 const LayoutState& layoutState() const { return m_formattingContext.layoutState(); } 128 LayoutState& layoutState() { return m_formattingContext.layoutState(); } 129 const FormattingContext& formattingContext() const { return m_formattingContext; } 125 130 126 131 private: … … 139 144 LayoutUnit staticHorizontalPositionForOutOfFlowPositioned(const Box&) const; 140 145 141 LayoutState& m_layoutState;146 const FormattingContext& m_formattingContext; 142 147 }; 143 FormattingContext::Geometry geometry() const { return Geometry( layoutState()); }148 FormattingContext::Geometry geometry() const { return Geometry(*this); } 144 149 145 150 class Quirks { 146 151 public: 147 Quirks( LayoutState&);152 Quirks(const FormattingContext&); 148 153 149 154 LayoutUnit heightValueOfNearestContainingBlockWithFixedHeight(const Box&); 150 155 151 156 protected: 152 const LayoutState& layoutState() const { return m_layoutState; } 153 LayoutState& layoutState() { return m_layoutState; } 154 155 LayoutState& m_layoutState; 157 const LayoutState& layoutState() const { return m_formattingContext.layoutState(); } 158 LayoutState& layoutState() { return m_formattingContext.layoutState(); } 159 const FormattingContext& formattingContext() const { return m_formattingContext; } 160 161 const FormattingContext& m_formattingContext; 156 162 }; 157 FormattingContext::Quirks quirks() const { return Quirks( layoutState()); }163 FormattingContext::Quirks quirks() const { return Quirks(*this); } 158 164 159 165 private: … … 165 171 }; 166 172 167 inline FormattingContext::Geometry::Geometry( LayoutState& layoutState)168 : m_ layoutState(layoutState)169 { 170 } 171 172 inline FormattingContext::Quirks::Quirks( LayoutState& layoutState)173 : m_ layoutState(layoutState)173 inline FormattingContext::Geometry::Geometry(const FormattingContext& formattingContext) 174 : m_formattingContext(formattingContext) 175 { 176 } 177 178 inline FormattingContext::Quirks::Quirks(const FormattingContext& formattingContext) 179 : m_formattingContext(formattingContext) 174 180 { 175 181 } … … 190 196 } 191 197 } 198 199 #define SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(ToValueTypeName, predicate) \ 200 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::Layout::ToValueTypeName) \ 201 static bool isType(const WebCore::Layout::FormattingContext& formattingContext) { return formattingContext.predicate; } \ 202 SPECIALIZE_TYPE_TRAITS_END() 203 192 204 #endif -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r249331 r249349 77 77 } else { 78 78 if (layoutState.inQuirksMode()) 79 containingBlockHeightValue = Quirks( const_cast<LayoutState&>(layoutState)).heightValueOfNearestContainingBlockWithFixedHeight(layoutBox);79 containingBlockHeightValue = Quirks(formattingContext()).heightValueOfNearestContainingBlockWithFixedHeight(layoutBox); 80 80 else { 81 81 auto containingBlockHeight = layoutBox.containingBlock()->style().logicalHeight(); -
trunk/Source/WebCore/layout/FormattingContextQuirks.cpp
r249331 r249349 54 54 55 55 auto usedValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*containingBlock->containingBlock()).contentBoxWidth() }; 56 auto verticalMargin = Geometry( layoutState).computedVerticalMargin(*containingBlock, usedValues);56 auto verticalMargin = Geometry(formattingContext()).computedVerticalMargin(*containingBlock, usedValues); 57 57 auto verticalPadding = displayBox.paddingTop().valueOr(0) + displayBox.paddingBottom().valueOr(0); 58 58 auto verticalBorder = displayBox.borderTop() + displayBox.borderBottom(); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r249331 r249349 76 76 class Geometry : public FormattingContext::Geometry { 77 77 public: 78 Geometry( LayoutState&);78 Geometry(const BlockFormattingContext&); 79 79 80 80 HeightAndMargin inFlowHeightAndMargin(const Box&, UsedVerticalValues); … … 92 92 WidthAndMargin inFlowReplacedWidthAndMargin(const Box&, UsedHorizontalValues) const; 93 93 Point staticPositionForOutOfFlowPositioned(const Box&) const; 94 95 const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Geometry::formattingContext()); } 94 96 }; 95 BlockFormattingContext::Geometry geometry() const { return Geometry( layoutState()); }97 BlockFormattingContext::Geometry geometry() const { return Geometry(*this); } 96 98 97 99 // This class implements margin collapsing for block formatting context. 98 100 class MarginCollapse { 99 101 public: 100 MarginCollapse( LayoutState&);102 MarginCollapse(const BlockFormattingContext&); 101 103 102 104 UsedVerticalMargin::CollapsedValues collapsedVerticalValues(const Box&, const UsedVerticalMargin::NonCollapsedValues&); … … 126 128 PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginAfter(const Box&, const UsedVerticalMargin::NonCollapsedValues&); 127 129 128 LayoutState& layoutState() { return m_layoutState; } 129 const LayoutState& layoutState() const { return m_layoutState; } 130 LayoutState& layoutState() { return m_blockFormattingContext.layoutState(); } 131 const LayoutState& layoutState() const { return m_blockFormattingContext.layoutState(); } 132 const BlockFormattingContext& formattingContext() const { return m_blockFormattingContext; } 130 133 131 LayoutState& m_layoutState;134 const BlockFormattingContext& m_blockFormattingContext; 132 135 }; 133 MarginCollapse marginCollapse() const { return MarginCollapse( layoutState()); }136 MarginCollapse marginCollapse() const { return MarginCollapse(*this); } 134 137 135 138 class Quirks : public FormattingContext::Quirks { 136 139 public: 137 Quirks( LayoutState&);140 Quirks(const BlockFormattingContext&); 138 141 139 142 bool needsStretching(const Box&) const; … … 143 146 bool shouldIgnoreMarginBefore(const Box&) const; 144 147 bool shouldIgnoreMarginAfter(const Box&) const; 148 149 private: 150 const BlockFormattingContext& formattingContext() const { return downcast<BlockFormattingContext>(FormattingContext::Quirks::formattingContext()); } 151 145 152 }; 146 BlockFormattingContext::Quirks quirks() const { return Quirks( layoutState()); }153 BlockFormattingContext::Quirks quirks() const { return Quirks(*this); } 147 154 148 155 void setEstimatedMarginBefore(const Box&, const EstimatedMarginBefore&); … … 161 168 }; 162 169 163 inline BlockFormattingContext::Geometry::Geometry( LayoutState& layoutState)164 : FormattingContext::Geometry( layoutState)170 inline BlockFormattingContext::Geometry::Geometry(const BlockFormattingContext& blockFormattingContext) 171 : FormattingContext::Geometry(blockFormattingContext) 165 172 { 166 173 } 167 174 168 inline BlockFormattingContext::Quirks::Quirks( LayoutState& layoutState)169 : FormattingContext::Quirks( layoutState)175 inline BlockFormattingContext::Quirks::Quirks(const BlockFormattingContext& blockFormattingContext) 176 : FormattingContext::Quirks(blockFormattingContext) 170 177 { 171 178 } 172 179 173 inline BlockFormattingContext::MarginCollapse::MarginCollapse( LayoutState& layoutState)174 : m_ layoutState(layoutState)180 inline BlockFormattingContext::MarginCollapse::MarginCollapse(const BlockFormattingContext& blockFormattingContext) 181 : m_blockFormattingContext(blockFormattingContext) 175 182 { 176 183 } … … 178 185 } 179 186 } 187 188 SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(BlockFormattingContext, isBlockFormattingContext()) 189 180 190 #endif -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r249331 r249349 86 86 auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild(); 87 87 ASSERT(lastInFlowChild); 88 auto marginCollapse = MarginCollapse( layoutState);88 auto marginCollapse = MarginCollapse(formattingContext()); 89 89 if (!marginCollapse.marginAfterCollapsesWithParentMarginAfter(*lastInFlowChild)) { 90 90 auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild); … … 274 274 } 275 275 276 auto quirks = Quirks( layoutState());276 auto quirks = Quirks(formattingContext()); 277 277 if (!quirks.needsStretching(layoutBox)) 278 278 return heightAndMargin; -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp
r249331 r249349 83 83 // Stretch the body using the initial containing block's height and shrink it with document box's margin/border/padding. 84 84 // This looks extremely odd when html has non-auto height. 85 auto documentBoxVerticalMargin = Geometry( layoutState).computedVerticalMargin(documentBox, UsedHorizontalValues { initialContainingBlockDisplayBox.contentBoxWidth() });85 auto documentBoxVerticalMargin = Geometry(formattingContext()).computedVerticalMargin(documentBox, UsedHorizontalValues { initialContainingBlockDisplayBox.contentBoxWidth() }); 86 86 strechedHeight -= (documentBoxVerticalMargin.before.valueOr(0) + documentBoxVerticalMargin.after.valueOr(0)); 87 87 … … 90 90 91 91 auto nonCollapsedMargin = heightAndMargin.nonCollapsedMargin; 92 auto collapsedMargin = MarginCollapse( layoutState).collapsedVerticalValues(layoutBox, nonCollapsedMargin);92 auto collapsedMargin = MarginCollapse(formattingContext()).collapsedVerticalValues(layoutBox, nonCollapsedMargin); 93 93 totalVerticalMargin = collapsedMargin.before.valueOr(nonCollapsedMargin.before); 94 94 totalVerticalMargin += collapsedMargin.isCollapsedThrough ? nonCollapsedMargin.after : collapsedMargin.after.valueOr(nonCollapsedMargin.after); -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r249331 r249349 516 516 // This is the estimate path. We don't yet have positive/negative margin computed. 517 517 auto usedValues = UsedHorizontalValues { layoutState.displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() }; 518 auto computedVerticalMargin = Geometry( layoutState).computedVerticalMargin(layoutBox, usedValues);518 auto computedVerticalMargin = Geometry(formattingContext()).computedVerticalMargin(layoutBox, usedValues); 519 519 auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) }; 520 520 … … 542 542 // 3. Compute min/max positive and negative collapsed margin values using non-collpased computed margin before. 543 543 auto collapsedMarginBefore = computedPositiveAndNegativeMargin(firstChildCollapsedMarginBefore(), previouSiblingCollapsedMarginAfter()); 544 if (collapsedMarginBefore.isQuirk && Quirks( layoutState()).shouldIgnoreCollapsedQuirkMargin(layoutBox))544 if (collapsedMarginBefore.isQuirk && Quirks(formattingContext()).shouldIgnoreCollapsedQuirkMargin(layoutBox)) 545 545 collapsedMarginBefore = { }; 546 546 … … 584 584 585 585 auto usedValues = UsedHorizontalValues { layoutState().displayBoxForLayoutBox(*layoutBox.containingBlock()).contentBoxWidth() }; 586 auto computedVerticalMargin = Geometry( layoutState()).computedVerticalMargin(layoutBox, usedValues);586 auto computedVerticalMargin = Geometry(formattingContext()).computedVerticalMargin(layoutBox, usedValues); 587 587 auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) }; 588 588 auto marginsCollapseThrough = this->marginsCollapseThrough(layoutBox); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r249331 r249349 59 59 60 60 private: 61 LayoutState& layoutState() const { return m_layoutState; } 61 LayoutState& layoutState() const { return m_inlineFormattingContext.layoutState(); } 62 const InlineFormattingContext& formattingContext() const { return m_inlineFormattingContext; } 63 const Container& formattingRoot() const { return downcast<Container>(m_inlineFormattingContext.root()); } 62 64 LineContent placeInlineItems(const LineInput&) const; 63 65 void createDisplayRuns(const Line::Content&, const Vector<WeakPtr<InlineItem>>& floats, LayoutUnit widthConstraint) const; … … 65 67 66 68 private: 67 LayoutState& m_layoutState; 68 const Container& m_formattingRoot; 69 const InlineFormattingContext& m_inlineFormattingContext; 69 70 }; 70 71 71 72 class Quirks : public FormattingContext::Quirks { 72 73 public: 73 Quirks( LayoutState&);74 Quirks(const InlineFormattingContext&); 74 75 75 76 bool lineDescentNeedsCollapsing(const Line::Content&) const; 76 77 Line::InitialConstraints::HeightAndBaseline lineHeightConstraints(const Box& formattingRoot) const; 78 79 private: 80 const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Quirks::formattingContext()); } 81 77 82 }; 78 InlineFormattingContext::Quirks quirks() const { return Quirks( layoutState()); }83 InlineFormattingContext::Quirks quirks() const { return Quirks(*this); } 79 84 80 85 class Geometry : public FormattingContext::Geometry { 81 86 public: 82 Geometry( LayoutState&);87 Geometry(const InlineFormattingContext&); 83 88 84 89 HeightAndMargin inlineBlockHeightAndMargin(const Box&) const; 85 90 WidthAndMargin inlineBlockWidthAndMargin(const Box&, UsedHorizontalValues); 91 92 private: 93 const InlineFormattingContext& formattingContext() const { return downcast<InlineFormattingContext>(FormattingContext::Geometry::formattingContext()); } 94 86 95 }; 87 InlineFormattingContext::Geometry geometry() const { return Geometry( layoutState()); }96 InlineFormattingContext::Geometry geometry() const { return Geometry(*this); } 88 97 89 98 void layoutFormattingContextRoot(const Box&, UsedHorizontalValues); … … 103 112 }; 104 113 105 inline InlineFormattingContext::Geometry::Geometry( LayoutState& layoutState)106 : FormattingContext::Geometry( layoutState)114 inline InlineFormattingContext::Geometry::Geometry(const InlineFormattingContext& inlineFormattingContext) 115 : FormattingContext::Geometry(inlineFormattingContext) 107 116 { 108 117 } 109 118 110 inline InlineFormattingContext::Quirks::Quirks( LayoutState& layoutState)111 : FormattingContext::Quirks( layoutState)119 inline InlineFormattingContext::Quirks::Quirks(const InlineFormattingContext& inlineFormattingContext) 120 : FormattingContext::Quirks(inlineFormattingContext) 112 121 { 113 122 } … … 115 124 } 116 125 } 126 127 SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(InlineFormattingContext, isInlineFormattingContext()) 128 117 129 #endif -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextLineLayout.cpp
r249331 r249349 101 101 class LineLayout { 102 102 public: 103 LineLayout( LayoutState&, const LineInput&);103 LineLayout(const InlineFormattingContext&, LayoutState&, const LineInput&); 104 104 105 105 LineContent layout(); … … 154 154 } 155 155 156 LineLayout::LineLayout( LayoutState& layoutState, const LineInput& lineInput)156 LineLayout::LineLayout(const InlineFormattingContext& inlineFormattingContext, LayoutState& layoutState, const LineInput& lineInput) 157 157 : m_layoutState(layoutState) 158 158 , m_lineInput(lineInput) 159 , m_line( layoutState, lineInput.initialConstraints, lineInput.skipVerticalAligment)159 , m_line(inlineFormattingContext, lineInput.initialConstraints, lineInput.skipVerticalAligment) 160 160 , m_lineHasFloatBox(lineInput.floatMinimumLogicalBottom.hasValue()) 161 161 { … … 273 273 274 274 InlineFormattingContext::InlineLayout::InlineLayout(const InlineFormattingContext& inlineFormattingContext) 275 : m_layoutState(inlineFormattingContext.layoutState()) 276 , m_formattingRoot(downcast<Container>(inlineFormattingContext.root())) 275 : m_inlineFormattingContext(inlineFormattingContext) 277 276 { 278 277 } … … 281 280 { 282 281 auto& layoutState = this->layoutState(); 283 auto& formattingRootDisplayBox = layoutState.displayBoxForLayoutBox(m_formattingRoot); 284 auto& floatingState = layoutState.establishedFormattingState(m_formattingRoot).floatingState(); 282 auto& formattingRoot = this->formattingRoot(); 283 auto& formattingRootDisplayBox = layoutState.displayBoxForLayoutBox(formattingRoot); 284 auto& floatingState = layoutState.establishedFormattingState(formattingRoot).floatingState(); 285 285 286 286 auto lineLogicalTop = formattingRootDisplayBox.contentBoxTop(); … … 293 293 auto availableWidth = lineInput.initialConstraints.availableLogicalWidth; 294 294 auto lineLogicalLeft = lineInput.initialConstraints.logicalTopLeft.x(); 295 auto floatConstraints = floatingState.constraints({ lineLogicalTop }, m_formattingRoot);295 auto floatConstraints = floatingState.constraints({ lineLogicalTop }, formattingRoot); 296 296 // Check if these constraints actually put limitation on the line. 297 297 if (floatConstraints.left && floatConstraints.left->x <= formattingRootDisplayBox.contentBoxLeft()) … … 324 324 325 325 IndexAndRange currentInlineItem; 326 auto quirks = Quirks( layoutState);326 auto quirks = Quirks(formattingContext()); 327 327 while (currentInlineItem.index < inlineItems.size()) { 328 auto lineInput = LineInput { { { lineLogicalLeft, lineLogicalTop }, widthConstraint, quirks.lineHeightConstraints( m_formattingRoot) }, Line::SkipVerticalAligment::No, currentInlineItem, inlineItems };328 auto lineInput = LineInput { { { lineLogicalLeft, lineLogicalTop }, widthConstraint, quirks.lineHeightConstraints(formattingRoot) }, Line::SkipVerticalAligment::No, currentInlineItem, inlineItems }; 329 329 applyFloatConstraint(lineInput); 330 auto lineContent = LineLayout( layoutState, lineInput).layout();330 auto lineContent = LineLayout(formattingContext(), layoutState, lineInput).layout(); 331 331 createDisplayRuns(*lineContent.runs, lineContent.floats, widthConstraint); 332 332 if (!lineContent.lastCommitted) { … … 347 347 LayoutUnit maximumLineWidth; 348 348 IndexAndRange currentInlineItem; 349 auto quirks = Quirks( layoutState);349 auto quirks = Quirks(formattingContext()); 350 350 while (currentInlineItem.index < inlineItems.size()) { 351 auto lineContent = LineLayout( layoutState, { { { }, widthConstraint, quirks.lineHeightConstraints(m_formattingRoot) }, Line::SkipVerticalAligment::Yes, currentInlineItem, inlineItems }).layout();351 auto lineContent = LineLayout(formattingContext(), layoutState, { { { }, widthConstraint, quirks.lineHeightConstraints(formattingRoot()) }, Line::SkipVerticalAligment::Yes, currentInlineItem, inlineItems }).layout(); 352 352 currentInlineItem = { lineContent.lastCommitted->index + 1, WTF::nullopt }; 353 353 LayoutUnit floatsWidth; … … 362 362 { 363 363 auto& layoutState = this->layoutState(); 364 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState( m_formattingRoot));364 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(formattingRoot())); 365 365 auto& floatingState = formattingState.floatingState(); 366 366 auto floatingContext = FloatingContext { floatingState }; … … 392 392 // Create final display runs. 393 393 auto& lineRuns = lineContent.runs(); 394 auto geometry = Geometry( layoutState);394 auto geometry = Geometry(formattingContext()); 395 395 for (unsigned index = 0; index < lineRuns.size(); ++index) { 396 396 auto& lineRun = lineRuns.at(index); … … 471 471 // FIXME linebox needs to be ajusted after content alignment. 472 472 formattingState.addLineBox({ lineBoxRect, lineContent.baseline(), lineContent.baselineOffset() }); 473 alignRuns( m_formattingRoot.style().textAlign(), inlineDisplayRuns, previousLineLastRunIndex.valueOr(-1) + 1, widthConstraint - lineContent.logicalWidth());473 alignRuns(formattingRoot().style().textAlign(), inlineDisplayRuns, previousLineLastRunIndex.valueOr(-1) + 1, widthConstraint - lineContent.logicalWidth()); 474 474 } 475 475 -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp
r249331 r249349 53 53 } 54 54 55 Line::Line( LayoutState& layoutState, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment)56 : m_ layoutState(layoutState)55 Line::Line(const InlineFormattingContext& inlineFormattingContext, const InitialConstraints& initialConstraints, SkipVerticalAligment skipVerticalAligment) 56 : m_inlineFormattingContext(inlineFormattingContext) 57 57 , m_content(makeUnique<Line::Content>()) 58 58 , m_logicalTopLeft(initialConstraints.logicalTopLeft) … … 76 76 // FIXME: This should be cached instead -as the inline items are being added. 77 77 // Return true for empty inline containers like <span></span>. 78 auto& layoutState = this->layoutState(); 78 79 for (auto& run : m_content->runs()) { 79 80 if (run->isContainerStart()) { 80 if (!isInlineContainerConsideredEmpty( m_layoutState, run->layoutBox()))81 if (!isInlineContainerConsideredEmpty(layoutState, run->layoutBox())) 81 82 return false; 82 83 continue; … … 86 87 if (run->layoutBox().establishesFormattingContext()) { 87 88 ASSERT(run->layoutBox().isInlineBlockBox()); 88 auto& displayBox = m_layoutState.displayBoxForLayoutBox(run->layoutBox());89 auto& displayBox = layoutState.displayBoxForLayoutBox(run->layoutBox()); 89 90 if (!displayBox.width()) 90 91 continue; … … 110 111 111 112 // Remove descent when all content is baseline aligned but none of them have descent. 112 if (InlineFormattingContext::Quirks( m_layoutState).lineDescentNeedsCollapsing(*m_content)) {113 if (InlineFormattingContext::Quirks(formattingContext()).lineDescentNeedsCollapsing(*m_content)) { 113 114 m_lineLogicalHeight -= m_baseline.descent; 114 115 m_baseline.descent = { }; 115 116 } 116 117 118 auto& layoutState = this->layoutState(); 117 119 for (auto& run : m_content->runs()) { 118 120 LayoutUnit logicalTop; … … 126 128 logicalTop = baselineOffset() - ascent; 127 129 else if (run->isContainerStart()) { 128 auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox);130 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox); 129 131 logicalTop = baselineOffset() - ascent - displayBox.borderTop() - displayBox.paddingTop().valueOr(0); 130 132 } else if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) { 131 auto& formattingState = downcast<InlineFormattingState>( m_layoutState.establishedFormattingState(layoutBox));133 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox)); 132 134 // Spec makes us generate at least one line -even if it is empty. 133 135 ASSERT(!formattingState.lineBoxes().isEmpty()); … … 293 295 void Line::appendNonReplacedInlineBox(const InlineItem& inlineItem, LayoutUnit logicalWidth) 294 296 { 295 auto& displayBox = m_layoutState.displayBoxForLayoutBox(inlineItem.layoutBox());297 auto& displayBox = layoutState().displayBoxForLayoutBox(inlineItem.layoutBox()); 296 298 auto horizontalMargin = displayBox.horizontalMargin(); 297 299 auto logicalRect = Display::Rect { }; … … 372 374 if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) { 373 375 // Inline-blocks with inline content always have baselines. 374 auto& formattingState = downcast<InlineFormattingState>( m_layoutState.establishedFormattingState(layoutBox));376 auto& formattingState = downcast<InlineFormattingState>(layoutState().establishedFormattingState(layoutBox)); 375 377 // Spec makes us generate at least one line -even if it is empty. 376 378 ASSERT(!formattingState.lineBoxes().isEmpty()); … … 412 414 413 415 auto& layoutBox = inlineItem.layoutBox(); 414 ASSERT( m_layoutState.hasDisplayBox(layoutBox));415 auto& displayBox = m_layoutState.displayBoxForLayoutBox(layoutBox);416 ASSERT(layoutState().hasDisplayBox(layoutBox)); 417 auto& displayBox = layoutState().displayBoxForLayoutBox(layoutBox); 416 418 417 419 if (layoutBox.isFloatingPositioned()) … … 440 442 } 441 443 444 LayoutState& Line::layoutState() const 445 { 446 return formattingContext().layoutState(); 447 } 448 449 const InlineFormattingContext& Line::formattingContext() const 450 { 451 return m_inlineFormattingContext; 452 } 453 442 454 } 443 455 } -
trunk/Source/WebCore/layout/inlineformatting/InlineLine.h
r249331 r249349 36 36 namespace Layout { 37 37 38 class InlineFormattingContext; 39 38 40 class Line { 39 41 WTF_MAKE_ISO_ALLOCATED(Line); … … 50 52 }; 51 53 enum class SkipVerticalAligment { No, Yes }; 52 Line( LayoutState&, const InitialConstraints&, SkipVerticalAligment);54 Line(const InlineFormattingContext&, const InitialConstraints&, SkipVerticalAligment); 53 55 54 56 class Content { … … 157 159 bool isVisuallyEmpty() const; 158 160 159 LayoutState& m_layoutState; 161 LayoutState& layoutState() const; 162 const InlineFormattingContext& formattingContext() const; 163 164 const InlineFormattingContext& m_inlineFormattingContext; 160 165 std::unique_ptr<Content> m_content; 161 166 ListHashSet<Content::Run*> m_trimmableContent; -
trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.h
r249331 r249349 46 46 class Geometry : public FormattingContext::Geometry { 47 47 public: 48 Geometry( LayoutState&);48 Geometry(const TableFormattingContext&); 49 49 50 50 HeightAndMargin tableCellHeightAndMargin(const Box&) const; 51 52 private: 53 const TableFormattingContext& formattingContext() const { return downcast<TableFormattingContext>(FormattingContext::Geometry::formattingContext()); } 51 54 }; 52 TableFormattingContext::Geometry geometry() const { return Geometry( layoutState()); }55 TableFormattingContext::Geometry geometry() const { return Geometry(*this); } 53 56 54 57 IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override; … … 64 67 }; 65 68 66 inline TableFormattingContext::Geometry::Geometry( LayoutState& layoutState)67 : FormattingContext::Geometry( layoutState)69 inline TableFormattingContext::Geometry::Geometry(const TableFormattingContext& tableFormattingContext) 70 : FormattingContext::Geometry(tableFormattingContext) 68 71 { 69 72 } … … 71 74 } 72 75 } 76 77 SPECIALIZE_TYPE_TRAITS_LAYOUT_FORMATTING_CONTEXT(TableFormattingContext, isTableFormattingContext()) 78 73 79 #endif
Note: See TracChangeset
for help on using the changeset viewer.