Diff
Modified: trunk/Source/WebCore/ChangeLog (250342 => 250343)
--- trunk/Source/WebCore/ChangeLog 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/ChangeLog 2019-09-25 14:43:32 UTC (rev 250343)
@@ -1,3 +1,62 @@
+2019-09-25 Antti Koivisto <[email protected]>
+
+ Rename LineLayoutInterface to LineLayoutTraversal
+ https://bugs.webkit.org/show_bug.cgi?id=202202
+
+ Reviewed by Zalan Bujtas.
+
+ Use a bit more informative namespace name.
+
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Position.cpp:
+ (WebCore::Position::upstream const):
+ (WebCore::Position::downstream const):
+ * editing/TextIterator.cpp:
+ (WebCore::TextIterator::handleTextNode):
+ (WebCore::TextIterator::handleTextBox):
+ (WebCore::TextIterator::handleTextNodeFirstLetter):
+ * editing/TextIterator.h:
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::RenderTreeAsText::writeRenderObject):
+ (WebCore::writeTextBox):
+ (WebCore::write):
+ * rendering/line/LineLayoutTraversal.cpp: Renamed from Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.cpp.
+ (WebCore::LineLayoutTraversal::TextBox::rect const):
+ (WebCore::LineLayoutTraversal::TextBox::logicalRect const):
+ (WebCore::LineLayoutTraversal::TextBox::hasHyphen const):
+ (WebCore::LineLayoutTraversal::TextBox::isLeftToRightDirection const):
+ (WebCore::LineLayoutTraversal::TextBox::dirOverride const):
+ (WebCore::LineLayoutTraversal::TextBox::text const):
+ (WebCore::LineLayoutTraversal::TextBox::localStartOffset const):
+ (WebCore::LineLayoutTraversal::TextBox::localEndOffset const):
+ (WebCore::LineLayoutTraversal::TextBox::length const):
+ (WebCore::LineLayoutTraversal::TextBox::isLastOnLine const):
+ (WebCore::LineLayoutTraversal::TextBox::isLast const):
+ (WebCore::LineLayoutTraversal::TextBox::iterator const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::TextBoxIterator):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::traverseNextInVisualOrder):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::ComplexPath::nextInlineTextBoxInTextOrder const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::traverseNextInTextOrder):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator== const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::atEnd const):
+ (WebCore::LineLayoutTraversal::firstTextBoxInVisualOrderFor):
+ (WebCore::LineLayoutTraversal::firstTextBoxInTextOrderFor):
+ (WebCore::LineLayoutTraversal::textBoxRangeFor):
+ * rendering/line/LineLayoutTraversal.h: Renamed from Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.h.
+ (WebCore::LineLayoutTraversal::TextBoxIterator::TextBoxIterator):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator++):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator bool const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator!= const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator== const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator* const):
+ (WebCore::LineLayoutTraversal::TextBoxIterator::operator-> const):
+ (WebCore::LineLayoutTraversal::TextBoxRange::TextBoxRange):
+ (WebCore::LineLayoutTraversal::TextBoxRange::begin const):
+ (WebCore::LineLayoutTraversal::TextBoxRange::end const):
+ (WebCore::LineLayoutTraversal::hasTextBoxes):
+
2019-09-25 Zalan Bujtas <[email protected]>
[LFC][IFC] Use existing Line::Content::LineBox to track the current line geometry
Modified: trunk/Source/WebCore/Headers.cmake (250342 => 250343)
--- trunk/Source/WebCore/Headers.cmake 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/Headers.cmake 2019-09-25 14:43:32 UTC (rev 250343)
@@ -1306,7 +1306,7 @@
rendering/SimpleLineLayoutFlowContents.h
rendering/SimpleLineLayoutResolver.h
- rendering/line/LineLayoutInterfaceTextBoxes.h
+ rendering/line/LineLayoutTraversal.h
rendering/line/LineWidth.h
rendering/line/TrailingObjects.h
Modified: trunk/Source/WebCore/Sources.txt (250342 => 250343)
--- trunk/Source/WebCore/Sources.txt 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/Sources.txt 2019-09-25 14:43:32 UTC (rev 250343)
@@ -2169,7 +2169,7 @@
rendering/line/LineBreaker.cpp
rendering/line/LineInfo.cpp
-rendering/line/LineLayoutInterfaceTextBoxes.cpp
+rendering/line/LineLayoutTraversal.cpp
rendering/line/LineWidth.cpp
rendering/line/TrailingObjects.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (250342 => 250343)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-09-25 14:43:32 UTC (rev 250343)
@@ -4806,7 +4806,7 @@
E47C39331FE6E10800BBBC6B /* RenderTreeBuilderMultiColumn.h in Headers */ = {isa = PBXBuildFile; fileRef = E47C39271FE6E0DC00BBBC6B /* RenderTreeBuilderMultiColumn.h */; };
E47E276516036ED200EE2AFB /* ExtensionStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
E48137B91DB3B526005C59BF /* StyleValidity.h in Headers */ = {isa = PBXBuildFile; fileRef = E48137B81DB3B526005C59BF /* StyleValidity.h */; settings = {ATTRIBUTES = (Private, ); }; };
- E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */ = {isa = PBXBuildFile; fileRef = E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E484A33E23055325009ADE6A /* LineLayoutTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = E484A33B23055303009ADE6A /* LineLayoutTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
E48944A3180B57D800F165D8 /* SimpleLineLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = E48944A1180B57D800F165D8 /* SimpleLineLayout.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4916FF7195DF6A0005AB349 /* LayerFlushThrottleState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */; settings = {ATTRIBUTES = (Private, ); }; };
E4946EAF156E64DD00D3297F /* StyleRuleImport.h in Headers */ = {isa = PBXBuildFile; fileRef = E4946EAD156E64DD00D3297F /* StyleRuleImport.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -15022,8 +15022,8 @@
E47E276416036ED200EE2AFB /* ExtensionStyleSheets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtensionStyleSheets.h; sourceTree = "<group>"; };
E47E276716036EDC00EE2AFB /* ExtensionStyleSheets.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtensionStyleSheets.cpp; sourceTree = "<group>"; };
E48137B81DB3B526005C59BF /* StyleValidity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleValidity.h; sourceTree = "<group>"; };
- E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutInterfaceTextBoxes.h; sourceTree = "<group>"; };
- E484A33D23055303009ADE6A /* LineLayoutInterfaceTextBoxes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineLayoutInterfaceTextBoxes.cpp; sourceTree = "<group>"; };
+ E484A33B23055303009ADE6A /* LineLayoutTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineLayoutTraversal.h; sourceTree = "<group>"; };
+ E484A33D23055303009ADE6A /* LineLayoutTraversal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineLayoutTraversal.cpp; sourceTree = "<group>"; };
E48944A0180B57D800F165D8 /* SimpleLineLayout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SimpleLineLayout.cpp; sourceTree = "<group>"; };
E48944A1180B57D800F165D8 /* SimpleLineLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleLineLayout.h; sourceTree = "<group>"; };
E4916FF6195DF6A0005AB349 /* LayerFlushThrottleState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerFlushThrottleState.h; sourceTree = "<group>"; };
@@ -28306,8 +28306,8 @@
FFB698CD1833F17600158A31 /* LineInfo.cpp */,
FFB698CE1833F17600158A31 /* LineInfo.h */,
FFEFAB2D183BCB6F00514534 /* LineInlineHeaders.h */,
- E484A33D23055303009ADE6A /* LineLayoutInterfaceTextBoxes.cpp */,
- E484A33B23055303009ADE6A /* LineLayoutInterfaceTextBoxes.h */,
+ E484A33D23055303009ADE6A /* LineLayoutTraversal.cpp */,
+ E484A33B23055303009ADE6A /* LineLayoutTraversal.h */,
FFEFAB2918380DA000514534 /* LineLayoutState.h */,
FFDBC046183D27B700407109 /* LineWidth.cpp */,
FFDBC045183D27B700407109 /* LineWidth.h */,
@@ -30744,7 +30744,7 @@
84730D911248F0B300D3A9C9 /* LightSource.h in Headers */,
B22279650D00BF220071B782 /* LinearGradientAttributes.h in Headers */,
AB31C91E10AE1B8E000C7B92 /* LineClampValue.h in Headers */,
- E484A33E23055325009ADE6A /* LineLayoutInterfaceTextBoxes.h in Headers */,
+ E484A33E23055325009ADE6A /* LineLayoutTraversal.h in Headers */,
FFEFAB2A18380DA000514534 /* LineLayoutState.h in Headers */,
FFDBC047183D27B700407109 /* LineWidth.h in Headers */,
CBA9DC0B1DF44DF40005675C /* LinkHeader.h in Headers */,
Modified: trunk/Source/WebCore/dom/Position.cpp (250342 => 250343)
--- trunk/Source/WebCore/dom/Position.cpp 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/dom/Position.cpp 2019-09-25 14:43:32 UTC (rev 250343)
@@ -37,7 +37,7 @@
#include "InlineElementBox.h"
#include "InlineIterator.h"
#include "InlineTextBox.h"
-#include "LineLayoutInterfaceTextBoxes.h"
+#include "LineLayoutTraversal.h"
#include "Logging.h"
#include "NodeTraversal.h"
#include "PositionIterator.h"
@@ -738,7 +738,7 @@
if (is<RenderText>(*renderer)) {
auto& textRenderer = downcast<RenderText>(*renderer);
- auto firstTextBox = LineLayoutInterface::firstTextBoxInTextOrderFor(textRenderer);
+ auto firstTextBox = LineLayoutTraversal::firstTextBoxInTextOrderFor(textRenderer);
if (!firstTextBox)
continue;
@@ -848,7 +848,7 @@
if (is<RenderText>(*renderer)) {
auto& textRenderer = downcast<RenderText>(*renderer);
- auto firstTextBox = LineLayoutInterface::firstTextBoxInTextOrderFor(textRenderer);
+ auto firstTextBox = LineLayoutTraversal::firstTextBoxInTextOrderFor(textRenderer);
if (!firstTextBox)
continue;
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (250342 => 250343)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2019-09-25 14:43:32 UTC (rev 250343)
@@ -615,7 +615,7 @@
return true;
}
- m_textBox = LineLayoutInterface::firstTextBoxInTextOrderFor(renderer);
+ m_textBox = LineLayoutTraversal::firstTextBoxInTextOrderFor(renderer);
bool shouldHandleFirstLetter = !m_handledFirstLetter && is<RenderTextFragment>(renderer) && !m_offset;
if (shouldHandleFirstLetter)
@@ -642,7 +642,7 @@
return;
}
- auto firstTextBox = LineLayoutInterface::firstTextBoxInTextOrderFor(renderer);
+ auto firstTextBox = LineLayoutTraversal::firstTextBoxInTextOrderFor(renderer);
String rendererText = renderer.text();
unsigned start = m_offset;
@@ -736,7 +736,7 @@
if (auto* firstLetterText = firstRenderTextInFirstLetter(firstLetter)) {
m_handledFirstLetter = true;
m_remainingTextBox = m_textBox;
- m_textBox = LineLayoutInterface::firstTextBoxInTextOrderFor(*firstLetterText);
+ m_textBox = LineLayoutTraversal::firstTextBoxInTextOrderFor(*firstLetterText);
m_firstLetterText = firstLetterText;
}
}
Modified: trunk/Source/WebCore/editing/TextIterator.h (250342 => 250343)
--- trunk/Source/WebCore/editing/TextIterator.h 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/editing/TextIterator.h 2019-09-25 14:43:32 UTC (rev 250343)
@@ -28,7 +28,7 @@
// FIXME: Move each iterator class into a separate header file.
#include "FindOptions.h"
-#include "LineLayoutInterfaceTextBoxes.h"
+#include "LineLayoutTraversal.h"
#include "Range.h"
#include "TextIteratorBehavior.h"
#include <wtf/Vector.h>
@@ -168,10 +168,10 @@
// Used when there is still some pending text from the current node; when these are false and null, we go back to normal iterating.
Node* m_nodeForAdditionalNewline { nullptr };
- LineLayoutInterface::TextBoxIterator m_textBox;
+ LineLayoutTraversal::TextBoxIterator m_textBox;
// Used when iterating over :first-letter text to save pointer to remaining text box.
- LineLayoutInterface::TextBoxIterator m_remainingTextBox;
+ LineLayoutTraversal::TextBoxIterator m_remainingTextBox;
// Used to point to RenderText object for :first-letter.
RenderText* m_firstLetterText { nullptr };
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (250342 => 250343)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2019-09-25 14:43:32 UTC (rev 250343)
@@ -35,7 +35,7 @@
#include "HTMLNames.h"
#include "HTMLSpanElement.h"
#include "InlineTextBox.h"
-#include "LineLayoutInterfaceTextBoxes.h"
+#include "LineLayoutTraversal.h"
#include "Logging.h"
#include "PrintContext.h"
#include "PseudoElement.h"
@@ -202,7 +202,7 @@
// many test results.
const RenderText& text = downcast<RenderText>(o);
r = IntRect(text.firstRunLocation(), text.linesBoundingBox().size());
- if (!LineLayoutInterface::hasTextBoxes(text))
+ if (!LineLayoutTraversal::hasTextBoxes(text))
adjustForTableCells = false;
} else if (o.isBR()) {
const RenderLineBreak& br = downcast<RenderLineBreak>(o);
@@ -477,7 +477,7 @@
}
}
-static void writeTextBox(TextStream& ts, const RenderText& o, const LineLayoutInterface::TextBox& textBox)
+static void writeTextBox(TextStream& ts, const RenderText& o, const LineLayoutTraversal::TextBox& textBox)
{
auto rect = textBox.rect();
auto logicalRect = textBox.logicalRect();
@@ -549,7 +549,7 @@
if (is<RenderText>(o)) {
auto& text = downcast<RenderText>(o);
- for (auto& textBox : LineLayoutInterface::textBoxRangeFor(text)) {
+ for (auto& textBox : LineLayoutTraversal::textBoxRangeFor(text)) {
ts << indent;
writeTextBox(ts, text, textBox);
}
Deleted: trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.cpp (250342 => 250343)
--- trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.cpp 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.cpp 2019-09-25 14:43:32 UTC (rev 250343)
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "LineLayoutInterfaceTextBoxes.h"
-
-#include "InlineTextBox.h"
-#include "RenderText.h"
-#include "SimpleLineLayoutResolver.h"
-
-namespace WebCore {
-namespace LineLayoutInterface {
-
-FloatRect TextBox::rect() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).rect();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->frameRect();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-FloatRect TextBox::logicalRect() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).rect();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->logicalFrameRect();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-bool TextBox::hasHyphen() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).hasHyphen();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->hasHyphen();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-bool TextBox::isLeftToRightDirection() const
-{
- auto simple = [](const TextBoxIterator::SimplePath&) {
- return true;
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->isLeftToRightDirection();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-bool TextBox::dirOverride() const
-{
- auto simple = [](const TextBoxIterator::SimplePath&) {
- return false;
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->dirOverride();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-StringView TextBox::text() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).text();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return StringView(path.inlineTextBox->renderer().text()).substring(path.inlineTextBox->start(), path.inlineTextBox->len());
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-unsigned TextBox::localStartOffset() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).localStart();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->start();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-unsigned TextBox::localEndOffset() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).localEnd();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->end();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-unsigned TextBox::length() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- return (*path.iterator).end() - (*path.iterator).start();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return path.inlineTextBox->len();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-bool TextBox::isLastOnLine() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- auto next = path.iterator;
- ++next;
- return next == path.end || (*path.iterator).lineIndex() != (*next).lineIndex();
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- auto* next = path.nextInlineTextBoxInTextOrder();
- return !next || &path.inlineTextBox->root() != &next->root();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-bool TextBox::isLast() const
-{
- auto simple = [](const TextBoxIterator::SimplePath& path) {
- auto next = path.iterator;
- ++next;
- return next == path.end;
- };
-
- auto complex = [](const TextBoxIterator::ComplexPath& path) {
- return !path.nextInlineTextBoxInTextOrder();
- };
-
- return WTF::switchOn(iterator().m_pathVariant, simple, complex);
-}
-
-
-inline const TextBoxIterator& TextBox::iterator() const
-{
- return static_cast<const TextBoxIterator&>(*this);
-}
-
-TextBoxIterator::TextBoxIterator(const InlineTextBox* inlineTextBox)
- : m_pathVariant(ComplexPath { inlineTextBox, { } })
-{
-}
-TextBoxIterator::TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index)
- : m_pathVariant(ComplexPath { index < sorted.size() ? sorted[index] : nullptr, WTFMove(sorted), index })
-{
-}
-
-TextBoxIterator::TextBoxIterator(SimpleLineLayout::RunResolver::Iterator iterator, SimpleLineLayout::RunResolver::Iterator end)
- : m_pathVariant(SimplePath { iterator, end })
-{
-}
-
-TextBoxIterator& TextBoxIterator::traverseNextInVisualOrder()
-{
- auto simple = [](SimplePath& path) {
- ++path.iterator;
- };
-
- auto complex = [](ComplexPath& path) {
- path.inlineTextBox = path.inlineTextBox->nextTextBox();
- };
-
- WTF::switchOn(m_pathVariant, simple, complex);
-
- return *this;
-}
-
-const InlineTextBox* TextBoxIterator::ComplexPath::nextInlineTextBoxInTextOrder() const
-{
- if (!sortedInlineTextBoxes.isEmpty()) {
- if (sortedInlineTextBoxIndex + 1 < sortedInlineTextBoxes.size())
- return sortedInlineTextBoxes[sortedInlineTextBoxIndex + 1];
- return nullptr;
- }
- return inlineTextBox->nextTextBox();
-}
-
-TextBoxIterator& TextBoxIterator::traverseNextInTextOrder()
-{
- auto simple = [](SimplePath& path) {
- ++path.iterator;
- };
-
- auto complex = [](ComplexPath& path) {
- path.inlineTextBox = path.nextInlineTextBoxInTextOrder();
- if (!path.sortedInlineTextBoxes.isEmpty())
- ++path.sortedInlineTextBoxIndex;
- };
-
- WTF::switchOn(m_pathVariant, simple, complex);
-
- return *this;
-}
-
-bool TextBoxIterator::operator==(const TextBoxIterator& other) const
-{
- if (m_pathVariant.index() != other.m_pathVariant.index())
- return false;
-
- auto simple = [&](const SimplePath& path) {
- return path.iterator == WTF::get<SimplePath>(other.m_pathVariant).iterator;
- };
-
- auto complex = [&](const ComplexPath& path) {
- return path.inlineTextBox == WTF::get<ComplexPath>(other.m_pathVariant).inlineTextBox;
- };
-
- return WTF::switchOn(m_pathVariant, simple, complex);
-}
-
-bool TextBoxIterator::atEnd() const
-{
- auto simple = [&](const SimplePath& path) {
- return path.iterator == path.end;
- };
-
- auto complex = [&](const ComplexPath& path) {
- return !path.inlineTextBox;
- };
-
- return WTF::switchOn(m_pathVariant, simple, complex);
-}
-
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText& text)
-{
- if (auto* simpleLineLayout = text.simpleLineLayout()) {
- auto range = simpleLineLayout->runResolver().rangeForRenderer(text);
- return { range.begin(), range.end() };
- }
-
- return TextBoxIterator { text.firstTextBox() };
-}
-
-TextBoxIterator firstTextBoxInTextOrderFor(const RenderText& text)
-{
- if (!text.simpleLineLayout() && text.containsReversedText()) {
- Vector<const InlineTextBox*> sortedTextBoxes;
- for (auto* textBox = text.firstTextBox(); textBox; textBox = textBox->nextTextBox())
- sortedTextBoxes.append(textBox);
- std::sort(sortedTextBoxes.begin(), sortedTextBoxes.end(), InlineTextBox::compareByStart);
- return TextBoxIterator { WTFMove(sortedTextBoxes), 0 };
- }
-
- return firstTextBoxInVisualOrderFor(text);
-}
-
-TextBoxRange textBoxRangeFor(const RenderText& text)
-{
- return { firstTextBoxInVisualOrderFor(text) };
-}
-
-}
-}
Deleted: trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.h (250342 => 250343)
--- trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.h 2019-09-25 14:33:02 UTC (rev 250342)
+++ trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.h 2019-09-25 14:43:32 UTC (rev 250343)
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include "FloatRect.h"
-#include "SimpleLineLayoutResolver.h"
-#include <wtf/HashMap.h>
-#include <wtf/IteratorRange.h>
-#include <wtf/Variant.h>
-#include <wtf/text/StringView.h>
-
-namespace WebCore {
-
-class InlineTextBox;
-class RenderText;
-
-namespace LineLayoutInterface {
-
-class TextBoxContext;
-class TextBoxIterator;
-
-struct EndIterator { };
-
-class TextBox {
-public:
- FloatRect rect() const;
- FloatRect logicalRect() const;
-
- bool hasHyphen() const;
- bool isLeftToRightDirection() const;
- bool dirOverride() const;
-
- StringView text() const;
-
- // These offsets are relative to the text renderer (not flow).
- unsigned localStartOffset() const;
- unsigned localEndOffset() const;
- unsigned length() const;
-
- bool isLastOnLine() const;
- bool isLast() const;
-
-protected:
- TextBox() = default;
- TextBox(const TextBox&) = default;
- TextBox(TextBox&&) = default;
- TextBox& operator=(const TextBox&) = default;
- TextBox& operator=(TextBox&&) = default;
-
-private:
- const TextBoxIterator& iterator() const;
-};
-
-class TextBoxIterator : private TextBox {
-public:
- TextBoxIterator() : m_pathVariant(ComplexPath { nullptr, { } }) { };
- explicit TextBoxIterator(const InlineTextBox*);
- TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index);
-
- TextBoxIterator(SimpleLineLayout::RunResolver::Iterator, SimpleLineLayout::RunResolver::Iterator end);
-
- TextBoxIterator& operator++() { return traverseNextInVisualOrder(); }
- TextBoxIterator& traverseNextInVisualOrder();
- TextBoxIterator& traverseNextInTextOrder();
-
- explicit operator bool() const { return !atEnd(); }
-
- bool operator==(const TextBoxIterator&) const;
- bool operator!=(const TextBoxIterator& other) const { return !(*this == other); }
-
- bool operator==(EndIterator) const { return atEnd(); }
- bool operator!=(EndIterator) const { return !atEnd(); }
-
- const TextBox& operator*() const { return *this; }
- const TextBox* operator->() const { return this; }
-
- bool atEnd() const;
-
-private:
- friend class TextBox;
-
- struct SimplePath {
- SimpleLineLayout::RunResolver::Iterator iterator;
- SimpleLineLayout::RunResolver::Iterator end;
- };
- struct ComplexPath {
- const InlineTextBox* inlineTextBox;
- Vector<const InlineTextBox*> sortedInlineTextBoxes;
- size_t sortedInlineTextBoxIndex { 0 };
-
- const InlineTextBox* nextInlineTextBoxInTextOrder() const;
- };
- Variant<SimplePath, ComplexPath> m_pathVariant;
-};
-
-class TextBoxRange {
-public:
- TextBoxRange(TextBoxIterator begin)
- : m_begin(begin)
- {
- }
-
- TextBoxIterator begin() const { return m_begin; }
- EndIterator end() const { return { }; }
-
-private:
- TextBoxIterator m_begin;
-};
-
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText&);
-TextBoxIterator firstTextBoxInTextOrderFor(const RenderText&);
-TextBoxRange textBoxRangeFor(const RenderText&);
-inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxInVisualOrderFor(text).atEnd(); }
-
-}
-}
Copied: trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp (from rev 250342, trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.cpp) (0 => 250343)
--- trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp (rev 0)
+++ trunk/Source/WebCore/rendering/line/LineLayoutTraversal.cpp 2019-09-25 14:43:32 UTC (rev 250343)
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LineLayoutTraversal.h"
+
+#include "InlineTextBox.h"
+#include "RenderText.h"
+#include "SimpleLineLayoutResolver.h"
+
+namespace WebCore {
+namespace LineLayoutTraversal {
+
+FloatRect TextBox::rect() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).rect();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->frameRect();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+FloatRect TextBox::logicalRect() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).rect();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->logicalFrameRect();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+bool TextBox::hasHyphen() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).hasHyphen();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->hasHyphen();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+bool TextBox::isLeftToRightDirection() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath&) {
+ return true;
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->isLeftToRightDirection();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+bool TextBox::dirOverride() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath&) {
+ return false;
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->dirOverride();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+StringView TextBox::text() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).text();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return StringView(path.inlineTextBox->renderer().text()).substring(path.inlineTextBox->start(), path.inlineTextBox->len());
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+unsigned TextBox::localStartOffset() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).localStart();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->start();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+unsigned TextBox::localEndOffset() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).localEnd();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->end();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+unsigned TextBox::length() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ return (*path.iterator).end() - (*path.iterator).start();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return path.inlineTextBox->len();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+bool TextBox::isLastOnLine() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ auto next = path.iterator;
+ ++next;
+ return next == path.end || (*path.iterator).lineIndex() != (*next).lineIndex();
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ auto* next = path.nextInlineTextBoxInTextOrder();
+ return !next || &path.inlineTextBox->root() != &next->root();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+bool TextBox::isLast() const
+{
+ auto simple = [](const TextBoxIterator::SimplePath& path) {
+ auto next = path.iterator;
+ ++next;
+ return next == path.end;
+ };
+
+ auto complex = [](const TextBoxIterator::ComplexPath& path) {
+ return !path.nextInlineTextBoxInTextOrder();
+ };
+
+ return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
+
+inline const TextBoxIterator& TextBox::iterator() const
+{
+ return static_cast<const TextBoxIterator&>(*this);
+}
+
+TextBoxIterator::TextBoxIterator(const InlineTextBox* inlineTextBox)
+ : m_pathVariant(ComplexPath { inlineTextBox, { } })
+{
+}
+TextBoxIterator::TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index)
+ : m_pathVariant(ComplexPath { index < sorted.size() ? sorted[index] : nullptr, WTFMove(sorted), index })
+{
+}
+
+TextBoxIterator::TextBoxIterator(SimpleLineLayout::RunResolver::Iterator iterator, SimpleLineLayout::RunResolver::Iterator end)
+ : m_pathVariant(SimplePath { iterator, end })
+{
+}
+
+TextBoxIterator& TextBoxIterator::traverseNextInVisualOrder()
+{
+ auto simple = [](SimplePath& path) {
+ ++path.iterator;
+ };
+
+ auto complex = [](ComplexPath& path) {
+ path.inlineTextBox = path.inlineTextBox->nextTextBox();
+ };
+
+ WTF::switchOn(m_pathVariant, simple, complex);
+
+ return *this;
+}
+
+const InlineTextBox* TextBoxIterator::ComplexPath::nextInlineTextBoxInTextOrder() const
+{
+ if (!sortedInlineTextBoxes.isEmpty()) {
+ if (sortedInlineTextBoxIndex + 1 < sortedInlineTextBoxes.size())
+ return sortedInlineTextBoxes[sortedInlineTextBoxIndex + 1];
+ return nullptr;
+ }
+ return inlineTextBox->nextTextBox();
+}
+
+TextBoxIterator& TextBoxIterator::traverseNextInTextOrder()
+{
+ auto simple = [](SimplePath& path) {
+ ++path.iterator;
+ };
+
+ auto complex = [](ComplexPath& path) {
+ path.inlineTextBox = path.nextInlineTextBoxInTextOrder();
+ if (!path.sortedInlineTextBoxes.isEmpty())
+ ++path.sortedInlineTextBoxIndex;
+ };
+
+ WTF::switchOn(m_pathVariant, simple, complex);
+
+ return *this;
+}
+
+bool TextBoxIterator::operator==(const TextBoxIterator& other) const
+{
+ if (m_pathVariant.index() != other.m_pathVariant.index())
+ return false;
+
+ auto simple = [&](const SimplePath& path) {
+ return path.iterator == WTF::get<SimplePath>(other.m_pathVariant).iterator;
+ };
+
+ auto complex = [&](const ComplexPath& path) {
+ return path.inlineTextBox == WTF::get<ComplexPath>(other.m_pathVariant).inlineTextBox;
+ };
+
+ return WTF::switchOn(m_pathVariant, simple, complex);
+}
+
+bool TextBoxIterator::atEnd() const
+{
+ auto simple = [&](const SimplePath& path) {
+ return path.iterator == path.end;
+ };
+
+ auto complex = [&](const ComplexPath& path) {
+ return !path.inlineTextBox;
+ };
+
+ return WTF::switchOn(m_pathVariant, simple, complex);
+}
+
+TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText& text)
+{
+ if (auto* simpleLineLayout = text.simpleLineLayout()) {
+ auto range = simpleLineLayout->runResolver().rangeForRenderer(text);
+ return { range.begin(), range.end() };
+ }
+
+ return TextBoxIterator { text.firstTextBox() };
+}
+
+TextBoxIterator firstTextBoxInTextOrderFor(const RenderText& text)
+{
+ if (!text.simpleLineLayout() && text.containsReversedText()) {
+ Vector<const InlineTextBox*> sortedTextBoxes;
+ for (auto* textBox = text.firstTextBox(); textBox; textBox = textBox->nextTextBox())
+ sortedTextBoxes.append(textBox);
+ std::sort(sortedTextBoxes.begin(), sortedTextBoxes.end(), InlineTextBox::compareByStart);
+ return TextBoxIterator { WTFMove(sortedTextBoxes), 0 };
+ }
+
+ return firstTextBoxInVisualOrderFor(text);
+}
+
+TextBoxRange textBoxRangeFor(const RenderText& text)
+{
+ return { firstTextBoxInVisualOrderFor(text) };
+}
+
+}
+}
Copied: trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h (from rev 250342, trunk/Source/WebCore/rendering/line/LineLayoutInterfaceTextBoxes.h) (0 => 250343)
--- trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h (rev 0)
+++ trunk/Source/WebCore/rendering/line/LineLayoutTraversal.h 2019-09-25 14:43:32 UTC (rev 250343)
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "FloatRect.h"
+#include "SimpleLineLayoutResolver.h"
+#include <wtf/HashMap.h>
+#include <wtf/IteratorRange.h>
+#include <wtf/Variant.h>
+#include <wtf/text/StringView.h>
+
+namespace WebCore {
+
+class InlineTextBox;
+class RenderText;
+
+namespace LineLayoutTraversal {
+
+class TextBoxContext;
+class TextBoxIterator;
+
+struct EndIterator { };
+
+class TextBox {
+public:
+ FloatRect rect() const;
+ FloatRect logicalRect() const;
+
+ bool hasHyphen() const;
+ bool isLeftToRightDirection() const;
+ bool dirOverride() const;
+
+ StringView text() const;
+
+ // These offsets are relative to the text renderer (not flow).
+ unsigned localStartOffset() const;
+ unsigned localEndOffset() const;
+ unsigned length() const;
+
+ bool isLastOnLine() const;
+ bool isLast() const;
+
+protected:
+ TextBox() = default;
+ TextBox(const TextBox&) = default;
+ TextBox(TextBox&&) = default;
+ TextBox& operator=(const TextBox&) = default;
+ TextBox& operator=(TextBox&&) = default;
+
+private:
+ const TextBoxIterator& iterator() const;
+};
+
+class TextBoxIterator : private TextBox {
+public:
+ TextBoxIterator() : m_pathVariant(ComplexPath { nullptr, { } }) { };
+ explicit TextBoxIterator(const InlineTextBox*);
+ TextBoxIterator(Vector<const InlineTextBox*>&& sorted, size_t index);
+
+ TextBoxIterator(SimpleLineLayout::RunResolver::Iterator, SimpleLineLayout::RunResolver::Iterator end);
+
+ TextBoxIterator& operator++() { return traverseNextInVisualOrder(); }
+ TextBoxIterator& traverseNextInVisualOrder();
+ TextBoxIterator& traverseNextInTextOrder();
+
+ explicit operator bool() const { return !atEnd(); }
+
+ bool operator==(const TextBoxIterator&) const;
+ bool operator!=(const TextBoxIterator& other) const { return !(*this == other); }
+
+ bool operator==(EndIterator) const { return atEnd(); }
+ bool operator!=(EndIterator) const { return !atEnd(); }
+
+ const TextBox& operator*() const { return *this; }
+ const TextBox* operator->() const { return this; }
+
+ bool atEnd() const;
+
+private:
+ friend class TextBox;
+
+ struct SimplePath {
+ SimpleLineLayout::RunResolver::Iterator iterator;
+ SimpleLineLayout::RunResolver::Iterator end;
+ };
+ struct ComplexPath {
+ const InlineTextBox* inlineTextBox;
+ Vector<const InlineTextBox*> sortedInlineTextBoxes;
+ size_t sortedInlineTextBoxIndex { 0 };
+
+ const InlineTextBox* nextInlineTextBoxInTextOrder() const;
+ };
+ Variant<SimplePath, ComplexPath> m_pathVariant;
+};
+
+class TextBoxRange {
+public:
+ TextBoxRange(TextBoxIterator begin)
+ : m_begin(begin)
+ {
+ }
+
+ TextBoxIterator begin() const { return m_begin; }
+ EndIterator end() const { return { }; }
+
+private:
+ TextBoxIterator m_begin;
+};
+
+TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText&);
+TextBoxIterator firstTextBoxInTextOrderFor(const RenderText&);
+TextBoxRange textBoxRangeFor(const RenderText&);
+inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxInVisualOrderFor(text).atEnd(); }
+
+}
+}