Title: [287519] trunk
Revision
287519
Author
[email protected]
Date
2022-01-02 10:30:52 -0800 (Sun, 02 Jan 2022)

Log Message

[LFC][Integration] Support outlines
https://bugs.webkit.org/show_bug.cgi?id=234766

Reviewed by Alan Bujtas.

Source/WebCore:

Outlines should not require legacy line layout.

* layout/integration/InlineIteratorInlineBox.cpp:
(WebCore::InlineIterator::firstInlineBoxFor):
(WebCore::InlineIterator::firstRootInlineBoxFor):

Add iterator support for getting inline boxes from renderer.

* layout/integration/InlineIteratorInlineBox.h:
* layout/integration/LayoutIntegrationCoverage.cpp:
(WebCore::LayoutIntegration::printReason):
(WebCore::LayoutIntegration::canUseForRenderInlineChild):
(WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
* layout/integration/LayoutIntegrationCoverage.h:
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::firstInlineBoxFor const):
(WebCore::LayoutIntegration::LineLayout::firstRootInlineBox const):
(WebCore::LayoutIntegration::LineLayout::paint):

Support outline painting.

* layout/integration/LayoutIntegrationLineLayout.h:
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::paintObject):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::addFocusRingRectsForInlineChildren):

Port to use iterator.

* rendering/RenderInline.cpp:
(WebCore::RenderInline::paintOutline):

Port to use iterator.

LayoutTests:

* fast/repaint/focus-ring-repaint-expected.txt:
* platform/ios/fast/table/table-continuation-outline-paint-crash-expected.txt:
* platform/mac/fast/table/table-continuation-outline-paint-crash-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (287518 => 287519)


--- trunk/LayoutTests/ChangeLog	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/LayoutTests/ChangeLog	2022-01-02 18:30:52 UTC (rev 287519)
@@ -1,3 +1,14 @@
+2022-01-02  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Support outlines
+        https://bugs.webkit.org/show_bug.cgi?id=234766
+
+        Reviewed by Alan Bujtas.
+
+        * fast/repaint/focus-ring-repaint-expected.txt:
+        * platform/ios/fast/table/table-continuation-outline-paint-crash-expected.txt:
+        * platform/mac/fast/table/table-continuation-outline-paint-crash-expected.txt:
+
 2022-01-02  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Nested inline box continuation fails to omit margin/border/padding start/end values

Modified: trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt (287518 => 287519)


--- trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/LayoutTests/fast/repaint/focus-ring-repaint-expected.txt	2022-01-02 18:30:52 UTC (rev 287519)
@@ -6,27 +6,27 @@
 
 
 (repaint rects
+  (rect 5 457 103 67)
   (rect 5 457 106 70)
-  (rect 5 457 106 70)
-  (rect 5 542 106 66)
-  (rect 15 62 36 40)
-  (rect 18 65 30 34)
-  (rect 5 92 56 10)
-  (rect 5 35 56 67)
-  (rect 5 117 36 60)
-  (rect 8 120 30 54)
+  (rect 5 542 106 70)
+  (rect 15 62 36 36)
+  (rect 18 65 30 30)
+  (rect 15 62 36 26)
+  (rect 18 65 30 20)
+  (rect 5 89 56 10)
+  (rect 5 35 56 64)
+  (rect 5 117 36 56)
+  (rect 8 120 30 50)
   (rect 5 117 36 86)
   (rect 8 120 30 80)
-  (rect 5 177 56 30)
-  (rect 5 120 56 87)
+  (rect 5 174 56 30)
+  (rect 5 120 56 84)
   (rect 5 205 56 37)
   (rect 5 375 56 37)
-  (rect 5 457 106 70)
+  (rect 5 457 103 67)
   (rect 8 460 100 64)
   (rect 8 545 100 64)
-  (rect 5 542 106 70)
-  (rect 5 609 772 3)
-  (rect 0 609 785 3)
+  (rect 5 542 103 67)
   (rect 45 212 36 40)
   (rect 48 215 30 34)
   (rect 155 212 36 40)

Modified: trunk/LayoutTests/platform/ios/fast/table/table-continuation-outline-paint-crash-expected.txt (287518 => 287519)


--- trunk/LayoutTests/platform/ios/fast/table/table-continuation-outline-paint-crash-expected.txt	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/LayoutTests/platform/ios/fast/table/table-continuation-outline-paint-crash-expected.txt	2022-01-02 18:30:52 UTC (rev 287519)
@@ -14,4 +14,4 @@
               RenderInline {SPAN} at (0,0) size 37x19
                 RenderText {#text} at (0,0) size 37x19
                   text run at (0,0) width 37: "PASS"
-              RenderInline {SPAN} at (0,0) size 1x19
+              RenderInline {SPAN} at (0,0) size 0x18

Modified: trunk/LayoutTests/platform/mac/fast/table/table-continuation-outline-paint-crash-expected.txt (287518 => 287519)


--- trunk/LayoutTests/platform/mac/fast/table/table-continuation-outline-paint-crash-expected.txt	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/LayoutTests/platform/mac/fast/table/table-continuation-outline-paint-crash-expected.txt	2022-01-02 18:30:52 UTC (rev 287519)
@@ -14,4 +14,4 @@
               RenderInline {SPAN} at (0,0) size 37x18
                 RenderText {#text} at (0,0) size 37x18
                   text run at (0,0) width 37: "PASS"
-              RenderInline {SPAN} at (0,0) size 1x18
+              RenderInline {SPAN} at (0,0) size 0x18

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


--- trunk/Source/WebCore/ChangeLog	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/ChangeLog	2022-01-02 18:30:52 UTC (rev 287519)
@@ -1,3 +1,44 @@
+2022-01-02  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] Support outlines
+        https://bugs.webkit.org/show_bug.cgi?id=234766
+
+        Reviewed by Alan Bujtas.
+
+        Outlines should not require legacy line layout.
+
+        * layout/integration/InlineIteratorInlineBox.cpp:
+        (WebCore::InlineIterator::firstInlineBoxFor):
+        (WebCore::InlineIterator::firstRootInlineBoxFor):
+
+        Add iterator support for getting inline boxes from renderer.
+
+        * layout/integration/InlineIteratorInlineBox.h:
+        * layout/integration/LayoutIntegrationCoverage.cpp:
+        (WebCore::LayoutIntegration::printReason):
+        (WebCore::LayoutIntegration::canUseForRenderInlineChild):
+        (WebCore::LayoutIntegration::canUseForLineLayoutWithReason):
+        * layout/integration/LayoutIntegrationCoverage.h:
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::firstInlineBoxFor const):
+        (WebCore::LayoutIntegration::LineLayout::firstRootInlineBox const):
+        (WebCore::LayoutIntegration::LineLayout::paint):
+
+        Support outline painting.
+
+        * layout/integration/LayoutIntegrationLineLayout.h:
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::paintObject):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::addFocusRingRectsForInlineChildren):
+
+        Port to use iterator.
+
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::paintOutline):
+
+        Port to use iterator.
+
 2022-01-02  Antoine Quint  <[email protected]>
 
         [Web Animations] getKeyframes() should ensure that all properties are present on 0% and 100% keyframes

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -27,6 +27,7 @@
 #include "InlineIteratorInlineBox.h"
 
 #include "LayoutIntegrationLineLayout.h"
