Changeset 284380 in webkit
- Timestamp:
- Oct 18, 2021 10:17:56 AM (9 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/inline/inline-background-clip-text-multiline-expected.html (added)
-
LayoutTests/fast/inline/inline-background-clip-text-multiline.html (added)
-
LayoutTests/platform/win/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/InlineBoxPainter.cpp (modified) (3 diffs)
-
Source/WebCore/rendering/RenderBox.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderBoxModelObject.cpp (modified) (7 diffs)
-
Source/WebCore/rendering/RenderBoxModelObject.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r284377 r284380 1 2021-10-18 Antti Koivisto <antti@apple.com> 2 3 background-clip:text doesn't paint correctly for inline box spanning multiple lines 4 https://bugs.webkit.org/show_bug.cgi?id=231891 5 6 Reviewed by Alan Bujtas. 7 8 * fast/inline/inline-background-clip-text-multiline-expected.html: Added. 9 * fast/inline/inline-background-clip-text-multiline.html: Added. 10 1 11 2021-10-18 Ayumi Kojima <ayumi_kojima@apple.com> 2 12 -
trunk/LayoutTests/platform/win/TestExpectations
r284334 r284380 2913 2913 fast/inline/padding-ellipsis-right.html [ ImageOnlyFailure ] 2914 2914 fast/inline/inline-background-clip-text.html [ ImageOnlyFailure ] 2915 fast/inline/inline-background-clip-text-multiline.html [ ImageOnlyFailure ] 2915 2916 2916 2917 # This test hardcodes the result of a platform-dependent font lookup algorithm. -
trunk/Source/WebCore/ChangeLog
r284371 r284380 1 2021-10-18 Antti Koivisto <antti@apple.com> 2 3 background-clip:text doesn't paint correctly for inline box spanning multiple lines 4 https://bugs.webkit.org/show_bug.cgi?id=231891 5 6 Reviewed by Alan Bujtas. 7 8 'background-clip: text' paints to a wrong position if the inline box spans multiple lines. 9 10 Test: fast/inline/inline-background-clip-text-multiline.html 11 12 * rendering/InlineBoxPainter.cpp: 13 (WebCore::InlineBoxPainter::paintFillLayer): 14 * rendering/RenderBox.cpp: 15 (WebCore::RenderBox::paintFillLayer): 16 * rendering/RenderBoxModelObject.cpp: 17 (WebCore::RenderBoxModelObject::getBackgroundRoundedRect const): 18 (WebCore::RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance const): 19 20 No need to pass box size separately as it now always matches the passed in border rect. 21 22 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 23 24 The 'rect' parameter used to be either the border box rect of the box being painted or, 25 in the case of multiline inline box background image, the image strip being painted. 26 27 Make the 'rect' parameter to always be the border box and pass the background image strip 28 separately. 29 30 Use the background image strip only during background image painting. 31 32 * rendering/RenderBoxModelObject.h: 33 (WebCore::RenderBoxModelObject::paintFillLayerExtended): 34 1 35 2021-10-18 Kimmo Kinnunen <kkinnunen@apple.com> 2 36 -
trunk/Source/WebCore/rendering/InlineBoxPainter.cpp
r283981 r284380 299 299 300 300 if (!hasFillImageOrBorderRadious || hasSingleLine || m_isRootInlineBox) { 301 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, rect.size(), op);301 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, { }, op); 302 302 return; 303 303 } … … 307 307 GraphicsContextStateSaver stateSaver(m_paintInfo.context()); 308 308 m_paintInfo.context().clip({ rect.x(), rect.y(), LayoutUnit(m_inlineBox.rect().width()), LayoutUnit(m_inlineBox.rect().height()) }); 309 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, rect.size(), op);309 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, { }, op); 310 310 return; 311 311 } … … 333 333 totalLogicalWidth += box->logicalWidth(); 334 334 } 335 LayoutUnit stripX = rect.x() - (isHorizontal() ? logicalOffsetOnLine : 0_lu); 336 LayoutUnit stripY = rect.y() - (isHorizontal() ? 0_lu : logicalOffsetOnLine); 337 LayoutUnit stripWidth = isHorizontal() ? totalLogicalWidth : LayoutUnit(m_inlineBox.rect().width()); 338 LayoutUnit stripHeight = isHorizontal() ? LayoutUnit(m_inlineBox.rect().height()) : totalLogicalWidth; 335 LayoutRect backgroundImageStrip { 336 rect.x() - (isHorizontal() ? logicalOffsetOnLine : 0_lu), 337 rect.y() - (isHorizontal() ? 0_lu : logicalOffsetOnLine), 338 isHorizontal() ? totalLogicalWidth : LayoutUnit(m_inlineBox.rect().width()), 339 isHorizontal() ? LayoutUnit(m_inlineBox.rect().height()) : totalLogicalWidth 340 }; 339 341 340 342 GraphicsContextStateSaver stateSaver(m_paintInfo.context()); 341 m_paintInfo.context().clip( { rect.x(), rect.y(), LayoutUnit(m_inlineBox.rect().width()), LayoutUnit(m_inlineBox.rect().height())});342 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, LayoutRect(stripX, stripY, stripWidth, stripHeight), BackgroundBleedNone, m_inlineBox, rect.size(), op);343 m_paintInfo.context().clip(FloatRect { rect }); 344 renderer().paintFillLayerExtended(m_paintInfo, color, fillLayer, rect, BackgroundBleedNone, m_inlineBox, backgroundImageStrip, op); 343 345 } 344 346 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r283893 r284380 1884 1884 BackgroundBleedAvoidance bleedAvoidance, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage) 1885 1885 { 1886 paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, { }, LayoutSize(), op, backgroundObject, baseBgColorUsage);1886 paintFillLayerExtended(paintInfo, c, fillLayer, rect, bleedAvoidance, { }, { }, op, backgroundObject, baseBgColorUsage); 1887 1887 } 1888 1888 -
trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp
r284334 r284380 624 624 } 625 625 626 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, const InlineIterator::InlineBoxIterator& box, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight,626 RoundedRect RenderBoxModelObject::getBackgroundRoundedRect(const LayoutRect& borderRect, const InlineIterator::InlineBoxIterator& box, 627 627 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const 628 628 { 629 629 RoundedRect border = style().getRoundedBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge); 630 630 if (box && (box->nextInlineBox() || box->previousInlineBox())) { 631 RoundedRect segmentBorder = style().getRoundedBorderFor(LayoutRect(0_lu, 0_lu, inlineBoxWidth, inlineBoxHeight), includeLogicalLeftEdge, includeLogicalRightEdge);631 RoundedRect segmentBorder = style().getRoundedBorderFor(LayoutRect(0_lu, 0_lu, borderRect.width(), borderRect.height()), includeLogicalLeftEdge, includeLogicalRightEdge); 632 632 border.setRadii(segmentBorder.radii()); 633 633 } … … 685 685 } 686 686 687 RoundedRect RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext& context, const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, const LayoutSize& boxSize,bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const687 RoundedRect RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext& context, const LayoutRect& borderRect, BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const 688 688 { 689 689 if (bleedAvoidance == BackgroundBleedShrinkBackground) { 690 690 // We shrink the rectangle by one device pixel on each side because the bleed is one pixel maximum. 691 return getBackgroundRoundedRect(shrinkRectByOneDevicePixel(context, borderRect, document().deviceScaleFactor()), box, boxSize.width(), boxSize.height(),691 return getBackgroundRoundedRect(shrinkRectByOneDevicePixel(context, borderRect, document().deviceScaleFactor()), box, 692 692 includeLogicalLeftEdge, includeLogicalRightEdge); 693 693 } … … 695 695 return style().getRoundedInnerBorderFor(borderRect, includeLogicalLeftEdge, includeLogicalRightEdge); 696 696 697 return getBackgroundRoundedRect(borderRect, box, boxSize.width(), boxSize.height(),includeLogicalLeftEdge, includeLogicalRightEdge);697 return getBackgroundRoundedRect(borderRect, box, includeLogicalLeftEdge, includeLogicalRightEdge); 698 698 } 699 699 … … 738 738 739 739 void RenderBoxModelObject::paintFillLayerExtended(const PaintInfo& paintInfo, const Color& color, const FillLayer& bgLayer, const LayoutRect& rect, 740 BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, const Layout Size& boxSize, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage)740 BackgroundBleedAvoidance bleedAvoidance, const InlineIterator::InlineBoxIterator& box, const LayoutRect& backgroundImageStrip, CompositeOperator op, RenderElement* backgroundObject, BaseBackgroundColorUsage baseBgColorUsage) 741 741 { 742 742 GraphicsContext& context = paintInfo.context(); … … 813 813 814 814 if (hasRoundedBorder && bleedAvoidance != BackgroundBleedUseTransparencyLayer) { 815 FloatRoundedRect pixelSnappedBorder = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize,815 FloatRoundedRect pixelSnappedBorder = backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, 816 816 includeLeftEdge, includeRightEdge).pixelSnappedRoundedRectForPainting(deviceScaleFactor); 817 817 if (pixelSnappedBorder.isRenderable()) { … … 841 841 GraphicsContextStateSaver clipToBorderStateSaver(context, clipToBorderRadius); 842 842 if (clipToBorderRadius) { 843 RoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, boxSize, includeLeftEdge, includeRightEdge) : getBackgroundRoundedRect(rect, box, boxSize.width(), boxSize.height(), includeLeftEdge, includeRightEdge);843 RoundedRect border = isBorderFill ? backgroundRoundedRectAdjustedForBleedAvoidance(context, rect, bleedAvoidance, box, includeLeftEdge, includeRightEdge) : getBackgroundRoundedRect(rect, box, includeLeftEdge, includeRightEdge); 844 844 845 845 // Clip to the padding or content boxes as necessary. … … 955 955 // no progressive loading of the background image 956 956 if (!baseBgColorOnly && shouldPaintBackgroundImage) { 957 auto geometry = calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, rect.location(), scrolledPaintRect, backgroundObject); 957 // Multiline inline boxes paint like the image was one long strip spanning lines. The backgroundImageStrip is this fictional rectangle. 958 auto imageRect = backgroundImageStrip.isEmpty() ? scrolledPaintRect : backgroundImageStrip; 959 auto paintOffset = backgroundImageStrip.isEmpty() ? rect.location() : backgroundImageStrip.location(); 960 auto geometry = calculateBackgroundImageGeometry(paintInfo.paintContainer, bgLayer, paintOffset, imageRect, backgroundObject); 958 961 geometry.clip(LayoutRect(pixelSnappedRect)); 959 962 RefPtr<Image> image; -
trunk/Source/WebCore/rendering/RenderBoxModelObject.h
r283893 r284380 214 214 bool paintNinePieceImage(GraphicsContext&, const LayoutRect&, const RenderStyle&, const NinePieceImage&, CompositeOperator = CompositeOperator::SourceOver); 215 215 void paintBoxShadow(const PaintInfo&, const LayoutRect&, const RenderStyle&, ShadowStyle, bool includeLogicalLeftEdge = true, bool includeLogicalRightEdge = true); 216 void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, const Layout Size& = LayoutSize(), CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse);216 void paintFillLayerExtended(const PaintInfo&, const Color&, const FillLayer&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, const LayoutRect& backgroundImageStrip = { }, CompositeOperator = CompositeOperator::SourceOver, RenderElement* backgroundObject = nullptr, BaseBackgroundColorUsage = BaseBackgroundColorUse); 217 217 218 218 virtual bool boxShadowShouldBeAppliedToBackground(const LayoutPoint& absolutePaintPostion, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&) const; … … 260 260 bool borderObscuresBackgroundEdge(const FloatSize& contextScale) const; 261 261 bool borderObscuresBackground() const; 262 RoundedRect backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, const LayoutSize&,bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const;262 RoundedRect backgroundRoundedRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance, const InlineIterator::InlineBoxIterator&, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const; 263 263 LayoutRect borderInnerRectAdjustedForBleedAvoidance(const GraphicsContext&, const LayoutRect&, BackgroundBleedAvoidance) const; 264 264 … … 311 311 LayoutSize calculateFillTileSize(const FillLayer&, const LayoutSize& scaledPositioningAreaSize) const; 312 312 313 RoundedRect getBackgroundRoundedRect(const LayoutRect&, const InlineIterator::InlineBoxIterator&, LayoutUnit inlineBoxWidth, LayoutUnit inlineBoxHeight, 314 bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const; 313 RoundedRect getBackgroundRoundedRect(const LayoutRect&, const InlineIterator::InlineBoxIterator&, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const; 315 314 316 315 bool fixedBackgroundPaintsInLocalCoordinates() const;
Note: See TracChangeset
for help on using the changeset viewer.