Title: [287520] trunk/Source/WebCore
Revision
287520
Author
an...@apple.com
Date
2022-01-02 10:48:04 -0800 (Sun, 02 Jan 2022)

Log Message

[LFC][Integration] RenderBlockFlow::containsNonZeroBidiLevel should use iterator
https://bugs.webkit.org/show_bug.cgi?id=234796

Reviewed by Alan Bujtas.

Also rename Line::first/lastRun -> Line::first/lastLeafBox for consistency and accuracy.

* editing/VisibleUnits.cpp:
(WebCore::startPositionForLine):
(WebCore::endPositionForLine):
(WebCore::previousLinePosition):
(WebCore::nextLinePosition):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
* layout/integration/InlineIteratorLine.cpp:
(WebCore::InlineIterator::Line::firstLeafBox const):
(WebCore::InlineIterator::Line::lastLeafBox const):
(WebCore::InlineIterator::Line::closestRunForLogicalLeftPosition const):
(WebCore::InlineIterator::Line::selectionState const):
(WebCore::InlineIterator::Line::firstSelectedBox const):
(WebCore::InlineIterator::Line::lastSelectedBox const):
(WebCore::InlineIterator::Line::firstRun const): Deleted.
(WebCore::InlineIterator::Line::lastRun const): Deleted.
* layout/integration/InlineIteratorLine.h:
* layout/integration/InlineIteratorLineLegacyPath.h:
(WebCore::InlineIterator::LineIteratorLegacyPath::firstLeafBox const):
(WebCore::InlineIterator::LineIteratorLegacyPath::lastLeafBox const):
(WebCore::InlineIterator::LineIteratorLegacyPath::firstRun const): Deleted.
(WebCore::InlineIterator::LineIteratorLegacyPath::lastRun const): Deleted.
* layout/integration/InlineIteratorLineModernPath.h:
(WebCore::InlineIterator::LineIteratorModernPath::firstLeafBox const):
(WebCore::InlineIterator::LineIteratorModernPath::lastLeafBox const):
(WebCore::InlineIterator::LineIteratorModernPath::firstRun const): Deleted.
(WebCore::InlineIterator::LineIteratorModernPath::lastRun const): Deleted.
* layout/integration/InlineIteratorLogicalOrderTraversal.h:
(WebCore::InlineIterator::leafBoxesInLogicalOrder):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::containsNonZeroBidiLevel const):
(WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
* style/InlineTextBoxStyle.cpp:
(WebCore::minLogicalTopForTextDecorationLine):
(WebCore::maxLogicalBottomForTextDecorationLine):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287519 => 287520)


--- trunk/Source/WebCore/ChangeLog	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/ChangeLog	2022-01-02 18:48:04 UTC (rev 287520)
@@ -1,5 +1,50 @@
 2022-01-02  Antti Koivisto  <an...@apple.com>
 
