Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4d774bdad1260cf75c4b21611a52d14f2d5a3219
      
https://github.com/WebKit/WebKit/commit/4d774bdad1260cf75c4b21611a52d14f2d5a3219
  Author: Simon Fraser <[email protected]>
  Date:   2025-01-10 (Fri, 10 Jan 2025)

  Changed paths:
    M LayoutTests/platform/gtk/TestExpectations
    M LayoutTests/platform/wpe/TestExpectations
    A LayoutTests/printing/background-clip-text-expected.html
    A LayoutTests/printing/background-clip-text.html
    M Source/WebCore/rendering/BackgroundPainter.cpp
    M Source/WebCore/rendering/StyledMarkedText.cpp
    M Source/WebCore/rendering/TextPaintStyle.cpp
    M Source/WebCore/rendering/TextPaintStyle.h
    M Source/WebCore/rendering/style/RenderStyle.cpp
    M Source/WebCore/rendering/style/RenderStyle.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/DrawingToPDF.mm

  Log Message:
  -----------
  REGRESSION (283135@main): Headings using `background-clip: text` become 
rectangles when exported as PDF
https://bugs.webkit.org/show_bug.cgi?id=285760
rdar://142698412

Reviewed by Tim Horton.

There were a couple of issues with `background-clip: text` that affect 
printing. First, when printing
skips backgrounds (because of `print-color-adjust: economy` and the user 
unchecking the Print Backgrounds
checkbox in the print dialog), `background-clip: text` did not show at all 
because it's painted as a background.
Fix this by changing the `layerClip` from `FillBox::Text` to 
`FillBox::BorderBox` in `BackgroundPainter::paintFillLayer()`,
and making the text black in `computeTextPaintStyle()`; the spec[1] allows us 
to make these adjustments for `economy`.
This is tested by a layout test.

Second, when printing or generating a PDF when including backgrounds, i.e. for 
`print-color-adjust: exact` or with
the Print Backgrounds checkbox checked, the SourceIn blend mode is not 
supported, which resulted in a solid background
and missing text. Fix this by falling back to clipping to an image buffer for 
PDF contexts, in `BackgroundPainter::paintFillLayer()`.
This is tested by a new API test.

[1] https://drafts.csswg.org/css-color-adjust/#propdef-print-color-adjust

* LayoutTests/platform/gtk/TestExpectations:
* LayoutTests/platform/wpe/TestExpectations:
* LayoutTests/printing/background-clip-text-expected.html: Added.
* LayoutTests/printing/background-clip-text.html: Added.
* Source/WebCore/rendering/BackgroundPainter.cpp:
(WebCore::BackgroundPainter::paintFillLayer const):
* Source/WebCore/rendering/StyledMarkedText.cpp:
(WebCore::StyledMarkedText::computeStyleForUnmarkedMarkedText):
* Source/WebCore/rendering/TextPaintStyle.cpp:
(WebCore::computeTextPaintStyle):
* Source/WebCore/rendering/TextPaintStyle.h:
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::hasEntirelyFixedBackground const):
(WebCore::RenderStyle::hasAnyBackgroundClipText const):
(WebCore::allLayersAreFixed): Deleted.
* Source/WebCore/rendering/style/RenderStyle.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/DrawingToPDF.mm:
(TestWebKitAPI::TEST(DrawingToPDF, BackgroundClipText)):

Canonical link: https://commits.webkit.org/288753@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to