Title: [267734] trunk/Source/WebCore
Revision
267734
Author
an...@apple.com
Date
2020-09-29 06:19:05 -0700 (Tue, 29 Sep 2020)

Log Message

[LFC][Integration] Generalize run iterator for non-text runs
https://bugs.webkit.org/show_bug.cgi?id=217083

Reviewed by Zalan Bujtas.

Add RunIterator base for TextRunIterator.
Add type traits.
Naming improvements.

* dom/Position.cpp:
(WebCore::Position::upstream const):
(WebCore::Position::downstream const):
* editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextRun):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::textRunsFor const):
(WebCore::LayoutIntegration::LineLayout::runFor const):
(WebCore::LayoutIntegration::LineLayout::elementRunFor const): Deleted.
* layout/integration/LayoutIntegrationLineLayout.h:
* layout/integration/LayoutIntegrationRunIterator.cpp:
(WebCore::LayoutIntegration::RunIterator::RunIterator):
(WebCore::LayoutIntegration::RunIterator::traverseNextTextRunInVisualOrder):
(WebCore::LayoutIntegration::RunIterator::traverseNextTextRunInTextOrder):
(WebCore::LayoutIntegration::RunIterator::operator== const):
(WebCore::LayoutIntegration::RunIterator::atEnd const):
(WebCore::LayoutIntegration::TextRunIterator::TextRunIterator):
(WebCore::LayoutIntegration::runFor):
(WebCore::LayoutIntegration::TextRunIterator::traverseNextInVisualOrder): Deleted.
(WebCore::LayoutIntegration::TextRunIterator::traverseNextInTextOrder): Deleted.
(WebCore::LayoutIntegration::TextRunIterator::operator== const): Deleted.
(WebCore::LayoutIntegration::TextRunIterator::atEnd const): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::ElementRunIterator): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::atEnd const): Deleted.
(WebCore::LayoutIntegration::elementRunFor): Deleted.
* layout/integration/LayoutIntegrationRunIterator.h:
(WebCore::LayoutIntegration::RunIterator::RunIterator):
(WebCore::LayoutIntegration::RunIterator::operator!= const):
(WebCore::LayoutIntegration::RunIterator::operator* const):
(WebCore::LayoutIntegration::RunIterator::operator-> const):
(WebCore::LayoutIntegration::TextRunIterator::TextRunIterator):
(WebCore::LayoutIntegration::TextRunIterator::operator++):
(WebCore::LayoutIntegration::TextRunIterator::operator* const):
(WebCore::LayoutIntegration::TextRunIterator::operator-> const):
(WebCore::LayoutIntegration::TextRunIterator::get const):
(WebCore::LayoutIntegration::Run::isText const):
(WebCore::LayoutIntegration::Run::minimumCaretOffset const):
(WebCore::LayoutIntegration::Run::maximumCaretOffset const):
(WebCore::LayoutIntegration::TextRun::isLastTextRunOnLine const):
(WebCore::LayoutIntegration::TextRun::isLastTextRun const):
(isType):
(WebCore::LayoutIntegration::TextRunIterator::operator bool const): Deleted.
(WebCore::LayoutIntegration::TextRunIterator::operator!= const): Deleted.
(WebCore::LayoutIntegration::TextRunIterator::operator== const): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::ElementRunIterator): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::operator bool const): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::operator* const): Deleted.
(WebCore::LayoutIntegration::ElementRunIterator::operator-> const): Deleted.
(WebCore::LayoutIntegration::TextRun::isLastOnLine const): Deleted.
(WebCore::LayoutIntegration::TextRun::isLast const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
(WebCore::LayoutIntegration::LegacyPath::isText const):
(WebCore::LayoutIntegration::LegacyPath::minimumCaretOffset const):
(WebCore::LayoutIntegration::LegacyPath::maximumCaretOffset const):
(WebCore::LayoutIntegration::LegacyPath::isLastTextRunOnLine const):
(WebCore::LayoutIntegration::LegacyPath::isLastTextRun const):
(WebCore::LayoutIntegration::LegacyPath::isLastOnLine const): Deleted.
(WebCore::LayoutIntegration::LegacyPath::isLast const): Deleted.
* layout/integration/LayoutIntegrationRunIteratorModernPath.h:
(WebCore::LayoutIntegration::ModernPath::isText const):
(WebCore::LayoutIntegration::ModernPath::minimumCaretOffset const):
(WebCore::LayoutIntegration::ModernPath::maximumCaretOffset const):
(WebCore::LayoutIntegration::ModernPath::isLastTextRunOnLine const):
(WebCore::LayoutIntegration::ModernPath::isLastTextRun const):
(WebCore::LayoutIntegration::ModernPath::isLastOnLine const): Deleted.
(WebCore::LayoutIntegration::ModernPath::isLast const): Deleted.
* rendering/RenderLineBreak.cpp:
(WebCore::RenderLineBreak::linesBoundingBox const):
(WebCore::RenderLineBreak::boundingBoxForRenderTreeDump const):
(WebCore::RenderLineBreak::absoluteRects const):
(WebCore::RenderLineBreak::absoluteQuads const):
* rendering/RenderText.cpp:
(WebCore::containsOffset):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267733 => 267734)