+        [LFC][Integration] RenderBlockFlow::containsNonZeroBidiLevel should use iterator
+        https://bugs.webkit.org/show_bug.cgi?id=234796
+
+        Reviewed by Alan Bujtas.
+
+        Also rename Line::first/lastRun -> Line::first/lastLeafBox for consistency and accuracy.
+
+        * editing/VisibleUnits.cpp:
+        (WebCore::startPositionForLine):
+        (WebCore::endPositionForLine):
+        (WebCore::previousLinePosition):
+        (WebCore::nextLinePosition):
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::valueWithHardLineBreaks const):
+        * layout/integration/InlineIteratorLine.cpp:
+        (WebCore::InlineIterator::Line::firstLeafBox const):
+        (WebCore::InlineIterator::Line::lastLeafBox const):
+        (WebCore::InlineIterator::Line::closestRunForLogicalLeftPosition const):
+        (WebCore::InlineIterator::Line::selectionState const):
+        (WebCore::InlineIterator::Line::firstSelectedBox const):
+        (WebCore::InlineIterator::Line::lastSelectedBox const):
+        (WebCore::InlineIterator::Line::firstRun const): Deleted.
+        (WebCore::InlineIterator::Line::lastRun const): Deleted.
+        * layout/integration/InlineIteratorLine.h:
+        * layout/integration/InlineIteratorLineLegacyPath.h:
+        (WebCore::InlineIterator::LineIteratorLegacyPath::firstLeafBox const):
+        (WebCore::InlineIterator::LineIteratorLegacyPath::lastLeafBox const):
+        (WebCore::InlineIterator::LineIteratorLegacyPath::firstRun const): Deleted.
+        (WebCore::InlineIterator::LineIteratorLegacyPath::lastRun const): Deleted.
+        * layout/integration/InlineIteratorLineModernPath.h:
+        (WebCore::InlineIterator::LineIteratorModernPath::firstLeafBox const):
+        (WebCore::InlineIterator::LineIteratorModernPath::lastLeafBox const):
+        (WebCore::InlineIterator::LineIteratorModernPath::firstRun const): Deleted.
+        (WebCore::InlineIterator::LineIteratorModernPath::lastRun const): Deleted.
+        * layout/integration/InlineIteratorLogicalOrderTraversal.h:
+        (WebCore::InlineIterator::leafBoxesInLogicalOrder):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::containsNonZeroBidiLevel const):
+        (WebCore::RenderBlockFlow::positionForPointWithInlineChildren):
+        * style/InlineTextBoxStyle.cpp:
+        (WebCore::minLogicalTopForTextDecorationLine):
+        (WebCore::maxLogicalBottomForTextDecorationLine):
+
+2022-01-02  Antti Koivisto  <an...@apple.com>
+
         [LFC][Integration] Support outlines
         https://bugs.webkit.org/show_bug.cgi?id=234766
 

Modified: trunk/Source/WebCore/editing/VisibleUnits.cpp (287519 => 287520)


--- trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/editing/VisibleUnits.cpp	2022-01-02 18:48:04 UTC (rev 287520)
@@ -752,7 +752,7 @@
     InlineIterator::LineLogicalOrderCache orderCache;
 
     Node* startNode = nullptr;
-    auto startRun = mode == UseLogicalOrdering ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(line, orderCache) : line->firstRun();
+    auto startRun = mode == UseLogicalOrdering ? InlineIterator::firstLeafOnLineInLogicalOrderWithNode(line, orderCache) : line->firstLeafBox();
     // Generated content (e.g. list markers and CSS :before and :after pseudoelements) have no corresponding DOM element,
     // and so cannot be represented by a VisiblePosition. Use whatever follows instead.
     while (true) {
@@ -824,7 +824,7 @@
     InlineIterator::LineLogicalOrderCache orderCache;
 
     Node* endNode = nullptr;
-    auto endRun = mode == UseLogicalOrdering ? InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache) : line->lastRun();
+    auto endRun = mode == UseLogicalOrdering ? InlineIterator::lastLeafOnLineInLogicalOrder(line, orderCache) : line->lastLeafBox();
     // Generated content (e.g. list markers and CSS :before and :after pseudoelements) have no corresponding DOM element,
     // and so cannot be represented by a VisiblePosition. Use whatever precedes instead.
     while (true) {
@@ -973,7 +973,7 @@
         line = run->line()->previous();
         // We want to skip zero height boxes.
         // This could happen in case it is a LegacyRootInlineBox with trailing floats.
-        if (!line || !line->logicalHeight() || !line->firstRun())
+        if (!line || !line->logicalHeight() || !line->firstLeafBox())
             line = { };
     }
 
@@ -1026,7 +1026,7 @@
         line = run->line()->next();
         // We want to skip zero height boxes.
         // This could happen in case it is a LegacyRootInlineBox with trailing floats.
-        if (!line || !line->logicalHeight() || !line->firstRun())
+        if (!line || !line->logicalHeight() || !line->firstLeafBox())
             line = { };
     }
 

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (287519 => 287520)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-01-02 18:48:04 UTC (rev 287520)
@@ -707,7 +707,7 @@
 
     auto skipToNextSoftLineBreakPosition = [&] {
         for (; currentLine; currentLine.traverseNext()) {
-            auto lastRun = currentLine->lastRun();
+            auto lastRun = currentLine->lastLeafBox();
             ASSERT(lastRun);
             auto& renderer = lastRun->renderer();
             auto lineEndsWithBR = is<RenderLineBreak>(renderer) && !downcast<RenderLineBreak>(renderer).isWBR();

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp (287519 => 287520)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.cpp	2022-01-02 18:48:04 UTC (rev 287520)
@@ -101,17 +101,17 @@
     return LineIterator(*this).traversePrevious();
 }
 
-LeafBoxIterator Line::firstRun() const
+LeafBoxIterator Line::firstLeafBox() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) -> LeafBoxIterator {
-        return { path.firstRun() };
+        return { path.firstLeafBox() };
     });
 }
 
