Use LineLayoutTraversal for RenderText functions
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2019 18:25:47 +0000 (18:25 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Sep 2019 18:25:47 +0000 (18:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202266

Reviewed by Zalan Bujtas.

Replace a bunch of functions that have separate simple and complex line layout versions with
shared functions that use LineLayoutTraversal.

* rendering/RenderText.cpp:
(WebCore::RenderText::absoluteRects const):
(WebCore::RenderText::firstRunLocation const):
(WebCore::RenderText::linesBoundingBox const):

This is substantially simpler than RenderTextLineBoxes::boundingBox because it uses physical rects for all computations
instead of using logical rects and flipping to physical at the end.

(WebCore::RenderText::caretMinOffset const):
(WebCore::RenderText::caretMaxOffset const):
(WebCore::RenderText::countRenderedCharacterOffsetsUntil const):
(WebCore::containsOffset):
(WebCore::RenderText::containsRenderedCharacterOffset const):
(WebCore::RenderText::containsCaretOffset const):
(WebCore::RenderText::hasRenderedText const):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::boundingBox const): Deleted.
(WebCore::RenderTextLineBoxes::firstRunLocation const): Deleted.
(WebCore::RenderTextLineBoxes::hasRenderedText const): Deleted.
(WebCore::RenderTextLineBoxes::caretMinOffset const): Deleted.
(WebCore::RenderTextLineBoxes::caretMaxOffset const): Deleted.
(WebCore::RenderTextLineBoxes::containsOffset const): Deleted.
(WebCore::RenderTextLineBoxes::countCharacterOffsetsUntil const): Deleted.
(WebCore::RenderTextLineBoxes::absoluteRects const): Deleted.
* rendering/RenderTreeAsText.cpp:
(WebCore::write):
* rendering/SimpleLineLayout.cpp:
(WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
* rendering/SimpleLineLayout.h:
(WebCore::SimpleLineLayout::Run::Run):
* rendering/SimpleLineLayoutFunctions.cpp:
(WebCore::SimpleLineLayout::computeFirstRunLocation): Deleted.
* rendering/SimpleLineLayoutFunctions.h:
(WebCore::SimpleLineLayout::findCaretMinimumOffset): Deleted.
(WebCore::SimpleLineLayout::findCaretMaximumOffset): Deleted.
(WebCore::SimpleLineLayout::containsOffset): Deleted.
(WebCore::SimpleLineLayout::isTextRendered): Deleted.
* rendering/SimpleLineLayoutResolver.h:
(WebCore::SimpleLineLayout::RunResolver::Run::isLineBreak const):
* rendering/line/LineLayoutTraversal.cpp:
(WebCore::LineLayoutTraversal::TextBox::isLineBreak const):
(WebCore::LineLayoutTraversal::firstTextBoxFor):
(WebCore::LineLayoutTraversal::firstTextBoxInTextOrderFor):
(WebCore::LineLayoutTraversal::textBoxesFor):
(WebCore::LineLayoutTraversal::firstTextBoxInVisualOrderFor): Deleted.
(WebCore::LineLayoutTraversal::textBoxRangeFor): Deleted.
* rendering/line/LineLayoutTraversal.h:
(WebCore::LineLayoutTraversal::hasTextBoxes):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250390 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderText.cpp
Source/WebCore/rendering/RenderTextLineBoxes.cpp
Source/WebCore/rendering/RenderTextLineBoxes.h
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/SimpleLineLayout.cpp
Source/WebCore/rendering/SimpleLineLayout.h
Source/WebCore/rendering/SimpleLineLayoutFunctions.cpp
Source/WebCore/rendering/SimpleLineLayoutFunctions.h
Source/WebCore/rendering/SimpleLineLayoutResolver.h
Source/WebCore/rendering/line/LineLayoutTraversal.cpp
Source/WebCore/rendering/line/LineLayoutTraversal.h

index efaaf90..419a66d 100644 (file)
@@ -1,3 +1,62 @@
+2019-09-26  Antti Koivisto  <antti@apple.com>
+
+        Use LineLayoutTraversal for RenderText functions
+        https://bugs.webkit.org/show_bug.cgi?id=202266
+
+        Reviewed by Zalan Bujtas.
+
+        Replace a bunch of functions that have separate simple and complex line layout versions with
+        shared functions that use LineLayoutTraversal.
+
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::absoluteRects const):
+        (WebCore::RenderText::firstRunLocation const):
+        (WebCore::RenderText::linesBoundingBox const):
+
+        This is substantially simpler than RenderTextLineBoxes::boundingBox because it uses physical rects for all computations
+        instead of using logical rects and flipping to physical at the end.
+
+        (WebCore::RenderText::caretMinOffset const):
+        (WebCore::RenderText::caretMaxOffset const):
+        (WebCore::RenderText::countRenderedCharacterOffsetsUntil const):
+        (WebCore::containsOffset):
+        (WebCore::RenderText::containsRenderedCharacterOffset const):
+        (WebCore::RenderText::containsCaretOffset const):
+        (WebCore::RenderText::hasRenderedText const):
+        * rendering/RenderTextLineBoxes.cpp:
+        (WebCore::RenderTextLineBoxes::boundingBox const): Deleted.
+        (WebCore::RenderTextLineBoxes::firstRunLocation const): Deleted.
+        (WebCore::RenderTextLineBoxes::hasRenderedText const): Deleted.
+        (WebCore::RenderTextLineBoxes::caretMinOffset const): Deleted.
+        (WebCore::RenderTextLineBoxes::caretMaxOffset const): Deleted.
+        (WebCore::RenderTextLineBoxes::containsOffset const): Deleted.
+        (WebCore::RenderTextLineBoxes::countCharacterOffsetsUntil const): Deleted.
+        (WebCore::RenderTextLineBoxes::absoluteRects const): Deleted.
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::write):
+        * rendering/SimpleLineLayout.cpp:
+        (WebCore::SimpleLineLayout::LineState::appendFragmentAndCreateRunIfNeeded):
+        * rendering/SimpleLineLayout.h:
+        (WebCore::SimpleLineLayout::Run::Run):
+        * rendering/SimpleLineLayoutFunctions.cpp:
+        (WebCore::SimpleLineLayout::computeFirstRunLocation): Deleted.
+        * rendering/SimpleLineLayoutFunctions.h:
+        (WebCore::SimpleLineLayout::findCaretMinimumOffset): Deleted.
+        (WebCore::SimpleLineLayout::findCaretMaximumOffset): Deleted.
+        (WebCore::SimpleLineLayout::containsOffset): Deleted.
+        (WebCore::SimpleLineLayout::isTextRendered): Deleted.
+        * rendering/SimpleLineLayoutResolver.h:
+        (WebCore::SimpleLineLayout::RunResolver::Run::isLineBreak const):
+        * rendering/line/LineLayoutTraversal.cpp:
+        (WebCore::LineLayoutTraversal::TextBox::isLineBreak const):
+        (WebCore::LineLayoutTraversal::firstTextBoxFor):
+        (WebCore::LineLayoutTraversal::firstTextBoxInTextOrderFor):
+        (WebCore::LineLayoutTraversal::textBoxesFor):
+        (WebCore::LineLayoutTraversal::firstTextBoxInVisualOrderFor): Deleted.
+        (WebCore::LineLayoutTraversal::textBoxRangeFor): Deleted.
+        * rendering/line/LineLayoutTraversal.h:
+        (WebCore::LineLayoutTraversal::hasTextBoxes):
+
 2019-09-26  Truitt Savell  <tsavell@apple.com>
 
         Unreviewed, rolling out r250381.