--- trunk/Source/WebCore/ChangeLog	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/ChangeLog	2020-09-29 13:19:05 UTC (rev 267734)
@@ -1,3 +1,88 @@
+2020-09-29  Antti Koivisto  <an...@apple.com>
+
+        [LFC][Integration] Generalize run iterator for non-text runs
+        https://bugs.webkit.org/show_bug.cgi?id=217083
+
+        Reviewed by Zalan Bujtas.
+
+        Add RunIterator base for TextRunIterator.
+        Add type traits.
+        Naming improvements.
+
+        * dom/Position.cpp:
+        (WebCore::Position::upstream const):
+        (WebCore::Position::downstream const):
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::handleTextRun):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::textRunsFor const):
+        (WebCore::LayoutIntegration::LineLayout::runFor const):
+        (WebCore::LayoutIntegration::LineLayout::elementRunFor const): Deleted.
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * layout/integration/LayoutIntegrationRunIterator.cpp:
+        (WebCore::LayoutIntegration::RunIterator::RunIterator):
+        (WebCore::LayoutIntegration::RunIterator::traverseNextTextRunInVisualOrder):
+        (WebCore::LayoutIntegration::RunIterator::traverseNextTextRunInTextOrder):
+        (WebCore::LayoutIntegration::RunIterator::operator== const):
+        (WebCore::LayoutIntegration::RunIterator::atEnd const):
+        (WebCore::LayoutIntegration::TextRunIterator::TextRunIterator):
+        (WebCore::LayoutIntegration::runFor):
+        (WebCore::LayoutIntegration::TextRunIterator::traverseNextInVisualOrder): Deleted.
+        (WebCore::LayoutIntegration::TextRunIterator::traverseNextInTextOrder): Deleted.
+        (WebCore::LayoutIntegration::TextRunIterator::operator== const): Deleted.
+        (WebCore::LayoutIntegration::TextRunIterator::atEnd const): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::ElementRunIterator): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::atEnd const): Deleted.
+        (WebCore::LayoutIntegration::elementRunFor): Deleted.
+        * layout/integration/LayoutIntegrationRunIterator.h:
+        (WebCore::LayoutIntegration::RunIterator::RunIterator):
+        (WebCore::LayoutIntegration::RunIterator::operator!= const):
+        (WebCore::LayoutIntegration::RunIterator::operator* const):
+        (WebCore::LayoutIntegration::RunIterator::operator-> const):
+        (WebCore::LayoutIntegration::TextRunIterator::TextRunIterator):
+        (WebCore::LayoutIntegration::TextRunIterator::operator++):
+        (WebCore::LayoutIntegration::TextRunIterator::operator* const):
+        (WebCore::LayoutIntegration::TextRunIterator::operator-> const):
+        (WebCore::LayoutIntegration::TextRunIterator::get const):
+        (WebCore::LayoutIntegration::Run::isText const):
+        (WebCore::LayoutIntegration::Run::minimumCaretOffset const):
+        (WebCore::LayoutIntegration::Run::maximumCaretOffset const):
+        (WebCore::LayoutIntegration::TextRun::isLastTextRunOnLine const):
+        (WebCore::LayoutIntegration::TextRun::isLastTextRun const):
+        (isType):
+        (WebCore::LayoutIntegration::TextRunIterator::operator bool const): Deleted.
+        (WebCore::LayoutIntegration::TextRunIterator::operator!= const): Deleted.
+        (WebCore::LayoutIntegration::TextRunIterator::operator== const): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::ElementRunIterator): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::operator bool const): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::operator* const): Deleted.
+        (WebCore::LayoutIntegration::ElementRunIterator::operator-> const): Deleted.
+        (WebCore::LayoutIntegration::TextRun::isLastOnLine const): Deleted.
+        (WebCore::LayoutIntegration::TextRun::isLast const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorLegacyPath.h:
+        (WebCore::LayoutIntegration::LegacyPath::isText const):
+        (WebCore::LayoutIntegration::LegacyPath::minimumCaretOffset const):
+        (WebCore::LayoutIntegration::LegacyPath::maximumCaretOffset const):
+        (WebCore::LayoutIntegration::LegacyPath::isLastTextRunOnLine const):
+        (WebCore::LayoutIntegration::LegacyPath::isLastTextRun const):
+        (WebCore::LayoutIntegration::LegacyPath::isLastOnLine const): Deleted.
+        (WebCore::LayoutIntegration::LegacyPath::isLast const): Deleted.
+        * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+        (WebCore::LayoutIntegration::ModernPath::isText const):
+        (WebCore::LayoutIntegration::ModernPath::minimumCaretOffset const):
+        (WebCore::LayoutIntegration::ModernPath::maximumCaretOffset const):
+        (WebCore::LayoutIntegration::ModernPath::isLastTextRunOnLine const):
+        (WebCore::LayoutIntegration::ModernPath::isLastTextRun const):
+        (WebCore::LayoutIntegration::ModernPath::isLastOnLine const): Deleted.
+        (WebCore::LayoutIntegration::ModernPath::isLast const): Deleted.
+        * rendering/RenderLineBreak.cpp:
+        (WebCore::RenderLineBreak::linesBoundingBox const):
+        (WebCore::RenderLineBreak::boundingBoxForRenderTreeDump const):
+        (WebCore::RenderLineBreak::absoluteRects const):
+        (WebCore::RenderLineBreak::absoluteQuads const):
+        * rendering/RenderText.cpp:
+        (WebCore::containsOffset):
+
 2020-09-29  Zalan Bujtas  <za...@apple.com>
 
         [LFC][IFC] LineBreaker renames

Modified: trunk/Source/WebCore/dom/Position.cpp (267733 => 267734)


--- trunk/Source/WebCore/dom/Position.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/dom/Position.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -742,7 +742,7 @@
             }
 
             unsigned textOffset = currentPosition.offsetInLeafNode();