+#include "RenderInline.h"
 
 namespace WebCore {
 namespace InlineIterator {
@@ -106,6 +107,22 @@
     return *this;
 }
 
+InlineBoxIterator firstInlineBoxFor(const RenderInline& renderInline)
+{
+    if (auto* lineLayout = LayoutIntegration::LineLayout::containing(renderInline))
+        return lineLayout->firstInlineBoxFor(renderInline);
+
+    return { BoxLegacyPath { renderInline.firstLineBox() } };
+}
+
+InlineBoxIterator firstRootInlineBoxFor(const RenderBlockFlow& block)
+{
+    if (auto* lineLayout = block.modernLineLayout())
+        return lineLayout->firstRootInlineBox();
+
+    return { BoxLegacyPath { block.firstRootBox() } };
+}
+
 InlineBoxIterator inlineBoxFor(const LegacyInlineFlowBox& legacyInlineFlowBox)
 {
     return { BoxLegacyPath { &legacyInlineFlowBox } };

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h	2022-01-02 18:30:52 UTC (rev 287519)
@@ -69,6 +69,9 @@
     const InlineBox& get() const { return downcast<InlineBox>(m_box); }
 };
 
+InlineBoxIterator firstInlineBoxFor(const RenderInline&);
+InlineBoxIterator firstRootInlineBoxFor(const RenderBlockFlow&);
+
 InlineBoxIterator inlineBoxFor(const LegacyInlineFlowBox&);
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 InlineBoxIterator inlineBoxFor(const LayoutIntegration::InlineContent&, const InlineDisplay::Box&);

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -89,9 +89,6 @@
     case AvoidanceReason::FlowHasHorizonalWritingMode:
         stream << "horizontal writing mode";
         break;
-    case AvoidanceReason::ContentHasOutline:
-        stream << "outline";
-        break;
     case AvoidanceReason::ContentIsRuby:
         stream << "ruby";
         break;
@@ -474,8 +471,6 @@
     if (style.boxDecorationBreak() == BoxDecorationBreak::Clone)
         SET_REASON_AND_RETURN_IF_NEEDED(BoxDecorationBreakClone, reasons, includeReasons);
 #endif
-    if (style.hasOutline())
-        SET_REASON_AND_RETURN_IF_NEEDED(ContentHasOutline, reasons, includeReasons);
     if (renderInline.isInFlowPositioned())
         SET_REASON_AND_RETURN_IF_NEEDED(ChildBoxIsFloatingOrPositioned, reasons, includeReasons);
     if (renderInline.containingBlock()->style().lineBoxContain() != RenderStyle::initialLineBoxContain())
@@ -606,8 +601,6 @@
     }
     if (!flow.isHorizontalWritingMode())
         SET_REASON_AND_RETURN_IF_NEEDED(FlowHasHorizonalWritingMode, reasons, includeReasons);
-    if (flow.hasOutline())
-        SET_REASON_AND_RETURN_IF_NEEDED(ContentHasOutline, reasons, includeReasons);
     if (flow.isRubyText() || flow.isRubyBase())
         SET_REASON_AND_RETURN_IF_NEEDED(ContentIsRuby, reasons, includeReasons);
     if (!flow.style().hangingPunctuation().isEmpty())

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationCoverage.h	2022-01-02 18:30:52 UTC (rev 287519)
@@ -40,7 +40,7 @@
 enum class AvoidanceReason : uint64_t {
     FlowIsInsideANonMultiColumnThread            = 1LLU  << 0,
     FlowHasHorizonalWritingMode                  = 1LLU  << 1,
-    ContentHasOutline                            = 1LLU  << 2,
+    // Unused                                    = 1LLU  << 2,
     ContentIsRuby                                = 1LLU  << 3,
     FlowIsPaginated                              = 1LLU  << 4,
     FlowHasTextOverflow                          = 1LLU  << 5,

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -456,6 +456,27 @@
     return InlineIterator::boxFor(*m_inlineContent, *firstIndex);
 }
 