index 6b432f3..2ac0b1e 100644 (file)
@@ -37,6 +37,7 @@
 #include "HTMLParserIdioms.h"
 #include "Hyphenation.h"
 #include "InlineTextBox.h"
+#include "LineLayoutTraversal.h"
 #include "Range.h"
 #include "RenderBlock.h"
 #include "RenderCombineText.h"
@@ -318,11 +319,10 @@ String RenderText::originalText() const
 
 void RenderText::absoluteRects(Vector<IntRect>& rects, const LayoutPoint& accumulatedOffset) const
 {
-    if (auto* layout = simpleLineLayout()) {
-        rects.appendVector(SimpleLineLayout::collectAbsoluteRects(*this, *layout, accumulatedOffset));
-        return;
+    for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+        auto rect = box.rect();
+        rects.append(enclosingIntRect(FloatRect(accumulatedOffset + rect.location(), rect.size())));
     }
-    rects.appendVector(m_lineBoxes.absoluteRects(accumulatedOffset));
 }
 
 Vector<IntRect> RenderText::absoluteRectsForRange(unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const
@@ -1080,10 +1080,10 @@ Vector<std::pair<unsigned, unsigned>> RenderText::draggedContentRangesBetweenOff
 
 IntPoint RenderText::firstRunLocation() const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::computeFirstRunLocation(*this, *layout);
-
-    return m_lineBoxes.firstRunLocation();
+    auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+    if (!first)
+        return { };
+    return IntPoint(first->rect().location());
 }
 
 void RenderText::setSelectionState(SelectionState state)