-            for (auto run = firstTextRun; run; run.traverseNextInTextOrder()) {
+            for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {
                 if (textOffset <= run->localEndOffset()) {
                     if (textOffset > run->localStartOffset())
                         return currentPosition;
@@ -749,7 +749,7 @@
                     continue;
                 }
 
-                if (textOffset == run->localEndOffset() + 1 && run->isLastOnLine() && !run->isLast())
+                if (textOffset == run->localEndOffset() + 1 && run->isLastTextRunOnLine() && !run->isLastTextRun())
                     return currentPosition;
             }
         }
@@ -845,7 +845,7 @@
             }
 
             unsigned textOffset = currentPosition.offsetInLeafNode();
-            for (auto run = firstTextRun; run; run.traverseNextInTextOrder()) {
+            for (auto run = firstTextRun; run; run.traverseNextTextRunInTextOrder()) {
                 if (!run->length() && textOffset == run->localStartOffset())
                     return currentPosition;
 
@@ -855,7 +855,7 @@
                     continue;
                 }
 
-                if (textOffset == run->localEndOffset() && run->isLastOnLine() && !run->isLast())
+                if (textOffset == run->localEndOffset() && run->isLastTextRunOnLine() && !run->isLastTextRun())
                     return currentPosition;
             }
         }