+InlineIterator::InlineBoxIterator LineLayout::firstInlineBoxFor(const RenderInline& renderInline) const
+{
+    if (!m_inlineContent)
+        return { };
+
+    auto& layoutBox = m_boxTree.layoutBoxForRenderer(renderInline);
+    auto* box = m_inlineContent->firstBoxForLayoutBox(layoutBox);
+    if (!box)
+        return { };
+
+    return InlineIterator::inlineBoxFor(*m_inlineContent, *box);
+}
+
+InlineIterator::InlineBoxIterator LineLayout::firstRootInlineBox() const
+{
+    if (!m_inlineContent || !m_inlineContent->hasContent())
+        return { };
+
+    return InlineIterator::inlineBoxFor(*m_inlineContent, m_inlineContent->boxes[0]);
+}
+
 InlineIterator::LineIterator LineLayout::firstLine() const
 {
     if (!m_inlineContent)
@@ -541,7 +562,24 @@
     if (!m_inlineContent)
         return;
 
-    if (paintInfo.phase != PaintPhase::Foreground && paintInfo.phase != PaintPhase::EventRegion && paintInfo.phase != PaintPhase::TextClip && paintInfo.phase != PaintPhase::Selection)
+    auto paintPhase = paintInfo.phase;
+
+    auto shouldPaintForPhase = [&] {
+        switch (paintPhase) {
+        case PaintPhase::Foreground:
+        case PaintPhase::EventRegion:
+        case PaintPhase::TextClip:
+        case PaintPhase::Selection:
+        case PaintPhase::Outline:
+        case PaintPhase::ChildOutlines:
+        case PaintPhase::SelfOutline:
+            return true;
+        default:
+            return false;
+        }
+    };
+
+    if (!shouldPaintForPhase())
         return;
 
     auto damageRect = paintInfo.rect;
@@ -556,7 +594,21 @@
         return damageRect.maxY() > rect.y() && damageRect.y() < rect.maxY();
     };
 
+    auto shouldPaintBoxForPhase = [&](auto& box) {
+        switch (paintPhase) {
+        case PaintPhase::ChildOutlines: return box.isNonRootInlineBox();
+        case PaintPhase::SelfOutline: return box.isRootInlineBox();
+        case PaintPhase::Outline: return box.isInlineBox();
+        default: return true;
+        }
+    };
+
+    ListHashSet<RenderInline*> outlineObjects;
+
     for (auto& box : m_inlineContent->boxesForRect(damageRect)) {
+        if (!shouldPaintBoxForPhase(box))
+            continue;
+
         if (box.isLineBreak())
             continue;
 
@@ -564,7 +616,11 @@
             if (!hasDamage(box))
                 continue;
 
-            InlineBoxPainter painter(*m_inlineContent, box, paintInfo, paintOffset);
+            PaintInfo inlineBoxPaintInfo(paintInfo);
+            inlineBoxPaintInfo.phase = paintPhase == PaintPhase::ChildOutlines ? PaintPhase::Outline : paintPhase;
+            inlineBoxPaintInfo.outlineObjects = &outlineObjects;
+
+            InlineBoxPainter painter(*m_inlineContent, box, inlineBoxPaintInfo, paintOffset);
             painter.paint();
             continue;
         }
@@ -584,6 +640,9 @@
                 renderBox.paintAsInlineBlock(paintInfo, paintOffset);
         }
     }