@@ -1382,10 +1382,15 @@ float RenderText::width(unsigned from, unsigned len, const FontCascade& f, float
 
 IntRect RenderText::linesBoundingBox() const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::computeBoundingBox(*this, *layout);
+    auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+    if (!first)
+        return { };
+
+    auto boundingBox = first->rect();
+    for (auto box = first; ++box;)
+        boundingBox.uniteEvenIfEmpty(box->rect());
 
-    return m_lineBoxes.boundingBox(*this);
+    return enclosingIntRect(boundingBox);
 }
 
 LayoutRect RenderText::linesVisualOverflowBoundingBox() const
@@ -1468,43 +1473,84 @@ LayoutRect RenderText::selectionRectForRepaint(const RenderLayerModelObject* rep
 
 int RenderText::caretMinOffset() const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::findCaretMinimumOffset(*this, *layout);
-    return m_lineBoxes.caretMinOffset();
+    auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+    if (!first)
+        return 0;
+
+    int minOffset = first->localStartOffset();
+    for (auto box = first; ++box;)
+        minOffset = std::min<int>(minOffset, box->localStartOffset());
+
+    return minOffset;
 }
 
 int RenderText::caretMaxOffset() const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::findCaretMaximumOffset(*this, *layout);
-    return m_lineBoxes.caretMaxOffset(*this);
+    auto first = LineLayoutTraversal::firstTextBoxFor(*this);
+    if (!first)
+        return text().length();
+
+    int maxOffset = first->localEndOffset();
+    for (auto box = first; ++box;)
+        maxOffset = std::max<int>(maxOffset, box->localEndOffset());
+
+    return maxOffset;
 }
 
 unsigned RenderText::countRenderedCharacterOffsetsUntil(unsigned offset) const
 {
-    ASSERT(!simpleLineLayout());
-    return m_lineBoxes.countCharacterOffsetsUntil(offset);
+    unsigned result = 0;
+    for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+        auto start = box.localStartOffset();
+        auto length = box.length();
+        if (offset < start)
+            return result;
+        if (offset <= start + length) {
+            result += offset - start;
+            return result;
+        }
+        result += length;
+    }
+    return result;
+}
+
+enum class OffsetType { Character, Caret };
+static bool containsOffset(const RenderText& text, unsigned offset, OffsetType type)
+{
+    for (auto box = LineLayoutTraversal::firstTextBoxInTextOrderFor(text); box; box.traverseNextInTextOrder()) {
+        auto start = box->localStartOffset();
+        if (offset < start)
+            return false;
+        unsigned end = box->localEndOffset();
+        if (offset >= start && offset <= end) {
+            if (offset == end && (type == OffsetType::Character || box->isLineBreak()))
+                continue;
+            if (type == OffsetType::Character)
+                return true;
+            // Return false for offsets inside composed characters.
+            return !offset || offset == static_cast<unsigned>(text.nextOffset(text.previousOffset(offset)));
+        }
+    }
+    return false;
 }
 
 bool RenderText::containsRenderedCharacterOffset(unsigned offset) const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::containsOffset(*this, *layout, offset, SimpleLineLayout::OffsetType::CharacterOffset);
-    return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CharacterOffset);
+    return containsOffset(*this, offset, OffsetType::Character);
 }
 
 bool RenderText::containsCaretOffset(unsigned offset) const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::containsOffset(*this, *layout, offset, SimpleLineLayout::OffsetType::CaretOffset);
-    return m_lineBoxes.containsOffset(*this, offset, RenderTextLineBoxes::CaretOffset);
+    return containsOffset(*this, offset, OffsetType::Caret);
 }
 
 bool RenderText::hasRenderedText() const
 {
-    if (auto* layout = simpleLineLayout())
-        return SimpleLineLayout::isTextRendered(*this, *layout);
-    return m_lineBoxes.hasRenderedText();
+    for (auto& box : LineLayoutTraversal::textBoxesFor(*this)) {
+        if (box.length())
+            return true;
+    }
+    return false;
 }
 
 int RenderText::previousOffset(int current) const
index 34822b4..8d70f42 100644 (file)
@@ -146,37 +146,6 @@ InlineTextBox* RenderTextLineBoxes::findNext(int offset, int& position) const
     return current;
 }
 
-IntRect RenderTextLineBoxes::boundingBox(const RenderText& renderer) const
-{
-    if (!m_first)
-        return IntRect();
-
-    // Return the width of the minimal left side and the maximal right side.
-    float logicalLeftSide = 0;
-    float logicalRightSide = 0;
-    for (auto* current = m_first; current; current = current->nextTextBox()) {
-        if (current == m_first || current->logicalLeft() < logicalLeftSide)
-            logicalLeftSide = current->logicalLeft();
-        if (current == m_first || current->logicalRight() > logicalRightSide)
-            logicalRightSide = current->logicalRight();
-    }
-    
-    bool isHorizontal = renderer.style().isHorizontalWritingMode();
-    
-    float x = isHorizontal ? logicalLeftSide : m_first->x();
-    float y = isHorizontal ? m_first->y() : logicalLeftSide;
-    float width = isHorizontal ? logicalRightSide - logicalLeftSide : m_last->logicalBottom() - x;
-    float height = isHorizontal ? m_last->logicalBottom() - y : logicalRightSide - logicalLeftSide;
-    return enclosingIntRect(FloatRect(x, y, width, height));
-}
-
-IntPoint RenderTextLineBoxes::firstRunLocation() const
-{
-    if (!m_first)
-        return IntPoint();
-    return IntPoint(m_first->topLeft());
-}
-
 LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& renderer) const
 {
     if (!m_first)
@@ -200,71 +169,6 @@ LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& rend
     return rect;
 }
 
-bool RenderTextLineBoxes::hasRenderedText() const
-{
-    for (auto* box = m_first; box; box = box->nextTextBox()) {
-        if (box->len())
-            return true;
-    }
-    return false;
-}
-
-int RenderTextLineBoxes::caretMinOffset() const
-{
-    auto box = m_first;
-    if (!box)
-        return 0;
-    int minOffset = box->start();
-    for (box = box->nextTextBox(); box; box = box->nextTextBox())
-        minOffset = std::min<int>(minOffset, box->start());
-    return minOffset;
-}
-
-int RenderTextLineBoxes::caretMaxOffset(const RenderText& renderer) const
-{
-    auto box = m_last;
-    if (!box)
-        return renderer.text().length();
-
-    int maxOffset = box->start() + box->len();
-    for (box = box->prevTextBox(); box; box = box->prevTextBox())
-        maxOffset = std::max<int>(maxOffset, box->start() + box->len());
-    return maxOffset;
-}
-
-bool RenderTextLineBoxes::containsOffset(const RenderText& renderer, unsigned offset, OffsetType type) const
-{
-    for (auto* box = m_first; box; box = box->nextTextBox()) {
-        if (offset < box->start() && !renderer.containsReversedText())
-            return false;
-        unsigned boxEnd = box->start() + box->len();
-        if (offset >= box->start() && offset <= boxEnd) {
-            if (offset == boxEnd && (type == CharacterOffset || box->isLineBreak()))
-                continue;
-            if (type == CharacterOffset)
-                return true;
-            // Return false for offsets inside composed characters.
-            return !offset || offset == static_cast<unsigned>(renderer.nextOffset(renderer.previousOffset(offset)));
-        }
-    }
-    return false;
-}
-
-unsigned RenderTextLineBoxes::countCharacterOffsetsUntil(unsigned offset) const
-{
-    unsigned result = 0;
-    for (auto* box = m_first; box; box = box->nextTextBox()) {
-        if (offset < box->start())
-            return result;
-        if (offset <= box->start() + box->len()) {
-            result += offset - box->start();
-            return result;
-        }
-        result += box->len();
-    }
-    return result;
-}
-
 enum ShouldAffinityBeDownstream { AlwaysDownstream, AlwaysUpstream, UpstreamIfPositionIsNotAtStart };
 
 static bool lineDirectionPointFitsInBox(int pointLineDirection, const InlineTextBox& box, ShouldAffinityBeDownstream& shouldAffinityBeDownstream)
@@ -505,14 +409,6 @@ void RenderTextLineBoxes::collectSelectionRectsForRange(unsigned start, unsigned
     }
 }
 
-Vector<IntRect> RenderTextLineBoxes::absoluteRects(const LayoutPoint& accumulatedOffset) const
-{
-    Vector<IntRect> rects;
-    for (auto* box = m_first; box; box = box->nextTextBox())
-        rects.append(enclosingIntRect(FloatRect(accumulatedOffset + box->topLeft(), box->size())));
-    return rects;
-}
-
 static FloatRect localQuadForTextBox(const InlineTextBox& box, unsigned start, unsigned end, bool useSelectionHeight)
 {
     unsigned realEnd = std::min(box.end(), end);
index 2e5ae5a..8970e0e 100644 (file)
@@ -56,24 +56,14 @@ public:
 
     InlineTextBox* findNext(int offset, int& position) const;
 
-    bool hasRenderedText() const;
-    int caretMinOffset() const;
-    int caretMaxOffset(const RenderText&) const;
-    enum OffsetType { CaretOffset, CharacterOffset };
-    bool containsOffset(const RenderText&, unsigned, OffsetType) const;
-    unsigned countCharacterOffsetsUntil(unsigned) const;
-
     VisiblePosition positionForPoint(const RenderText&, const LayoutPoint&) const;
 
     void setSelectionState(RenderText&, RenderObject::SelectionState);
     LayoutRect selectionRectForRange(unsigned start, unsigned end);
     void collectSelectionRectsForRange(unsigned start, unsigned end, Vector<LayoutRect>& rects);
 
-    IntRect boundingBox(const RenderText&) const;
-    IntPoint firstRunLocation() const;
     LayoutRect visualOverflowBoundingBox(const RenderText&) const;
 
-    Vector<IntRect> absoluteRects(const LayoutPoint& accumulatedOffset) const;
     Vector<IntRect> absoluteRectsForRange(const RenderText&, unsigned start, unsigned end, bool useSelectionHeight, bool* wasFixed) const;
     enum ClippingOption { NoClipping, ClipToEllipsis };
     Vector<FloatQuad> absoluteQuads(const RenderText&, bool* wasFixed, ClippingOption) const;
index 69c598a..7c859c7 100644 (file)
@@ -549,7 +549,7 @@ void write(TextStream& ts, const RenderObject& o, OptionSet<RenderAsTextFlag> be
 
     if (is<RenderText>(o)) {
         auto& text = downcast<RenderText>(o);
-        for (auto& textBox : LineLayoutTraversal::textBoxRangeFor(text)) {
+        for (auto& textBox : LineLayoutTraversal::textBoxesFor(text)) {
             ts << indent;
             writeTextBox(ts, text, textBox);
         }
index 537c917..5166aea 100644 (file)
@@ -473,7 +473,7 @@ public:
         // New line needs new run.
         if (!m_runsWidth) {
             ASSERT(!m_uncompletedWidth);
-            runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen()));
+            runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen(), fragment.isLineBreak()));
         } else {
             // Advance last completed fragment when the previous fragment is all set (including multiple parts across renderers)
             if ((m_lastFragment.type() != fragment.type()) || !m_lastFragment.overlapsToNextRenderer()) {
@@ -492,7 +492,7 @@ public:
                 return;
             }
             if (m_lastFragment.isLastInRenderer() || m_lastFragment.isCollapsed())
-                runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen()));
+                runs.append(Run(fragment.start(), endPosition, m_runsWidth, m_runsWidth + fragment.width(), false, fragment.hasHyphen(), fragment.isLineBreak()));
             else {
                 Run& lastRun = runs.last();
                 lastRun.end = endPosition;
index 4beb98c..4d9f2bd 100644 (file)
@@ -51,19 +51,21 @@ struct Run {
 #if COMPILER(MSVC)
     Run() { }
 #endif
-    Run(unsigned start, unsigned end, float logicalLeft, float logicalRight, bool isEndOfLine, bool hasHyphen)
+    Run(unsigned start, unsigned end, float logicalLeft, float logicalRight, bool isEndOfLine, bool hasHyphen, bool isLineBreak)
         : end(end)
         , start(start)
         , isEndOfLine(isEndOfLine)
         , hasHyphen(hasHyphen)
+        , isLineBreak(isLineBreak)
         , logicalLeft(logicalLeft)
         , logicalRight(logicalRight)
     { }
 
     unsigned end;
-    unsigned start : 30;
+    unsigned start : 29;
     unsigned isEndOfLine : 1;
     unsigned hasHyphen : 1;
+    unsigned isLineBreak : 1;
     float logicalLeft;
     float logicalRight;
     // TODO: Move these optional items out of SimpleLineLayout::Run to a supplementary structure.
index 9df03c3..6197997 100644 (file)
@@ -197,16 +197,6 @@ IntRect computeBoundingBox(const RenderObject& renderer, const Layout& layout)
     return enclosingIntRect(boundingBoxRect);
 }
 
-IntPoint computeFirstRunLocation(const RenderObject& renderer, const Layout& layout)
-{
-    auto& resolver = layout.runResolver();
-    auto range = resolver.rangeForRenderer(renderer);
-    auto begin = range.begin();
-    if (begin == range.end())
-        return IntPoint(0, 0);
-    return flooredIntPoint((*begin).rect().location());
-}
-
 Vector<IntRect> collectAbsoluteRects(const RenderObject& renderer, const Layout& layout, const LayoutPoint& accumulatedOffset)
 {
     Vector<IntRect> rects;
index ddad1d0..70d6ad9 100644 (file)
@@ -49,13 +49,7 @@ void paintFlow(const RenderBlockFlow&, const Layout&, PaintInfo&, const LayoutPo
 bool hitTestFlow(const RenderBlockFlow&, const Layout&, const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
 void collectFlowOverflow(RenderBlockFlow&, const Layout&);
 
-bool isTextRendered(const RenderText&, const Layout&);
-enum class OffsetType { CaretOffset, CharacterOffset };
-bool containsOffset(const RenderText&, const Layout&, unsigned, OffsetType);
-unsigned findCaretMinimumOffset(const RenderText&, const Layout&);
-unsigned findCaretMaximumOffset(const RenderText&, const Layout&);
 IntRect computeBoundingBox(const RenderObject&, const Layout&);
-IntPoint computeFirstRunLocation(const RenderObject&, const Layout&);
 
 Vector<IntRect> collectAbsoluteRects(const RenderObject&, const Layout&, const LayoutPoint& accumulatedOffset);
 Vector<FloatQuad> collectAbsoluteQuads(const RenderObject&, const Layout&, bool* wasFixed);
@@ -102,43 +96,6 @@ inline LayoutUnit computeFlowLastLineBaseline(const RenderBlockFlow& flow, const
     return flow.borderAndPaddingBefore() + lineHeightFromFlow(flow) * (layout.lineCount() - 1) + baselineFromFlow(flow);
 }
 
-inline unsigned findCaretMinimumOffset(const RenderText&, const Layout& layout)
-{
-    if (!layout.runCount())
-        return 0;
-    return layout.runAt(0).start;
-}
-
-inline unsigned findCaretMaximumOffset(const RenderText& renderer, const Layout& layout)
-{
-    if (!layout.runCount())
-        return renderer.text().length();
-    auto& last = layout.runAt(layout.runCount() - 1);
-    return last.end;
-}
-
-inline bool containsOffset(const RenderText&, const Layout& layout, unsigned offset, OffsetType offsetType)
-{
-    for (unsigned i = 0; i < layout.runCount(); ++i) {
-        auto& run = layout.runAt(i);
-        if (offset < run.start)
-            return false;
-        if (offset < run.end || (offsetType == OffsetType::CaretOffset && offset == run.end))
-            return true;
-    }
-    return false;
-}
-
-inline bool isTextRendered(const RenderText&, const Layout& layout)
-{
-    for (unsigned i = 0; i < layout.runCount(); ++i) {
-        auto& run = layout.runAt(i);
-        if (run.end > run.start)
-            return true;
-    }
-    return false;
-}
-
 inline LayoutUnit lineHeightFromFlow(const RenderBlockFlow& flow)
 {
     return flow.lineHeight(false, HorizontalLine, PositionOfInteriorLineBoxes);
index ca13cbe..0e6fe25 100644 (file)
@@ -63,6 +63,7 @@ public:
         const RenderObject& renderer() const;
         bool isEndOfLine() const;
         bool hasHyphen() const { return m_iterator.simpleRun().hasHyphen; }
+        bool isLineBreak() const { return m_iterator.simpleRun().isLineBreak; }
         const SimpleLineLayout::Run& simpleRun() const { return m_iterator.simpleRun(); }
 
         unsigned lineIndex() const;
index 34d226a..9b8c60e 100644 (file)
@@ -111,6 +111,19 @@ StringView TextBox::text() const
     return WTF::switchOn(iterator().m_pathVariant, simple, complex);
 }
 
+bool TextBox::isLineBreak() const
+{
+    auto simple = [](const TextBoxIterator::SimplePath& path) {
+        return (*path.iterator).isLineBreak();
+    };
+
+    auto complex = [](const TextBoxIterator::ComplexPath& path) {
+        return path.inlineTextBox->isLineBreak();
+    };
+
+    return WTF::switchOn(iterator().m_pathVariant, simple, complex);
+}
+
 unsigned TextBox::localStartOffset() const
 {
     auto simple = [](const TextBoxIterator::SimplePath& path) {
@@ -272,7 +285,7 @@ bool TextBoxIterator::atEnd() const
     return WTF::switchOn(m_pathVariant, simple, complex);
 }
 
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText& text)
+TextBoxIterator firstTextBoxFor(const RenderText& text)
 {
     if (auto* simpleLineLayout = text.simpleLineLayout()) {
         auto range = simpleLineLayout->runResolver().rangeForRenderer(text);
@@ -292,12 +305,12 @@ TextBoxIterator firstTextBoxInTextOrderFor(const RenderText& text)
         return TextBoxIterator { WTFMove(sortedTextBoxes), 0 };
     }
 
-    return firstTextBoxInVisualOrderFor(text);
+    return firstTextBoxFor(text);
 }
 
-TextBoxRange textBoxRangeFor(const RenderText& text)
+TextBoxRange textBoxesFor(const RenderText& text)
 {
-    return { firstTextBoxInVisualOrderFor(text) };
+    return { firstTextBoxFor(text) };
 }
 
 }
index 1f61965..fc92781 100644 (file)
@@ -54,6 +54,7 @@ public:
     bool dirOverride() const;
 
     StringView text() const;
+    bool isLineBreak() const;
 
     // These offsets are relative to the text renderer (not flow).
     unsigned localStartOffset() const;
@@ -67,6 +68,7 @@ protected:
     TextBox() = default;
     TextBox(const TextBox&) = default;
     TextBox(TextBox&&) = default;
+    ~TextBox() = default;
     TextBox& operator=(const TextBox&) = default;
     TextBox& operator=(TextBox&&) = default;
 
@@ -130,10 +132,11 @@ private:
     TextBoxIterator m_begin;
 };
 
-TextBoxIterator firstTextBoxInVisualOrderFor(const RenderText&);
+TextBoxIterator firstTextBoxFor(const RenderText&);
 TextBoxIterator firstTextBoxInTextOrderFor(const RenderText&);
-TextBoxRange textBoxRangeFor(const RenderText&);
-inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxInVisualOrderFor(text).atEnd(); }
+TextBoxRange textBoxesFor(const RenderText&);
+
+inline bool hasTextBoxes(const RenderText& text) { return !firstTextBoxFor(text).atEnd(); }
 
 }
 }