Modified: trunk/Source/WebCore/editing/TextIterator.cpp (267733 => 267734)


--- trunk/Source/WebCore/editing/TextIterator.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/editing/TextIterator.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -633,7 +633,7 @@
         
         // Determine what the next text run will be, but don't advance yet
         auto nextTextRun = m_textRun;
-        nextTextRun.traverseNextInTextOrder();
+        nextTextRun.traverseNextTextRunInTextOrder();
 
         if (runStart < runEnd) {
             auto isNewlineOrTab = [&](UChar character) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -294,7 +294,7 @@
     return *m_displayInlineContent;
 }
 
-LayoutIntegration::TextRunIterator LineLayout::textRunsFor(const RenderText& renderText) const
+TextRunIterator LineLayout::textRunsFor(const RenderText& renderText) const
 {
     auto* inlineContent = displayInlineContent();
     if (!inlineContent)
@@ -319,12 +319,12 @@
     return { LayoutIntegration::ModernPath(*inlineContent, *firstIndex, lastIndex + 1) };
 }
 
-LayoutIntegration::ElementRunIterator LineLayout::elementRunFor(const RenderLineBreak& renderLineBreak) const
+RunIterator LineLayout::runFor(const RenderElement& renderElement) const
 {
     auto* inlineContent = displayInlineContent();
     if (!inlineContent)
         return { };
-    auto* layoutBox = m_boxTree.layoutBoxForRenderer(renderLineBreak);
+    auto* layoutBox = m_boxTree.layoutBoxForRenderer(renderElement);
     ASSERT(layoutBox);
 
     for (size_t i = 0; i < inlineContent->runs.size(); ++i) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2020-09-29 13:19:05 UTC (rev 267734)
@@ -78,7 +78,7 @@
     bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation&, const LayoutPoint& accumulatedOffset, HitTestAction);
 
     TextRunIterator textRunsFor(const RenderText&) const;
