Changeset 253032 in webkit
- Timestamp:
- Dec 3, 2019 2:51:46 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 13 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r253031 r253032 1 2019-12-03 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] Setup root box properties 4 https://bugs.webkit.org/show_bug.cgi?id=204743 5 6 Reviewed by Zalan Bujtas. 7 8 * fast/layoutformattingcontext/flow-integration-basic.html: Added. 9 * platform/mac/fast/layoutformattingcontext/flow-integration-basic-expected.txt: Added. 10 1 11 2019-12-03 Zan Dobersek <zdobersek@igalia.com> 2 12 -
trunk/Source/WebCore/CMakeLists.txt
r252226 r253032 106 106 "${WEBCORE_DIR}/layout/inlineformatting" 107 107 "${WEBCORE_DIR}/layout/inlineformatting/text" 108 "${WEBCORE_DIR}/layout/integration" 108 109 "${WEBCORE_DIR}/layout/layouttree" 109 110 "${WEBCORE_DIR}/loader" -
trunk/Source/WebCore/ChangeLog
r253031 r253032 1 2019-12-03 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] Setup root box properties 4 https://bugs.webkit.org/show_bug.cgi?id=204743 5 6 Reviewed by Zalan Bujtas. 7 8 Test: fast/layoutformattingcontext/flow-integration-basic.html 9 10 Line layout needs to know about flow borders and padding so that boxes are offset correctly. 11 12 * CMakeLists.txt: 13 * Sources.txt: 14 * WebCore.xcodeproj/project.pbxproj: 15 * layout/LayoutContext.cpp: 16 (WebCore::Layout::LayoutContext::layout): 17 (WebCore::Layout::LayoutContext::layoutWithPreparedRootGeometry): 18 19 Split setup and layout into separate functions. 20 21 * layout/LayoutContext.h: 22 * layout/LayoutState.cpp: 23 (WebCore::Layout::LayoutState::displayBoxForLayoutRoot): 24 * layout/LayoutState.h: 25 * layout/displaytree/DisplayPainter.cpp: 26 (WebCore::Display::paintInlineContent): 27 (WebCore::Display::Painter::paint): 28 (WebCore::Display::Painter::paintInlineFlow): 29 30 Avoid accessing tree root box properties when painting (since margins are not set up). 31 32 * layout/integration/RenderBlockFlowLineLayout.cpp: Renamed from Source/WebCore/layout/RenderBlockFlowLineLayout.cpp. 33 34 Moved to integration subdirectory. 35 36 (WebCore::Layout::RenderBlockFlowLineLayout::layout): 37 38 Drop the content size paramater, the caller is responsible of setting up the root display box. 39 40 (WebCore::Layout::RenderBlockFlowLineLayout::prepareRootDisplayBoxForLayout): 41 42 Setup padding and borders. 43 44 (WebCore::Layout::RenderBlockFlowLineLayout::displayInlineContent const): 45 (WebCore::Layout::RenderBlockFlowLineLayout::rootLayoutBox const): 46 * layout/integration/RenderBlockFlowLineLayout.h: Renamed from Source/WebCore/layout/RenderBlockFlowLineLayout.h. 47 (WebCore::Layout::RenderBlockFlowLineLayout::contentLogicalHeight const): 48 49 Use a member to pass content height. 50 51 * layout/layouttree/LayoutTreeBuilder.h: 52 (WebCore::Layout::LayoutTreeContent::layoutBoxForRenderer const): 53 * rendering/RenderBlockFlow.cpp: 54 (WebCore::RenderBlockFlow::layoutLFCLines): 55 1 56 2019-12-03 Zan Dobersek <zdobersek@igalia.com> 2 57 -
trunk/Source/WebCore/Sources.txt
r252966 r253032 1423 1423 layout/LayoutState.cpp 1424 1424 layout/LayoutUnits.cpp 1425 layout/RenderBlockFlowLineLayout.cpp1426 1425 layout/Verification.cpp 1427 1426 layout/blockformatting/BlockFormattingContext.cpp … … 1446 1445 layout/inlineformatting/LineLayoutContext.cpp 1447 1446 layout/inlineformatting/text/TextUtil.cpp 1447 layout/integration/RenderBlockFlowLineLayout.cpp 1448 1448 layout/invalidation/InvalidationContext.cpp 1449 1449 layout/invalidation/InvalidationState.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r253025 r253032 16630 16630 6FCFC055212DACC2007695D2 /* floats */, 16631 16631 115CFA9A208BC140001E6991 /* inlineformatting */, 16632 E4FB4B1E2395356F003C336A /* integration */, 16632 16633 6F95DE4A237B883000E517E1 /* invalidation */, 16633 16634 115CFA90208B9441001E6991 /* layouttree */, … … 16648 16649 6F73918C2106CEDD006AF262 /* LayoutUnits.h */, 16649 16650 6FE7AA2621C37B6300296DCD /* MarginTypes.h */, 16650 E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */,16651 E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */,16652 16651 11FF02D520BA3C810083F25B /* Verification.cpp */, 16653 16652 ); … … 16692 16691 isa = PBXGroup; 16693 16692 children = ( 16693 E435505223953457004829C0 /* integration */, 16694 16694 6FE7DDDD20EC6E8B008B5B4E /* text */, 16695 16695 6F7CA3C9208C2B2E002F29AB /* InlineFormattingContext.cpp */, … … 27022 27022 sourceTree = "<group>"; 27023 27023 }; 27024 E435505223953457004829C0 /* integration */ = { 27025 isa = PBXGroup; 27026 children = ( 27027 ); 27028 path = integration; 27029 sourceTree = "<group>"; 27030 }; 27024 27031 E46E97860DAAD61B0071E894 /* animation */ = { 27025 27032 isa = PBXGroup; … … 27143 27150 ); 27144 27151 path = updating; 27152 sourceTree = "<group>"; 27153 }; 27154 E4FB4B1E2395356F003C336A /* integration */ = { 27155 isa = PBXGroup; 27156 children = ( 27157 E4ABABDE2360893D00FA4345 /* RenderBlockFlowLineLayout.cpp */, 27158 E4ABABDB236088FD00FA4345 /* RenderBlockFlowLineLayout.h */, 27159 ); 27160 path = integration; 27145 27161 sourceTree = "<group>"; 27146 27162 }; -
trunk/Source/WebCore/layout/LayoutContext.cpp
r252912 r253032 59 59 void LayoutContext::layout(const LayoutSize& rootContentBoxSize, InvalidationState& invalidationState) 60 60 { 61 PhaseScope scope(Phase::Type::Layout);62 61 // Set the geometry on the root. 63 62 // Note that we never layout the root box. It has to have an already computed geometry (in case of ICB, it's the view geometry). 64 63 // ICB establishes the initial BFC, but it does not live in a formatting context and while a non-ICB root(subtree layout) has to have a formatting context, 65 64 // we could not lay it out even if we wanted to since it's outside of this LayoutContext. 66 auto& displayBox = layoutState().displayBoxFor LayoutBox(layoutState().root());65 auto& displayBox = layoutState().displayBoxForRootLayoutBox(); 67 66 displayBox.setHorizontalMargin({ }); 68 67 displayBox.setHorizontalComputedMargin({ }); … … 74 73 displayBox.setContentBoxWidth(rootContentBoxSize.width()); 75 74 75 layoutWithPreparedRootGeometry(invalidationState); 76 } 77 78 void LayoutContext::layoutWithPreparedRootGeometry(InvalidationState& invalidationState) 79 { 80 PhaseScope scope(Phase::Type::Layout); 81 76 82 auto& formattingContextRootsForLayout = invalidationState.formattingContextRoots(); 77 83 // When invalidation is empty, we assume constraint mutation and start running layout on the context root. Layout logic should be able to figure out the damage. … … 82 88 layoutFormattingContextSubtree(formattingContextRoot, invalidationState); 83 89 } 90 84 91 85 92 void LayoutContext::layoutFormattingContextSubtree(const Container& formattingContextRoot, InvalidationState& invalidationState) -
trunk/Source/WebCore/layout/LayoutContext.h
r252534 r253032 53 53 public: 54 54 LayoutContext(LayoutState&); 55 55 56 void layout(const LayoutSize& rootContentBoxSize, InvalidationState&); 57 void layoutWithPreparedRootGeometry(InvalidationState&); 56 58 57 59 static std::unique_ptr<FormattingContext> createFormattingContext(const Container& formattingContextRoot, LayoutState&); -
trunk/Source/WebCore/layout/LayoutState.cpp
r252534 r253032 57 57 58 58 LayoutState::~LayoutState() = default; 59 60 Display::Box& LayoutState::displayBoxForRootLayoutBox() 61 { 62 return displayBoxForLayoutBox(m_layoutTreeContent->rootLayoutBox()); 63 } 59 64 60 65 Display::Box& LayoutState::displayBoxForLayoutBox(const Box& layoutBox) -
trunk/Source/WebCore/layout/LayoutState.h
r252534 r253032 63 63 #endif 64 64 65 Display::Box& displayBoxForRootLayoutBox(); 65 66 Display::Box& displayBoxForLayoutBox(const Box& layoutBox); 66 67 const Display::Box& displayBoxForLayoutBox(const Box& layoutBox) const; -
trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp
r252979 r253032 111 111 } 112 112 113 static void paintInlineContent(GraphicsContext& context, const Box& rootAbsoluteDisplayBox, const Layout::InlineFormattingState& formattingState)113 static void paintInlineContent(GraphicsContext& context, LayoutPoint absoluteOffset, const Layout::InlineFormattingState& formattingState) 114 114 { 115 115 auto* displayInlineContent = formattingState.displayInlineContent(); … … 127 127 context.setFillColor(style.color()); 128 128 129 auto logicalLeft = rootAbsoluteDisplayBox.left() + run.logicalLeft();129 auto logicalLeft = absoluteOffset.x() + run.logicalLeft(); 130 130 // FIXME: Add non-baseline align painting 131 131 auto& lineBox = displayInlineContent->lineBoxForRun(run); 132 auto baselineOffset = rootAbsoluteDisplayBox.top() + lineBox.logicalTop() + lineBox.baselineOffset();132 auto baselineOffset = absoluteOffset.y() + lineBox.logicalTop() + lineBox.baselineOffset(); 133 133 if (auto expansionContext = textContext->expansion()) 134 134 context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft, expansionContext->horizontalExpansion, expansionContext->behavior }, { logicalLeft, baselineOffset }); … … 136 136 context.drawText(style.fontCascade(), TextRun { textContext->content(), logicalLeft }, { logicalLeft, baselineOffset }); 137 137 } else if (auto* cachedImage = run.image()) { 138 auto runAbsoluteRect = FloatRect { rootAbsoluteDisplayBox.left() + run.logicalLeft(), rootAbsoluteDisplayBox.top() + run.logicalTop(), run.logicalWidth(), run.logicalHeight() };138 auto runAbsoluteRect = FloatRect { absoluteOffset.x() + run.logicalLeft(), absoluteOffset.y() + run.logicalTop(), run.logicalWidth(), run.logicalHeight() }; 139 139 context.drawImage(*cachedImage->image(), runAbsoluteRect); 140 140 } … … 195 195 if (layoutBox.establishesInlineFormattingContext()) { 196 196 auto& container = downcast<Layout::Container>(layoutBox); 197 paintInlineContent(context, absoluteDisplayBox , downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(container)));197 paintInlineContent(context, absoluteDisplayBox.topLeft(), downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(container))); 198 198 continue; 199 199 } … … 207 207 ASSERT(layoutRoot.establishesInlineFormattingContext()); 208 208 209 auto& displayBox = layoutState.displayBoxForLayoutBox(layoutRoot); 210 211 paintInlineContent(context, displayBox, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(layoutRoot))); 209 paintInlineContent(context, { }, downcast<Layout::InlineFormattingState>(layoutState.establishedFormattingState(layoutRoot))); 212 210 } 213 211 -
trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.cpp
r253031 r253032 75 75 m_layoutState = makeUnique<LayoutState>(*m_treeContent); 76 76 77 auto& rootContainer = m_layoutState->root(); 77 prepareRootGeometryForLayout(); 78 78 79 auto layoutContext = LayoutContext { *m_layoutState }; 79 80 auto invalidationState = InvalidationState { }; 80 layoutContext.layout(m_flow.contentSize(), invalidationState);81 81 82 auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootContainer)).displayInlineContent()->lineBoxes; 83 auto height = lineBoxes.last().logicalBottom(); 82 layoutContext.layoutWithPreparedRootGeometry(invalidationState); 84 83 85 auto& displayBox = m_layoutState->displayBoxForLayoutBox(rootContainer);86 displayBox.setContentBoxHeight(height);84 auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent()->lineBoxes; 85 m_contentLogicalHeight = lineBoxes.last().logicalBottom() - lineBoxes.first().logicalTop(); 87 86 } 88 87 89 LayoutUnit RenderBlockFlowLineLayout::contentBoxHeight() const 88 void RenderBlockFlowLineLayout::prepareRootGeometryForLayout() 90 89 { 91 return m_layoutState ? m_layoutState->displayBoxForLayoutBox(m_layoutState->root()).contentBoxHeight() : 0_lu; 90 auto& displayBox = m_layoutState->displayBoxForRootLayoutBox(); 91 92 // Don't set marging properties or height. These should not be be accessed by inline layout. 93 displayBox.setBorder(Layout::Edges { { m_flow.borderStart(), m_flow.borderEnd() }, { m_flow.borderBefore(), m_flow.borderAfter() } }); 94 displayBox.setPadding(Layout::Edges { { m_flow.paddingStart(), m_flow.paddingEnd() }, { m_flow.paddingBefore(), m_flow.paddingAfter() } }); 95 displayBox.setContentBoxWidth(m_flow.contentSize().width()); 92 96 } 93 97 94 98 const Display::InlineContent* RenderBlockFlowLineLayout::displayInlineContent() const 95 99 { 96 return downcast<InlineFormattingState>(m_layoutState->establishedFormattingState( m_treeContent->rootLayoutBox())).displayInlineContent();100 return downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootLayoutBox())).displayInlineContent(); 97 101 } 98 102 … … 150 154 } 151 155 156 const Container& RenderBlockFlowLineLayout::rootLayoutBox() const 157 { 158 return m_treeContent->rootLayoutBox(); 159 } 160 152 161 } 153 162 } -
trunk/Source/WebCore/layout/integration/RenderBlockFlowLineLayout.h
r253031 r253032 56 56 57 57 void layout(); 58 LayoutUnit contentBoxHeight() const; 58 59 LayoutUnit contentLogicalHeight() const { return m_contentLogicalHeight; } 59 60 const Display::InlineContent* displayInlineContent() const; 60 61 … … 65 66 66 67 private: 68 const Container& rootLayoutBox() const; 69 void prepareRootGeometryForLayout(); 70 67 71 const RenderBlockFlow& m_flow; 68 std::unique_ptr< LayoutTreeContent> m_treeContent;72 std::unique_ptr<const LayoutTreeContent> m_treeContent; 69 73 std::unique_ptr<LayoutState> m_layoutState; 74 LayoutUnit m_contentLogicalHeight; 70 75 }; 71 76 -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r252979 r253032 455 455 auto& layoutRoot = layoutState.root(); 456 456 auto invalidationState = InvalidationState { }; 457 457 458 LayoutContext(layoutState).layout(renderView.size(), invalidationState); 458 459 showLayoutTree(layoutRoot, &layoutState); -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.h
r252893 r253032 58 58 void addBox(std::unique_ptr<Box> box) { m_boxes.add(WTFMove(box)); } 59 59 60 using RenderObjectToLayoutBoxMap = HashMap<const RenderObject*, Box*>;61 60 Box* layoutBoxForRenderer(const RenderObject& renderer) { return m_renderObjectToLayoutBox.get(&renderer); } 61 const Box* layoutBoxForRenderer(const RenderObject& renderer) const { return m_renderObjectToLayoutBox.get(&renderer); } 62 62 63 void addLayoutBoxForRenderer(const RenderObject& renderer, Box& layoutBox) { m_renderObjectToLayoutBox.add(&renderer, &layoutBox); } 63 64 … … 66 67 std::unique_ptr<Container> m_rootLayoutBox; 67 68 HashSet<std::unique_ptr<Box>> m_boxes; 68 RenderObjectToLayoutBoxMap m_renderObjectToLayoutBox; 69 70 HashMap<const RenderObject*, Box*> m_renderObjectToLayoutBox; 69 71 }; 70 72 -
trunk/Source/WebCore/rendering/RenderBlockFlow.cpp
r252907 r253032 3681 3681 lfcLineLayout.layout(); 3682 3682 3683 LayoutUnit lineLayoutHeight = lfcLineLayout.contentBoxHeight(); 3684 LayoutUnit lineLayoutTop = borderAndPaddingBefore(); 3685 repaintLogicalTop = lineLayoutTop; 3686 repaintLogicalBottom = repaintLogicalTop + lineLayoutHeight + borderAndPaddingAfter(); 3687 setLogicalHeight(lineLayoutTop + lineLayoutHeight + borderAndPaddingAfter()); 3683 auto contentHeight = lfcLineLayout.contentLogicalHeight(); 3684 auto contentTop = borderAndPaddingBefore(); 3685 auto contentBottom = contentTop + contentHeight; 3686 auto totalHeight = contentBottom + borderAndPaddingAfter(); 3687 3688 repaintLogicalTop = contentTop; 3689 repaintLogicalBottom = contentBottom; 3690 3691 setLogicalHeight(totalHeight); 3688 3692 } 3689 3693 #endif
Note: See TracChangeset
for help on using the changeset viewer.