Changeset 269852 in webkit
- Timestamp:
- Nov 16, 2020 6:51:27 AM (3 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269850 r269852 1 2020-11-16 Antti Koivisto <antti@apple.com> 2 3 [LFC][Integration] Remove isLastTextRunOnLine/isLastTextRun from run iterator 4 https://bugs.webkit.org/show_bug.cgi?id=218978 5 6 Reviewed by Zalan Bujtas. 7 8 Use the line interface instead. This both more readable and more generic. 9 10 * dom/Position.cpp: 11 (WebCore::Position::upstream const): 12 (WebCore::Position::downstream const): 13 * layout/integration/LayoutIntegrationLineIterator.cpp: 14 (WebCore::LayoutIntegration::LineIterator::operator== const): 15 16 Also use Variant default operator==. 17 18 * layout/integration/LayoutIntegrationRunIterator.cpp: 19 (WebCore::LayoutIntegration::RunIterator::operator== const): 20 * layout/integration/LayoutIntegrationRunIterator.h: 21 (WebCore::LayoutIntegration::PathTextRun::isLastTextRunOnLine const): Deleted. 22 (WebCore::LayoutIntegration::PathTextRun::isLastTextRun const): Deleted. 23 * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h: 24 25 Also use RefCountedArray instead of Vector to avoid unnecessary copies of the order cache. 26 27 (WebCore::LayoutIntegration::RunIteratorLegacyPath::isLastTextRunOnLine const): Deleted. 28 (WebCore::LayoutIntegration::RunIteratorLegacyPath::isLastTextRun const): Deleted. 29 * layout/integration/LayoutIntegrationRunIteratorModernPath.h: 30 (WebCore::LayoutIntegration::RunIteratorModernPath::isLastTextRunOnLine const): Deleted. 31 (WebCore::LayoutIntegration::RunIteratorModernPath::isLastTextRun const): Deleted. 32 1 33 2020-11-16 Kimmo Kinnunen <kkinnunen@apple.com> 2 34 -
trunk/Source/WebCore/dom/Position.cpp
r269568 r269852 751 751 752 752 unsigned textOffset = currentPosition.offsetInLeafNode(); 753 for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) { 754 if (textOffset <= run->end()) { 755 if (textOffset > run->start()) 756 return currentPosition; 757 continue; 758 } 759 760 if (textOffset == run->end() + 1 && run->isLastTextRunOnLine() && !run->isLastTextRun()) 753 for (auto run = firstTextRun; run;) { 754 if (textOffset > run->start() && textOffset <= run->end()) 761 755 return currentPosition; 756 757 auto nextRun = run.nextTextRunInTextOrder(); 758 if (textOffset == run->end() + 1 && nextRun && run.line() != nextRun.line()) 759 return currentPosition; 760 761 run = nextRun; 762 762 } 763 763 } … … 854 854 855 855 unsigned textOffset = currentPosition.offsetInLeafNode(); 856 for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {856 for (auto run = firstTextRun; run;) { 857 857 if (!run->length() && textOffset == run->start()) 858 858 return currentPosition; 859 859 860 if (textOffset < run->end()) { 861 if (textOffset >= run->start()) 862 return currentPosition; 863 continue; 864 } 865 866 if (textOffset == run->end() && run->isLastTextRunOnLine() && !run->isLastTextRun()) 860 if (textOffset >= run->start() && textOffset < run->end()) 867 861 return currentPosition; 862 863 auto nextRun = run.nextTextRunInTextOrder(); 864 if (textOffset == run->end() && nextRun && run.line() != nextRun.line()) 865 return currentPosition; 866 867 run = nextRun; 868 868 } 869 869 } -
trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp
r269732 r269852 74 74 bool LineIterator::operator==(const LineIterator& other) const 75 75 { 76 if (m_line.m_pathVariant.index() != other.m_line.m_pathVariant.index()) 77 return false; 78 79 return WTF::switchOn(m_line.m_pathVariant, [&](const auto& path) { 80 return path == WTF::get<std::decay_t<decltype(path)>>(other.m_line.m_pathVariant); 81 }); 76 return m_line.m_pathVariant == other.m_line.m_pathVariant; 82 77 } 83 78 -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp
r269732 r269852 43 43 bool RunIterator::operator==(const RunIterator& other) const 44 44 { 45 if (m_run.m_pathVariant.index() != other.m_run.m_pathVariant.index()) 46 return false; 47 48 return WTF::switchOn(m_run.m_pathVariant, [&](const auto& path) { 49 return path == WTF::get<std::decay_t<decltype(path)>>(other.m_run.m_pathVariant); 50 }); 45 return m_run.m_pathVariant == other.m_run.m_pathVariant; 51 46 } 52 47 -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h
r269732 r269852 112 112 LayoutRect selectionRect(unsigned start, unsigned end) const; 113 113 114 bool isLastTextRunOnLine() const;115 bool isLastTextRun() const;116 117 114 InlineTextBox* legacyInlineBox() const { return downcast<InlineTextBox>(PathRun::legacyInlineBox()); } 118 115 }; … … 344 341 } 345 342 346 inline bool PathTextRun::isLastTextRunOnLine() const347 {348 return WTF::switchOn(m_pathVariant, [](auto& path) {349 return path.isLastTextRunOnLine();350 });351 }352 353 inline bool PathTextRun::isLastTextRun() const354 {355 return WTF::switchOn(m_pathVariant, [](auto& path) {356 return path.isLastTextRun();357 });358 }359 360 343 } 361 344 } -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h
r269510 r269852 28 28 #include "InlineTextBox.h" 29 29 #include "RenderText.h" 30 #include <wtf/RefCountedArray.h> 30 31 #include <wtf/Vector.h> 31 32 … … 66 67 LayoutRect selectionRect(unsigned start, unsigned end) const { return inlineTextBox()->localSelectionRect(start, end); } 67 68 68 bool isLastTextRunOnLine() const69 {70 auto* next = nextInlineTextBoxInTextOrder();71 return !next || &inlineTextBox()->root() != &next->root();72 }73 bool isLastTextRun() const { return !nextInlineTextBoxInTextOrder(); };74 75 69 const RenderObject& renderer() const 76 70 { … … 109 103 110 104 const InlineBox* m_inlineBox; 111 Vector<const InlineTextBox*> m_sortedInlineTextBoxes;105 RefCountedArray<const InlineTextBox*> m_sortedInlineTextBoxes; 112 106 size_t m_sortedInlineTextBoxIndex { 0 }; 113 107 }; -
trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h
r269571 r269852 130 130 } 131 131 132 bool isLastTextRunOnLine() const133 {134 if (isLastTextRun())135 return true;136 137 auto& next = runs()[m_runIndex + 1];138 return run().lineIndex() != next.lineIndex();139 }140 141 bool isLastTextRun() const142 {143 ASSERT(!atEnd());144 ASSERT(run().textContent());145 146 if (m_runIndex + 1 == runs().size())147 return true;148 return &run().layoutBox() != &runs()[m_runIndex + 1].layoutBox();149 };150 151 132 const RenderObject& renderer() const 152 133 {
Note: See TracChangeset
for help on using the changeset viewer.