Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a9724ba0366deca0cb55ccc214f8ed7cf2851dec
https://github.com/WebKit/WebKit/commit/a9724ba0366deca0cb55ccc214f8ed7cf2851dec
Author: Alan Baradlay <[email protected]>
Date: 2026-06-26 (Fri, 26 Jun 2026)
Changed paths:
A LayoutTests/fast/text/text-decoration-underline-snapping-expected.html
A LayoutTests/fast/text/text-decoration-underline-snapping.html
M Source/WebCore/platform/graphics/GraphicsContext.cpp
Log Message:
-----------
WKWebView: PDF export creates broken text underlines
https://bugs.webkit.org/show_bug.cgi?id=317820
<rdar://problem/180631575>
Reviewed by Abrar Rahman Protyasha.
<body style="transform: scale(0.75)">
<div style="margin-top: 15.5px; font-size: 17px; text-decoration:
underline">underlined text</div>
</body>
The underline should be one continuous line just below the text. Instead it was
rounded up onto the
text, and text-decoration-skip-ink then chopped it into pieces around the
letters it now overlapped.
CoreGraphics y axis points up while WebKit lays out with y pointing down,
so any destination that paints into a flipped context (scale 1, -1) has a
negative y scale in getCTM().
The snap always rounded toward larger device y, which is down the page (away
from the text)
only when the context is not flipped; in a flipped context that direction
points up, into the text.
Round toward increasing local y regardless of the flip: ceil the device y in an
unflipped context and
floor it in a flipped one, so the line always snaps to the device pixel away
from the text.
* LayoutTests/fast/text/text-decoration-underline-snapping-expected.html: Added.
* LayoutTests/fast/text/text-decoration-underline-snapping.html: Added.
* Source/WebCore/platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText): Snap
the line away from the
text whether or not the destination context flips y.
Canonical link: https://commits.webkit.org/315888@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications