Changeset 252979 in webkit
- Timestamp:
- Dec 2, 2019 1:28:57 AM (4 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 18 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r252977 r252979 1 2019-12-02 Antti Koivisto <antti@apple.com> 2 3 [LFC][Render tree] Support LFC in LineLayoutTraversal 4 https://bugs.webkit.org/show_bug.cgi?id=204727 5 6 Reviewed by Zalan Bujtas. 7 8 Add support for traversing LFC inline layout to TextBoxIterator and ElementBoxIterator. 9 This makes render tree dumps and TextIterator work with LFC layout. 10 11 * Headers.cmake: 12 * WebCore.xcodeproj/project.pbxproj: 13 * layout/FormattingContextGeometry.cpp: 14 (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const): 15 * layout/RenderBlockFlowLineLayout.cpp: 16 (WebCore::Layout::RenderBlockFlowLineLayout::layout): 17 (WebCore::Layout::RenderBlockFlowLineLayout::inlineResults const): 18 (WebCore::Layout::RenderBlockFlowLineLayout::textBoxesFor const): 19 (WebCore::Layout::RenderBlockFlowLineLayout::elementBoxFor const): 20 * layout/RenderBlockFlowLineLayout.h: 21 * layout/Verification.cpp: 22 (WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded): 23 (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded): 24 * layout/blockformatting/BlockFormattingContextGeometry.cpp: 25 (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin): 26 * layout/blockformatting/BlockMarginCollapse.cpp: 27 (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough const): 28 * layout/displaytree/DisplayPainter.cpp: 29 (WebCore::Display::paintInlineContent): 30 * layout/displaytree/DisplayRun.h: 31 (WebCore::Display::Run::layoutBox const): 32 33 Replace style with layout box weak pointer. This allows finding runs for a given box. 34 35 (WebCore::Display::Run::style const): 36 37 Get style from the layout box. 38 39 (WebCore::Display::Run::Run): 40 * layout/inlineformatting/InlineFormattingContext.cpp: 41 (WebCore::Layout::InlineFormattingContext::setDisplayBoxesForLine): 42 (WebCore::Layout::InlineFormattingContext::invalidateFormattingState): 43 * layout/inlineformatting/InlineFormattingContextQuirks.cpp: 44 (WebCore::Layout::InlineFormattingContext::Quirks::lineDescentNeedsCollapsing const): 45 * layout/inlineformatting/InlineFormattingState.h: 46 (WebCore::Layout::InlineFormattingState::results const): 47 (WebCore::Layout::InlineFormattingState::clearResults): 48 (WebCore::Layout::InlineFormattingState::ensureResults): 49 (WebCore::Layout::InlineFormattingState::displayRuns const): Deleted. 50 (WebCore::Layout::InlineFormattingState::displayRuns): Deleted. 51 (WebCore::Layout::InlineFormattingState::lineBoxes const): Deleted. 52 (WebCore::Layout::InlineFormattingState::lineBoxes): Deleted. 53 (WebCore::Layout::InlineFormattingState::addLineBox): Deleted. 54 (WebCore::Layout::InlineFormattingState::lineBoxForRun const): Deleted. 55 (WebCore::Layout::InlineFormattingState::addDisplayRun): Deleted. 56 (WebCore::Layout::InlineFormattingState::resetDisplayRuns): Deleted. 57 * layout/inlineformatting/InlineLineBuilder.cpp: 58 (WebCore::Layout::LineBuilder::alignContentVertically): 59 (WebCore::Layout::LineBuilder::adjustBaselineAndLineHeight): 60 * layout/displaytree/DisplayInlineContent.h: Copied from Source/WebCore/layout/RenderBlockFlowLineLayout.h. 61 (WebCore::Display::InlineContent::lineBoxForRun const): 62 63 Factor into a struct. Make it refcounted for safe access from line layout iterators. 64 65 (WebCore::Layout::outputInlineRuns): 66 * rendering/line/LineLayoutTraversal.cpp: 67 (WebCore::LineLayoutTraversal::TextBoxIterator::TextBoxIterator): 68 (WebCore::LineLayoutTraversal::flowForText): 69 (WebCore::LineLayoutTraversal::firstTextBoxFor): 70 (WebCore::LineLayoutTraversal::firstTextBoxInTextOrderFor): 71 (WebCore::LineLayoutTraversal::ElementBoxIterator::ElementBoxIterator): 72 (WebCore::LineLayoutTraversal::elementBoxFor): 73 * rendering/line/LineLayoutTraversal.h: 74 * rendering/line/LineLayoutTraversalDisplayRunPath.h: Added. 75 (WebCore::LineLayoutTraversal::linePosition): 76 (WebCore::LineLayoutTraversal::DisplayRunPath::DisplayRunPath): 77 78 New path for traversing display runs. 79 80 (WebCore::LineLayoutTraversal::DisplayRunPath::rect const): 81 (WebCore::LineLayoutTraversal::DisplayRunPath::logicalRect const): 82 (WebCore::LineLayoutTraversal::DisplayRunPath::isLeftToRightDirection const): 83 (WebCore::LineLayoutTraversal::DisplayRunPath::dirOverride const): 84 (WebCore::LineLayoutTraversal::DisplayRunPath::isLineBreak const): 85 (WebCore::LineLayoutTraversal::DisplayRunPath::hasHyphen const): 86 (WebCore::LineLayoutTraversal::DisplayRunPath::text const): 87 (WebCore::LineLayoutTraversal::DisplayRunPath::localStartOffset const): 88 (WebCore::LineLayoutTraversal::DisplayRunPath::localEndOffset const): 89 (WebCore::LineLayoutTraversal::DisplayRunPath::length const): 90 (WebCore::LineLayoutTraversal::DisplayRunPath::isLastOnLine const): 91 (WebCore::LineLayoutTraversal::DisplayRunPath::isLast const): 92 (WebCore::LineLayoutTraversal::DisplayRunPath::traverseNextTextBoxInVisualOrder): 93 (WebCore::LineLayoutTraversal::DisplayRunPath::traverseNextTextBoxInTextOrder): 94 (WebCore::LineLayoutTraversal::DisplayRunPath::operator== const): 95 (WebCore::LineLayoutTraversal::DisplayRunPath::atEnd const): 96 (WebCore::LineLayoutTraversal::DisplayRunPath::displayRuns const): 97 (WebCore::LineLayoutTraversal::DisplayRunPath::firstRun const): 98 (WebCore::LineLayoutTraversal::DisplayRunPath::run const): 99 1 100 2019-12-01 Tim Horton <timothy_horton@apple.com> 2 101 -
trunk/Source/WebCore/Headers.cmake
r252959 r252979 1322 1322 rendering/line/LineLayoutTraversal.h 1323 1323 rendering/line/LineLayoutTraversalComplexPath.h 1324 rendering/line/LineLayoutTraversalDisplayRunPath.h 1324 1325 rendering/line/LineLayoutTraversalSimplePath.h 1325 1326 rendering/line/LineWidth.h -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r252966 r252979 2043 2043 6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; }; 2044 2044 6FB11B5C21783FD000E2A574 /* TextUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB11B5921783FCF00E2A574 /* TextUtil.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2045 6FB47E632277425A00C7BCB0 /* InlineLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */; };2045 6FB47E632277425A00C7BCB0 /* InlineLineBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB47E612277425A00C7BCB0 /* InlineLineBox.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2046 2046 6FB5E214221F2453003989CF /* ContentChangeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FB5E212221F2447003989CF /* ContentChangeObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2047 2047 6FCE1A1A22618ABD004F0343 /* DisplayRun.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FCE1A1822618AB3004F0343 /* DisplayRun.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4819 4819 E44B4BB4141650D7002B1D8B /* SelectorChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = E44B4BB2141650D7002B1D8B /* SelectorChecker.h */; }; 4820 4820 E44FA1851BCA6B5A0091B6EF /* ComposedTreeIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */; }; 4821 E451C628239293EC00993190 /* LineLayoutTraversalDisplayRunPath.h in Headers */ = {isa = PBXBuildFile; fileRef = E451C627239293EB00993190 /* LineLayoutTraversalDisplayRunPath.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4822 E451C6312394027900993190 /* LayoutUnits.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F73918C2106CEDD006AF262 /* LayoutUnits.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4823 E451C6322394031A00993190 /* MarginTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FE7AA2621C37B6300296DCD /* MarginTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4824 E451C6342394058F00993190 /* DisplayInlineContent.h in Headers */ = {isa = PBXBuildFile; fileRef = E451C6332394058E00993190 /* DisplayInlineContent.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4821 4825 E45322AC140CE267005A0F92 /* SelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = E45322AA140CE267005A0F92 /* SelectorQuery.h */; }; 4822 4826 E45BA6AA2374926C004DFC07 /* MatchedDeclarationsCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E45BA6A82374926B004DFC07 /* MatchedDeclarationsCache.h */; }; … … 15150 15154 E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComposedTreeIterator.h; sourceTree = "<group>"; }; 15151 15155 E44FA1861BCA91560091B6EF /* ComposedTreeIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComposedTreeIterator.cpp; sourceTree = "<group>"; }; 15156 E451C627239293EB00993190 /* LineLayoutTraversalDisplayRunPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversalDisplayRunPath.h; sourceTree = "<group>"; }; 15157 E451C6332394058E00993190 /* DisplayInlineContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisplayInlineContent.h; sourceTree = "<group>"; }; 15152 15158 E45322A9140CE267005A0F92 /* SelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectorQuery.cpp; sourceTree = "<group>"; }; 15153 15159 E45322AA140CE267005A0F92 /* SelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorQuery.h; sourceTree = "<group>"; }; … … 16715 16721 1199FA5A208E3C7F002358CC /* DisplayBox.cpp */, 16716 16722 1199FA59208E3C7F002358CC /* DisplayBox.h */, 16723 E451C6332394058E00993190 /* DisplayInlineContent.h */, 16717 16724 6F77868523491AC6004D9636 /* DisplayPainter.cpp */, 16718 16725 6F77868723491AD7004D9636 /* DisplayPainter.h */, … … 28732 28739 E484A33D23055303009ADE6A /* LineLayoutTraversal.cpp */, 28733 28740 E484A33B23055303009ADE6A /* LineLayoutTraversal.h */, 28741 E4343D242392778F00EBBB66 /* LineLayoutTraversalComplexPath.h */, 28742 E451C627239293EB00993190 /* LineLayoutTraversalDisplayRunPath.h */, 28734 28743 E4343D212392778300EBBB66 /* LineLayoutTraversalSimplePath.h */, 28735 E4343D242392778F00EBBB66 /* LineLayoutTraversalComplexPath.h */,28736 28744 FFDBC046183D27B700407109 /* LineWidth.cpp */, 28737 28745 FFDBC045183D27B700407109 /* LineWidth.h */, … … 30041 30049 A871DB2A0A150BD600B12A68 /* HTMLTableCellElement.h in Headers */, 30042 30050 A871DB2F0A150BD600B12A68 /* HTMLTableColElement.h in Headers */, 30051 E451C628239293EC00993190 /* LineLayoutTraversalDisplayRunPath.h in Headers */, 30043 30052 A871DB270A150BD600B12A68 /* HTMLTableElement.h in Headers */, 30044 30053 A871DB2C0A150BD600B12A68 /* HTMLTablePartElement.h in Headers */, … … 30152 30161 2D5A5931152525D00036EE51 /* ImageOrientation.h in Headers */, 30153 30162 72283F0E230B268C00F5D828 /* ImagePaintingOptions.h in Headers */, 30163 E451C6322394031A00993190 /* MarginTypes.h in Headers */, 30154 30164 B51A2F3F17D7D3AE0072517A /* ImageQualityController.h in Headers */, 30155 30165 49291E4B134172C800E753DE /* ImageRenderingMode.h in Headers */, … … 32487 32497 B2227ADD0D00BF220071B782 /* SVGTransformDistance.h in Headers */, 32488 32498 B2227ADF0D00BF220071B782 /* SVGTransformList.h in Headers */, 32499 E451C6312394027900993190 /* LayoutUnits.h in Headers */, 32489 32500 7CE58D581DD7D96D00128552 /* SVGTransformValue.h in Headers */, 32490 32501 B2227AE20D00BF220071B782 /* SVGTRefElement.h in Headers */, … … 32816 32827 D3F3D36A1A69B7B90059FC2B /* WebGLRenderingContextBase.h in Headers */, 32817 32828 6F995A221A7078B100A735F4 /* WebGLSampler.h in Headers */, 32829 E451C6342394058F00993190 /* DisplayInlineContent.h in Headers */, 32818 32830 49C7B9E31042D32F0009D447 /* WebGLShader.h in Headers */, 32819 32831 A07D3358152B632D001B6393 /* WebGLShaderPrecisionFormat.h in Headers */, -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r252942 r252979 132 132 auto& formattingRootContainer = downcast<Container>(layoutBox); 133 133 if (formattingRootContainer.establishesInlineFormattingContext()) { 134 auto& lineBoxes = downcast<InlineFormattingState>(layoutState.establishedFormattingState(formattingRootContainer)). lineBoxes();134 auto& lineBoxes = downcast<InlineFormattingState>(layoutState.establishedFormattingState(formattingRootContainer)).displayInlineContent()->lineBoxes; 135 135 // Even empty containers generate one line. 136 136 ASSERT(!lineBoxes.isEmpty()); -
trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.cpp
r252942 r252979 37 37 #include "PaintInfo.h" 38 38 #include "RenderBlockFlow.h" 39 #include "RenderLineBreak.h" 39 40 #include "RuntimeEnabledFeatures.h" 40 41 #include "SimpleLineLayout.h" … … 79 80 layoutContext.layout(m_flow.contentSize(), invalidationState); 80 81 81 auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootContainer)). lineBoxes();82 auto& lineBoxes = downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(rootContainer)).displayInlineContent()->lineBoxes; 82 83 auto height = lineBoxes.last().logicalBottom(); 83 84 … … 89 90 { 90 91 return m_layoutState ? m_layoutState->displayBoxForLayoutBox(m_layoutState->root()).contentBoxHeight() : 0_lu; 92 } 93 94 const Display::InlineContent* RenderBlockFlowLineLayout::displayInlineContent() const 95 { 96 return downcast<InlineFormattingState>(m_layoutState->establishedFormattingState(m_treeContent->rootLayoutBox())).displayInlineContent(); 91 97 } 92 98 … … 103 109 } 104 110 111 LineLayoutTraversal::TextBoxIterator RenderBlockFlowLineLayout::textBoxesFor(const RenderText& renderText) const 112 { 113 auto* inlineContent = displayInlineContent(); 114 if (!inlineContent) 115 return { }; 116 auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderText); 117 ASSERT(layoutBox); 118 119 Optional<size_t> firstIndex = 0; 120 size_t lastIndex = 0; 121 for (size_t i = 0; i < inlineContent->runs.size(); ++i) { 122 auto& run = inlineContent->runs[i]; 123 if (&run.layoutBox() == layoutBox) { 124 if (!firstIndex) 125 firstIndex = i; 126 lastIndex = i; 127 } 128 } 129 if (!firstIndex) 130 return { }; 131 132 return { LineLayoutTraversal::DisplayRunPath(*inlineContent, *firstIndex, lastIndex + 1) }; 133 } 134 135 LineLayoutTraversal::ElementBoxIterator RenderBlockFlowLineLayout::elementBoxFor(const RenderLineBreak& renderLineBreak) const 136 { 137 auto* inlineContent = displayInlineContent(); 138 if (!inlineContent) 139 return { }; 140 auto* layoutBox = m_treeContent->layoutBoxForRenderer(renderLineBreak); 141 ASSERT(layoutBox); 142 143 for (size_t i = 0; i < inlineContent->runs.size(); ++i) { 144 auto& run = inlineContent->runs[i]; 145 if (&run.layoutBox() == layoutBox) 146 return { LineLayoutTraversal::DisplayRunPath(*inlineContent, i, i + 1) }; 147 } 148 149 return { }; 150 } 151 105 152 } 106 153 } -
trunk/Source/WebCore/layout/RenderBlockFlowLineLayout.h
r252893 r252979 29 29 30 30 #include "LayoutPoint.h" 31 #include "LineLayoutTraversal.h" 31 32 32 33 namespace WebCore { … … 34 35 class GraphicsContext; 35 36 class RenderBlockFlow; 37 class RenderLineBreak; 36 38 struct PaintInfo; 39 40 namespace Display { 41 struct InlineContent; 42 } 37 43 38 44 namespace Layout { … … 50 56 51 57 void layout(); 52 53 58 LayoutUnit contentBoxHeight() const; 59 const Display::InlineContent* displayInlineContent() const; 54 60 55 61 void paint(PaintInfo&, const LayoutPoint& paintOffset); 62 63 LineLayoutTraversal::TextBoxIterator textBoxesFor(const RenderText&) const; 64 LineLayoutTraversal::ElementBoxIterator elementBoxFor(const RenderLineBreak&) const; 56 65 57 66 private: -
trunk/Source/WebCore/layout/Verification.cpp
r252942 r252979 77 77 78 78 auto& inlineFormattingState = layoutState.establishedFormattingState(inlineFormattingRoot); 79 ASSERT(is<InlineFormattingState>(inlineFormattingState)); 80 auto& displayRuns = downcast<InlineFormattingState>(inlineFormattingState).displayRuns(); 79 auto* displayInlineContent = downcast<InlineFormattingState>(inlineFormattingState).displayInlineContent(); 80 if (!displayInlineContent) { 81 ASSERT_NOT_REACHED(); 82 return true; 83 } 84 85 auto& displayRuns = displayInlineContent->runs; 81 86 82 87 if (displayRuns.size() != lineLayoutData->runCount()) { … … 158 163 { 159 164 auto& inlineFormattingState = layoutState.establishedFormattingState(inlineFormattingRoot); 160 ASSERT(is<InlineFormattingState>(inlineFormattingState)); 161 auto& displayRuns = downcast<InlineFormattingState>(inlineFormattingState).displayRuns(); 165 166 auto* displayInlineContent = downcast<InlineFormattingState>(inlineFormattingState).displayInlineContent(); 167 if (!displayInlineContent) { 168 ASSERT_NOT_REACHED(); 169 return true; 170 } 171 auto& displayRuns = displayInlineContent->runs; 162 172 163 173 // Collect inlineboxes. -
trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp
r252942 r252979 73 73 auto& layoutContainer = downcast<Container>(layoutBox); 74 74 if (layoutContainer.establishesInlineFormattingContext()) { 75 auto& lineBoxes = downcast<InlineFormattingState>(layoutState().establishedFormattingState(layoutContainer)). lineBoxes();75 auto& lineBoxes = downcast<InlineFormattingState>(layoutState().establishedFormattingState(layoutContainer)).displayInlineContent()->lineBoxes; 76 76 // Even empty containers generate one line. 77 77 ASSERT(!lineBoxes.isEmpty()); -
trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
r252942 r252979 396 396 auto isConsideredEmpty = [&] { 397 397 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutContainer)); 398 for (auto& lineBox : formattingState. lineBoxes()) {398 for (auto& lineBox : formattingState.displayInlineContent()->lineBoxes) { 399 399 if (!lineBox.isConsideredEmpty()) 400 400 return false; -
trunk/Source/WebCore/layout/displaytree/DisplayInlineContent.h
r252978 r252979 28 28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 29 30 #include "LayoutPoint.h" 30 #include "DisplayRun.h" 31 #include "InlineLineBox.h" 32 #include <wtf/Vector.h> 31 33 32 34 namespace WebCore { 35 namespace Display { 33 36 34 class GraphicsContext; 35 class RenderBlockFlow;36 struct PaintInfo;37 struct InlineContent : public RefCounted<InlineContent> { 38 using Runs = Vector<Run, 10>; 39 using LineBoxes = Vector<Layout::LineBox, 5>; 37 40 38 namespace Layout { 41 Runs runs; 42 LineBoxes lineBoxes; 39 43 40 class LayoutTreeContent; 41 class LayoutState; 42 43 class RenderBlockFlowLineLayout { 44 WTF_MAKE_FAST_ALLOCATED; 45 public: 46 RenderBlockFlowLineLayout(const RenderBlockFlow&); 47 ~RenderBlockFlowLineLayout(); 48 49 static bool canUseFor(const RenderBlockFlow&); 50 51 void layout(); 52 53 LayoutUnit contentBoxHeight() const; 54 55 void paint(PaintInfo&, const LayoutPoint& paintOffset); 56 57 private: 58 const RenderBlockFlow& m_flow; 59 std::unique_ptr<LayoutTreeContent> m_treeContent; 60 std::unique_ptr<LayoutState> m_layoutState; 44 const Layout::LineBox& lineBoxForRun(const Run& run) const { return lineBoxes[run.lineIndex()]; } 61 45 }; 62 46 -
trunk/Source/WebCore/layout/displaytree/DisplayPainter.cpp
r252942 r252979 113 113 static void paintInlineContent(GraphicsContext& context, const Box& rootAbsoluteDisplayBox, const Layout::InlineFormattingState& formattingState) 114 114 { 115 auto& displayRuns = formattingState.displayRuns(); 115 auto* displayInlineContent = formattingState.displayInlineContent(); 116 if (!displayInlineContent) 117 return; 118 119 auto& displayRuns = displayInlineContent->runs; 116 120 if (displayRuns.isEmpty()) 117 121 return; … … 125 129 auto logicalLeft = rootAbsoluteDisplayBox.left() + run.logicalLeft(); 126 130 // FIXME: Add non-baseline align painting 127 auto& lineBox = formattingState.lineBoxForRun(run);131 auto& lineBox = displayInlineContent->lineBoxForRun(run); 128 132 auto baselineOffset = rootAbsoluteDisplayBox.top() + lineBox.logicalTop() + lineBox.baselineOffset(); 129 133 if (auto expansionContext = textContext->expansion()) -
trunk/Source/WebCore/layout/displaytree/DisplayRun.h
r252932 r252979 29 29 30 30 #include "DisplayRect.h" 31 #include "LayoutBox.h" 31 32 #include "LayoutUnit.h" 32 33 #include "RenderStyle.h" … … 68 69 }; 69 70 70 Run(size_t lineIndex, const RenderStyle&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt);71 Run(size_t lineIndex, const Layout::Box&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt); 71 72 72 73 size_t lineIndex() const { return m_lineIndex; } … … 98 99 CachedImage* image() const { return m_cachedImage; } 99 100 100 const RenderStyle& style() const { return m_style; } 101 const Layout::Box& layoutBox() const { return *m_layoutBox; } 102 const RenderStyle& style() const { return m_layoutBox->style(); } 101 103 102 104 private: 103 105 // FIXME: Find out the Display::Run <-> paint style setup. 104 106 const size_t m_lineIndex; 105 const RenderStyle& m_style;107 WeakPtr<const Layout::Box> m_layoutBox; 106 108 CachedImage* m_cachedImage { nullptr }; 107 109 Rect m_logicalRect; … … 109 111 }; 110 112 111 inline Run::Run(size_t lineIndex, const RenderStyle& style, const Rect& logicalRect, Optional<TextContext> textContext)113 inline Run::Run(size_t lineIndex, const Layout::Box& layoutBox, const Rect& logicalRect, Optional<TextContext> textContext) 112 114 : m_lineIndex(lineIndex) 113 , m_ style(style)115 , m_layoutBox(makeWeakPtr(layoutBox)) 114 116 , m_logicalRect(logicalRect) 115 117 , m_textContext(textContext) -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r252958 r252979 427 427 } 428 428 429 auto lineIndex = formattingState.lineBoxes().size(); 430 formattingState.addLineBox(LineBox { lineContent.lineBox }); 429 auto& inlineContent = formattingState.ensureDisplayInlineContent(); 430 431 auto lineIndex = inlineContent.lineBoxes.size(); 432 inlineContent.lineBoxes.append(LineBox { lineContent.lineBox }); 431 433 432 434 // Compute box final geometry. … … 442 444 auto initiatesInlineRun = !lineRun.isContainerStart() && !lineRun.isContainerEnd() && !lineRun.isCollapsedToVisuallyEmpty(); 443 445 if (initiatesInlineRun) 444 formattingState.addDisplayRun({ lineIndex, lineRun.layoutBox().style(), lineRun.logicalRect(), lineRun.textContext() });446 inlineContent.runs.append({ lineIndex, lineRun.layoutBox(), lineRun.logicalRect(), lineRun.textContext() }); 445 447 446 448 if (lineRun.isForcedLineBreak()) { … … 502 504 // Find out what we need to invalidate. This is where we add some smarts to do partial line layout. 503 505 // For now let's just clear the runs. 504 formattingState(). resetDisplayRuns();506 formattingState().clearDisplayInlineContent(); 505 507 // FIXME: This is also where we would delete inline items if their content changed. 506 508 } -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextQuirks.cpp
r252942 r252979 64 64 if (layoutBox.isInlineBlockBox() && layoutBox.establishesInlineFormattingContext()) { 65 65 auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(downcast<Container>(layoutBox))); 66 ASSERT(!formattingState.lineBoxes().isEmpty()); 67 auto inlineBlockBaseline = formattingState.lineBoxes().last().baseline(); 66 auto inlineBlockBaseline = formattingState.displayInlineContent()->lineBoxes.last().baseline(); 68 67 if (inlineBlockBaseline.descent()) 69 68 return false; -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h
r252942 r252979 28 28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 29 29 30 #include "DisplayInlineContent.h" 30 31 #include "DisplayRun.h" 31 32 #include "FormattingState.h" … … 33 34 #include "InlineLineBox.h" 34 35 #include <wtf/IsoMalloc.h> 35 #include <wtf/OptionSet.h>36 36 37 37 namespace WebCore { … … 51 51 void addInlineItem(std::unique_ptr<InlineItem>&& inlineItem) { m_inlineItems.append(WTFMove(inlineItem)); } 52 52 53 using DisplayRuns = Vector<Display::Run, 10>; 54 using LineBoxes = Vector<LineBox, 5>; 55 56 const DisplayRuns& displayRuns() const { return m_displayRuns; } 57 DisplayRuns& displayRuns() { return m_displayRuns; } 58 void addDisplayRun(Display::Run&&); 59 void resetDisplayRuns(); 60 61 const LineBoxes& lineBoxes() const { return m_lineBoxes; } 62 LineBoxes& lineBoxes() { return m_lineBoxes; } 63 void addLineBox(LineBox&& lineBox) { m_lineBoxes.append(lineBox); } 64 65 const LineBox& lineBoxForRun(const Display::Run& displayRun) const { return m_lineBoxes[displayRun.lineIndex()]; } 53 const Display::InlineContent* displayInlineContent() const { return m_displayInlineContent.get(); } 54 Display::InlineContent& ensureDisplayInlineContent(); 55 void clearDisplayInlineContent() { m_displayInlineContent = nullptr; } 66 56 67 57 private: … … 69 59 InlineItems m_inlineItems; 70 60 71 // Line layout results 72 DisplayRuns m_displayRuns; 73 LineBoxes m_lineBoxes; 61 RefPtr<Display::InlineContent> m_displayInlineContent; 74 62 }; 75 63 76 inline void InlineFormattingState::addDisplayRun(Display::Run&& displayRun)64 inline Display::InlineContent& InlineFormattingState::ensureDisplayInlineContent() 77 65 { 78 m_displayRuns.append(WTFMove(displayRun)); 79 } 80 81 inline void InlineFormattingState::resetDisplayRuns() 82 { 83 m_displayRuns.clear(); 84 // Resetting the runs means no more line boxes either. 85 m_lineBoxes.clear(); 86 66 if (!m_displayInlineContent) 67 m_displayInlineContent = adoptRef(*new Display::InlineContent); 68 return *m_displayInlineContent; 87 69 } 88 70 -
trunk/Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp
r252972 r252979 262 262 auto& formattingState = downcast<InlineFormattingState>(layoutState().establishedFormattingState(downcast<Container>(layoutBox))); 263 263 // Spec makes us generate at least one line -even if it is empty. 264 ASSERT(!formattingState.lineBoxes().isEmpty()); 265 auto inlineBlockBaselineOffset = formattingState.lineBoxes().last().baselineOffset(); 264 auto inlineBlockBaselineOffset = formattingState.displayInlineContent()->lineBoxes.last().baselineOffset(); 266 265 // The inline-block's baseline offset is relative to its content box. Let's convert it relative to the margin box. 267 266 // inline-block … … 600 599 auto& formattingState = downcast<InlineFormattingState>(layoutState().establishedFormattingState(downcast<Container>(layoutBox))); 601 600 // Spec makes us generate at least one line -even if it is empty. 602 ASSERT(!formattingState.lineBoxes().isEmpty()); 603 auto& lastLineBox = formattingState.lineBoxes().last(); 601 auto& lastLineBox = formattingState.displayInlineContent()->lineBoxes.last(); 604 602 auto inlineBlockBaseline = lastLineBox.baseline(); 605 603 auto beforeHeight = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0); -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r252942 r252979 312 312 { 313 313 auto& inlineFormattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(inlineFormattingRoot)); 314 auto& displayRuns = inlineFormattingState.displayRuns(); 315 auto& lineBoxes = inlineFormattingState.lineBoxes(); 314 auto* displayInlineContent = inlineFormattingState.displayInlineContent(); 315 if (!displayInlineContent) 316 return; 317 318 auto& displayRuns = displayInlineContent->runs; 319 auto& lineBoxes = displayInlineContent->lineBoxes; 316 320 317 321 unsigned printedCharacters = 0; -
trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp
r252959 r252979 27 27 #include "LineLayoutTraversal.h" 28 28 29 #include "RenderBlockFlowLineLayout.h" 29 30 #include "RenderLineBreak.h" 30 31 … … 32 33 namespace LineLayoutTraversal { 33 34 34 TextBoxIterator::TextBoxIterator(const InlineTextBox* inlineTextBox) 35 : m_textBox(ComplexPath { inlineTextBox, { } }) 36 { 37 } 38 TextBoxIterator::TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index) 39 : m_textBox(ComplexPath { index < sorted.size() ? sorted[index] : nullptr, WTFMove(sorted), index }) 40 { 41 } 42 43 TextBoxIterator::TextBoxIterator(SimpleLineLayout::RunResolver::Iterator iterator, SimpleLineLayout::RunResolver::Iterator end) 44 : m_textBox(SimplePath { iterator, end }) 35 TextBoxIterator::TextBoxIterator(Box::PathVariant&& pathVariant) 36 : m_textBox(WTFMove(pathVariant)) 45 37 { 46 38 } … … 79 71 } 80 72 73 static const RenderBlockFlow& flowForText(const RenderText& text) 74 { 75 return downcast<RenderBlockFlow>(*text.containingBlockForObjectInFlow()); 76 } 77 81 78 TextBoxIterator firstTextBoxFor(const RenderText& text) 82 79 { 83 if (auto* simpleLineLayout = text.simpleLineLayout()) { 80 auto& flow = flowForText(text); 81 82 if (auto* simpleLineLayout = flow.simpleLineLayout()) { 84 83 auto range = simpleLineLayout->runResolver().rangeForRenderer(text); 85 return { range.begin(), range.end()};84 return { SimplePath { range.begin(), range.end() } }; 86 85 } 87 86 88 return TextBoxIterator { text.firstTextBox() }; 87 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 88 if (auto* lfcLineLayout = flow.lfcLineLayout()) 89 return lfcLineLayout->textBoxesFor(text); 90 #endif 91 92 return { ComplexPath { text.firstTextBox() } }; 89 93 } 90 94 91 95 TextBoxIterator firstTextBoxInTextOrderFor(const RenderText& text) 92 96 { 93 if (!text.simpleLineLayout() && text.containsReversedText()) { 97 auto& flow = flowForText(text); 98 99 if (flow.complexLineLayout() && text.containsReversedText() && text.firstTextBox()) { 94 100 Vector<const InlineTextBox*> sortedTextBoxes; 95 101 for (auto* textBox = text.firstTextBox(); textBox; textBox = textBox->nextTextBox()) 96 102 sortedTextBoxes.append(textBox); 97 103 std::sort(sortedTextBoxes.begin(), sortedTextBoxes.end(), InlineTextBox::compareByStart); 98 return TextBoxIterator { WTFMove(sortedTextBoxes), 0 }; 104 auto* first = sortedTextBoxes[0]; 105 return { ComplexPath { first, WTFMove(sortedTextBoxes), 0 } }; 99 106 } 100 107 … … 107 114 } 108 115 109 ElementBoxIterator::ElementBoxIterator(const InlineElementBox* inlineElementBox) 110 : m_box(ComplexPath { inlineElementBox, { } }) 111 { 112 } 113 ElementBoxIterator::ElementBoxIterator(SimpleLineLayout::RunResolver::Iterator iterator, SimpleLineLayout::RunResolver::Iterator end) 114 : m_box(SimplePath { iterator, end }) 116 ElementBoxIterator::ElementBoxIterator(Box::PathVariant&& pathVariant) 117 : m_box(WTFMove(pathVariant)) 115 118 { 116 119 } … … 125 128 ElementBoxIterator elementBoxFor(const RenderLineBreak& renderElement) 126 129 { 127 if (auto& parent = *renderElement.parent(); is<RenderBlockFlow>(parent)) { 128 if (auto* simpleLineLayout = downcast<RenderBlockFlow>(parent).simpleLineLayout()) { 129 auto range = simpleLineLayout->runResolver().rangeForRenderer(renderElement); 130 return { range.begin(), range.end() }; 131 } 130 auto* containingBlock = renderElement.containingBlock(); 131 if (!is<RenderBlockFlow>(containingBlock)) 132 return { }; 133 134 auto& flow = downcast<RenderBlockFlow>(*containingBlock); 135 136 if (auto* simpleLineLayout = flow.simpleLineLayout()) { 137 auto range = simpleLineLayout->runResolver().rangeForRenderer(renderElement); 138 return { SimplePath(range.begin(), range.end()) }; 132 139 } 133 140 134 return ElementBoxIterator { renderElement.inlineBoxWrapper() }; 141 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 142 if (auto* lfcLineLayout = flow.lfcLineLayout()) 143 return lfcLineLayout->elementBoxFor(renderElement); 144 #endif 145 146 return { ComplexPath(renderElement.inlineBoxWrapper()) }; 135 147 } 136 148 -
trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h
r252959 r252979 28 28 #include "InlineElementBox.h" 29 29 #include "LineLayoutTraversalComplexPath.h" 30 #include "LineLayoutTraversalDisplayRunPath.h" 30 31 #include "LineLayoutTraversalSimplePath.h" 31 32 #include "RenderText.h" … … 48 49 class Box { 49 50 public: 50 using PathVariant = Variant<SimplePath, ComplexPath>; 51 using PathVariant = Variant< 52 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 53 DisplayRunPath, 54 #endif 55 ComplexPath, 56 SimplePath 57 >; 51 58 52 59 Box(PathVariant&&); … … 85 92 public: 86 93 TextBoxIterator() : m_textBox(ComplexPath { nullptr, { } }) { }; 87 88 explicit TextBoxIterator(const InlineTextBox*); 89 TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index); 90 TextBoxIterator(SimpleLineLayout::RunResolver::Iterator, SimpleLineLayout::RunResolver::Iterator end); 94 TextBoxIterator(Box::PathVariant&&); 91 95 92 96 TextBoxIterator& operator++() { return traverseNextInVisualOrder(); } … … 114 118 public: 115 119 ElementBoxIterator() : m_box(ComplexPath { nullptr, { } }) { }; 116 117 explicit ElementBoxIterator(const InlineElementBox*); 118 ElementBoxIterator(SimpleLineLayout::RunResolver::Iterator, SimpleLineLayout::RunResolver::Iterator end); 120 ElementBoxIterator(Box::PathVariant&&); 119 121 120 122 explicit operator bool() const { return !atEnd(); }
Note: See TracChangeset
for help on using the changeset viewer.