Title: [283893] trunk/Source/WebCore
Revision
283893
Author
[email protected]
Date
2021-10-11 08:12:27 -0700 (Mon, 11 Oct 2021)

Log Message

[LFC][Integration] paintFillLayerExtended should use inline iterator
https://bugs.webkit.org/show_bug.cgi?id=231502

Reviewed by Alan Bujtas.

Prepare for LFC inline box painting.

* layout/integration/InlineIteratorInlineBox.cpp:
(WebCore::InlineIterator::InlineBox::hasClosedLeftAndRightEdge const):

Add a shared helper.

The answer is computed here though this information is needed for layout too.
We should be able to consult layout to get it.

* layout/integration/InlineIteratorInlineBox.h:
* rendering/InlineBoxPainter.cpp:
(WebCore::clipRectForNinePieceImageStrip):
(WebCore::InlineBoxPainter::paintDecorations):
(WebCore::InlineBoxPainter::paintFillLayer):
(WebCore::InlineBoxPainter::paintBoxShadow):
* rendering/LegacyInlineBox.h:
* rendering/LegacyInlineFlowBox.cpp:
(WebCore::LegacyInlineFlowBox::boxShadowCanBeAppliedToBackground const): Deleted.

Move to the only call site as a lambda.

* rendering/LegacyInlineFlowBox.h:
* rendering/RenderBox.cpp:
(WebCore::RenderBox::paintBoxDecorations):
(WebCore::RenderBox::paintBackground):
(WebCore::RenderBox::paintFillLayer):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::getBackgroundRoundedRect const):
(WebCore::RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance const):
(WebCore::RenderBoxModelObject::paintMaskForTextFillBox):
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
(WebCore::RenderBoxModelObject::boxShadowShouldBeAppliedToBackground const):
* rendering/RenderBoxModelObject.h:
* rendering/RenderImage.cpp:
(WebCore::RenderImage::boxShadowShouldBeAppliedToBackground const):
* rendering/RenderImage.h:
* rendering/RenderTable.cpp:
(WebCore::RenderTable::paintBoxDecorations):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::boxShadowShouldBeAppliedToBackground const):
* rendering/RenderTableCell.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (283892 => 283893)


--- trunk/Source/WebCore/ChangeLog	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/ChangeLog	2021-10-11 15:12:27 UTC (rev 283893)
@@ -1,3 +1,53 @@
+2021-10-11  Antti Koivisto  <[email protected]>
+
+        [LFC][Integration] paintFillLayerExtended should use inline iterator
+        https://bugs.webkit.org/show_bug.cgi?id=231502
+
+        Reviewed by Alan Bujtas.
+
+        Prepare for LFC inline box painting.
+
+        * layout/integration/InlineIteratorInlineBox.cpp:
+        (WebCore::InlineIterator::InlineBox::hasClosedLeftAndRightEdge const):
+
+        Add a shared helper.
+
+        The answer is computed here though this information is needed for layout too.
+        We should be able to consult layout to get it.
+
+        * layout/integration/InlineIteratorInlineBox.h:
+        * rendering/InlineBoxPainter.cpp:
+        (WebCore::clipRectForNinePieceImageStrip):
+        (WebCore::InlineBoxPainter::paintDecorations):
+        (WebCore::InlineBoxPainter::paintFillLayer):
+        (WebCore::InlineBoxPainter::paintBoxShadow):
+        * rendering/LegacyInlineBox.h:
+        * rendering/LegacyInlineFlowBox.cpp:
+        (WebCore::LegacyInlineFlowBox::boxShadowCanBeAppliedToBackground const): Deleted.
+
+        Move to the only call site as a lambda.
+
+        * rendering/LegacyInlineFlowBox.h:
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::paintBoxDecorations):
+        (WebCore::RenderBox::paintBackground):
+        (WebCore::RenderBox::paintFillLayer):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::getBackgroundRoundedRect const):
+        (WebCore::RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance const):
+        (WebCore::RenderBoxModelObject::paintMaskForTextFillBox):
+        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
+        (WebCore::RenderBoxModelObject::boxShadowShouldBeAppliedToBackground const):
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::boxShadowShouldBeAppliedToBackground const):
+        * rendering/RenderImage.h:
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::paintBoxDecorations):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::boxShadowShouldBeAppliedToBackground const):
+        * rendering/RenderTableCell.h:
+
 2021-10-10  Sihui Liu  <[email protected]>
 
         Add support for iterating FileSystemDirectoryHandle

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp (283892 => 283893)


--- trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -36,6 +36,19 @@
 {
 }
 
+std::pair<bool, bool> InlineBox::hasClosedLeftAndRightEdge() const
+{
+    // FIXME: Layout knows the answer to this question so we should consult it.
+#if ENABLE(CSS_BOX_DECORATION_BREAK)
+    if (style().boxDecorationBreak() == BoxDecorationBreak::Clone)
+        return { true, true };
+#endif
+    bool isLTR = style().isLeftToRightDirection();
+    bool isFirst = !previousInlineBox() && !renderer().isContinuation();
+    bool isLast = !nextInlineBox() && !renderer().continuation();
+    return { isLTR ? isFirst : isLast, isLTR ? isLast : isFirst };
+};
+
 InlineBoxIterator InlineBox::nextInlineBox() const
 {
     return InlineBoxIterator(*this).traverseNextInlineBox();

Modified: trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h (283892 => 283893)


--- trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/layout/integration/InlineIteratorInlineBox.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -39,6 +39,8 @@
 
     const RenderBoxModelObject& renderer() const { return downcast<RenderBoxModelObject>(Box::renderer()); }
 
+    std::pair<bool, bool> hasClosedLeftAndRightEdge() const;
+
     // FIXME: Remove. For intermediate porting steps only.
     const LegacyInlineFlowBox* legacyInlineBox() const { return downcast<LegacyInlineFlowBox>(Box::legacyInlineBox()); }
 

Modified: trunk/Source/WebCore/rendering/InlineBoxPainter.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/InlineBoxPainter.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/InlineBoxPainter.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -100,23 +100,24 @@
     LayoutRect clipRect(paintRect);
     auto& style = box.renderer().style();
     LayoutBoxExtent outsets = style.imageOutsets(image);
+    auto [hasClosedLeftEdge, hasClosedRightEdge] = box.hasClosedLeftAndRightEdge();
     if (box.isHorizontal()) {
         clipRect.setY(paintRect.y() - outsets.top());
         clipRect.setHeight(paintRect.height() + outsets.top() + outsets.bottom());
-        if (box.legacyInlineBox()->includeLogicalLeftEdge()) {
+        if (hasClosedLeftEdge) {
             clipRect.setX(paintRect.x() - outsets.left());
             clipRect.setWidth(paintRect.width() + outsets.left());
         }
-        if (box.legacyInlineBox()->includeLogicalRightEdge())
+        if (hasClosedRightEdge)
             clipRect.setWidth(clipRect.width() + outsets.right());
     } else {
         clipRect.setX(paintRect.x() - outsets.left());
         clipRect.setWidth(paintRect.width() + outsets.left() + outsets.right());
-        if (box.legacyInlineBox()->includeLogicalLeftEdge()) {
+        if (hasClosedLeftEdge) {
             clipRect.setY(paintRect.y() - outsets.top());
             clipRect.setHeight(paintRect.height() + outsets.top());
         }
-        if (box.legacyInlineBox()->includeLogicalRightEdge())
+        if (hasClosedRightEdge)
             clipRect.setHeight(clipRect.height() + outsets.bottom());
     }
     return clipRect;
@@ -218,7 +219,7 @@
     GraphicsContext& context = m_paintInfo.context();
     LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size());
     // Shadow comes first and is behind the background and border.
-    if (!renderer().boxShadowShouldBeAppliedToBackground(adjustedPaintoffset, BackgroundBleedNone, m_inlineBox.legacyInlineBox()))
+    if (!renderer().boxShadowShouldBeAppliedToBackground(adjustedPaintoffset, BackgroundBleedNone, m_inlineBox))
         paintBoxShadow(ShadowStyle::Normal, paintRect);
 
     auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
@@ -242,7 +243,8 @@
 
     bool hasSingleLine = !m_inlineBox.previousInlineBox() && !m_inlineBox.nextInlineBox();
     if (!hasBorderImage || hasSingleLine) {
-        renderer().paintBorder(m_paintInfo, paintRect, style, BackgroundBleedNone, m_inlineBox.legacyInlineBox()->includeLogicalLeftEdge(), m_inlineBox.legacyInlineBox()->includeLogicalRightEdge());
+        auto [hasClosedLeftEdge, hasClosedRightEdge] = m_inlineBox.hasClosedLeftAndRightEdge();
+        renderer().paintBorder(m_paintInfo, paintRect, style, BackgroundBleedNone, hasClosedLeftEdge, hasClosedRightEdge);
         return;
     }
 
@@ -290,7 +292,7 @@
     bool hasSingleLine = !m_inlineBox.previousInlineBox() && !m_inlineBox.nextInlineBox();
 
     if (!hasFillImageOrBorderRadious || hasSingleLine || m_isRootInlineBox) {
-        renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox.legacyInlineBox(), rect.size(), op);
+        renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, rect.size(), op);
         return;
     }
 
