Title: [282050] trunk
Revision
282050
Author
[email protected]
Date
2021-09-05 12:17:14 -0700 (Sun, 05 Sep 2021)

Log Message

[LFC][Integration] Skip inline boxes in iterator
https://bugs.webkit.org/show_bug.cgi?id=229922

Reviewed by Alan Bujtas.

Source/WebCore:

Start including root and non-root inline boxes to the run vector.
Change the iterator to skip over these boxes.

The new boxes are not used for anything yet.

* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::build):
(WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineSpanningInlineBoxes):
* layout/integration/LayoutIntegrationInlineContent.cpp:
(WebCore::LayoutIntegration::InlineContent::hasContent const):
* layout/integration/LayoutIntegrationInlineContent.h:
* layout/integration/LayoutIntegrationLineIteratorModernPath.h:
(WebCore::LayoutIntegration::LineIteratorModernPath::firstRun const):
(WebCore::LayoutIntegration::LineIteratorModernPath::lastRun const):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::lineCount const):
(WebCore::LayoutIntegration::LineLayout::enclosingBorderBoxRectFor const):
(WebCore::LayoutIntegration::LineLayout::paint):
(WebCore::LayoutIntegration::LineLayout::hitTest):
* layout/integration/LayoutIntegrationRunIteratorModernPath.h:
(WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextTextRun):
(WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextOnLine):
(WebCore::LayoutIntegration::RunIteratorModernPath::traversePreviousOnLine):
(WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextLeaf):
(WebCore::LayoutIntegration::RunIteratorModernPath::traversePreviousLeaf):

LayoutTests:

* fast/repaint/iframe-on-subpixel-position-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (282049 => 282050)


--- trunk/LayoutTests/ChangeLog	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/LayoutTests/ChangeLog	2021-09-05 19:17:14 UTC (rev 282050)
@@ -1,3 +1,12 @@
+2021-09-05  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Skip inline boxes in iterator
+        https://bugs.webkit.org/show_bug.cgi?id=229922
+
+        Reviewed by Alan Bujtas.
+
+        * fast/repaint/iframe-on-subpixel-position-expected.txt:
+
 2021-09-04  Antti Koivisto  <[email protected]>
 
         REGRESSION(r275515): pointer-events:none may get stuck in LFC runs

Modified: trunk/LayoutTests/fast/repaint/iframe-on-subpixel-position-expected.txt (282049 => 282050)


