Changeset 248290 in webkit
- Timestamp:
- Aug 5, 2019, 10:20:09 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContext.cpp (modified) (1 diff)
-
layout/FormattingContext.h (modified) (1 diff)
-
layout/FormattingState.h (modified) (3 diffs)
-
layout/LayoutState.cpp (modified) (4 diffs)
-
layout/LayoutState.h (modified) (3 diffs)
-
layout/blockformatting/BlockFormattingContext.cpp (modified) (2 diffs)
-
layout/inlineformatting/InlineFormattingContext.cpp (modified) (1 diff)
-
layout/layouttree/LayoutBox.h (modified) (1 diff)
-
layout/layouttree/LayoutContainer.cpp (modified) (1 diff)
-
layout/layouttree/LayoutContainer.h (modified) (2 diffs)
-
layout/layouttree/LayoutTreeBuilder.cpp (modified) (1 diff)
-
page/FrameViewLayoutContext.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r248289 r248290 1 2019-08-05 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Remove out-of-flow descendants from Container 4 https://bugs.webkit.org/show_bug.cgi?id=200430 5 <rdar://problem/53923980> 6 7 Reviewed by Antti Koivisto. 8 9 The out-of-flow descendant list is the last "formatting context type" bit in the layout tree. 10 Let's cached them in the FormattingStates instead for now. 11 12 * layout/FormattingContext.cpp: 13 (WebCore::Layout::FormattingContext::layoutOutOfFlowDescendants const): 14 * layout/FormattingContext.h: 15 * layout/FormattingState.h: 16 (WebCore::Layout::FormattingState::addOutOfFlowBox): 17 (WebCore::Layout::FormattingState::outOfFlowBoxes const): 18 * layout/LayoutState.cpp: 19 (WebCore::Layout::LayoutState::layoutFormattingContextSubtree): 20 (WebCore::Layout::LayoutState::createFormattingStateForFormattingRootIfNeeded): 21 (WebCore::Layout::LayoutState::run): 22 * layout/LayoutState.h: 23 * layout/blockformatting/BlockFormattingContext.cpp: 24 (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot const): 25 * layout/inlineformatting/InlineFormattingContext.cpp: 26 (WebCore::Layout::InlineFormattingContext::layoutFormattingContextRoot const): 27 * layout/layouttree/LayoutBox.h: 28 * layout/layouttree/LayoutContainer.cpp: 29 (WebCore::Layout::Container::addOutOfFlowDescendant): Deleted. 30 * layout/layouttree/LayoutContainer.h: 31 * layout/layouttree/LayoutTreeBuilder.cpp: 32 (WebCore::Layout::TreeBuilder::createLayoutTree): 33 * page/FrameViewLayoutContext.cpp: 34 (WebCore::layoutUsingFormattingContext): 35 1 36 2019-08-05 Devin Rousso <drousso@apple.com> 2 37 -
trunk/Source/WebCore/layout/FormattingContext.cpp
r247198 r248290 134 134 } 135 135 136 void FormattingContext::layoutOutOfFlowDescendants(const Box& layoutBox) const 137 { 138 if (!is<Container>(layoutBox)) 139 return; 140 141 auto& container = downcast<Container>(layoutBox); 142 if (!container.hasChild()) 143 return; 144 145 auto& layoutState = this->layoutState(); 146 LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: layout out-of-flow descendants -> context: " << &layoutState << " root: " << &root()); 147 148 for (auto& outOfFlowBox : container.outOfFlowDescendants()) { 149 auto& layoutBox = *outOfFlowBox; 150 151 ASSERT(layoutBox.establishesFormattingContext()); 152 153 computeBorderAndPadding(layoutBox); 154 computeOutOfFlowHorizontalGeometry(layoutBox); 155 156 layoutState.createFormattingContext(layoutBox)->layout(); 157 158 computeOutOfFlowVerticalGeometry(layoutBox); 159 layoutOutOfFlowDescendants(layoutBox); 160 } 161 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutState << " root: " << &root()); 136 void FormattingContext::layoutOutOfFlowDescendants() const 137 { 138 LOG_WITH_STREAM(FormattingContextLayout, stream << "Start: layout out-of-flow descendants -> context: " << &layoutState() << " root: " << &root()); 139 140 for (auto& outOfFlowBox : formattingState().outOfFlowBoxes()) { 141 ASSERT(outOfFlowBox->establishesFormattingContext()); 142 143 computeBorderAndPadding(*outOfFlowBox); 144 computeOutOfFlowHorizontalGeometry(*outOfFlowBox); 145 146 auto formattingContext = layoutState().createFormattingContext(*outOfFlowBox); 147 formattingContext->layout(); 148 149 computeOutOfFlowVerticalGeometry(*outOfFlowBox); 150 formattingContext->layoutOutOfFlowDescendants(); 151 } 152 LOG_WITH_STREAM(FormattingContextLayout, stream << "End: layout out-of-flow descendants -> context: " << &layoutState() << " root: " << &root()); 162 153 } 163 154 -
trunk/Source/WebCore/layout/FormattingContext.h
r248262 r248290 51 51 52 52 virtual void layout() const = 0; 53 void layoutOutOfFlowDescendants( const Box&) const;53 void layoutOutOfFlowDescendants() const; 54 54 55 55 struct IntrinsicWidthConstraints { -
trunk/Source/WebCore/layout/FormattingState.h
r248262 r248290 34 34 #include "LayoutUnit.h" 35 35 #include <wtf/IsoMalloc.h> 36 #include <wtf/WeakPtr.h> 36 37 37 38 namespace WebCore { … … 65 66 LayoutState& layoutState() const { return m_layoutState; } 66 67 68 // Since we layout the out-of-flow boxes at the end of the formatting context layout, it's okay to store them in the formatting state -as opposed to the containing block level. 69 using OutOfFlowBoxList = Vector<WeakPtr<const Box>>; 70 void addOutOfFlowBox(const Box& outOfFlowBox) { m_outOfFlowBoxes.append(makeWeakPtr(outOfFlowBox)); } 71 void removeOutOfFlowBox(const Box&); 72 const OutOfFlowBoxList& outOfFlowBoxes() const { return m_outOfFlowBoxes; } 73 67 74 protected: 68 75 enum class Type { Block, Inline, Table }; … … 74 81 HashMap<const Box*, FormattingContext::IntrinsicWidthConstraints> m_intrinsicWidthConstraintsForBoxes; 75 82 Optional<FormattingContext::IntrinsicWidthConstraints> m_intrinsicWidthConstraints; 83 // FIXME: This needs WeakListHashSet 84 OutOfFlowBoxList m_outOfFlowBoxes; 76 85 Type m_type; 77 86 }; -
trunk/Source/WebCore/layout/LayoutState.cpp
r248263 r248290 39 39 #include "LayoutBox.h" 40 40 #include "LayoutContainer.h" 41 #include "LayoutTreeBuilder.h" 42 #include "RenderView.h" 41 43 #include "TableFormattingContext.h" 42 44 #include "TableFormattingState.h" … … 81 83 auto formattingContext = createFormattingContext(layoutRoot); 82 84 formattingContext->layout(); 83 formattingContext->layoutOutOfFlowDescendants( layoutRoot);85 formattingContext->layoutOutOfFlowDescendants(); 84 86 } 85 87 … … 138 140 // Otherwise, the formatting context inherits the floats from the parent formatting context. 139 141 // Find the formatting state in which this formatting root lives, not the one it creates and use its floating state. 140 return std::make_unique<InlineFormattingState>(formattingStateForBox(formattingRoot).floatingState(), *this); 142 auto& parentFormattingState = createFormattingStateForFormattingRootIfNeeded(formattingRoot.formattingContextRoot()); 143 auto& parentFloatingState = parentFormattingState.floatingState(); 144 return std::make_unique<InlineFormattingState>(parentFloatingState, *this); 141 145 }).iterator->value; 142 146 } … … 183 187 } 184 188 189 void LayoutState::run(const RenderView& renderView) 190 { 191 auto initialContainingBlock = TreeBuilder::createLayoutTree(renderView); 192 auto layoutState = LayoutState(*initialContainingBlock); 193 // Not efficient, but this is temporary anyway. 194 // Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same). 195 for (auto& descendant : descendantsOfType<Box>(*initialContainingBlock)) { 196 if (!descendant.isOutOfFlowPositioned()) 197 continue; 198 auto& formattingState = layoutState.createFormattingStateForFormattingRootIfNeeded(descendant.formattingContextRoot()); 199 formattingState.addOutOfFlowBox(descendant); 200 } 201 auto quirksMode = [&] { 202 auto& document = renderView.document(); 203 if (document.inLimitedQuirksMode()) 204 return QuirksMode::Limited; 205 if (document.inQuirksMode()) 206 return QuirksMode::Yes; 207 return QuirksMode::No; 208 }; 209 layoutState.setQuirksMode(quirksMode()); 210 layoutState.updateLayout(); 211 layoutState.verifyAndOutputMismatchingLayoutTree(renderView); 212 } 213 185 214 } 186 215 } -
trunk/Source/WebCore/layout/LayoutState.h
r246540 r248290 28 28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 29 30 #include "LayoutContainer.h" 30 31 #include <wtf/HashMap.h> 31 32 #include <wtf/HashSet.h> … … 48 49 enum class StyleDiff; 49 50 class Box; 50 class Container;51 51 class FormattingContext; 52 52 class FormattingState; … … 62 62 public: 63 63 LayoutState(const Container& initialContainingBlock); 64 65 // FIXME: This is a temporary entry point for LFC layout. 66 static void run(const RenderView&); 64 67 65 68 void updateLayout(); -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
r248262 r248290 173 173 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Height][Margin] -> for layoutBox(" << &layoutBox << ")"); 174 174 computeHeightAndMargin(layoutBox); 175 // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any). 176 formattingContext->layoutOutOfFlowDescendants(); 175 177 176 178 // Float related final positioning. … … 180 182 } else if (layoutBox.establishesBlockFormattingContext()) 181 183 computePositionToAvoidFloats(floatingContext, layoutBox); 182 183 // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any).184 formattingContext->layoutOutOfFlowDescendants(layoutBox);185 184 } 186 185 -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r248262 r248290 250 250 computeHeightAndMargin(root); 251 251 // Now that we computed the root's height, we can go back and layout the out-of-flow descedants (if any). 252 formattingContext->layoutOutOfFlowDescendants( root);252 formattingContext->layoutOutOfFlowDescendants(); 253 253 } 254 254 -
trunk/Source/WebCore/layout/layouttree/LayoutBox.h
r248200 r248290 98 98 99 99 const Container* containingBlock() const; 100 virtualconst Container& formattingContextRoot() const;100 const Container& formattingContextRoot() const; 101 101 const Container& initialContainingBlock() const; 102 102 -
trunk/Source/WebCore/layout/layouttree/LayoutContainer.cpp
r239427 r248290 92 92 } 93 93 94 void Container::addOutOfFlowDescendant(const Box& outOfFlowBox)95 {96 // Since we layout the out-of-flow boxes at the end of the formatting context layout,97 // it's okay to store them at the formatting context root level -as opposed to the containing block level.98 ASSERT(establishesFormattingContext());99 m_outOfFlowDescendants.append(makeWeakPtr(outOfFlowBox));100 }101 102 94 } 103 95 } -
trunk/Source/WebCore/layout/layouttree/LayoutContainer.h
r248200 r248290 30 30 #include "LayoutBox.h" 31 31 #include <wtf/IsoMalloc.h> 32 #include <wtf/WeakPtr.h>33 32 34 33 namespace WebCore { … … 54 53 bool hasInFlowOrFloatingChild() const { return firstInFlowOrFloatingChild(); } 55 54 56 const Vector<WeakPtr<const Box>>& outOfFlowDescendants() const { return m_outOfFlowDescendants; }57 58 55 void setFirstChild(Box&); 59 56 void setLastChild(Box&); 60 void addOutOfFlowDescendant(const Box&);61 57 62 58 private: 63 59 Box* m_firstChild { nullptr }; 64 60 Box* m_lastChild { nullptr }; 65 Vector<WeakPtr<const Box>> m_outOfFlowDescendants;66 61 }; 67 62 -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r248200 r248290 76 76 std::unique_ptr<Container> initialContainingBlock(new Container(WTF::nullopt, WTFMove(style))); 77 77 TreeBuilder::createSubTree(renderView, *initialContainingBlock); 78 79 // Not efficient, but this is temporary anyway.80 // Collect the out-of-flow descendants at the formatting root level (as opposed to at the containing block level, though they might be the same).81 for (auto& descendant : descendantsOfType<Box>(*initialContainingBlock)) {82 if (!descendant.isOutOfFlowPositioned())83 continue;84 const_cast<Container&>(descendant.formattingContextRoot()).addOutOfFlowDescendant(descendant);85 }86 87 78 return initialContainingBlock; 88 79 } -
trunk/Source/WebCore/page/FrameViewLayoutContext.cpp
r246477 r248290 40 40 #include "ScriptDisallowedScope.h" 41 41 #include "Settings.h" 42 43 42 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 44 #include "FormattingState.h"45 #include "LayoutContainer.h"46 43 #include "LayoutState.h" 47 #include "LayoutTreeBuilder.h"48 44 #endif 49 45 … … 59 55 if (!RuntimeEnabledFeatures::sharedFeatures().layoutFormattingContextEnabled()) 60 56 return; 61 auto initialContainingBlock = Layout::TreeBuilder::createLayoutTree(renderView); 62 auto layoutState = std::make_unique<Layout::LayoutState>(*initialContainingBlock); 63 auto quirksMode = Layout::LayoutState::QuirksMode::No; 64 if (renderView.document().inLimitedQuirksMode()) 65 quirksMode = Layout::LayoutState::QuirksMode::Limited; 66 else if (renderView.document().inQuirksMode()) 67 quirksMode = Layout::LayoutState::QuirksMode::Yes; 68 layoutState->setQuirksMode(quirksMode); 69 layoutState->updateLayout(); 70 layoutState->verifyAndOutputMismatchingLayoutTree(renderView); 57 Layout::LayoutState::run(renderView); 71 58 } 72 59 #endif
Note:
See TracChangeset
for help on using the changeset viewer.