Changeset 234084 in webkit
- Timestamp:
- Jul 21, 2018 11:47:01 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r234083 r234084 1 2018-07-21 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Do not use virtual methods to construct floating/formatting states. 4 https://bugs.webkit.org/show_bug.cgi?id=187875 5 6 Reviewed by Antti Koivisto. 7 8 LayoutContext::establishedFormattingState() does not require FormattingContext anymore only the root of the context. 9 10 * layout/FormattingContext.cpp: 11 (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): 12 * layout/FormattingContext.h: 13 * layout/LayoutContext.cpp: 14 (WebCore::Layout::LayoutContext::layoutFormattingContextSubtree): 15 (WebCore::Layout::LayoutContext::formattingStateForBox const): 16 (WebCore::Layout::LayoutContext::establishedFormattingState): 17 * layout/LayoutContext.h: 18 * layout/blockformatting/BlockFormattingContext.cpp: 19 (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const): 20 (WebCore::Layout::BlockFormattingContext::instrinsicWidthConstraints const): 21 (WebCore::Layout::BlockFormattingContext::createFormattingState const): Deleted. 22 (WebCore::Layout::BlockFormattingContext::createOrFindFloatingState const): Deleted. 23 * layout/blockformatting/BlockFormattingContext.h: 24 * layout/inlineformatting/InlineFormattingContext.cpp: 25 (WebCore::Layout::InlineFormattingContext::createFormattingState const): Deleted. 26 (WebCore::Layout::InlineFormattingContext::createOrFindFloatingState const): Deleted. 27 * layout/inlineformatting/InlineFormattingContext.h: 28 1 29 2018-07-21 Zalan Bujtas <zalan@apple.com> 2 30 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r233469 r234084 131 131 ASSERT(layoutBox.establishesFormattingContext()); 132 132 auto formattingContext = layoutContext.formattingContext(layoutBox); 133 auto& establishedFormattingState = layoutContext.establishedFormattingState(layoutBox, *formattingContext);134 133 135 134 computeBorderAndPadding(layoutContext, layoutBox, displayBox); 136 135 computeOutOfFlowHorizontalGeometry(layoutContext, layoutBox, displayBox); 137 136 138 formattingContext->layout(layoutContext, establishedFormattingState);137 formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox)); 139 138 140 139 computeOutOfFlowVerticalGeometry(layoutContext, layoutBox, displayBox); -
trunk/Source/WebCore/layout/FormattingContext.h
r233469 r234084 53 53 virtual void layout(LayoutContext&, FormattingState&) const = 0; 54 54 void layoutOutOfFlowDescendants(LayoutContext&, const Box&) const; 55 virtual std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&, const LayoutContext&) const = 0;56 virtual Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const = 0;57 55 58 56 struct InstrinsicWidthConstraints { -
trunk/Source/WebCore/layout/LayoutContext.cpp
r233469 r234084 82 82 RELEASE_ASSERT(layoutRoot.establishesFormattingContext()); 83 83 auto formattingContext = this->formattingContext(layoutRoot); 84 auto& formattingState = establishedFormattingState(layoutRoot, *formattingContext); 85 formattingContext->layout(*this, formattingState); 84 formattingContext->layout(*this, establishedFormattingState(layoutRoot)); 86 85 formattingContext->layoutOutOfFlowDescendants(*this, layoutRoot); 87 86 } … … 120 119 } 121 120 122 FormattingState& LayoutContext::establishedFormattingState(const Box& formatting ContextRoot, const FormattingContext& context)121 FormattingState& LayoutContext::establishedFormattingState(const Box& formattingRoot) 123 122 { 124 return *m_formattingStates.ensure(&formattingContextRoot, [this, &context] { 125 return context.createFormattingState(context.createOrFindFloatingState(*this), *this); 126 }).iterator->value; 123 if (formattingRoot.establishesInlineFormattingContext()) { 124 return *m_formattingStates.ensure(&formattingRoot, [&] { 125 126 // If the block container box that initiates this inline formatting context also establishes a block context, the floats outside of the formatting root 127 // should not interfere with the content inside. 128 // <div style="float: left"></div><div style="overflow: hidden"> <- is a non-intrusive float, because overflow: hidden triggers new block formatting context.</div> 129 if (formattingRoot.establishesBlockFormattingContext()) 130 return std::make_unique<InlineFormattingState>(FloatingState::create(), *this); 131 132 // Otherwise, the formatting context inherits the floats from the parent formatting context. 133 // Find the formatting state in which this formatting root lives, not the one it creates and use its floating state. 134 return std::make_unique<InlineFormattingState>(formattingStateForBox(formattingRoot).floatingState(), *this); 135 }).iterator->value; 136 } 137 138 if (formattingRoot.establishesBlockFormattingContext()) { 139 return *m_formattingStates.ensure(&formattingRoot, [&] { 140 141 // Block formatting context always establishes a new floating state. 142 return std::make_unique<BlockFormattingState>(FloatingState::create(), *this); 143 }).iterator->value; 144 } 145 CRASH(); 127 146 } 128 147 -
trunk/Source/WebCore/layout/LayoutContext.h
r233469 r234084 75 75 bool needsUpdate(const Box&) const; 76 76 77 std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot); 78 77 79 FormattingState& formattingStateForBox(const Box&) const; 78 FormattingState& establishedFormattingState(const Box& formattingContextRoot, const FormattingContext&); 79 std::unique_ptr<FormattingContext> formattingContext(const Box& formattingContextRoot); 80 FormattingState& establishedFormattingState(const Box& formattingRoot); 80 81 81 82 Display::Box& createDisplayBox(const Box&); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r233469 r234084 142 142 // Swich over to the new formatting context (the one that the root creates). 143 143 auto formattingContext = layoutContext.formattingContext(layoutBox); 144 auto& establishedFormattingState = layoutContext.establishedFormattingState(layoutBox, *formattingContext); 145 formattingContext->layout(layoutContext, establishedFormattingState); 144 formattingContext->layout(layoutContext, layoutContext.establishedFormattingState(layoutBox)); 146 145 147 146 // Come back and finalize the root's geometry. … … 151 150 // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any). 152 151 formattingContext->layoutOutOfFlowDescendants(layoutContext, layoutBox); 153 }154 155 std::unique_ptr<FormattingState> BlockFormattingContext::createFormattingState(Ref<FloatingState>&& floatingState, const LayoutContext& layoutContext) const156 {157 return std::make_unique<BlockFormattingState>(WTFMove(floatingState), layoutContext);158 }159 160 Ref<FloatingState> BlockFormattingContext::createOrFindFloatingState(LayoutContext&) const161 {162 // Block formatting context always establishes a new floating state.163 return FloatingState::create();164 152 } 165 153 … … 238 226 queue.append(firstChild); 239 227 240 auto& formattingStateForChildren = layoutBox.establishesFormattingContext() ? layoutContext.establishedFormattingState(layoutBox , *this) : formattingState;228 auto& formattingStateForChildren = layoutBox.establishesFormattingContext() ? layoutContext.establishedFormattingState(layoutBox) : formattingState; 241 229 while (!queue.isEmpty()) { 242 230 while (true) { -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h
r233469 r234084 48 48 49 49 void layout(LayoutContext&, FormattingState&) const override; 50 std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&, const LayoutContext&) const override;51 Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override;52 50 53 51 private: -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r234048 r234084 100 100 } 101 101 102 std::unique_ptr<FormattingState> InlineFormattingContext::createFormattingState(Ref<FloatingState>&& floatingState, const LayoutContext& layoutContext) const103 {104 return std::make_unique<InlineFormattingState>(WTFMove(floatingState), layoutContext);105 }106 107 Ref<FloatingState> InlineFormattingContext::createOrFindFloatingState(LayoutContext& layoutContext) const108 {109 // If the block container box that initiates this inline formatting context also establishes a block context, the floats outside of the formatting root110 // should not interfere with the content inside.111 // <div style="float: left"></div><div style="overflow: hidden"> <- is a non-intrusive float, because overflow: hidden triggers new block formatting context.</div>112 if (root().establishesBlockFormattingContext())113 return FloatingState::create();114 // Otherwise, the formatting context inherits the floats from the parent formatting context.115 // Find the formatting state in which this formatting root lives, not the one it creates (this) and use its floating state.116 auto& formattingState = layoutContext.formattingStateForBox(root());117 return formattingState.floatingState();118 }119 120 102 void InlineFormattingContext::computeStaticPosition(LayoutContext&, const Box&, Display::Box&) const 121 103 { -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.h
r233469 r234084 45 45 46 46 void layout(LayoutContext&, FormattingState&) const override; 47 std::unique_ptr<FormattingState> createFormattingState(Ref<FloatingState>&&, const LayoutContext&) const override;48 Ref<FloatingState> createOrFindFloatingState(LayoutContext&) const override;49 47 50 48 private:
Note: See TracChangeset
for help on using the changeset viewer.