-    ElementRunIterator elementRunFor(const RenderLineBreak&) const;
+    RunIterator runFor(const RenderElement&) const;
 
     static void releaseCaches(RenderView&);
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -33,44 +33,49 @@
 namespace WebCore {
 namespace LayoutIntegration {
 
-TextRunIterator::TextRunIterator(Run::PathVariant&& pathVariant)
-    : m_textRun(WTFMove(pathVariant))
+RunIterator::RunIterator(Run::PathVariant&& pathVariant)
+    : m_run(WTFMove(pathVariant))
 {
 }
 
-TextRunIterator& TextRunIterator::traverseNextInVisualOrder()
+TextRunIterator& RunIterator::traverseNextTextRunInVisualOrder()
 {
-    WTF::switchOn(m_textRun.m_pathVariant, [](auto& path) {
+    WTF::switchOn(m_run.m_pathVariant, [](auto& path) {
         path.traverseNextTextRunInVisualOrder();
     });
-    return *this;
+    return downcast<TextRunIterator>(*this);
 }
 
-TextRunIterator& TextRunIterator::traverseNextInTextOrder()
+TextRunIterator& RunIterator::traverseNextTextRunInTextOrder()
 {
-    WTF::switchOn(m_textRun.m_pathVariant, [](auto& path) {
+    WTF::switchOn(m_run.m_pathVariant, [](auto& path) {
         path.traverseNextTextRunInTextOrder();
     });
-    return *this;
+    return downcast<TextRunIterator>(*this);
 }
 
-bool TextRunIterator::operator==(const TextRunIterator& other) const
+bool RunIterator::operator==(const RunIterator& other) const
 {
-    if (m_textRun.m_pathVariant.index() != other.m_textRun.m_pathVariant.index())
+    if (m_run.m_pathVariant.index() != other.m_run.m_pathVariant.index())
         return false;
 
-    return WTF::switchOn(m_textRun.m_pathVariant, [&](const auto& path) {
-        return path == WTF::get<std::decay_t<decltype(path)>>(other.m_textRun.m_pathVariant);
+    return WTF::switchOn(m_run.m_pathVariant, [&](const auto& path) {
+        return path == WTF::get<std::decay_t<decltype(path)>>(other.m_run.m_pathVariant);
     });
 }
 
-bool TextRunIterator::atEnd() const
+bool RunIterator::atEnd() const
 {
-    return WTF::switchOn(m_textRun.m_pathVariant, [](auto& path) {
+    return WTF::switchOn(m_run.m_pathVariant, [](auto& path) {
         return path.atEnd();
     });
 }
 
+TextRunIterator::TextRunIterator(Run::PathVariant&& pathVariant)
+    : RunIterator(WTFMove(pathVariant))
+{
+}
+
 static const RenderBlockFlow* lineLayoutSystemFlowForRenderer(const RenderObject& renderer)
 {
     // In currently supported cases the renderer is always direct child of the flow.
@@ -110,24 +115,12 @@
     return { firstTextRunFor(text) };
 }
 
-ElementRunIterator::ElementRunIterator(Run::PathVariant&& pathVariant)
-    : m_run(WTFMove(pathVariant))
+RunIterator runFor(const RenderLineBreak& renderElement)
 {
-}
-
-bool ElementRunIterator::atEnd() const
-{
-    return WTF::switchOn(m_run.m_pathVariant, [](auto& path) {
-        return path.atEnd();
-    });
-}
-
-ElementRunIterator elementRunFor(const RenderLineBreak& renderElement)
-{
     if (auto* flow = lineLayoutSystemFlowForRenderer(renderElement)) {
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
         if (auto* layoutFormattingContextLineLayout = flow->layoutFormattingContextLineLayout())
-            return layoutFormattingContextLineLayout->elementRunFor(renderElement);
+            return layoutFormattingContextLineLayout->runFor(renderElement);
 #endif
     }
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h	2020-09-29 13:19:05 UTC (rev 267734)
@@ -53,6 +53,8 @@
 
     Run(PathVariant&&);
 
+    bool isText() const;
+
     FloatRect rect() const;
 
     float baseline() const;
@@ -63,8 +65,11 @@
     bool isLineBreak() const;
     bool useLineBreakBoxRenderTreeDumpQuirk() const;
 
+    unsigned minimumCaretOffset() const;
+    unsigned maximumCaretOffset() const;
+
 protected:
-    friend class ElementRunIterator;
+    friend class RunIterator;
     friend class TextRunIterator;
 
     PathVariant m_pathVariant;
@@ -82,50 +87,47 @@
     unsigned localEndOffset() const;
     unsigned length() const;
 
-    bool isLastOnLine() const;
-    bool isLast() const;
+    bool isLastTextRunOnLine() const;
+    bool isLastTextRun() const;
 };
 
-class TextRunIterator {
+class RunIterator {
 public:
-    TextRunIterator() : m_textRun(LegacyPath { nullptr, { } }) { };
-    TextRunIterator(Run::PathVariant&&);
+    RunIterator() : m_run(LegacyPath { nullptr, { } }) { };
+    RunIterator(Run::PathVariant&&);
 
-    TextRunIterator& operator++() { return traverseNextInVisualOrder(); }
-    TextRunIterator& traverseNextInVisualOrder();
-    TextRunIterator& traverseNextInTextOrder();
+    TextRunIterator& traverseNextTextRunInVisualOrder();
+    TextRunIterator& traverseNextTextRunInTextOrder();
 
     explicit operator bool() const { return !atEnd(); }
 
-    bool operator==(const TextRunIterator&) const;
-    bool operator!=(const TextRunIterator& other) const { return !(*this == other); }
+    bool operator==(const RunIterator&) const;
+    bool operator!=(const RunIterator& other) const { return !(*this == other); }
 
     bool operator==(EndIterator) const { return atEnd(); }
     bool operator!=(EndIterator) const { return !atEnd(); }
 
-    const TextRun& operator*() const { return m_textRun; }
-    const TextRun* operator->() const { return &m_textRun; }
+    const Run& operator*() const { return m_run; }
+    const Run* operator->() const { return &m_run; }
 
     bool atEnd() const;
 
-private:
-    TextRun m_textRun;
+protected:
+    Run m_run;
 };
 
-class ElementRunIterator {
+class TextRunIterator : public RunIterator {
 public:
-    ElementRunIterator() : m_run(LegacyPath { nullptr, { } }) { };
-    ElementRunIterator(Run::PathVariant&&);
+    TextRunIterator() { }
+    TextRunIterator(Run::PathVariant&&);
 
-    explicit operator bool() const { return !atEnd(); }
+    TextRunIterator& operator++() { return traverseNextTextRunInVisualOrder(); }
 
-    const Run& operator*() const { return m_run; }
-    const Run* operator->() const { return &m_run; }
+    const TextRun& operator*() const { return get(); }
+    const TextRun* operator->() const { return &get(); }
 
-    bool atEnd() const;
-
 private:
-    Run m_run;
+    const TextRun& get() const { return downcast<TextRun>(m_run); }
 };
 
 class TextRunRange {
@@ -145,7 +147,7 @@
 TextRunIterator firstTextRunFor(const RenderText&);
 TextRunIterator firstTextRunInTextOrderFor(const RenderText&);
 TextRunRange textRunsFor(const RenderText&);
-ElementRunIterator elementRunFor(const RenderLineBreak&);
+RunIterator runFor(const RenderLineBreak&);
 
 // -----------------------------------------------
 
@@ -154,6 +156,13 @@
 {
 }
 
+inline bool Run::isText() const
+{
+    return WTF::switchOn(m_pathVariant, [](auto& path) {
+        return path.isText();
+    });
+}
+
 inline FloatRect Run::rect() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) {
@@ -203,6 +212,20 @@
     });
 }
 
+inline unsigned Run::minimumCaretOffset() const
+{
+    return WTF::switchOn(m_pathVariant, [](auto& path) {
+        return path.minimumCaretOffset();
+    });
+}
+
+inline unsigned Run::maximumCaretOffset() const
+{
+    return WTF::switchOn(m_pathVariant, [](auto& path) {
+        return path.maximumCaretOffset();
+    });
+}
+
 inline bool TextRun::hasHyphen() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) {
@@ -243,20 +266,27 @@
     });
 }
 
-inline bool TextRun::isLastOnLine() const
+inline bool TextRun::isLastTextRunOnLine() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) {
-        return path.isLastOnLine();
+        return path.isLastTextRunOnLine();
     });
 }
 
-inline bool TextRun::isLast() const
+inline bool TextRun::isLastTextRun() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) {
-        return path.isLast();
+        return path.isLastTextRun();
     });
 }
 
-
 }
 }
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LayoutIntegration::TextRun)
+static bool isType(const WebCore::LayoutIntegration::Run& run) { return run.isText(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::LayoutIntegration::TextRunIterator)
+static bool isType(const WebCore::LayoutIntegration::RunIterator& runIterator) { return !runIterator || runIterator->isText(); }
+SPECIALIZE_TYPE_TRAITS_END()

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h	2020-09-29 13:19:05 UTC (rev 267734)
@@ -40,6 +40,8 @@
         , m_sortedInlineTextBoxIndex(sortedInlineTextBoxIndex)
     { }
 
+    bool isText() const { return m_inlineBox->isInlineTextBox(); }
+
     FloatRect rect() const { return m_inlineBox->frameRect(); }
 
     bool isLeftToRightDirection() const { return m_inlineBox->isLeftToRightDirection(); }
@@ -48,6 +50,9 @@
     bool isLineBreak() const { return m_inlineBox->isLineBreak(); }
     float baseline() const { return m_inlineBox->baselinePosition(AlphabeticBaseline); }
 
+    unsigned minimumCaretOffset() const { return m_inlineBox->caretMinOffset(); }
+    unsigned maximumCaretOffset() const { return m_inlineBox->caretMaxOffset(); }
+
     bool useLineBreakBoxRenderTreeDumpQuirk() const
     {
         return !m_inlineBox->behavesLikeText();
@@ -59,12 +64,12 @@
     unsigned localEndOffset() const { return inlineTextBox()->end(); }
     unsigned length() const { return inlineTextBox()->len(); }
 
-    inline bool isLastOnLine() const
+    inline bool isLastTextRunOnLine() const
     {
         auto* next = nextInlineTextBoxInTextOrder();
         return !next || &inlineTextBox()->root() != &next->root();
     }
-    inline bool isLast() const { return !nextInlineTextBoxInTextOrder(); };
+    inline bool isLastTextRun() const { return !nextInlineTextBoxInTextOrder(); };
 
     void traverseNextTextRunInVisualOrder() { m_inlineBox = inlineTextBox()->nextTextBox(); }
     void traverseNextTextRunInTextOrder()

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (267733 => 267734)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h	2020-09-29 13:19:05 UTC (rev 267734)
@@ -50,6 +50,8 @@
     ModernPath& operator=(const ModernPath&) = default;
     ModernPath& operator=(ModernPath&&) = default;
 
+    bool isText() const { return !!run().textContent(); }
+
     FloatRect rect() const;
 
     float baseline() const { return line().baseline(); }
@@ -59,6 +61,9 @@
     bool dirOverride() const { return false; }
     bool isLineBreak() const { return run().isLineBreak(); }
 
+    unsigned minimumCaretOffset() const { return isText() ? localStartOffset() : 0; }
+    unsigned maximumCaretOffset() const { return isText() ? localStartOffset() : 1; }
+
     bool useLineBreakBoxRenderTreeDumpQuirk() const
     {
         if (!m_runIndex)
@@ -73,14 +78,14 @@
     unsigned localEndOffset() const { return run().textContent()->end(); }
     unsigned length() const { return run().textContent()->length(); }
 
-    bool isLastOnLine() const
+    bool isLastTextRunOnLine() const
     {
-        if (isLast())
+        if (isLastTextRun())
             return true;
         auto& next = runs()[m_runIndex + 1];
         return run().lineIndex() != next.lineIndex();
     }
-    bool isLast() const
+    bool isLastTextRun() const
     {
         return m_runIndex + 1 == m_endIndex;
     };

Modified: trunk/Source/WebCore/rendering/RenderLineBreak.cpp (267733 => 267734)


--- trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/rendering/RenderLineBreak.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -170,7 +170,7 @@
 
 IntRect RenderLineBreak::linesBoundingBox() const
 {
-    auto box = LayoutIntegration::elementRunFor(*this);
+    auto box = LayoutIntegration::runFor(*this);
     if (!box)
         return { };
 
@@ -179,7 +179,7 @@
 
 IntRect RenderLineBreak::boundingBoxForRenderTreeDump() const
 {
-    auto box = LayoutIntegration::elementRunFor(*this);
+    auto box = LayoutIntegration::runFor(*this);
     if (!box)
         return { };
 
@@ -201,7 +201,7 @@
 
 void RenderLineBreak::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
 {
-    auto box = LayoutIntegration::elementRunFor(*this);
+    auto box = LayoutIntegration::runFor(*this);
     if (!box)
         return;
 
@@ -211,7 +211,7 @@
 
 void RenderLineBreak::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
 {
-    auto box = LayoutIntegration::elementRunFor(*this);
+    auto box = LayoutIntegration::runFor(*this);
     if (!box)
         return;
 

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (267733 => 267734)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2020-09-29 13:12:38 UTC (rev 267733)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2020-09-29 13:19:05 UTC (rev 267734)
@@ -1488,7 +1488,7 @@
 enum class OffsetType { Character, Caret };
 static bool containsOffset(const RenderText& text, unsigned offset, OffsetType type)
 {
-    for (auto box = LayoutIntegration::firstTextRunInTextOrderFor(text); box; box.traverseNextInTextOrder()) {
+    for (auto box = LayoutIntegration::firstTextRunInTextOrderFor(text); box; box.traverseNextTextRunInTextOrder()) {
         auto start = box->localStartOffset();
         if (offset < start)
             return false;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to