wpt icon indicating copy to clipboard operation
wpt copied to clipboard

HighlightOverlayPainting: fix ‘text-decoration-skip-ink’

Open chromium-wpt-export-bot opened this issue 3 years ago • 0 comments

Underlines skip descenders when ‘text-decoration-skip-ink’ is ‘auto’, but this relies on NGTextPainter having the correct range to compute the text intercepts over. NGTextPainter is stateful, with a mutable NGTextFragmentPaintInfo that affects things like the calculation of text intercepts for skip ink.

This is generally not a problem, but for highlight painting we break the text fragment into parts, often painting text for one range then decorations for another. This means we might compute text intercepts for the wrong range.

This patch fixes that bug by eliminating the NGTextFragmentPaintInfo field, making functions that need one take it as an argument.

To make it easier to safely slice NGTextFragmentPaintInfo, we add methods to do that while checking that the new range is a subrange of the old range. That way, any guarantees the caller wants to make about the StringView and/or ShapeResultView in the old instance remain true for the new instance (for example, some callers don’t care if there’s a valid ShapeResultView, and sometimes it’s nullptr).

To avoid messy template member functions, we duplicate a small method (PaintDecorationUnderOrOverLine) for legacy, and move two others from TextPainterBase into a new NGTextPainterBase, which contains LayoutNG- specific code shared between NGTextPainter and NGTextCombinePainter.

Fixed: 1350469 Change-Id: Ic51ff58da4e2a80bae2527f7ea90b57b9e361000

Reviewed-on: https://chromium-review.googlesource.com/3820621 WPT-Export-Revision: b75a2fa06b12c21c222f231e9ba39049209a8fea

chromium-wpt-export-bot avatar Aug 10 '22 11:08 chromium-wpt-export-bot