@@ -298,7 +300,7 @@
     if (renderer().style().boxDecorationBreak() == BoxDecorationBreak::Clone) {
         GraphicsContextStateSaver stateSaver(m_paintInfo.context());
         m_paintInfo.context().clip({ rect.x(), rect.y(), LayoutUnit(m_inlineBox.rect().width()), LayoutUnit(m_inlineBox.rect().height()) });
-        renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox.legacyInlineBox(), rect.size(), op);
+        renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, rect.size(), op);
         return;
     }
 #endif
@@ -331,7 +333,7 @@
 
     GraphicsContextStateSaver stateSaver(m_paintInfo.context());
     m_paintInfo.context().clip({ rect.x(), rect.y(), LayoutUnit(m_inlineBox.rect().width()), LayoutUnit(m_inlineBox.rect().height()) });
-    renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, LayoutRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, m_inlineBox.legacyInlineBox(), rect.size(), op);
+    renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, LayoutRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, m_inlineBox, rect.size(), op);
 }
 
 void InlineBoxPainter::paintBoxShadow(ShadowStyle shadowStyle, const LayoutRect& paintRect)
@@ -344,7 +346,8 @@
 
     // FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't
     // protrude incorrectly at the edges, and we want to possibly include shadows cast from the previous/following lines
-    renderer().paintBoxShadow(m_paintInfo, paintRect, style(), shadowStyle, m_inlineBox.legacyInlineBox()->includeLogicalLeftEdge(), m_inlineBox.legacyInlineBox()->includeLogicalRightEdge());
+    auto [hasClosedLeftEdge, hasClosedRightEdge] = m_inlineBox.hasClosedLeftAndRightEdge();
+    renderer().paintBoxShadow(m_paintInfo, paintRect, style(), shadowStyle, hasClosedLeftEdge, hasClosedRightEdge);
 }
 
 void InlineBoxPainter::constrainToLineTopAndBottomIfNeeded(LayoutRect& rect) const

Modified: trunk/Source/WebCore/rendering/LegacyInlineBox.h (283892 => 283893)


--- trunk/Source/WebCore/rendering/LegacyInlineBox.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/LegacyInlineBox.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -31,6 +31,7 @@
 namespace WebCore {
 
 class HitTestResult;
+class LegacyInlineFlowBox;
 class LegacyRootInlineBox;
 
 // LegacyInlineBox represents a rectangle that occurs on a line. It corresponds to

Modified: trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/LegacyInlineFlowBox.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -1134,15 +1134,6 @@
     }
 }
 
-bool LegacyInlineFlowBox::boxShadowCanBeAppliedToBackground(const FillLayer& lastBackgroundLayer) const
-{
-    // The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow
-    // would be clipped out, so it has to be drawn separately).
-    StyleImage* image = lastBackgroundLayer.image();
-    bool hasFillImage = image && image->canRender(&renderer(), renderer().style().effectiveZoom());
-    return (!hasFillImage && !renderer().style().hasBorderRadius()) || (!prevLineBox() && !nextLineBox()) || !parent();
-}
-
 LegacyInlineBox* LegacyInlineFlowBox::firstLeafDescendant() const
 {
     LegacyInlineBox* leaf = nullptr;

Modified: trunk/Source/WebCore/rendering/LegacyInlineFlowBox.h (283892 => 283893)


--- trunk/Source/WebCore/rendering/LegacyInlineFlowBox.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/LegacyInlineFlowBox.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -118,8 +118,6 @@
     void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom, HitTestAction) override;
 
-    bool boxShadowCanBeAppliedToBackground(const FillLayer&) const;
-
     // logicalLeft = left in a horizontal line and top in a vertical line.
     LayoutUnit marginBorderPaddingLogicalLeft() const { return LayoutUnit(marginLogicalLeft() + borderLogicalLeft() + paddingLogicalLeft()); }
     LayoutUnit marginBorderPaddingLogicalRight() const { return LayoutUnit(marginLogicalRight() + borderLogicalRight() + paddingLogicalRight()); }

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -47,6 +47,7 @@
 #include "HTMLSelectElement.h"
 #include "HTMLTextAreaElement.h"
 #include "HitTestResult.h"
+#include "InlineIteratorInlineBox.h"
 #include "InlineIteratorLine.h"
 #include "InlineRunAndOffset.h"
 #include "LayoutIntegrationLineLayout.h"
@@ -1524,7 +1525,7 @@
 
     // FIXME: Should eventually give the theme control over whether the box shadow should paint, since controls could have
     // custom shadows of their own.
-    if (!boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance))
+    if (!boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance, { }))
         paintBoxShadow(paintInfo, paintRect, style(), ShadowStyle::Normal);
 
     GraphicsContextStateSaver stateSaver(paintInfo.context(), false);
@@ -1590,7 +1591,7 @@
     if (!paintsOwnBackground())
         return;
 
-    if (backgroundIsKnownToBeObscured(paintRect.location()) && !boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance))
+    if (backgroundIsKnownToBeObscured(paintRect.location()) && !boxShadowShouldBeAppliedToBackground(paintRect.location(), bleedAvoidance, { }))
         return;
 
     auto backgroundColor = style().visitedDependentColor(CSSPropertyBackgroundColor);
@@ -1882,7 +1883,7 @@
 void RenderBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, const FillLayer& fillLayer, const LayoutRect& rect,
     BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)
 {
-    paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, nullptr, LayoutSize(), op, backgroundObject, baseBgColorUsage);
+    paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, { }, LayoutSize(), op, backgroundObject, baseBgColorUsage);
 }
 
 static StyleImage* findLayerUsedImage(WrappedImagePtr image, const FillLayer& layers)

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -621,11 +621,11 @@
     return minimumValueForLength(padding, w);
 }
 
-RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, const LegacyInlineFlowBox* box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
+RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, const InlineIterator::InlineBoxIterator& box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
     bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
     RoundedRect border = style().getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge);
-    if (box && (box->nextLineBox() || box->prevLineBox())) {
+    if (box && (box->nextInlineBox() || box->previousInlineBox())) {
         RoundedRect segmentBorder = style().getRoundedBorderFor(LayoutRect(0_lu, 0_lu, inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightEdge);
         border.setRadii(segmentBorder.radii());
     }
@@ -682,7 +682,7 @@
     return shrinkRectByOneDevicePixel(context, rect, document().deviceScaleFactor());
 }
 
-RoundedRect RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext& context, const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const LegacyInlineFlowBox* box, const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
+RoundedRect RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext& context, const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, const LayoutSize& boxSize, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const
 {
     if (bleedAvoidance == BackgroundBleedShrinkBackground) {
         // We shrink the rectangle by one device pixel on each side because the bleed is one pixel maximum.
@@ -710,7 +710,7 @@
     return view().imageQualityController().chooseInterpolationQuality(context, this, image, layer, size);
 }
 
-void RenderBoxModelObject::paintMaskForTextFillBox(ImageBuffer* maskImage, const FloatRect& maskRect, const LegacyInlineFlowBox* box, const LayoutRect& scrolledPaintRect)
+void RenderBoxModelObject::paintMaskForTextFillBox(ImageBuffer* maskImage, const FloatRect& maskRect, const InlineIterator::InlineBoxIterator& box, const LayoutRect& scrolledPaintRect)
 {
     GraphicsContext& maskImageContext = maskImage->context();
     maskImageContext.translate(-maskRect.location());
@@ -719,8 +719,9 @@
     // LegacyInlineTextBoxes that they should just add their contents to the clip.
     PaintInfo info(maskImageContext, LayoutRect { maskRect }, PaintPhase::TextClip, PaintBehavior::ForceBlackText);
     if (box) {
-        const LegacyRootInlineBox& rootBox = box->root();
-        const_cast<LegacyInlineFlowBox*>(box)->paint(info, LayoutPoint(scrolledPaintRect.x() - box->x(), scrolledPaintRect.y() - box->y()), rootBox.lineTop(), rootBox.lineBottom());
+        auto* legacyInlineBox = const_cast<LegacyInlineFlowBox*>(box->legacyInlineBox());
+        const auto& rootBox = legacyInlineBox->root();
+        legacyInlineBox->paint(info, LayoutPoint(scrolledPaintRect.x() - legacyInlineBox->x(), scrolledPaintRect.y() - legacyInlineBox->y()), rootBox.lineTop(), rootBox.lineBottom());
     } else {
         LayoutSize localOffset = is<RenderBox>(*this) ? downcast<RenderBox>(*this).locationOffset() : LayoutSize();
         paint(info, scrolledPaintRect.location() - localOffset);
@@ -728,7 +729,7 @@
 }
 
 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& rect,
-    BackgroundBleedAvoidance bleedAvoidance, const LegacyInlineFlowBox* box, const LayoutSize& boxSize, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)
+    BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, const LayoutSize& boxSize, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)
 {
     GraphicsContext& context = paintInfo.context();
 
@@ -735,8 +736,7 @@
     if ((context.paintingDisabled() && !context.detectingContentfulPaint()) || rect.isEmpty())
         return;
 
-    bool includeLeftEdge = box ? box->includeLogicalLeftEdge() : true;
-    bool includeRightEdge = box ? box->includeLogicalRightEdge() : true;
+    auto [includeLeftEdge, includeRightEdge] = box ? box->hasClosedLeftAndRightEdge() : std::pair(true, true);
 
     bool hasRoundedBorder = style().hasBorderRadius() && (includeLeftEdge || includeRightEdge);
     bool clippedWithLocalScrolling = hasNonVisibleOverflow() && bgLayer.attachment() == FillAttachment::LocalBackground;
@@ -2326,7 +2326,7 @@
     return true;
 }
 
-bool RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(const LayoutPoint&, BackgroundBleedAvoidance bleedAvoidance, const LegacyInlineFlowBox* inlineFlowBox) const
+bool RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(const LayoutPoint&, BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& inlineBox) const
 {
     if (bleedAvoidance != BackgroundBleedNone)
         return false;
@@ -2364,7 +2364,20 @@
     if (lastBackgroundLayer->image() && style().hasBorderRadius())
         return false;
 
-    if (inlineFlowBox && !inlineFlowBox->boxShadowCanBeAppliedToBackground(*lastBackgroundLayer))
+    auto applyToInlineBox = [&] {
+        // The checks here match how paintFillLayer() decides whether to clip (if it does, the shadow
+        // would be clipped out, so it has to be drawn separately).
+        if (inlineBox->isRootInlineBox())
+            return true;
+        if (!inlineBox->previousInlineBox() && !inlineBox->nextInlineBox())
+            return true;
+        auto* image = lastBackgroundLayer->image();
+        auto& renderer = inlineBox->renderer();
+        bool hasFillImage = image && image->canRender(&renderer, renderer.style().effectiveZoom());
+        return !hasFillImage && !renderer.style().hasBorderRadius();
+    };
+
+    if (inlineBox && !applyToInlineBox())
         return false;
 
     if (hasNonVisibleOverflow() && lastBackgroundLayer->attachment() == FillAttachment::LocalBackground)

Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.h (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -60,10 +60,13 @@
 
 class BorderEdge;
 class ImageBuffer;
-class LegacyInlineFlowBox;
 class RenderTextFragment;
 class StickyPositionViewportConstraints;
 
+namespace InlineIterator {
+class InlineBoxIterator;
+};
+
 enum class BoxSideFlag : uint8_t;
 using BoxSideSet = OptionSet<BoxSideFlag>;
 using BorderEdges = RectEdges<BorderEdge>;
@@ -210,9 +213,9 @@
     void paintBorder(const PaintInfo&, const LayoutRect&, const RenderStyle&, BackgroundBleedAvoidance = BackgroundBleedNone, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
     bool paintNinePieceImage(GraphicsContext&, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeOperator::SourceOver);
     void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle&, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true);
-    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, const LegacyInlineFlowBox*  = nullptr, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse);
+    void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, const LayoutSize& = LayoutSize(), CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse);
 
-    virtual bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& absolutePaintPostion, BackgroundBleedAvoidance, const LegacyInlineFlowBox*  = nullptr) const;
+    virtual bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& absolutePaintPostion, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&) const;
 
     // Overridden by subclasses to determine line height and baseline position.
     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const = 0;