+
+    for (auto* renderInline : outlineObjects)
+        renderInline->paintOutline(paintInfo, paintOffset);
 }
 
 bool LineLayout::hitTest(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (287518 => 287519)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h	2022-01-02 18:30:52 UTC (rev 287519)
@@ -28,6 +28,7 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "FloatRect.h"
+#include "InlineIteratorInlineBox.h"
 #include "InlineIteratorLine.h"
 #include "InlineIteratorTextBox.h"
 #include "LayoutIntegrationBoxTree.h"
@@ -101,6 +102,8 @@
 
     InlineIterator::TextBoxIterator textBoxesFor(const RenderText&) const;
     InlineIterator::LeafBoxIterator boxFor(const RenderElement&) const;
+    InlineIterator::InlineBoxIterator firstInlineBoxFor(const RenderInline&) const;
+    InlineIterator::InlineBoxIterator firstRootInlineBox() const;
     InlineIterator::LineIterator firstLine() const;
     InlineIterator::LineIterator lastLine() const;
 

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (287518 => 287519)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -39,6 +39,7 @@
 #include "HitTestLocation.h"
 #include "HitTestResult.h"
 #include "ImageBuffer.h"
+#include "InlineIteratorInlineBox.h"
 #include "InlineWalker.h"
 #include "LayoutRepainter.h"
 #include "LegacyInlineElementBox.h"
@@ -1347,7 +1348,7 @@
             // in the same layer. 
             if (!inlineEnclosedInSelfPaintingLayer && !hasLayer())
                 containingBlock->addContinuationWithOutline(inlineRenderer);
-            else if (!inlineRenderer->firstLineBox() || (!inlineEnclosedInSelfPaintingLayer && hasLayer()))
+            else if (!InlineIterator::firstInlineBoxFor(*inlineRenderer) || (!inlineEnclosedInSelfPaintingLayer && hasLayer()))
                 inlineRenderer->paintOutline(paintInfo, paintOffset - locationOffset() + inlineRenderer->containingBlock()->location());
         }
         paintContinuationOutlines(paintInfo, paintOffset);

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


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -3449,10 +3449,12 @@
 void RenderBlockFlow::addFocusRingRectsForInlineChildren(Vector<LayoutRect>& rects, const LayoutPoint& additionalOffset, const RenderLayerModelObject*)
 {
     ASSERT(childrenInline());
-    for (auto* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
-        LayoutUnit top = std::max(curr->lineTop(), LayoutUnit(curr->top()));
-        LayoutUnit bottom = std::min(curr->lineBottom(), LayoutUnit(curr->top() + curr->height()));
-        LayoutRect rect { LayoutUnit(additionalOffset.x() + curr->x()), additionalOffset.y() + top, LayoutUnit(curr->width()), bottom - top };
+    for (auto box = InlineIterator::firstRootInlineBoxFor(*this); box; box.traverseNextInlineBox()) {
+        auto line = box->line();
+        // FIXME: This is mixing physical and logical coordinates.
+        LayoutUnit top = std::max(line->top(), LayoutUnit(box->rect().y()));
+        LayoutUnit bottom = std::min(line->bottom(), LayoutUnit(box->rect().maxY()));
+        LayoutRect rect { LayoutUnit(additionalOffset.x() + box->rect().x()), additionalOffset.y() + top, LayoutUnit(box->rect().width()), bottom - top };
         if (!rect.isEmpty())
             rects.append(rect);
     }

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (287518 => 287519)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2022-01-02 17:59:08 UTC (rev 287518)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2022-01-02 18:30:52 UTC (rev 287519)
@@ -28,6 +28,7 @@
 #include "FrameSelection.h"
 #include "GraphicsContext.h"
 #include "HitTestResult.h"
+#include "InlineIteratorInlineBox.h"
 #include "LayoutIntegrationLineLayout.h"
 #include "LegacyInlineElementBox.h"
 #include "LegacyInlineTextBox.h"
@@ -957,11 +958,13 @@
 
     Vector<LayoutRect> rects;
     rects.append(LayoutRect());
-    for (auto* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
-        const LegacyRootInlineBox& rootBox = curr->root();
-        LayoutUnit top = std::max(rootBox.lineTop(), LayoutUnit(curr->logicalTop()));
-        LayoutUnit bottom = std::min(rootBox.lineBottom(), LayoutUnit(curr->logicalBottom()));
-        rects.append({ LayoutUnit(curr->x()), top, LayoutUnit(curr->logicalWidth()), bottom - top });
+
+    for (auto box = InlineIterator::firstInlineBoxFor(*this); box; box.traverseNextInlineBox()) {
+        auto line = box->line();
+        LayoutUnit top = std::max(line->top(), LayoutUnit(box->logicalTop()));
+        LayoutUnit bottom = std::min(line->bottom(), LayoutUnit(box->logicalBottom()));
+        // FIXME: This is mixing physical and logical coordinates.
+        rects.append({ LayoutUnit(box->rect().x()), top, LayoutUnit(box->logicalWidth()), bottom - top });
     }
     rects.append(LayoutRect());
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to