--- trunk/LayoutTests/fast/repaint/iframe-on-subpixel-position-expected.txt	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/LayoutTests/fast/repaint/iframe-on-subpixel-position-expected.txt	2021-09-05 19:17:14 UTC (rev 282050)
@@ -8,7 +8,7 @@
       (contentsOpaque 1)
       (children 1
         (GraphicsLayer
-          (bounds 301.00 151.00)
+          (bounds 301.00 155.00)
           (drawsContent 1)
           (repaint rects
             (rect 0.00 0.00 101.00 101.00)

Modified: trunk/Source/WebCore/ChangeLog (282049 => 282050)


--- trunk/Source/WebCore/ChangeLog	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/ChangeLog	2021-09-05 19:17:14 UTC (rev 282050)
@@ -1,3 +1,36 @@
+2021-09-05  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Skip inline boxes in iterator
+        https://bugs.webkit.org/show_bug.cgi?id=229922
+
+        Reviewed by Alan Bujtas.
+
+        Start including root and non-root inline boxes to the run vector.
+        Change the iterator to skip over these boxes.
+
+        The new boxes are not used for anything yet.
+
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::build):
+        (WebCore::Layout::InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineSpanningInlineBoxes):
+        * layout/integration/LayoutIntegrationInlineContent.cpp:
+        (WebCore::LayoutIntegration::InlineContent::hasContent const):
+        * layout/integration/LayoutIntegrationInlineContent.h:
+        * layout/integration/LayoutIntegrationLineIteratorModernPath.h:
+        (WebCore::LayoutIntegration::LineIteratorModernPath::firstRun const):
+        (WebCore::LayoutIntegration::LineIteratorModernPath::lastRun const):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::lineCount const):
+        (WebCore::LayoutIntegration::LineLayout::enclosingBorderBoxRectFor const):
+        (WebCore::LayoutIntegration::LineLayout::paint):
+        (WebCore::LayoutIntegration::LineLayout::hitTest):
+        * layout/integration/LayoutIntegrationRunIteratorModernPath.h:
+        (WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextTextRun):
+        (WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextOnLine):
+        (WebCore::LayoutIntegration::RunIteratorModernPath::traversePreviousOnLine):
+        (WebCore::LayoutIntegration::RunIteratorModernPath::traverseNextLeaf):
+        (WebCore::LayoutIntegration::RunIteratorModernPath::traversePreviousLeaf):
+
 2021-09-05  Myles C. Maxfield  <[email protected]>
 
         Remove unnecessary uses of Ref protect = m_backing from FontFaceSet

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (282049 => 282050)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-09-05 19:17:14 UTC (rev 282050)
@@ -36,8 +36,6 @@
 namespace WebCore {
 namespace Layout {
 
-#define ALLOW_ROOT_AND_LINE_SPANNING_INLINE_BOX 0
-
 InlineDisplayContentBuilder::InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState& formattingState)
     : m_formattingContextRoot(formattingContextRoot)
     , m_formattingState(formattingState)
@@ -48,12 +46,10 @@
 void InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, const size_t lineIndex)
 {
     auto& formattingState = this->formattingState();
-#if ALLOW_ROOT_AND_LINE_SPANNING_INLINE_BOX
     // Every line starts with a root run, even the empty ones.
     auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
     rootInlineBoxRect.moveBy(lineBoxLogicalTopLeft);
     formattingState.addRun({ lineIndex, Run::Type::RootInlineBox, root(), rootInlineBoxRect, rootInlineBoxRect, { }, { },  lineBox.rootInlineBox().hasContent()});
-#endif
     // Spanning inline boxes start at the very beginning of the line.
     auto lineSpanningInlineBoxIndex = formattingState.runs().size();
     createRunsAndUpdateGeometryForLineContent(lineContent, lineBox, lineBoxLogicalTopLeft, lineIndex);
@@ -183,7 +179,7 @@
     formattingState.lines().last().setNeedsIntegralPosition(lineNeedIntegralPosition);
 }
 
-void InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineSpanningInlineBoxes(const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, const size_t /*lineIndex*/, size_t /*lineSpanningInlineBoxIndex*/)
+void InlineDisplayContentBuilder::createRunsAndUpdateGeometryForLineSpanningInlineBoxes(const LineBox& lineBox, const InlineLayoutPoint& lineBoxLogicalTopLeft, const size_t lineIndex, size_t lineSpanningInlineBoxIndex)
 {
     if (!lineBox.hasContent()) {
         // When a spanning inline box (e.g. <div>text<span><br></span></div>) lands on an empty line
@@ -204,9 +200,8 @@
         auto inlineBoxBorderBox = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
         inlineBoxBorderBox.moveBy(lineBoxLogicalTopLeft);
 
-#if ALLOW_ROOT_AND_LINE_SPANNING_INLINE_BOX
         formattingState.runs().insert(lineSpanningInlineBoxIndex++, { lineIndex, Run::Type::NonRootInlineBox, layoutBox, inlineBoxBorderBox, inlineBoxBorderBox, { }, { }, inlineLevelBox.hasContent(), true });
-#endif
+
         auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
         auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };
         // Middle or end of the inline box. Let's stretch the box as needed.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp (282049 => 282050)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.cpp	2021-09-05 19:17:14 UTC (rev 282050)
@@ -41,6 +41,12 @@
 {
 }
 
+bool InlineContent::hasContent() const
+{
+    ASSERT(runs.isEmpty() || runs[0].isRootInlineBox());
+    return runs.size() > 1;
+};
+
 WTF::IteratorRange<const Run*> InlineContent::runsForRect(const LayoutRect&) const
 {
     // FIXME: Do something efficient e.g. using line boxes.

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h (282049 => 282050)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContent.h	2021-09-05 19:17:14 UTC (rev 282050)
@@ -63,6 +63,8 @@
 
     float clearGapAfterLastLine { 0 };
 
+    bool hasContent() const;
+    
     const Line& lineForRun(const Run& run) const { return lines[run.lineIndex()]; }
     WTF::IteratorRange<const Run*> runsForRect(const LayoutRect&) const;
     void shrinkToFit();

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h (282049 => 282050)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineIteratorModernPath.h	2021-09-05 19:17:14 UTC (rev 282050)
@@ -99,7 +99,10 @@
     {
         if (!line().runCount())
             return { *m_inlineContent };
-        return { *m_inlineContent, line().firstRunIndex() };
+        auto runIterator = RunIteratorModernPath { *m_inlineContent, line().firstRunIndex() };
+        if (runIterator.run().isInlineBox())
+            runIterator.traverseNextLeaf();
+        return runIterator;
     }
 
     RunIteratorModernPath lastRun() const
@@ -107,7 +110,10 @@
         auto runCount = line().runCount();
         if (!runCount)
             return { *m_inlineContent };
-        return { *m_inlineContent, line().firstRunIndex() + runCount - 1 };
+        auto runIterator = RunIteratorModernPath { *m_inlineContent, line().firstRunIndex() + runCount - 1 };
+        if (runIterator.run().isInlineBox())
+            runIterator.traversePreviousLeaf();
+        return runIterator;
     }
 
     RunIteratorModernPath logicalStartRun() const

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (282049 => 282050)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2021-09-05 19:17:14 UTC (rev 282050)
@@ -302,7 +302,7 @@
 {
     if (!m_inlineContent)
         return 0;
-    if (m_inlineContent->runs.isEmpty())
+    if (!m_inlineContent->hasContent())
         return 0;
 
     return m_inlineContent->lines.size();
@@ -416,7 +416,8 @@
     if (!m_inlineContent)
         return { };
 
-    if (m_inlineContent->runs.isEmpty())
+    // FIXME: This keeps the existing output.
+    if (!m_inlineContent->hasContent())
         return { };
 
     return Layout::BoxGeometry::borderBoxRect(m_inlineFormattingState.boxGeometry(m_boxTree.layoutBoxForRenderer(renderInline)));
@@ -455,6 +456,8 @@
     paintRect.moveBy(-paintOffset);
 
     for (auto& run : m_inlineContent->runsForRect(paintRect)) {
+        if (run.isInlineBox())
+            continue;
         if (run.text())
             paintTextRunUsingPhysicalCoordinates(paintInfo, paintOffset, m_inlineContent->lineForRun(run), run);
         else if (auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox()); is<RenderBox>(renderer) && renderer.isReplaced()) {
@@ -477,6 +480,10 @@
 
     // FIXME: This should do something efficient to find the run range.
     for (auto& run : WTF::makeReversedRange(inlineContent.runs)) {
+        // FIXME: Use for hit testing instead of nonRootInlineBoxes.
+        if (run.isInlineBox())
+            continue;
+
         auto& renderer = m_boxTree.rendererForLayoutBox(run.layoutBox());
 
         if (is<RenderText>(renderer)) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h (282049 => 282050)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h	2021-09-05 17:47:33 UTC (rev 282049)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationRunIteratorModernPath.h	2021-09-05 19:17:14 UTC (rev 282050)
@@ -141,10 +141,12 @@
 
         auto& layoutBox = run().layoutBox();
 
-        ++m_runIndex;
+        traverseNextLeaf();
 
         if (!atEnd() && &layoutBox != &run().layoutBox())
             setAtEnd();
+
+        ASSERT(atEnd() || run().text());
     }
 
     void traverseNextTextRunInTextOrder()
@@ -159,7 +161,7 @@
 
         auto oldLineIndex = run().lineIndex();
 
-        ++m_runIndex;
+        traverseNextLeaf();
 
         if (!atEnd() && oldLineIndex != run().lineIndex())
             setAtEnd();
@@ -169,16 +171,11 @@
     {
         ASSERT(!atEnd());
 
-        if (!m_runIndex) {
-            setAtEnd();
-            return;
-        }
-
         auto oldLineIndex = run().lineIndex();
 
-        --m_runIndex;
+        traversePreviousLeaf();
 
-        if (oldLineIndex != run().lineIndex())
+        if (!atEnd() && oldLineIndex != run().lineIndex())
             setAtEnd();
     }
 
@@ -202,9 +199,26 @@
     }
 
 private:
+    friend class LineIteratorModernPath;
     friend class PathRun;
     friend class RunIterator;
 
+    void traverseNextLeaf()
+    {
+        ASSERT(!atEnd());
+        do {
+            ++m_runIndex;
+        } while (!atEnd() && run().isInlineBox());
+    }
+
+    void traversePreviousLeaf()
+    {
+        ASSERT(!atEnd());
+        do {
+            m_runIndex = m_runIndex ? m_runIndex - 1 : runs().size();
+        } while (!atEnd() && run().isInlineBox());
+    }
+
     TextBoxSelectableRange selectableRange() const
     {
         return {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to