Skip to content

Commit ecc0b38

Browse files
committed
[LFC][Integration] Remove isLastTextRunOnLine/isLastTextRun from run iterator
https://bugs.webkit.org/show_bug.cgi?id=218978 Reviewed by Zalan Bujtas. Use the line interface instead. This both more readable and more generic. * dom/Position.cpp: (WebCore::Position::upstream const): (WebCore::Position::downstream const): * layout/integration/LayoutIntegrationLineIterator.cpp: (WebCore::LayoutIntegration::LineIterator::operator== const): Also use Variant default operator==. * layout/integration/LayoutIntegrationRunIterator.cpp: (WebCore::LayoutIntegration::RunIterator::operator== const): * layout/integration/LayoutIntegrationRunIterator.h: (WebCore::LayoutIntegration::PathTextRun::isLastTextRunOnLine const): Deleted. (WebCore::LayoutIntegration::PathTextRun::isLastTextRun const): Deleted. * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h: Also use RefCountedArray instead of Vector to avoid unnecessary copies of the order cache. (WebCore::LayoutIntegration::RunIteratorLegacyPath::isLastTextRunOnLine const): Deleted. (WebCore::LayoutIntegration::RunIteratorLegacyPath::isLastTextRun const): Deleted. * layout/integration/LayoutIntegrationRunIteratorModernPath.h: (WebCore::LayoutIntegration::RunIteratorModernPath::isLastTextRunOnLine const): Deleted. (WebCore::LayoutIntegration::RunIteratorModernPath::isLastTextRun const): Deleted. Canonical link: https://commits.webkit.org/231616@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3af5f59 commit ecc0b38

7 files changed

Lines changed: 51 additions & 71 deletions

Source/WebCore/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
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+
133
2020-11-16 Kimmo Kinnunen <kkinnunen@apple.com>
234

335
Final refactor for WebGL implementation to use only GraphicsContextGL

Source/WebCore/dom/Position.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -750,15 +750,15 @@ Position Position::upstream(EditingBoundaryCrossingRule rule) const
750750
}
751751

752752
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())
761755
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;
762762
}
763763
}
764764
}
@@ -853,18 +853,18 @@ Position Position::downstream(EditingBoundaryCrossingRule rule) const
853853
}
854854

855855
unsigned textOffset = currentPosition.offsetInLeafNode();
856-
for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {
856+
for (auto run = firstTextRun; run;) {
857857
if (!run->length() && textOffset == run->start())
858858
return currentPosition;
859859

860-
if (textOffset < run->end()) {
861-
if (textOffset >= run->start())
862-
return currentPosition;
863-
continue;
864-
}
860+
if (textOffset >= run->start() && textOffset < run->end())
861+
return currentPosition;
865862

866-
if (textOffset == run->end() && run->isLastTextRunOnLine() && !run->isLastTextRun())
863+
auto nextRun = run.nextTextRunInTextOrder();
864+
if (textOffset == run->end() && nextRun && run.line() != nextRun.line())
867865
return currentPosition;
866+
867+
run = nextRun;
868868
}
869869
}
870870
}

Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ LineIterator& LineIterator::traversePrevious()
7373

7474
bool LineIterator::operator==(const LineIterator& other) const
7575
{
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;
8277
}
8378

8479
RunIterator LineIterator::firstRun() const

Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ RunIterator::RunIterator(PathRun::PathVariant&& pathVariant)
4242

4343
bool RunIterator::operator==(const RunIterator& other) const
4444
{
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;
5146
}
5247

5348
bool RunIterator::atEnd() const

Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ class PathTextRun : public PathRun {
111111
bool isSelectable(unsigned start, unsigned end) const;
112112
LayoutRect selectionRect(unsigned start, unsigned end) const;
113113

114-
bool isLastTextRunOnLine() const;
115-
bool isLastTextRun() const;
116-
117114
InlineTextBox* legacyInlineBox() const { return downcast<InlineTextBox>(PathRun::legacyInlineBox()); }
118115
};
119116

@@ -343,20 +340,6 @@ inline LayoutRect PathTextRun::selectionRect(unsigned start, unsigned end) const
343340
});
344341
}
345342

346-
inline bool PathTextRun::isLastTextRunOnLine() const
347-
{
348-
return WTF::switchOn(m_pathVariant, [](auto& path) {
349-
return path.isLastTextRunOnLine();
350-
});
351-
}
352-
353-
inline bool PathTextRun::isLastTextRun() const
354-
{
355-
return WTF::switchOn(m_pathVariant, [](auto& path) {
356-
return path.isLastTextRun();
357-
});
358-
}
359-
360343
}
361344
}
362345

Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include "InlineTextBox.h"
2929
#include "RenderText.h"
30+
#include <wtf/RefCountedArray.h>
3031
#include <wtf/Vector.h>
3132

3233
namespace WebCore {
@@ -65,13 +66,6 @@ class RunIteratorLegacyPath {
6566
bool isSelectable(unsigned start, unsigned end) const { return inlineTextBox()->isSelected(start, end); }
6667
LayoutRect selectionRect(unsigned start, unsigned end) const { return inlineTextBox()->localSelectionRect(start, end); }
6768

68-
bool isLastTextRunOnLine() const
69-
{
70-
auto* next = nextInlineTextBoxInTextOrder();
71-
return !next || &inlineTextBox()->root() != &next->root();
72-
}
73-
bool isLastTextRun() const { return !nextInlineTextBoxInTextOrder(); };
74-
7569
const RenderObject& renderer() const
7670
{
7771
return m_inlineBox->renderer();
@@ -108,7 +102,7 @@ class RunIteratorLegacyPath {
108102
const InlineTextBox* nextInlineTextBoxInTextOrder() const;
109103

110104
const InlineBox* m_inlineBox;
111-
Vector<const InlineTextBox*> m_sortedInlineTextBoxes;
105+
RefCountedArray<const InlineTextBox*> m_sortedInlineTextBoxes;
112106
size_t m_sortedInlineTextBoxIndex { 0 };
113107
};
114108

Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,6 @@ class RunIteratorModernPath {
129129
return snappedSelectionRect(selectionRect, logicalRight, selectionTop, selectionHeight, isHorizontal());
130130
}
131131

132-
bool isLastTextRunOnLine() const
133-
{
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() const
142-
{
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-
151132
const RenderObject& renderer() const
152133
{
153134
return m_inlineContent->rendererForLayoutBox(run().layoutBox());

0 commit comments

Comments
 (0)