Closed Bug 1909584 Opened 6 months ago Closed 6 months ago

Click event not fired on the parent element if the click is within its child <object> element

Categories

(Core :: DOM: Events, defect)

defect

Tracking

()

RESOLVED FIXED
131 Branch
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.

Blocks: 1905278

Could you attach the test case?

Flags: needinfo?(kberezina)
Attached file 1905278.html

Oh sorry, attaching.

Flags: needinfo?(kberezina)

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?

Flags: needinfo?(smaug)
Attached file fixed testcase

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.

Didn't bug 1595491 change the behavior here.

Flags: needinfo?(smaug) → needinfo?(afarre)

Chrome with an iframe behaves the same as Firefox and the same as Firefox does for the object tag.

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.

(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.

Assignee: nobody → afarre
Severity: -- → S3
Status: NEW → ASSIGNED
Flags: needinfo?(afarre)

(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: afarre → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(emilio)

This seems to work and seems fairly straight-forward.

Assignee: nobody → emilio
Status: NEW → ASSIGNED

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: emilio → nobody
Status: ASSIGNED → NEW
Flags: needinfo?(emilio)
Assignee: nobody → emilio

(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!

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/db0d69dbd62b Don't propagate clicks into synthetic image documents. r=farre
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47511 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 131 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: