- Revision
- 269852
- Author
- [email protected]
- Date
- 2020-11-16 06:51:27 -0800 (Mon, 16 Nov 2020)
Log Message
[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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (269851 => 269852)
--- trunk/Source/WebCore/ChangeLog 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/ChangeLog 2020-11-16 14:51:27 UTC (rev 269852)
@@ -1,3 +1,35 @@
+2020-11-16 Antti Koivisto <[email protected]>
+
+ [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.
+
2020-11-16 Kimmo Kinnunen <[email protected]>
Final refactor for WebGL implementation to use only GraphicsContextGL
Modified: trunk/Source/WebCore/dom/Position.cpp (269851 => 269852)
--- trunk/Source/WebCore/dom/Position.cpp 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/dom/Position.cpp 2020-11-16 14:51:27 UTC (rev 269852)
@@ -750,15 +750,15 @@
}
unsigned textOffset = currentPosition.offsetInLeafNode();
- for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {
- if (textOffset <= run->end()) {
- if (textOffset > run->start())
- return currentPosition;
- continue;
- }
+ for (auto run = firstTextRun; run;) {
+ if (textOffset > run->start() && textOffset <= run->end())
+ return currentPosition;
- if (textOffset == run->end() + 1 && run->isLastTextRunOnLine() && !run->isLastTextRun())
+ auto nextRun = run.nextTextRunInTextOrder();
+ if (textOffset == run->end() + 1 && nextRun && run.line() != nextRun.line())
return currentPosition;
+
+ run = nextRun;
}
}
}
@@ -853,18 +853,18 @@
}
unsigned textOffset = currentPosition.offsetInLeafNode();
- for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {
+ for (auto run = firstTextRun; run;) {
if (!run->length() && textOffset == run->start())
return currentPosition;
- if (textOffset < run->end()) {
- if (textOffset >= run->start())
- return currentPosition;
- continue;
- }
+ if (textOffset >= run->start() && textOffset < run->end())
+ return currentPosition;
- if (textOffset == run->end() && run->isLastTextRunOnLine() && !run->isLastTextRun())
+ auto nextRun = run.nextTextRunInTextOrder();
+ if (textOffset == run->end() && nextRun && run.line() != nextRun.line())
return currentPosition;
+
+ run = nextRun;
}
}
}
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp (269851 => 269852)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp 2020-11-16 14:51:27 UTC (rev 269852)
@@ -73,12 +73,7 @@
bool LineIterator::operator==(const LineIterator& other) const
{
- if (m_line.m_pathVariant.index() != other.m_line.m_pathVariant.index())
- return false;
-
- return WTF::switchOn(m_line.m_pathVariant, [&](const auto& path) {
- return path == WTF::get<std::decay_t<decltype(path)>>(other.m_line.m_pathVariant);
- });
+ return m_line.m_pathVariant == other.m_line.m_pathVariant;
}
RunIterator LineIterator::firstRun() const
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp (269851 => 269852)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp 2020-11-16 14:51:27 UTC (rev 269852)
@@ -42,12 +42,7 @@
bool RunIterator::operator==(const RunIterator& other) const
{
- if (m_run.m_pathVariant.index() != other.m_run.m_pathVariant.index())
- return false;
-
- return WTF::switchOn(m_run.m_pathVariant, [&](const auto& path) {
- return path == WTF::get<std::decay_t<decltype(path)>>(other.m_run.m_pathVariant);
- });
+ return m_run.m_pathVariant == other.m_run.m_pathVariant;
}
bool RunIterator::atEnd() const
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h (269851 => 269852)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h 2020-11-16 14:51:27 UTC (rev 269852)
@@ -111,9 +111,6 @@
bool isSelectable(unsigned start, unsigned end) const;
LayoutRect selectionRect(unsigned start, unsigned end) const;
- bool isLastTextRunOnLine() const;
- bool isLastTextRun() const;
-
InlineTextBox* legacyInlineBox() const { return downcast<InlineTextBox>(PathRun::legacyInlineBox()); }
};
@@ -343,23 +340,9 @@
});
}
-inline bool PathTextRun::isLastTextRunOnLine() const
-{
- return WTF::switchOn(m_pathVariant, [](auto& path) {
- return path.isLastTextRunOnLine();
- });
}
-
-inline bool PathTextRun::isLastTextRun() const
-{
- return WTF::switchOn(m_pathVariant, [](auto& path) {
- return path.isLastTextRun();
- });
}
-}
-}
-
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LayoutIntegration::PathTextRun)
static bool isType(const WebCore::LayoutIntegration::PathRun& run) { return run.isText(); }
SPECIALIZE_TYPE_TRAITS_END()
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h (269851 => 269852)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h 2020-11-16 14:51:27 UTC (rev 269852)
@@ -27,6 +27,7 @@
#include "InlineTextBox.h"
#include "RenderText.h"
+#include <wtf/RefCountedArray.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -65,13 +66,6 @@
bool isSelectable(unsigned start, unsigned end) const { return inlineTextBox()->isSelected(start, end); }
LayoutRect selectionRect(unsigned start, unsigned end) const { return inlineTextBox()->localSelectionRect(start, end); }
- bool isLastTextRunOnLine() const
- {
- auto* next = nextInlineTextBoxInTextOrder();
- return !next || &inlineTextBox()->root() != &next->root();
- }
- bool isLastTextRun() const { return !nextInlineTextBoxInTextOrder(); };
-
const RenderObject& renderer() const
{
return m_inlineBox->renderer();
@@ -108,7 +102,7 @@
const InlineTextBox* nextInlineTextBoxInTextOrder() const;
const InlineBox* m_inlineBox;
- Vector<const InlineTextBox*> m_sortedInlineTextBoxes;
+ RefCountedArray<const InlineTextBox*> m_sortedInlineTextBoxes;
size_t m_sortedInlineTextBoxIndex { 0 };
};
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (269851 => 269852)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-11-16 14:05:59 UTC (rev 269851)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h 2020-11-16 14:51:27 UTC (rev 269852)
@@ -129,25 +129,6 @@
return snappedSelectionRect(selectionRect, logicalRight, selectionTop, selectionHeight, isHorizontal());
}
- bool isLastTextRunOnLine() const
- {
- if (isLastTextRun())
- return true;
-
- auto& next = runs()[m_runIndex + 1];
- return run().lineIndex() != next.lineIndex();
- }
-
- bool isLastTextRun() const
- {
- ASSERT(!atEnd());
- ASSERT(run().textContent());
-
- if (m_runIndex + 1 == runs().size())
- return true;
- return &run().layoutBox() != &runs()[m_runIndex + 1].layoutBox();
- };
-
const RenderObject& renderer() const
{
return m_inlineContent->rendererForLayoutBox(run().layoutBox());