Click event not fired on the parent element if the click is within its child <object> element
Categories
(Core :: DOM: Events, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox131 | --- | fixed |
People
(Reporter: ksenia, Assigned: emilio)
References
Details
(Keywords: webcompat:platform-bug)
Attachments
(4 files)
We've got a report in bug1905278, where a popup is not triggered when clicking on licence plates.
I've attached a reduced test case. Looks like the click event is not fired on the parent element (.plateCont
) if the click is within its child <object> element (it works if I click outside of the image within the blue border).
It is fired in both Chrome and Safari, but not in Firefox. Not sure which behaviour is correct, so filing this bug to track the difference.
Reporter | ||
Updated•6 months ago
|
Comment 3•6 months ago
|
||
It seems that an image of <object>
is loaded like as a image document in <iframe>
. So, that creates a document boundary, thus events in it are isolated from the parent document.
Smaug, do you know why did we implement <object>
as so rather than like an <img>
? And do you know who can handle this?
Comment 4•6 months ago
|
||
You'd need to set pointer-events: none; on the object so it doesn't swallow the events. SVG within <object> rather relies on that.
Comment 5•6 months ago
|
||
Didn't bug 1595491 change the behavior here.
Comment 6•6 months ago
|
||
Comment 7•6 months ago
|
||
Chrome with an iframe behaves the same as Firefox and the same as Firefox does for the object tag.
Comment 8•6 months ago
|
||
https://issues.chromium.org/issues/41286601 and https://issues.chromium.org/issues/40740247 may be relevant on the Chrome side
Comment 9•6 months ago
•
|
||
nsSubDocumentFrame::BuildDisplayList could check if the relevant browsing context is for image document. I think BrowsingContext::GetSyntheticDocumentContainer() could work there.
Hmm, focus handling is still unclear.
Reporter | ||
Comment 10•6 months ago
|
||
(In reply to Robert Longson [:longsonr] from comment #4)
You'd need to set pointer-events: none; on the object so it doesn't swallow the events. SVG within <object> rather relies on that.
I'll add an intervention with pointer-events: none;
for the affected site for now.
Updated•6 months ago
|
Comment 11•6 months ago
|
||
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #9)
nsSubDocumentFrame::BuildDisplayList could check if the relevant browsing context is for image document. I think BrowsingContext::GetSyntheticDocumentContainer() could work there.
Hmm, focus handling is still unclear.
I poked around a bit, and it doesn't seem to be that easy. We also have mIsInObjectOrEmbed
that one could inspect but neither that nor the browsing context has the data expected. This is a hard requirement for ORB, which is what was introduced in:
(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #5)
Didn't bug 1595491 change the behavior here.
We load images in a synthetic document that has the same origin as the image to ensure that it isn't possible to start loading arbitrary data into an object or embed element.
I'm guessing that Emilio is the one that would know more?
Assignee | ||
Comment 12•6 months ago
|
||
This seems to work and seems fairly straight-forward.
Updated•6 months ago
|
Assignee | ||
Comment 13•6 months ago
|
||
I'm confused, the object element should have all the info, right? A quick patch seems to work, if that seems reasonable I can write a test...
Assignee | ||
Updated•6 months ago
|
Comment 14•6 months ago
|
||
(In reply to Emilio Cobos Álvarez (:emilio) from comment #13)
I'm confused, the object element should have all the info, right? A quick patch seems to work, if that seems reasonable I can write a test...
\o/
Yeah, this is exactly what I expect. It's my understanding of nsSubDocumentFrame that's lacking, thanks Emilio!
Comment 15•6 months ago
|
||
Comment 18•6 months ago
|
||
bugherder |
Description
•