Changeset 269852 in webkit


Ignore:
Timestamp:
Nov 16, 2020 6:51:27 AM (3 years ago)
Author:
Antti Koivisto
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.

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r269850 r269852  
     12020-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
    1332020-11-16  Kimmo Kinnunen  <kkinnunen@apple.com>
    234
  • trunk/Source/WebCore/dom/Position.cpp

    r269568 r269852  
    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        }
     
    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                 }
    865 
    866                 if (textOffset == run->end() && run->isLastTextRunOnLine() && !run->isLastTextRun())
     860                if (textOffset >= run->start() && textOffset < run->end())
    867861                    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;
    868868            }
    869869        }
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIterator.cpp

    r269732 r269852  
    7474bool 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
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.cpp

    r269732 r269852  
    4343bool 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
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIterator.h

    r269732 r269852  
    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};
     
    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}
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorLegacyPath.h

    r269510 r269852  
    2828#include "InlineTextBox.h"
    2929#include "RenderText.h"
     30#include <wtf/RefCountedArray.h>
    3031#include <wtf/Vector.h>
    3132
     
    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    {
     
    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};
  • trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h

    r269571 r269852  
    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    {
Note: See TracChangeset for help on using the changeset viewer.