-LeafBoxIterator Line::lastRun() const
+LeafBoxIterator Line::lastLeafBox() const
 {
     return WTF::switchOn(m_pathVariant, [](auto& path) -> LeafBoxIterator {
-        return { path.lastRun() };
+        return { path.lastLeafBox() };
     });
 }
 
@@ -126,8 +126,8 @@
         return run && run->renderer().node() && run->renderer().node()->hasEditableStyle();
     };
 
-    auto firstRun = this->firstRun();
-    auto lastRun = this->lastRun();
+    auto firstRun = this->firstLeafBox();
+    auto lastRun = this->lastLeafBox();
 
     if (firstRun != lastRun) {
         if (firstRun->isLineBreak())
@@ -179,7 +179,7 @@
         return RenderObject::None;
 
     auto state = RenderObject::None;
-    for (auto box = firstRun(); box; box.traverseNextOnLine()) {
+    for (auto box = firstLeafBox(); box; box.traverseNextOnLine()) {
         auto boxState = box->selectionState();
         if ((boxState == RenderObject::HighlightState::Start && state == RenderObject::HighlightState::End)
             || (boxState == RenderObject::HighlightState::End && state == RenderObject::HighlightState::Start))
@@ -199,7 +199,7 @@
 
 LeafBoxIterator Line::firstSelectedBox() const
 {
-    for (auto box = firstRun(); box; box.traverseNextOnLine()) {
+    for (auto box = firstLeafBox(); box; box.traverseNextOnLine()) {
         if (box->selectionState() != RenderObject::HighlightState::None)
             return box;
     }
@@ -208,7 +208,7 @@
 
 LeafBoxIterator Line::lastSelectedBox() const
 {
-    for (auto box = lastRun(); box; box.traversePreviousOnLine()) {
+    for (auto box = lastLeafBox(); box; box.traversePreviousOnLine()) {
         if (box->selectionState() != RenderObject::HighlightState::None)
             return box;
     }

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLine.h (287519 => 287520)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLine.h	2022-01-02 18:48:04 UTC (rev 287520)
@@ -81,8 +81,8 @@
 
     bool isFirst() const;
 
-    LeafBoxIterator firstRun() const;
-    LeafBoxIterator lastRun() const;
+    LeafBoxIterator firstLeafBox() const;
+    LeafBoxIterator lastLeafBox() const;
 
     LineIterator next() const;
     LineIterator previous() const;

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h (287519 => 287520)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineLegacyPath.h	2022-01-02 18:48:04 UTC (rev 287520)
@@ -75,12 +75,12 @@
 
     bool atEnd() const { return !m_rootInlineBox; }
 
-    BoxLegacyPath firstRun() const
+    BoxLegacyPath firstLeafBox() const
     {
         return { m_rootInlineBox->firstLeafDescendant() };
     }
 
-    BoxLegacyPath lastRun() const
+    BoxLegacyPath lastLeafBox() const
     {
         return { m_rootInlineBox->lastLeafDescendant() };
     }

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h (287519 => 287520)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLineModernPath.h	2022-01-02 18:48:04 UTC (rev 287520)
@@ -95,7 +95,7 @@
 
     bool atEnd() const { return m_lineIndex == lines().size(); }
 
-    BoxModernPath firstRun() const
+    BoxModernPath firstLeafBox() const
     {
         if (!line().boxCount())
             return { *m_inlineContent };
@@ -105,7 +105,7 @@
         return runIterator;
     }
 
-    BoxModernPath lastRun() const
+    BoxModernPath lastLeafBox() const
     {
         auto boxCount = line().boxCount();
         if (!boxCount)

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.h (287519 => 287520)


--- trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.h	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorLogicalOrderTraversal.h	2022-01-02 18:48:04 UTC (rev 287520)
@@ -68,7 +68,7 @@
     unsigned char minLevel = 128;
     unsigned char maxLevel = 0;
 
-    for (auto box = line->firstRun(); box; box = box.traverseNextOnLine()) {
+    for (auto box = line->firstLeafBox(); box; box = box.traverseNextOnLine()) {
         minLevel = std::min(minLevel, box->bidiLevel());
         maxLevel = std::max(maxLevel, box->bidiLevel());
         boxes.append(box);

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (287519 => 287520)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-01-02 18:48:04 UTC (rev 287520)
@@ -3254,8 +3254,8 @@
 
 bool RenderBlockFlow::containsNonZeroBidiLevel() const
 {
-    for (auto* root = firstRootBox(); root; root = root->nextRootBox()) {
-        for (auto* box = root->firstLeafDescendant(); box; box = box->nextLeafOnLine()) {
+    for (auto line = InlineIterator::firstLineFor(*this); line; line.traverseNext()) {
+        for (auto box = line->firstLeafBox(); box; box = box.traverseNextOnLine()) {
             if (box->bidiLevel())
                 return true;
         }
@@ -3363,7 +3363,7 @@
         if (fragment && line->legacyRootInlineBox() && line->legacyRootInlineBox()->containingFragment() != fragment)
             continue;
 
-        if (!line->firstRun())
+        if (!line->firstLeafBox())
             continue;
         if (!firstLineWithChildren)
             firstLineWithChildren = line;
@@ -3378,7 +3378,7 @@
         if (pointInLogicalContents.y() < line->selectionBottom() || (blocksAreFlipped && pointInLogicalContents.y() == line->selectionBottom())) {
             if (linesAreFlipped) {
                 auto nextLineWithChildren = line->next();
-                while (nextLineWithChildren && !nextLineWithChildren->firstRun())
+                while (nextLineWithChildren && !nextLineWithChildren->firstLeafBox())
                     nextLineWithChildren.traverseNext();
 
                 if (nextLineWithChildren && nextLineWithChildren->legacyRootInlineBox() && nextLineWithChildren->legacyRootInlineBox()->isFirstAfterPageBreak()
@@ -3403,7 +3403,7 @@
             LayoutUnit firstLineWithChildrenTop = std::min(firstLineWithChildren->selectionTopForHitTesting(), LayoutUnit(firstLineWithChildren->top()));
             if (pointInLogicalContents.y() < firstLineWithChildrenTop
                 || (blocksAreFlipped && pointInLogicalContents.y() == firstLineWithChildrenTop)) {
-                auto run = firstLineWithChildren->firstRun();
+                auto run = firstLineWithChildren->firstLeafBox();
                 if (run->isLineBreak()) {
                     if (auto next = run->nextOnLineIgnoringLineBreak())
                         run = next;

Modified: trunk/Source/WebCore/style/InlineTextBoxStyle.cpp (287519 => 287520)


--- trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2022-01-02 18:30:52 UTC (rev 287519)
+++ trunk/Source/WebCore/style/InlineTextBoxStyle.cpp	2022-01-02 18:48:04 UTC (rev 287520)
@@ -51,7 +51,7 @@
 
 static void minLogicalTopForTextDecorationLine(const InlineIterator::LineIterator& line, float& minLogicalTop, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecoration)
 {
-    for (auto run = line->firstRun(); run; run.traverseNextOnLine()) {
+    for (auto run = line->firstLeafBox(); run; run.traverseNextOnLine()) {
         if (run->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
@@ -68,7 +68,7 @@
 
 static void maxLogicalBottomForTextDecorationLine(const InlineIterator::LineIterator& line, float& maxLogicalBottom, const RenderElement* decorationRenderer, OptionSet<TextDecorationLine> textDecoration)
 {
-    for (auto run = line->firstRun(); run; run.traverseNextOnLine()) {
+    for (auto run = line->firstLeafBox(); run; run.traverseNextOnLine()) {
         if (run->renderer().isOutOfFlowPositioned())
             continue; // Positioned placeholders don't affect calculations.
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to