@@ -256,7 +259,7 @@
         const LayoutRect& paintRect, RenderElement* = nullptr) const;
     bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const;
     bool borderObscuresBackground() const;
-    RoundedRect backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance, const LegacyInlineFlowBox* , const LayoutSize&, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
+    RoundedRect backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, const LayoutSize&, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
     LayoutRect borderInnerRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance) const;
 
     InterpolationQuality chooseInterpolationQuality(GraphicsContext&, Image&, const void*, const LayoutSize&);
@@ -307,7 +310,7 @@
 
     LayoutSize calculateFillTileSize(const FillLayer&, const LayoutSize& scaledPositioningAreaSize) const;
 
-    RoundedRect getBackgroundRoundedRect(const LayoutRect&, const LegacyInlineFlowBox* , LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
+    RoundedRect getBackgroundRoundedRect(const LayoutRect&, const InlineIterator::InlineBoxIterator&, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,
         bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;
     
     bool fixedBackgroundPaintsInLocalCoordinates() const;
@@ -326,7 +329,7 @@
     void drawBoxSideFromPath(GraphicsContext&, const LayoutRect&, const Path&, const BorderEdges&,
         float thickness, float drawThickness, BoxSide, const RenderStyle&,
         Color, BorderStyle, BackgroundBleedAvoidance, bool includeLogicalLeftEdge, bool includeLogicalRightEdge);
-    void paintMaskForTextFillBox(ImageBuffer*, const FloatRect&, const LegacyInlineFlowBox* , const LayoutRect&);
+    void paintMaskForTextFillBox(ImageBuffer*, const FloatRect&, const InlineIterator::InlineBoxIterator&, const LayoutRect&);
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderImage.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderImage.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderImage.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -44,7 +44,7 @@
 #include "HTMLMapElement.h"
 #include "HTMLNames.h"
 #include "HitTestResult.h"
-#include "InlineIteratorBox.h"
+#include "InlineIteratorInlineBox.h"
 #include "InlineIteratorLine.h"
 #include "Page.h"
 #include "PaintInfo.h"
@@ -692,9 +692,9 @@
     return drawResult;
 }
 
-bool RenderImage::boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance bleedAvoidance, const LegacyInlineFlowBox*) const
+bool RenderImage::boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator&) const
 {
-    if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(paintOffset, bleedAvoidance))
+    if (!RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(paintOffset, bleedAvoidance, { }))
         return false;
 
     return !const_cast<RenderImage*>(this)->backgroundIsKnownToBeObscured(paintOffset);

