Title: [282223] trunk/Source/WebCore
Revision
282223
Author
[email protected]
Date
2021-09-09 10:06:51 -0700 (Thu, 09 Sep 2021)

Log Message

Cull inline culling
https://bugs.webkit.org/show_bug.cgi?id=202920

Reviewed by Alan Bujtas.

The optimization was already disabled in r282129.
This patch removes all the associated code.

* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):
* page/FrameView.cpp:
(WebCore::FrameView::paintContents):
* rendering/LegacyInlineFlowBox.cpp:
(WebCore::LegacyInlineFlowBox::nodeAtPoint):
* rendering/LegacyLineLayout.cpp:
(WebCore::LegacyLineLayout::createLineBoxes):
(WebCore::LegacyLineLayout::layoutLineBoxes):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::RenderElement):
* rendering/RenderElement.h:
(WebCore::RenderElement::setRenderInlineAlwaysCreatesLineBoxes): Deleted.
(WebCore::RenderElement::renderInlineAlwaysCreatesLineBoxes const): Deleted.
* rendering/RenderInline.cpp:
(WebCore::RenderInline::styleDidChange):
(WebCore::RenderInline::mayAffectLayout const):

Rename mayAffectRendering -> mayAffectLayout for specificity.

(WebCore::RenderInline::generateLineBoxRects const):
(WebCore::RenderInline::firstInlineBoxTopLeft const):
(WebCore::RenderInline::linesBoundingBox const):
(WebCore::RenderInline::linesVisualOverflowBoundingBox const):
(WebCore::RenderInline::linesVisualOverflowBoundingBoxInFragment const):
(WebCore::RenderInline::clippedOverflowRect const):
(WebCore::RenderInline::dirtyLineBoxes):
(WebCore::RenderInline::createAndAppendInlineFlowBox):
(WebCore::RenderInline::mayAffectRendering const): Deleted.
(WebCore::RenderInline::updateAlwaysCreateLineBoxes): Deleted.
(WebCore::RenderInline::generateCulledLineBoxRects const): Deleted.
(WebCore::RenderInline::hitTestCulledInline): Deleted.
(WebCore::RenderInline::culledInlineFirstLineBox const): Deleted.
(WebCore::RenderInline::culledInlineLastLineBox const): Deleted.
(WebCore::RenderInline::culledInlineVisualOverflowBoundingBox const): Deleted.
* rendering/RenderInline.h:
(WebCore::RenderInline::lastLineBox const):
(WebCore::RenderInline::firstLineBoxIncludingCulling const): Deleted.
(WebCore::RenderInline::lastLineBoxIncludingCulling const): Deleted.
(WebCore::RenderInline::alwaysCreateLineBoxes const): Deleted.
(WebCore::RenderInline::setAlwaysCreateLineBoxes): Deleted.
* rendering/RenderLineBoxList.cpp:
(WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
* rendering/RenderText.cpp:
(WebCore::RenderText::linesVisualOverflowBoundingBox const): Deleted.
* rendering/RenderText.h:
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::visualOverflowBoundingBox const): Deleted.
* rendering/RenderTextLineBoxes.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::hasNonEmptySibling):
* rendering/svg/RenderSVGInline.cpp:
(WebCore::RenderSVGInline::RenderSVGInline):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282222 => 282223)


--- trunk/Source/WebCore/ChangeLog	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/ChangeLog	2021-09-09 17:06:51 UTC (rev 282223)
@@ -1,3 +1,67 @@
+2021-09-09  Antti Koivisto  <[email protected]>
+
+        Cull inline culling
+        https://bugs.webkit.org/show_bug.cgi?id=202920
+
+        Reviewed by Alan Bujtas.
+
+        The optimization was already disabled in r282129.
+        This patch removes all the associated code.
+
+        * editing/SimplifyMarkupCommand.cpp:
+        (WebCore::SimplifyMarkupCommand::doApply):
+        * page/FrameView.cpp:
+        (WebCore::FrameView::paintContents):
+        * rendering/LegacyInlineFlowBox.cpp:
+        (WebCore::LegacyInlineFlowBox::nodeAtPoint):
+        * rendering/LegacyLineLayout.cpp:
+        (WebCore::LegacyLineLayout::createLineBoxes):
+        (WebCore::LegacyLineLayout::layoutLineBoxes):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::RenderElement):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::setRenderInlineAlwaysCreatesLineBoxes): Deleted.
+        (WebCore::RenderElement::renderInlineAlwaysCreatesLineBoxes const): Deleted.
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::styleDidChange):
+        (WebCore::RenderInline::mayAffectLayout const):
+
+        Rename mayAffectRendering -> mayAffectLayout for specificity.
+
+        (WebCore::RenderInline::generateLineBoxRects const):
+        (WebCore::RenderInline::firstInlineBoxTopLeft const):
+        (WebCore::RenderInline::linesBoundingBox const):
+        (WebCore::RenderInline::linesVisualOverflowBoundingBox const):
+        (WebCore::RenderInline::linesVisualOverflowBoundingBoxInFragment const):
+        (WebCore::RenderInline::clippedOverflowRect const):
+        (WebCore::RenderInline::dirtyLineBoxes):
+        (WebCore::RenderInline::createAndAppendInlineFlowBox):
+        (WebCore::RenderInline::mayAffectRendering const): Deleted.
+        (WebCore::RenderInline::updateAlwaysCreateLineBoxes): Deleted.
+        (WebCore::RenderInline::generateCulledLineBoxRects const): Deleted.
+        (WebCore::RenderInline::hitTestCulledInline): Deleted.
+        (WebCore::RenderInline::culledInlineFirstLineBox const): Deleted.
+        (WebCore::RenderInline::culledInlineLastLineBox const): Deleted.
+        (WebCore::RenderInline::culledInlineVisualOverflowBoundingBox const): Deleted.
+        * rendering/RenderInline.h:
+        (WebCore::RenderInline::lastLineBox const):
+        (WebCore::RenderInline::firstLineBoxIncludingCulling const): Deleted.
+        (WebCore::RenderInline::lastLineBoxIncludingCulling const): Deleted.
+        (WebCore::RenderInline::alwaysCreateLineBoxes const): Deleted.
+        (WebCore::RenderInline::setAlwaysCreateLineBoxes): Deleted.
+        * rendering/RenderLineBoxList.cpp:
+        (WebCore::RenderLineBoxList::dirtyLinesFromChangedChild):
+        * rendering/RenderText.cpp:
+        (WebCore::RenderText::linesVisualOverflowBoundingBox const): Deleted.
+        * rendering/RenderText.h:
+        * rendering/RenderTextLineBoxes.cpp:
+        (WebCore::RenderTextLineBoxes::visualOverflowBoundingBox const): Deleted.
+        * rendering/RenderTextLineBoxes.h:
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::hasNonEmptySibling):
+        * rendering/svg/RenderSVGInline.cpp:
+        (WebCore::RenderSVGInline::RenderSVGInline):
+
 2021-09-09  Sihui Liu  <[email protected]>
 
         Address post-commit comments on r282130 (Add basic support for Storage API)

