Bug 257811

Summary: Inline-level elements with self-painting layer renders overlapping ellipsis.
Product: WebKit Reporter: Ethan Wong <bunnnywong>
Component: Layout and RenderingAssignee: zalan <zalan>
Status: RESOLVED FIXED    
Severity: Minor CC: bfulgham, bunnnywong, changseok, esprehn+autocc, ews-watchlist, fred.wang, glenn, kondapallykalyan, pdr, simon.fraser, webkit-bug-importer, zalan
Priority: P3 Keywords: InRadar
Version: Safari 16   
Hardware: All   
OS: All   
Attachments:
Description Flags
A case to reproduce this issue
none
Browser comparations of the attached case
none
Patch
none
Patch none

Description Ethan Wong 2023-06-07 09:33:10 PDT
Created attachment 466623 [details]
A case to reproduce this issue

Inline-level elements with self-painting layer (`hasSelfPaintingLayer == true`) may be rendered renders overlapping ellipsis generated by `text-overflow: ellipsis`. 

See the attached case and screenshot. Specifically `position: relative` causes the `<span>` element to be self-painted from the layer.

This issue is caused due to self-painting layer chilldrens being painted in a different flow without the knowledge about its the line layout context. The actual behavior that hides the overflow element happens at `InlineContentPainter::paintDisplayBox(const InlineDisplay::Box&)` when `box.isFullyTruncated() == true`.
Comment 1 Ethan Wong 2023-06-07 09:33:48 PDT
Created attachment 466624 [details]
Browser comparations of the attached case
Comment 2 zalan 2023-06-07 10:00:08 PDT
that's a good catch. so this can be triggered on any self-painting inline level element e.g.

<style>
div {
  width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre;
}
img {
  height: 50px;
  width: 50px;
  background: green;
}
.overflow {
  background: red;
  transform: translateZ(0);
}
</style>
PASS in no red shows.
<div><img><img class=overflow></div>
Comment 3 Ethan Wong 2023-06-07 10:04:49 PDT
Right, the initial issue we discovered in our app was an inline image with `position: relative` being cut in half.
Comment 4 zalan 2023-06-07 10:43:18 PDT
Ethan, are you planning on working on this? (asking because you landed some great fixes in the past and wanted to make sure we don't start working on the same issue).
Comment 5 Ethan Wong 2023-06-07 11:01:36 PDT
(In reply to zalan from comment #4)
> Ethan, are you planning on working on this? (asking because you landed some
> great fixes in the past and wanted to make sure we don't start working on
> the same issue).

I spent some time debugging on this issue but have no idea how to fix it, so I just reported it here.
Comment 6 zalan 2023-06-07 11:05:46 PDT
(In reply to Ethan Wong from comment #5)
> (In reply to zalan from comment #4)
> > Ethan, are you planning on working on this? (asking because you landed some
> > great fixes in the past and wanted to make sure we don't start working on
> > the same issue).
> 
> I spent some time debugging on this issue but have no idea how to fix it, so
> I just reported it here.
Thank you. Looking into it now.
Comment 7 Radar WebKit Bug Importer 2023-06-07 11:06:56 PDT
<rdar://problem/110408920>
Comment 8 zalan 2023-06-07 12:21:08 PDT
Created attachment 466628 [details]
Patch
Comment 9 zalan 2023-06-07 12:21:55 PDT
^^^ fixes the attached test case (I still need to come up with some more cases and include them in this patch).
Comment 10 zalan 2023-06-07 14:54:23 PDT
Created attachment 466630 [details]
Patch
Comment 11 EWS 2023-06-07 21:41:05 PDT
Committed 264973@main (c38822c4ed1c): <https://commits.webkit.org/264973@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 466630 [details].