Modified: trunk/Source/WebCore/rendering/RenderImage.h (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderImage.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderImage.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -121,7 +121,7 @@
     void notifyFinished(CachedResource&, const NetworkLoadMetrics&) final;
     bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) final;
 
-    bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance, const LegacyInlineFlowBox*) const final;
+    bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&) const final;
 
     IntSize imageSizeForError(CachedImage*) const;
     void repaintOrMarkForLayout(ImageSizeChangeType, const IntRect* = nullptr);

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -34,6 +34,7 @@
 #include "HitTestResult.h"
 #include "HTMLNames.h"
 #include "HTMLTableElement.h"
+#include "InlineIteratorInlineBox.h"
 #include "LayoutRepainter.h"
 #include "RenderBlockFlow.h"
 #include "RenderChildIterator.h"
@@ -787,7 +788,7 @@
     adjustBorderBoxRectForPainting(rect);
     
     BackgroundBleedAvoidance bleedAvoidance = determineBackgroundBleedAvoidance(paintInfo.context());
-    if (!boxShadowShouldBeAppliedToBackground(rect.location(), bleedAvoidance))
+    if (!boxShadowShouldBeAppliedToBackground(rect.location(), bleedAvoidance, { }))
         paintBoxShadow(paintInfo, rect, style(), ShadowStyle::Normal);
     paintBackground(paintInfo, rect, bleedAvoidance);
     paintBoxShadow(paintInfo, rect, style(), ShadowStyle::Inset);

Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderTableCell.cpp	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp	2021-10-11 15:12:27 UTC (rev 283893)
@@ -1348,7 +1348,7 @@
     paintMaskImages(paintInfo, paintRect);
 }
 
-bool RenderTableCell::boxShadowShouldBeAppliedToBackground(const LayoutPoint&, BackgroundBleedAvoidance, const LegacyInlineFlowBox*) const
+bool RenderTableCell::boxShadowShouldBeAppliedToBackground(const LayoutPoint&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&) const
 {
     return false;
 }

Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (283892 => 283893)


--- trunk/Source/WebCore/rendering/RenderTableCell.h	2021-10-11 13:50:39 UTC (rev 283892)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h	2021-10-11 15:12:27 UTC (rev 283893)
@@ -151,7 +151,7 @@
     void paintBoxDecorations(PaintInfo&, const LayoutPoint&) override;
     void paintMask(PaintInfo&, const LayoutPoint&) override;
 
-    bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance, const LegacyInlineFlowBox*) const override;
+    bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& paintOffset, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&) const override;
 
     LayoutSize offsetFromContainer(RenderElement&, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const override;
     std::optional<LayoutRect> computeVisibleRectInContainer(const LayoutRect&, const RenderLayerModelObject* container, VisibleRectContext) const override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to