Changeset 249084 in webkit
- Timestamp:
- Aug 24, 2019 6:31:50 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249083 r249084 1 2019-08-24 Antti Koivisto <antti@apple.com> 2 3 Implement layout system independent text box iterator 4 https://bugs.webkit.org/show_bug.cgi?id=201076 5 6 Reviewed by Zalan Bujtas. 7 8 Add a generic way to traverse line layout without caring about the details of the underlying layout system. 9 10 This patch adds basic support for traversing text boxes and uses it to remove layout path specific branches in RenderTreeAsText. 11 12 * Sources.txt: 13 * WebCore.xcodeproj/project.pbxproj: 14 * rendering/RenderTreeAsText.cpp: 15 (WebCore::RenderTreeAsText::writeRenderObject): 16 (WebCore::writeTextBox): 17 (WebCore::write): 18 (WebCore::writeTextRun): Deleted. 19 (WebCore::writeSimpleLine): Deleted. 20 * rendering/line/LineLayoutInterfaceTextBoxes.cpp: Added. 21 (WebCore::LineLayoutInterface::TextBox::rect const): 22 (WebCore::LineLayoutInterface::TextBox::logicalRect const): 23 (WebCore::LineLayoutInterface::TextBox::hasHyphen const): 24 (WebCore::LineLayoutInterface::TextBox::isLeftToRightDirection const): 25 (WebCore::LineLayoutInterface::TextBox::dirOverride const): 26 (WebCore::LineLayoutInterface::TextBox::text const): 27 (WebCore::LineLayoutInterface::TextBoxIterator::TextBoxIterator): 28 (WebCore::LineLayoutInterface::TextBoxIterator::traverseNext): 29 (WebCore::LineLayoutInterface::TextBoxIterator::operator== const): 30 (WebCore::LineLayoutInterface::simpleLineRunResolverForText): 31 (WebCore::LineLayoutInterface::rangeForText): 32 (WebCore::LineLayoutInterface::TextBoxRange::TextBoxRange): 33 (WebCore::LineLayoutInterface::textBoxes): 34 * rendering/line/LineLayoutInterfaceTextBoxes.h: Added. 35 (WebCore::LineLayoutInterface::TextBox::TextBox): 36 (WebCore::LineLayoutInterface::TextBoxIterator::operator++): 37 (WebCore::LineLayoutInterface::TextBoxIterator::operator!= const): 38 (WebCore::LineLayoutInterface::TextBoxIterator::operator* const): 39 (WebCore::LineLayoutInterface::TextBoxRange::begin const): 40 (WebCore::LineLayoutInterface::TextBoxRange::end const): 41 1 42 2019-08-24 Zalan Bujtas <zalan@apple.com> 2 43 -
trunk/Source/WebCore/Sources.txt
r249066 r249084 2153 2153 rendering/line/LineBreaker.cpp 2154 2154 rendering/line/LineInfo.cpp 2155 rendering/line/LineLayoutInterfaceTextBoxes.cpp 2155 2156 rendering/line/LineWidth.cpp 2156 2157 rendering/line/TrailingObjects.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r249066 r249084 4790 4790 E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4791 4791 E48137B91DB3B526005C59BF /* StyleValidity.h in Headers */ = {isa = PBXBuildFile; fileRef = E48137B81DB3B526005C59BF /* StyleValidity.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4792 E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */ = {isa = PBXBuildFile; fileRef = E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */; }; 4792 4793 E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4793 4794 E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 14952 14953 E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionStyleSheets.cpp; sourceTree = "<group>"; }; 14953 14954 E48137B81DB3B526005C59BF /* StyleValidity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleValidity.h; sourceTree = "<group>"; }; 14955 E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutInterfaceTextBoxes.h; sourceTree = "<group>"; }; 14956 E484A33D23055303009ADE6A /* LineLayoutInterfaceTextBoxes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineLayoutInterfaceTextBoxes.cpp; sourceTree = "<group>"; }; 14954 14957 E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; }; 14955 14958 E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; }; … … 28173 28176 FFB698CE1833F17600158A31 /* LineInfo.h */, 28174 28177 FFEFAB2D183BCB6F00514534 /* LineInlineHeaders.h */, 28178 E484A33D23055303009ADE6A /* LineLayoutInterfaceTextBoxes.cpp */, 28179 E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */, 28175 28180 FFEFAB2918380DA000514534 /* LineLayoutState.h */, 28176 28181 FFDBC046183D27B700407109 /* LineWidth.cpp */, … … 31918 31923 57EF5E601D20C83900171E60 /* TextCodecReplacement.h in Headers */, 31919 31924 B2C3DA400D006C1D00EF6F26 /* TextCodecUserDefined.h in Headers */, 31925 E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */, 31920 31926 B2C3DA420D006C1D00EF6F26 /* TextCodecUTF16.h in Headers */, 31921 31927 9343CB8212F25E510033C5EE /* TextCodecUTF8.h in Headers */, -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r245170 r249084 36 36 #include "HTMLSpanElement.h" 37 37 #include "InlineTextBox.h" 38 #include "LineLayoutInterfaceTextBoxes.h" 38 39 #include "Logging.h" 39 40 #include "PrintContext.h" … … 64 65 #include "SVGRenderTreeAsText.h" 65 66 #include "ShadowRoot.h" 66 #include "SimpleLineLayoutResolver.h"67 67 #include "StyleProperties.h" 68 68 #include <wtf/HexNumber.h> … … 203 203 const RenderText& text = downcast<RenderText>(o); 204 204 r = IntRect(text.firstRunLocation(), text.linesBoundingBox().size()); 205 if (!text.firstTextBox() && !text.simpleLineLayout()) 205 auto textBoxes = LineLayoutInterface::textBoxes(text); 206 if (textBoxes.begin() == textBoxes.end()) 206 207 adjustForTableCells = false; 207 208 } else if (o.isBR()) { … … 478 479 } 479 480 480 static void writeTextRun(TextStream& ts, const RenderText& o, const InlineTextBox& run) 481 { 482 // FIXME: For now use an "enclosingIntRect" model for x, y and logicalWidth, although this makes it harder 483 // to detect any changes caused by the conversion to floating point. :( 484 int x = run.x(); 485 int y = run.y(); 486 int logicalWidth = ceilf(run.left() + run.logicalWidth()) - x; 481 static void writeTextBox(TextStream& ts, const RenderText& o, const LineLayoutInterface::TextBox& textBox) 482 { 483 auto rect = textBox.rect(); 484 auto logicalRect = textBox.logicalRect(); 485 486 int x = rect.x(); 487 int y = rect.y(); 488 489 // FIXME: Mixing logical and physical here doesn't make sense. 490 int logicalWidth = ceilf(rect.x() + logicalRect.width()) - x; 487 491 488 492 // FIXME: Table cell adjustment is temporary until results can be updated. … … 491 495 492 496 ts << "text run at (" << x << "," << y << ") width " << logicalWidth; 493 if (! run.isLeftToRightDirection() || run.dirOverride()) {494 ts << (! run.isLeftToRightDirection() ? " RTL" : " LTR");495 if ( run.dirOverride())497 if (!textBox.isLeftToRightDirection() || textBox.dirOverride()) { 498 ts << (!textBox.isLeftToRightDirection() ? " RTL" : " LTR"); 499 if (textBox.dirOverride()) 496 500 ts << " override"; 497 501 } 498 502 ts << ": " 499 << quoteAndEscapeNonPrintables( String(o.text()).substring(run.start(), run.len()));500 if ( run.hasHyphen())503 << quoteAndEscapeNonPrintables(textBox.text()); 504 if (textBox.hasHyphen()) 501 505 ts << " + hyphen string " << quoteAndEscapeNonPrintables(o.style().hyphenString().string()); 502 506 ts << "\n"; 503 507 } 504 508 505 static void writeSimpleLine(TextStream& ts, const RenderText& renderText, const SimpleLineLayout::RunResolver::Run& run)506 {507 auto rect = run.rect();508 int x = rect.x();509 int y = rect.y();510 int logicalWidth = ceilf(rect.x() + rect.width()) - x;511 512 if (is<RenderTableCell>(*renderText.containingBlock()))513 y -= floorToInt(downcast<RenderTableCell>(*renderText.containingBlock()).intrinsicPaddingBefore());514 515 ts << "text run at (" << x << "," << y << ") width " << logicalWidth;516 ts << ": " << quoteAndEscapeNonPrintables(run.text());517 if (run.hasHyphen())518 ts << " + hyphen string " << quoteAndEscapeNonPrintables(renderText.style().hyphenString().string());519 ts << "\n";520 }521 522 509 void write(TextStream& ts, const RenderObject& o, OptionSet<RenderAsTextFlag> behavior) 523 510 { … … 564 551 if (is<RenderText>(o)) { 565 552 auto& text = downcast<RenderText>(o); 566 if (auto layout = text.simpleLineLayout()) { 567 ASSERT(!text.firstTextBox()); 568 auto resolver = runResolver(downcast<RenderBlockFlow>(*text.parent()), *layout); 569 for (auto run : resolver.rangeForRenderer(text)) { 570 ts << indent; 571 writeSimpleLine(ts, text, run); 572 } 573 } else { 574 for (auto* box = text.firstTextBox(); box; box = box->nextTextBox()) { 575 ts << indent; 576 writeTextRun(ts, text, *box); 577 } 578 } 579 553 for (auto textBox : LineLayoutInterface::textBoxes(text)) { 554 ts << indent; 555 writeTextBox(ts, text, textBox); 556 } 580 557 } else { 581 558 for (auto& child : childrenOfType<RenderObject>(downcast<RenderElement>(o))) {
Note: See TracChangeset
for help on using the changeset viewer.