Bug 230335

Summary: Multi-line text clipped to its background is painted in the wrong place
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: Layout and RenderingAssignee: Myles C. Maxfield <mmaxfield>
Status: NEW ---    
Severity: Normal CC: bfulgham, changseok, clopez, esprehn+autocc, ews-watchlist, glenn, kondapallykalyan, ntim, pdr, simon.fraser, webkit-bug-importer, youennf, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://github.com/web-platform-tests/wpt/pull/30812
Attachments:
Description Flags
Patch
none
Patch none

Description Myles C. Maxfield 2021-09-15 22:28:35 PDT
Multi-line text clipped to its background is painted in the wrong place
Comment 1 Myles C. Maxfield 2021-09-15 22:29:59 PDT
Created attachment 438317 [details]
Patch
Comment 2 Myles C. Maxfield 2021-09-15 22:30:02 PDT
<rdar://problem/59928689>
Comment 3 EWS Watchlist 2021-09-15 22:31:56 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 4 Myles C. Maxfield 2021-09-16 15:21:07 PDT
Created attachment 438405 [details]
Patch
Comment 5 zalan 2021-09-17 13:54:47 PDT
Comment on attachment 438405 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=438405&action=review

> Source/WebCore/rendering/LegacyInlineFlowBox.cpp:1215
> -            for (auto* curr = prevLineBox(); curr; curr = curr->prevLineBox())
> +            for (auto* curr = previousOnLine(); curr; curr = curr->previousOnLine())

I don't really know how this fill layer painting is supposed to work but according to the comment a few lines above, we are trying to form a long "strip" here. This strip includes the entire inline box (<span> in this case) with all its fragments spanning across multiple lines, if applicable. e.g <b>first line</b><span>still first line<br>second line</span>, would form 3 lines boxes across the 2 lines, one for the <b> and 2 for the <span>. When we are on the second line, the loop with prevLineBox() would collect the second line box from the first line (which belongs to the same inline box, <span> in this case). Then we offset the stripX with the logicalOffsetOnLine value potentially producing a negative starting point. The logical right of this strip should still fully include the current line box though. Not sure why we do this, but that's what the comment describes above. Now with your change we stop collecting the fragments from the previous line(s) (though interestingly we still do it for the next line(s) in the subsequent loop). If that's the desired behavior the comment should be updated accordingly. However previousOnLine() crosses the inline box boundary (as it walks all the boxes on the line) so our offset again would be incorrect if there was a previous content on the line (see the example above). I haven't tried this but it looks to be working only when the inline box starts at the logical left of the line.