Modified: trunk/Source/WebCore/editing/SimplifyMarkupCommand.cpp (282222 => 282223)


--- trunk/Source/WebCore/editing/SimplifyMarkupCommand.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/editing/SimplifyMarkupCommand.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -71,7 +71,7 @@
                 break;
 
             auto* renderer = currentNode->renderer();
-            if (!is<RenderInline>(renderer) || downcast<RenderInline>(*renderer).mayAffectRendering())
+            if (!is<RenderInline>(renderer) || downcast<RenderInline>(*renderer).mayAffectLayout())
                 continue;
             
             if (currentNode->firstChild() != currentNode->lastChild()) {

Modified: trunk/Source/WebCore/page/FrameView.cpp (282222 => 282223)


--- trunk/Source/WebCore/page/FrameView.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/page/FrameView.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -4324,11 +4324,6 @@
 
     RenderObject::SetLayoutNeededForbiddenScope forbidSetNeedsLayout(rootLayer->renderer());
 
-    // To work around http://webkit.org/b/135106, ensure that the paint root isn't an inline with culled line boxes.
-    // FIXME: This can cause additional content to be included in the snapshot, so remove this once that bug is fixed.
-    while (is<RenderInline>(renderer) && !downcast<RenderInline>(*renderer).firstLineBox())
-        renderer = renderer->parent();
-
     rootLayer->paint(context, dirtyRect, LayoutSize(), m_paintBehavior, renderer, { }, securityOriginPaintPolicy == SecurityOriginPaintPolicy::AnyOrigin ? RenderLayer::SecurityOriginPaintPolicy::AnyOrigin : RenderLayer::SecurityOriginPaintPolicy::AccessibleOriginOnly, eventRegionContext);
     if (auto* scrollableRootLayer = rootLayer->scrollableArea()) {
         if (scrollableRootLayer->containsDirtyOverlayScrollbars() && !eventRegionContext)

Modified: trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -1068,29 +1068,8 @@
         return false;
 
     // Check children first.
-    // We need to account for culled inline parents of the hit-tested nodes, so that they may also get included in area-based hit-tests.
-    RenderElement* culledParent = nullptr;
     for (auto* child = lastChild(); child; child = child->previousOnLine()) {
         if (is<RenderText>(child->renderer()) || !child->boxModelObject()->hasSelfPaintingLayer()) {
-            RenderElement* newParent = nullptr;
-            // Culled parents are only relevant for area-based hit-tests, so ignore it in point-based ones.
-            if (locationInContainer.isRectBasedTest()) {
-                newParent = child->renderer().parent();
-                if (newParent == &renderer())
-                    newParent = nullptr;
-            }
-            // Check the culled parent after all its children have been checked, to do this we wait until
-            // we are about to test an element with a different parent.
-            if (newParent != culledParent) {
-                if (!newParent || !newParent->isDescendantOf(culledParent)) {
-                    while (culledParent && culledParent != &renderer() && culledParent != newParent) {
-                        if (is<RenderInline>(*culledParent) && downcast<RenderInline>(*culledParent).hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
-                            return true;
-                        culledParent = culledParent->parent();
-                    }
-                }
-                culledParent = newParent;
-            }
             if (child->nodeAtPoint(request, result, locationInContainer, accumulatedOffset, lineTop, lineBottom, hitTestAction)) {
                 renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
                 return true;
@@ -1097,12 +1076,6 @@
             }
         }
     }
-    // Check any culled ancestor of the final children tested.
-    while (culledParent && culledParent != &renderer()) {
-        if (is<RenderInline>(*culledParent) && downcast<RenderInline>(*culledParent).hitTestCulledInline(request, result, locationInContainer, accumulatedOffset))
-            return true;
-        culledParent = culledParent->parent();
-    }
 
     // Now check ourselves. Pixel snap hit testing.
     if (!visibleToHitTesting(request))

Modified: trunk/Source/WebCore/rendering/LegacyLineLayout.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/LegacyLineLayout.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/LegacyLineLayout.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -227,9 +227,8 @@
         // as well. In this situation our inline has actually been split in two on
         // the same line (this can happen with very fancy language mixtures).
         bool constructedNewBox = false;
-        bool allowedToConstructNewBox = !hasDefaultLineBoxContain || !inlineFlow || inlineFlow->alwaysCreateLineBoxes();
         bool canUseExistingParentBox = parentBox && !parentIsConstructedOrHaveNext(parentBox);
-        if (allowedToConstructNewBox && !canUseExistingParentBox) {
+        if (!canUseExistingParentBox) {
             // We need to make a new box for this render object. Once
             // made, we need to place it at the end of the current line.
             LegacyInlineBox* newBox = createInlineBoxForRenderer(obj);
@@ -1769,8 +1768,6 @@
                         box.layoutIfNeeded();
                 }
             } else if (o.isTextOrLineBreak() || (is<RenderInline>(o) && !walker.atEndOfInline())) {
-                if (is<RenderInline>(o))
-                    downcast<RenderInline>(o).updateAlwaysCreateLineBoxes(layoutState.isFullLayout());
                 if (layoutState.isFullLayout() || o.selfNeedsLayout())
                     dirtyLineBoxesForRenderer(o, layoutState.isFullLayout());
                 o.clearNeedsLayout();

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -109,7 +109,6 @@
     , m_baseTypeFlags(baseTypeFlags)
     , m_ancestorLineBoxDirty(false)
     , m_hasInitializedStyle(false)
-    , m_renderInlineAlwaysCreatesLineBoxes(false)
     , m_renderBoxNeedsLazyRepaint(false)
     , m_hasPausedImageAnimations(false)
     , m_hasCounterNodeMap(false)

Modified: trunk/Source/WebCore/rendering/RenderElement.h (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderElement.h	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2021-09-09 17:06:51 UTC (rev 282223)
@@ -298,9 +298,6 @@
     void willBeDestroyed() override;
     void notifyFinished(CachedResource&, const NetworkLoadMetrics&) override;
 
-    void setRenderInlineAlwaysCreatesLineBoxes(bool b) { m_renderInlineAlwaysCreatesLineBoxes = b; }
-    bool renderInlineAlwaysCreatesLineBoxes() const { return m_renderInlineAlwaysCreatesLineBoxes; }
-
     void setHasContinuationChainNode(bool b) { m_hasContinuationChainNode = b; }
 
     void setRenderBlockHasMarginBeforeQuirk(bool b) { m_renderBlockHasMarginBeforeQuirk = b; }
@@ -372,7 +369,6 @@
     unsigned m_ancestorLineBoxDirty : 1;
     unsigned m_hasInitializedStyle : 1;
 
-    unsigned m_renderInlineAlwaysCreatesLineBoxes : 1;
     unsigned m_renderBoxNeedsLazyRepaint : 1;
     unsigned m_hasPausedImageAnimations : 1;
     unsigned m_hasCounterNodeMap : 1;

Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -186,15 +186,6 @@
             updateStyleOfAnonymousBlockContinuations(*containingBlock(), &newStyle, oldStyle);
     }
 
-    if (!alwaysCreateLineBoxes()) {
-        bool alwaysCreateLineBoxes = hasSelfPaintingLayer() || hasVisibleBoxDecorations() || newStyle.hasBorder() || newStyle.hasPadding() || newStyle.hasMargin() || hasOutline();
-        if (oldStyle && alwaysCreateLineBoxes) {
-            dirtyLineBoxes(false);
-            setNeedsLayout();
-        }
-        setRenderInlineAlwaysCreatesLineBoxes(alwaysCreateLineBoxes);
-    }
-
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
     if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this)) {
         if (diff >= StyleDifference::Repaint && selfNeedsLayout()) {
@@ -207,14 +198,13 @@
 #endif
 }
 
-bool RenderInline::mayAffectRendering() const
+bool RenderInline::mayAffectLayout() const
 {
-    // Test if we can get away with culling.
     auto* parentStyle = &parent()->style();
     RenderInline* parentRenderInline = is<RenderInline>(*parent()) ? downcast<RenderInline>(parent()) : nullptr;
     auto hasHardLineBreakChildOnly = firstChild() && firstChild() == lastChild() && firstChild()->isBR();
     bool checkFonts = document().inNoQuirksMode();
-    auto mayAffectRendering = (parentRenderInline && parentRenderInline->mayAffectRendering())
+    auto mayAffectLayout = (parentRenderInline && parentRenderInline->mayAffectLayout())
         || (parentRenderInline && parentStyle->verticalAlign() != VerticalAlign::Baseline)
         || style().verticalAlign() != VerticalAlign::Baseline
         || style().textEmphasisMark() != TextEmphasisMark::None
@@ -222,29 +212,17 @@
         || parentStyle->lineHeight() != style().lineHeight()))
         || hasHardLineBreakChildOnly;
 
-    if (!mayAffectRendering && checkFonts && view().usesFirstLineRules()) {
+    if (!mayAffectLayout && checkFonts && view().usesFirstLineRules()) {
         // Have to check the first line style as well.
         parentStyle = &parent()->firstLineStyle();
         auto& childStyle = firstLineStyle();
-        mayAffectRendering = !parentStyle->fontCascade().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.fontCascade().fontMetrics())
+        mayAffectLayout = !parentStyle->fontCascade().fontMetrics().hasIdenticalAscentDescentAndLineGap(childStyle.fontCascade().fontMetrics())
             || childStyle.verticalAlign() != VerticalAlign::Baseline
             || parentStyle->lineHeight() != childStyle.lineHeight();
     }
-    return mayAffectRendering;
+    return mayAffectLayout;
 }
 
-void RenderInline::updateAlwaysCreateLineBoxes(bool fullLayout)
-{
-    // Once we have been tainted once, just assume it will happen again. This way effects like hover highlighting that change the
-    // background color will only cause a layout on the first rollover.
-    if (alwaysCreateLineBoxes() || !mayAffectRendering())
-        return;
-
-    setAlwaysCreateLineBoxes();
-    if (!fullLayout)
-        dirtyLineBoxes(false);
-}
-
 void RenderInline::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
 {
     m_lineBoxes.paint(this, paintInfo, paintOffset);
@@ -265,9 +243,7 @@
         return;
     }
 #endif
-    if (!alwaysCreateLineBoxes())
-        generateCulledLineBoxRects(context, this);
-    else if (LegacyInlineFlowBox* curr = firstLineBox()) {
+    if (LegacyInlineFlowBox* curr = firstLineBox()) {
         for (; curr; curr = curr->nextLineBox())
             context.addRect(FloatRect(curr->topLeft(), curr->size()));
     } else
@@ -274,86 +250,6 @@
         context.addRect(FloatRect());
 }
 
-template<typename GeneratorContext>
-void RenderInline::generateCulledLineBoxRects(GeneratorContext& context, const RenderInline* container) const
-{
-    if (!culledInlineFirstLineBox()) {
-        context.addRect(FloatRect());
-        return;
-    }
-
-    bool isHorizontal = style().isHorizontalWritingMode();
-
-    for (auto& current : childrenOfType<RenderObject>(*this)) {
-        if (current.isFloatingOrOutOfFlowPositioned())
-            continue;
-
-        // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block
-        // direction (aligned to the root box's baseline).
-        if (is<RenderBox>(current)) {
-            auto& renderBox = downcast<RenderBox>(current);
-            if (renderBox.inlineBoxWrapper()) {
-                const LegacyRootInlineBox& rootBox = renderBox.inlineBoxWrapper()->root();
-                const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style();
-                int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().fontCascade().fontMetrics().ascent() - containerStyle.fontCascade().fontMetrics().ascent());
-                int logicalHeight = containerStyle.fontCascade().fontMetrics().height();
-                if (isHorizontal)
-                    context.addRect(FloatRect(renderBox.inlineBoxWrapper()->x() - renderBox.marginLeft(), logicalTop, renderBox.width() + renderBox.horizontalMarginExtent(), logicalHeight));
-                else
-                    context.addRect(FloatRect(logicalTop, renderBox.inlineBoxWrapper()->y() - renderBox.marginTop(), logicalHeight, renderBox.height() + renderBox.verticalMarginExtent()));
-            }
-        } else if (is<RenderInline>(current)) {
-            // If the child doesn't need line boxes either, then we can recur.
-            auto& renderInline = downcast<RenderInline>(current);
-            if (!renderInline.alwaysCreateLineBoxes())
-                renderInline.generateCulledLineBoxRects(context, container);
-            else {
-                for (auto* childLine = renderInline.firstLineBox(); childLine; childLine = childLine->nextLineBox()) {
-                    const LegacyRootInlineBox& rootBox = childLine->root();
-                    const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style();
-                    int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().fontCascade().fontMetrics().ascent() - containerStyle.fontCascade().fontMetrics().ascent());
-                    int logicalHeight = containerStyle.fontMetrics().height();
-                    if (isHorizontal) {
-                        context.addRect(FloatRect(childLine->x() - childLine->marginLogicalLeft(),
-                            logicalTop,
-                            childLine->logicalWidth() + childLine->marginLogicalLeft() + childLine->marginLogicalRight(),
-                            logicalHeight));
-                    } else {
-                        context.addRect(FloatRect(logicalTop,
-                            childLine->y() - childLine->marginLogicalLeft(),
-                            logicalHeight,
-                            childLine->logicalWidth() + childLine->marginLogicalLeft() + childLine->marginLogicalRight()));
-                    }
-                }
-            }
-        } else if (is<RenderText>(current)) {
-            auto& currText = downcast<RenderText>(current);
-            for (auto* childText = currText.firstTextBox(); childText; childText = childText->nextTextBox()) {
-                const LegacyRootInlineBox& rootBox = childText->root();
-                const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style();
-                int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().fontCascade().fontMetrics().ascent() - containerStyle.fontCascade().fontMetrics().ascent());
-                int logicalHeight = containerStyle.fontCascade().fontMetrics().height();
-                if (isHorizontal)
-                    context.addRect(FloatRect(childText->x(), logicalTop, childText->logicalWidth(), logicalHeight));
-                else
-                    context.addRect(FloatRect(logicalTop, childText->y(), logicalHeight, childText->logicalWidth()));
-            }
-        } else if (is<RenderLineBreak>(current)) {
-            if (auto* inlineBox = downcast<RenderLineBreak>(current).inlineBoxWrapper()) {
-                // FIXME: This could use a helper to share these with text path.
-                const LegacyRootInlineBox& rootBox = inlineBox->root();
-                const RenderStyle& containerStyle = rootBox.isFirstLine() ? container->firstLineStyle() : container->style();
-                int logicalTop = rootBox.logicalTop() + (rootBox.lineStyle().fontCascade().fontMetrics().ascent() - containerStyle.fontCascade().fontMetrics().ascent());
-                int logicalHeight = containerStyle.fontMetrics().height();
-                if (isHorizontal)
-                    context.addRect(FloatRect(inlineBox->x(), logicalTop, inlineBox->logicalWidth(), logicalHeight));
-                else
-                    context.addRect(FloatRect(logicalTop, inlineBox->y(), logicalHeight, inlineBox->logicalWidth()));
-            }
-        }
-    }
-}
-
 class AbsoluteRectsGeneratorContext {
 public:
     AbsoluteRectsGeneratorContext(Vector<LayoutRect>& rects, const LayoutPoint& accumulatedOffset)
@@ -447,7 +343,7 @@
     if (auto* lineLayout = LayoutIntegration::LineLayout::containing(*this))
         return lineLayout->firstInlineBoxRect(*this).location();
 #endif
-    if (LegacyInlineBox* firstBox = firstLineBoxIncludingCulling())
+    if (LegacyInlineBox* firstBox = firstLineBox())
         return flooredLayoutPoint(firstBox->topLeft());
     return { };
 }
@@ -527,54 +423,6 @@
     return m_lineBoxes.hitTest(this, request, result, locationInContainer, accumulatedOffset, hitTestAction);
 }
 
-namespace {
-
-class HitTestCulledInlinesGeneratorContext {
-public:
-    HitTestCulledInlinesGeneratorContext(Region& region, const HitTestLocation& location)
-        : m_intersected(false)
-        , m_region(region)
-        , m_location(location)
-    { }
-
-    void addRect(const FloatRect& rect)
-    {
-        m_intersected = m_intersected || m_location.intersects(rect);
-        m_region.unite(enclosingIntRect(rect));
-    }
-
-    bool intersected() const { return m_intersected; }
-
-private:
-    bool m_intersected;
-    Region& m_region;
-    const HitTestLocation& m_location;
-};
-
-} // unnamed namespace
-
-bool RenderInline::hitTestCulledInline(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset)
-{
-    ASSERT(result.isRectBasedTest() && !alwaysCreateLineBoxes());
-    if (!visibleToHitTesting(request))
-        return false;
-
-    HitTestLocation tmpLocation(locationInContainer, -toLayoutSize(accumulatedOffset));
-
-    Region regionResult;
-    HitTestCulledInlinesGeneratorContext context(regionResult, tmpLocation);
-    generateCulledLineBoxRects(context, this);
-
-    if (context.intersected()) {
-        updateHitTestResult(result, tmpLocation.point());
-        // We cannot use addNodeToListBasedTestResult to determine if we fully enclose the hit-test area
-        // because it can only handle rectangular targets.
-        result.addNodeToListBasedTestResult(nodeForHitTest(), request, locationInContainer);
-        return regionResult.contains(enclosingIntRect(tmpLocation.boundingBox()));
-    }
-    return false;
-}
-
 VisiblePosition RenderInline::positionForPoint(const LayoutPoint& point, const RenderFragmentContainer* fragment)
 {
     // FIXME: Does not deal with relative or sticky positioned inlines (should it?)
@@ -626,14 +474,6 @@
         return enclosingIntRect(layout->enclosingBorderBoxRectFor(*this));
 #endif
 
-    if (!alwaysCreateLineBoxes()) {
-        ASSERT(!firstLineBox());
-        FloatRect floatResult;
-        LinesBoundingBoxGeneratorContext context(floatResult);
-        generateCulledLineBoxRects(context, this);
-        return enclosingIntRect(floatResult);
-    }
-
     IntRect result;
     
     // See <rdar://problem/5289721>, for an unknown reason the linked list here is sometimes inconsistent, first is non-zero and last is zero.  We have been
@@ -663,105 +503,6 @@
     return result;
 }
 
-LegacyInlineBox* RenderInline::culledInlineFirstLineBox() const
-{
-    for (auto& current : childrenOfType<RenderObject>(*this)) {
-        if (current.isFloatingOrOutOfFlowPositioned())
-            continue;
-
-        // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block
-        // direction (aligned to the root box's baseline).
-        if (is<RenderBox>(current)) {
-            auto& renderBox = downcast<RenderBox>(current);
-            if (renderBox.inlineBoxWrapper())
-                return renderBox.inlineBoxWrapper();
-        } else if (is<RenderLineBreak>(current)) {
-            auto& renderBR = downcast<RenderLineBreak>(current);
-            if (renderBR.inlineBoxWrapper())
-                return renderBR.inlineBoxWrapper();
-        } else if (is<RenderInline>(current)) {
-            auto& renderInline = downcast<RenderInline>(current);
-            if (LegacyInlineBox* result = renderInline.firstLineBoxIncludingCulling())
-                return result;
-        } else if (is<RenderText>(current)) {
-            auto& renderText = downcast<RenderText>(current);
-            if (renderText.firstTextBox())
-                return renderText.firstTextBox();
-        }
-    }
-    return nullptr;
-}
-
-LegacyInlineBox* RenderInline::culledInlineLastLineBox() const
-{
-    for (RenderObject* current = lastChild(); current; current = current->previousSibling()) {
-        if (current->isFloatingOrOutOfFlowPositioned())
-            continue;
-            
-        // We want to get the margin box in the inline direction, and then use our font ascent/descent in the block
-        // direction (aligned to the root box's baseline).
-        if (is<RenderBox>(*current)) {
-            const auto& renderBox = downcast<RenderBox>(*current);
-            if (renderBox.inlineBoxWrapper())
-                return renderBox.inlineBoxWrapper();
-        } else if (is<RenderLineBreak>(*current)) {
-            RenderLineBreak& renderBR = downcast<RenderLineBreak>(*current);
-            if (renderBR.inlineBoxWrapper())
-                return renderBR.inlineBoxWrapper();
-        } else if (is<RenderInline>(*current)) {
-            RenderInline& renderInline = downcast<RenderInline>(*current);
-            if (LegacyInlineBox* result = renderInline.lastLineBoxIncludingCulling())
-                return result;
-        } else if (is<RenderText>(*current)) {
-            RenderText& renderText = downcast<RenderText>(*current);
-            if (renderText.lastTextBox())
-                return renderText.lastTextBox();
-        }
-    }
-    return nullptr;
-}
-
-LayoutRect RenderInline::culledInlineVisualOverflowBoundingBox() const
-{
-    FloatRect floatResult;
-    LinesBoundingBoxGeneratorContext context(floatResult);
-    generateCulledLineBoxRects(context, this);
-    LayoutRect result(enclosingLayoutRect(floatResult));
-    bool isHorizontal = style().isHorizontalWritingMode();
-    for (auto& current : childrenOfType<RenderObject>(*this)) {
-        if (current.isFloatingOrOutOfFlowPositioned())
-            continue;
-
-        // For overflow we just have to propagate by hand and recompute it all.
-        if (is<RenderBox>(current)) {
-            auto& renderBox = downcast<RenderBox>(current);
-            if (!renderBox.hasSelfPaintingLayer() && renderBox.inlineBoxWrapper()) {
-                LayoutRect logicalRect = renderBox.logicalVisualOverflowRectForPropagation(&style());
-                if (isHorizontal) {
-                    logicalRect.moveBy(renderBox.location());
-                    result.uniteIfNonZero(logicalRect);
-                } else {
-                    logicalRect.moveBy(renderBox.location());
-                    result.uniteIfNonZero(logicalRect.transposedRect());
-                }
-            }
-        } else if (is<RenderInline>(current)) {
-            // If the child doesn't need line boxes either, then we can recur.
-            auto& renderInline = downcast<RenderInline>(current);
-            if (!renderInline.alwaysCreateLineBoxes())
-                result.uniteIfNonZero(renderInline.culledInlineVisualOverflowBoundingBox());
-            else if (!renderInline.hasSelfPaintingLayer())
-                result.uniteIfNonZero(renderInline.linesVisualOverflowBoundingBox());
-        } else if (is<RenderText>(current)) {
-            // FIXME; Overflow from text boxes is lost. We will need to cache this information in
-            // LegacyInlineTextBoxes.
-            auto& renderText = downcast<RenderText>(current);
-            result.uniteIfNonZero(renderText.linesVisualOverflowBoundingBox());
-        }
-    }
-    return result;
-}
-
 LayoutRect RenderInline::linesVisualOverflowBoundingBox() const
 {
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
@@ -769,9 +510,6 @@
         return layout->visualOverflowBoundingBoxRectFor(*this);
 #endif
 
-    if (!alwaysCreateLineBoxes())
-        return culledInlineVisualOverflowBoundingBox();
-
     if (!firstLineBox() || !lastLineBox())
         return LayoutRect();
 
@@ -798,7 +536,6 @@
 
 LayoutRect RenderInline::linesVisualOverflowBoundingBoxInFragment(const RenderFragmentContainer* fragment) const
 {
-    ASSERT(alwaysCreateLineBoxes());
     ASSERT(fragment);
 
     if (!firstLineBox() || !lastLineBox())
@@ -846,7 +583,7 @@
     ASSERT(!view().frameView().layoutContext().isPaintOffsetCacheEnabled() || style().styleType() == PseudoId::FirstLetter || hasSelfPaintingLayer());
 
     auto knownEmpty = [&] {
-        if (firstLineBoxIncludingCulling())
+        if (firstLineBox())
             return false;
         if (continuation())
             return false;
@@ -1094,33 +831,7 @@
         return;
     }
 
-    if (!alwaysCreateLineBoxes()) {
-        // We have to grovel into our children in order to dirty the appropriate lines.
-        for (auto& current : childrenOfType<RenderObject>(*this)) {
-            if (current.isFloatingOrOutOfFlowPositioned())
-                continue;
-            if (is<RenderBox>(current) && !current.needsLayout()) {
-                auto& renderBox = downcast<RenderBox>(current);
-                if (renderBox.inlineBoxWrapper())
-                    renderBox.inlineBoxWrapper()->root().markDirty();
-            } else if (!current.selfNeedsLayout()) {
-                if (is<RenderInline>(current)) {
-                    auto& renderInline = downcast<RenderInline>(current);
-                    for (auto* childLine = renderInline.firstLineBox(); childLine; childLine = childLine->nextLineBox())
-                        childLine->root().markDirty();
-                } else if (is<RenderText>(current)) {
-                    auto& renderText = downcast<RenderText>(current);
-                    for (auto* childText = renderText.firstTextBox(); childText; childText = childText->nextTextBox())
-                        childText->root().markDirty();
-                } else if (is<RenderLineBreak>(current)) {
-                    auto& renderBR = downcast<RenderLineBreak>(current);
-                    if (renderBR.inlineBoxWrapper())
-                        renderBR.inlineBoxWrapper()->root().markDirty();
-                }
-            }
-        }
-    } else
-        m_lineBoxes.dirtyLineBoxes();
+    m_lineBoxes.dirtyLineBoxes();
 }
 
 void RenderInline::deleteLines()
@@ -1135,7 +846,6 @@
 
 LegacyInlineFlowBox* RenderInline::createAndAppendInlineFlowBox()
 {
-    setAlwaysCreateLineBoxes();
     auto newFlowBox = createInlineFlowBox();
     auto flowBox = newFlowBox.get();
     m_lineBoxes.appendLineBox(WTFMove(newFlowBox));

Modified: trunk/Source/WebCore/rendering/RenderInline.h (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderInline.h	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderInline.h	2021-09-09 17:06:51 UTC (rev 282223)
@@ -70,8 +70,6 @@
 
     LegacyInlineFlowBox* firstLineBox() const { return m_lineBoxes.firstLineBox(); }
     LegacyInlineFlowBox* lastLineBox() const { return m_lineBoxes.lastLineBox(); }
-    LegacyInlineBox* firstLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? firstLineBox() : culledInlineFirstLineBox(); }
-    LegacyInlineBox* lastLineBoxIncludingCulling() const { return alwaysCreateLineBoxes() ? lastLineBox() : culledInlineLastLineBox(); }
 
 #if PLATFORM(IOS_FAMILY)
     void absoluteQuadsForSelection(Vector<FloatQuad>& quads) const override;
@@ -82,13 +80,8 @@
     void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& additionalOffset, const RenderLayerModelObject* paintContainer = 0) final;
     void paintOutline(PaintInfo&, const LayoutPoint&);
 
-    bool alwaysCreateLineBoxes() const { return true; }
-    void setAlwaysCreateLineBoxes() { setRenderInlineAlwaysCreatesLineBoxes(true); }
-    bool mayAffectRendering() const;
-    void updateAlwaysCreateLineBoxes(bool fullLayout);
+    bool mayAffectLayout() const;
 
-    bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset);
-
     bool requiresLayer() const override { return isInFlowPositioned() || createsGroup() || hasClipPath() || willChangeCreatesStackingContext() || hasRunningAcceleratedAnimations(); }
 
 protected:
@@ -104,16 +97,10 @@
 
     bool canHaveChildren() const final { return true; }
 
-    LayoutRect culledInlineVisualOverflowBoundingBox() const;
-    LegacyInlineBox* culledInlineFirstLineBox() const;
-    LegacyInlineBox* culledInlineLastLineBox() const;
-
     void absoluteQuadsIgnoringContinuation(const FloatRect&, Vector<FloatQuad>&, bool* wasFixed) const override;
 
     template<typename GeneratorContext>
     void generateLineBoxRects(GeneratorContext& yield) const;
-    template<typename GeneratorContext>
-    void generateCulledLineBoxRects(GeneratorContext& yield, const RenderInline* container) const;
 
     void layout() final { ASSERT_NOT_REACHED(); } // Do nothing for layout()
 

Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -311,7 +311,7 @@
         return;
 
     RenderInline* inlineContainer = is<RenderInline>(container) ? &downcast<RenderInline>(container) : nullptr;
-    LegacyInlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBoxIncludingCulling() : firstLineBox();
+    LegacyInlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBox() : firstLineBox();
 
     // If we have no first line box, then just bail early.
     if (!firstBox) {
@@ -342,7 +342,7 @@
             if (LegacyInlineTextBox* textBox = downcast<RenderText>(*current).lastTextBox())
                 box = &textBox->root();
         } else if (is<RenderInline>(*current)) {
-            LegacyInlineBox* lastSiblingBox = downcast<RenderInline>(*current).lastLineBoxIncludingCulling();
+            LegacyInlineBox* lastSiblingBox = downcast<RenderInline>(*current).lastLineBox();
             if (lastSiblingBox)
                 box = &lastSiblingBox->root();
         }
@@ -350,21 +350,8 @@
         if (box)
             break;
     }
-    if (!box) {
-        if (inlineContainer && !inlineContainer->alwaysCreateLineBoxes()) {
-            // https://bugs.webkit.org/show_bug.cgi?id=60778
-            // We may have just removed a <br> with no line box that was our first child. In this case
-            // we won't find a previous sibling, but firstBox can be pointing to a following sibling.
-            // This isn't good enough, since we won't locate the root line box that encloses the removed
-            // <br>. We have to just over-invalidate a bit and go up to our parent.
-            if (!inlineContainer->ancestorLineBoxDirty()) {
-                inlineContainer->parent()->dirtyLinesFromChangedChild(*inlineContainer);
-                inlineContainer->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree.
-            }
-            return;
-        }
+    if (!box)
         box = &firstBox->root();
-    }
 
     // If we found a line box, then dirty it.
     if (box) {
@@ -387,7 +374,7 @@
             // Dedicated linebox for floats may be added as the last rootbox. If this occurs with BRs inside inlines that propagte their lineboxes to
             // the parent flow, we need to invalidate it explicitly.
             // FIXME: We should be able to figure out the actual "changed child" even when we are calling through empty inlines recursively.
-            if (is<RenderInline>(child) && !downcast<RenderInline>(child).firstLineBoxIncludingCulling()) {
+            if (is<RenderInline>(child) && !downcast<RenderInline>(child).firstLineBox()) {
                 auto* lastRootBox = nextBox->blockFlow().lastRootBox();
                 if (lastRootBox->isForTrailingFloats() && !lastRootBox->isDirty())
                     lastRootBox->markDirty();

Modified: trunk/Source/WebCore/rendering/RenderText.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderText.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderText.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -1584,11 +1584,6 @@
     return enclosingIntRect(boundingBox);
 }
 
-LayoutRect RenderText::linesVisualOverflowBoundingBox() const
-{
-    return m_lineBoxes.visualOverflowBoundingBox(*this);
-}
-
 LayoutRect RenderText::clippedOverflowRect(const RenderLayerModelObject* repaintContainer, VisibleRectContext context) const
 {
     RenderObject* rendererToRepaint = containingBlock();

Modified: trunk/Source/WebCore/rendering/RenderText.h (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderText.h	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderText.h	2021-09-09 17:06:51 UTC (rev 282223)
@@ -117,8 +117,6 @@
     static bool isHangableStopOrComma(UChar);
     
     WEBCORE_EXPORT virtual IntRect linesBoundingBox() const;
-    LayoutRect linesVisualOverflowBoundingBox() const;
-
     WEBCORE_EXPORT IntPoint firstRunLocation() const;
 
     virtual void setText(const String&, bool force = false);

Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -147,29 +147,6 @@
     return current;
 }
 
-LayoutRect RenderTextLineBoxes::visualOverflowBoundingBox(const RenderText& renderer) const
-{
-    if (!m_first)
-        return LayoutRect();
-
-    // Return the width of the minimal left side and the maximal right side.
-    auto logicalLeftSide = LayoutUnit::max();
-    auto logicalRightSide = LayoutUnit::min();
-    for (auto* current = m_first; current; current = current->nextTextBox()) {
-        logicalLeftSide = std::min(logicalLeftSide, current->logicalLeftVisualOverflow());
-        logicalRightSide = std::max(logicalRightSide, current->logicalRightVisualOverflow());
-    }
-    
-    auto logicalTop = m_first->logicalTopVisualOverflow();
-    auto logicalWidth = logicalRightSide - logicalLeftSide;
-    auto logicalHeight = m_last->logicalBottomVisualOverflow() - logicalTop;
-    
-    LayoutRect rect(logicalLeftSide, logicalTop, logicalWidth, logicalHeight);
-    if (!renderer.style().isHorizontalWritingMode())
-        rect = rect.transposedRect();
-    return rect;
-}
-
 void RenderTextLineBoxes::dirtyAll()
 {
     for (auto* box = m_first; box; box = box->nextTextBox())

Modified: trunk/Source/WebCore/rendering/RenderTextLineBoxes.h (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderTextLineBoxes.h	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderTextLineBoxes.h	2021-09-09 17:06:51 UTC (rev 282223)
@@ -56,8 +56,6 @@
 
     LegacyInlineTextBox* findNext(int offset, int& position) const;
 
-    LayoutRect visualOverflowBoundingBox(const RenderText&) const;
-
 #if ASSERT_ENABLED
     ~RenderTextLineBoxes();
 #endif

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -202,7 +202,7 @@
         if (!is<RenderInline>(sibling))
             return true;
         auto& siblingRendererInline = downcast<RenderInline>(sibling);
-        if (siblingRendererInline.mayAffectRendering() || !isRenderInlineEmpty(siblingRendererInline))
+        if (siblingRendererInline.mayAffectLayout() || !isRenderInlineEmpty(siblingRendererInline))
             return true;
     }
     return false;

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp (282222 => 282223)


--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp	2021-09-09 17:03:31 UTC (rev 282222)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp	2021-09-09 17:06:51 UTC (rev 282223)
@@ -36,7 +36,6 @@
 RenderSVGInline::RenderSVGInline(SVGGraphicsElement& element, RenderStyle&& style)
     : RenderInline(element, WTFMove(style))
 {
-    setAlwaysCreateLineBoxes();
 }
 
 std::unique_ptr<LegacyInlineFlowBox> RenderSVGInline::createInlineFlowBox()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to