WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 237446
266025
Using setDragImage with html element containing transparency generates incorrect bitmap preview
https://bugs.webkit.org/show_bug.cgi?id=266025
Summary
Using setDragImage with html element containing transparency generates incorr...
Stephen Thompson
Reported
2023-12-07 15:03:22 PST
When using setDragImage and passing it a HTMLElement which has a transparent background. The resulting bitmap preview contains baked in text elements from the underlying page which were not children of the HTMLElement. If the HTMLElement is opaque then the resulting snapshot doesn't contain any text elements from the page. Our HTMLElement has the following styles set before being passed to setDragImage; { position: 'fixed', top: 0, left: 0, zIndex: 2147483647, pointerEvents: 'none', } If the web page contains text near the 0,0 coords within the bounds of the HTMLElement Rect, then that text will be included in the snapshot. This is different behaviour when compared to chrome and firefox. They only take a snapshot of the element, and don't include text from the web page outside the element. This bug can be worked around by offsetting the container negative left by the container width-0.0001px. If we offset by -width then the drag operation will be cancelled which is why we need to leave a fraction of the container still within the viewport bounds.
Attachments
Picture of bug occurring in Safari@17.1
(42.07 KB, image/png)
2023-12-07 19:26 PST
,
alexreardon
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
alexreardon
Comment 1
2023-12-07 19:25:27 PST
Reproduction example:
https://codesandbox.io/s/safari-drag-preview-transparency-bug-2k58pt?file=/src/index.ts:775-889
The fix is also in the example, so you can uncomment it to fix the issue in Safari. ``` // Safari fix const rect = dragPreview.getBoundingClientRect(); dragPreview.style.left = `-${rect.width - 0.0001}px`; ```
alexreardon
Comment 2
2023-12-07 19:26:03 PST
Created
attachment 468936
[details]
Picture of bug occurring in
Safari@17.1
alexreardon
Comment 3
2023-12-07 19:28:00 PST
-
Safari@17.1
→ bug - Chrome@119 → no bug - Firefox@120 → no bug
Radar WebKit Bug Importer
Comment 4
2023-12-07 21:04:02 PST
<
rdar://problem/119355410
>
Abrar Rahman Protyasha
Comment 5
2023-12-07 21:43:42 PST
Thanks for the bug report Stephen! This was originally reported in
https://bugs.webkit.org/show_bug.cgi?id=237446
, so I'll dupe this bug to that. *** This bug has been marked as a duplicate of
bug 237446
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug