Changeset 234085 in webkit
- Timestamp:
- Jul 21, 2018 11:49:23 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r234084 r234085 1 2018-07-21 Zalan Bujtas <zalan@apple.com> 2 3 [LFC][IFC] Add verification for inline text runs. 4 https://bugs.webkit.org/show_bug.cgi?id=187879 5 6 Reviewed by Antti Koivisto. 7 8 * layout/Verification.cpp: 9 (WebCore::Layout::outputMismatchingSimpleLineInformationIfNeeded): 10 (WebCore::Layout::outputMismatchingComplexLineInformationIfNeeded): 11 (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded): 12 (WebCore::Layout::verifyAndOutputSubtree): 13 (WebCore::Layout::outputMismatchingBoxInformationIfNeeded): Deleted. 14 * layout/inlineformatting/InlineFormattingContext.cpp: 15 (WebCore::Layout::InlineFormattingContext::layout const): 16 * layout/inlineformatting/InlineFormattingState.h: 17 (WebCore::Layout::InlineFormattingState::addLayoutRuns): 18 (WebCore::Layout::InlineFormattingState::layoutRuns const): 19 * layout/layouttree/LayoutTreeBuilder.cpp: 20 (WebCore::Layout::outputLayoutBox): 21 (WebCore::Layout::outputLayoutTree): 22 (WebCore::Layout::TreeBuilder::showLayoutTree): 23 1 24 2018-07-21 Zalan Bujtas <zalan@apple.com> 2 25 -
trunk/Source/WebCore/layout/Verification.cpp
r233469 r234085 30 30 31 31 #include "DisplayBox.h" 32 #include "InlineTextBox.h" 32 33 #include "LayoutBox.h" 33 34 #include "LayoutContainer.h" … … 40 41 namespace Layout { 41 42 42 static bool outputMismatchingBoxInformationIfNeeded(TextStream& stream, const LayoutContext& context, const RenderBox& renderer, const Box& layoutBox) 43 static bool outputMismatchingSimpleLineInformationIfNeeded(TextStream& stream, const LayoutContext& layoutContext, const RenderBlockFlow& blockFlow, const Container& inlineFormattingRoot) 44 { 45 auto* lineLayoutData = blockFlow.simpleLineLayout(); 46 if (!lineLayoutData) { 47 ASSERT_NOT_REACHED(); 48 return true; 49 } 50 51 auto& inlineFormattingState = const_cast<LayoutContext&>(layoutContext).establishedFormattingState(inlineFormattingRoot); 52 ASSERT(is<InlineFormattingState>(inlineFormattingState)); 53 auto& layoutRuns = downcast<InlineFormattingState>(inlineFormattingState).layoutRuns(); 54 55 if (layoutRuns.size() != lineLayoutData->runCount()) { 56 stream << "Mismatching number of runs: simple runs(" << lineLayoutData->runCount() << ") layout runs(" << layoutRuns.size() << ")"; 57 stream.nextLine(); 58 return true; 59 } 60 61 auto mismatched = false; 62 for (unsigned i = 0; i < lineLayoutData->runCount(); ++i) { 63 auto& simpleRun = lineLayoutData->runAt(i); 64 auto& layoutRun = layoutRuns[i]; 65 66 if (simpleRun.start == layoutRun.start() && simpleRun.end == layoutRun.end() && simpleRun.logicalLeft == layoutRun.left() && simpleRun.logicalRight == layoutRun.right()) 67 continue; 68 69 stream << "Mismatching: simple run(" << simpleRun.start << ", " << simpleRun.end << ") (" << simpleRun.logicalLeft << ", " << simpleRun.logicalRight << ") layout run(" << layoutRun.start() << ", " << layoutRun.end() << ") (" << layoutRun.left() << ", " << layoutRun.right() << ")"; 70 stream.nextLine(); 71 mismatched = true; 72 } 73 return mismatched; 74 } 75 76 static bool outputMismatchingComplexLineInformationIfNeeded(TextStream& stream, const LayoutContext& layoutContext, const RenderBlockFlow& blockFlow, const Container& inlineFormattingRoot) 77 { 78 auto& inlineFormattingState = const_cast<LayoutContext&>(layoutContext).establishedFormattingState(inlineFormattingRoot); 79 ASSERT(is<InlineFormattingState>(inlineFormattingState)); 80 auto& layoutRuns = downcast<InlineFormattingState>(inlineFormattingState).layoutRuns(); 81 82 auto mismatched = false; 83 unsigned layoutRunIndex = 0; 84 for (auto* rootLine = blockFlow.firstRootBox(); rootLine; rootLine = rootLine->nextRootBox()) { 85 for (auto* lineBox = rootLine->firstChild(); lineBox; lineBox = lineBox->nextOnLine()) { 86 if (!is<InlineTextBox>(lineBox)) 87 continue; 88 89 if (layoutRunIndex >= layoutRuns.size()) { 90 // FIXME: <span>foobar</span>foobar generates 2 inline text boxes while we only generate one layout run (which is much better, since it enables us to do kerning across inline elements). 91 stream << "Mismatching number of runs: layout runs(" << layoutRuns.size() << ")"; 92 stream.nextLine(); 93 return true; 94 } 95 96 auto& layoutRun = layoutRuns[layoutRunIndex]; 97 auto& inlineTextBox = downcast<InlineTextBox>(*lineBox); 98 if (inlineTextBox.start() == layoutRun.start() && inlineTextBox.end() == layoutRun.end() && inlineTextBox.logicalLeft() == layoutRun.left() && inlineTextBox.logicalRight() == layoutRun.right()) { 99 stream << "Mismatching: simple run(" << inlineTextBox.start() << ", " << inlineTextBox.end() << ") (" << inlineTextBox.logicalLeft() << ", " << inlineTextBox.logicalRight() << ") layout run(" << layoutRun.start() << ", " << layoutRun.end() << ") (" << layoutRun.left() << ", " << layoutRun.right() << ")"; 100 stream.nextLine(); 101 mismatched = true; 102 } 103 ++layoutRunIndex; 104 } 105 } 106 return mismatched; 107 } 108 109 static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, const LayoutContext& context, const RenderBox& renderer, const Box& layoutBox) 43 110 { 44 111 bool firstMismatchingRect = true; … … 93 160 static bool verifyAndOutputSubtree(TextStream& stream, const LayoutContext& context, const RenderBox& renderer, const Box& layoutBox) 94 161 { 95 auto mismtachingGeometry = outputMismatchingB oxInformationIfNeeded(stream, context, renderer, layoutBox);162 auto mismtachingGeometry = outputMismatchingBlockBoxInformationIfNeeded(stream, context, renderer, layoutBox); 96 163 97 164 if (!is<Container>(layoutBox)) … … 108 175 } 109 176 110 auto mismatchingSubtreeGeometry = verifyAndOutputSubtree(stream, context, downcast<RenderBox>(*childRenderer), *childBox); 111 mismtachingGeometry |= mismatchingSubtreeGeometry; 177 if (is<RenderBlockFlow>(*childRenderer) && childBox->establishesInlineFormattingContext()) { 178 ASSERT(childRenderer->childrenInline()); 179 auto& blockFlow = downcast<RenderBlockFlow>(*childRenderer); 180 auto& formattingRoot = downcast<Container>(*childBox); 181 mismtachingGeometry |= blockFlow.lineLayoutPath() == RenderBlockFlow::SimpleLinesPath ? outputMismatchingSimpleLineInformationIfNeeded(stream, context, blockFlow, formattingRoot) : outputMismatchingComplexLineInformationIfNeeded(stream, context, blockFlow, formattingRoot); 182 } else { 183 auto mismatchingSubtreeGeometry = verifyAndOutputSubtree(stream, context, downcast<RenderBox>(*childRenderer), *childBox); 184 mismtachingGeometry |= mismatchingSubtreeGeometry; 185 } 112 186 113 187 childBox = childBox->nextSibling(); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp
r234084 r234085 52 52 } 53 53 54 void InlineFormattingContext::layout(LayoutContext& layoutContext, FormattingState& ) const54 void InlineFormattingContext::layout(LayoutContext& layoutContext, FormattingState& inlineFormattingState) const 55 55 { 56 56 if (!is<Container>(root())) … … 91 91 auto lineRight = formattingRootDisplayBox.contentBoxRight(); 92 92 93 auto textRuns = textContentProvider.textRuns();94 93 SimpleLineBreaker::LineConstraintList constraints; 95 94 constraints.append({ { }, lineLeft, lineRight }); 96 SimpleLineBreaker simpleLineBreaker(textRuns, textContentProvider, WTFMove(constraints), formattingRoot.style()); 97 auto layoutRuns = simpleLineBreaker.runs(); 95 auto textRunList = textContentProvider.textRuns(); 96 SimpleLineBreaker simpleLineBreaker(textRunList, textContentProvider, WTFMove(constraints), formattingRoot.style()); 97 98 // Since we don't yet have a display tree context for inline boxes, let's just cache the runs on the state so that they can be verified against the sll/inline tree runs later. 99 ASSERT(is<InlineFormattingState>(inlineFormattingState)); 100 downcast<InlineFormattingState>(inlineFormattingState).addLayoutRuns(simpleLineBreaker.runs()); 98 101 99 102 LOG_WITH_STREAM(FormattingContextLayout, stream << "[End] -> inline formatting context -> layout context(" << &layoutContext << ") formatting root(" << &root() << ")"); -
trunk/Source/WebCore/layout/inlineformatting/InlineFormattingState.h
r233469 r234085 29 29 30 30 #include "FormattingState.h" 31 #include "Runs.h" 31 32 #include <wtf/IsoMalloc.h> 32 33 … … 41 42 InlineFormattingState(Ref<FloatingState>&&, const LayoutContext&); 42 43 virtual ~InlineFormattingState(); 44 45 // This is temporary. We need to construct a display tree context for inlines. 46 void addLayoutRuns(Vector<LayoutRun>&& layoutRuns) { m_layoutRuns = WTFMove(layoutRuns); } 47 const Vector<LayoutRun>& layoutRuns() const { return m_layoutRuns; } 48 49 private: 50 Vector<LayoutRun> m_layoutRuns; 43 51 }; 44 52 -
trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp
r233482 r234085 119 119 120 120 #if ENABLE(TREE_DEBUGGING) 121 static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Display::Box &displayBox, unsigned depth)121 static void outputLayoutBox(TextStream& stream, const Box& layoutBox, const Display::Box* displayBox, unsigned depth) 122 122 { 123 123 unsigned printedCharacters = 0; … … 135 135 } else 136 136 stream << "box"; 137 stream << " at [" << displayBox.left() << " " << displayBox.top() << "] size [" << displayBox.width() << " " << displayBox.height() << "]"; 137 // FIXME: Inline text runs don't create display boxes yet. 138 if (displayBox) 139 stream << " at [" << displayBox->left() << " " << displayBox->top() << "] size [" << displayBox->width() << " " << displayBox->height() << "]"; 138 140 stream << " object [" << &layoutBox << "]"; 139 141 … … 144 146 { 145 147 for (auto& child : childrenOfType<Box>(rootContainer)) { 146 outputLayoutBox(stream, child, *layoutContext.displayBoxForLayoutBox(child), depth);148 outputLayoutBox(stream, child, layoutContext.displayBoxForLayoutBox(child), depth); 147 149 if (is<Container>(child)) 148 150 outputLayoutTree(layoutContext, stream, downcast<Container>(child), depth + 1); … … 153 155 { 154 156 TextStream stream(TextStream::LineMode::MultipleLine, TextStream::Formatting::SVGStyleRect); 155 outputLayoutBox(stream, layoutBox, *layoutContext.displayBoxForLayoutBox(layoutBox), 0);157 outputLayoutBox(stream, layoutBox, layoutContext.displayBoxForLayoutBox(layoutBox), 0); 156 158 outputLayoutTree(layoutContext, stream, layoutBox, 1); 157 159 WTFLogAlways("%s", stream.release().utf8().data());
Note: See TracChangeset
for help on using the changeset viewer.