Closed Bug 2066045 Opened 2 months ago Closed 2 months ago

MouseEvent.offsetX/Y for SVG <tspan> uses wrong origin

Categories

(Core :: SVG, defect)

Firefox 154
defect

Tracking

()

RESOLVED FIXED
156 Branch
Tracking Status
firefox156 --- fixed

People

(Reporter: seb.p.mueller, Assigned: longsonr)

Details

Attachments

(1 file, 1 external file)

Steps to reproduce:

Open the attached tspan-offset.html.
Move the pointer over RECT, TEXT, and TSPAN.
Compare event.offsetX/Y with coordinates calculated from event.clientX/Y and the outer SVG's getBoundingClientRect().

Actual results:

For <tspan>, Firefox uses a different/local origin, while <text> and ordinary SVG elements remain outer-SVG-relative.

Expected results:

offsetX/Y use the same outer-SVG origin for <tspan> as for <text> and other SVG elements. This is inline with what happens with all other SVG elements in FF and how other UAs implement offsetX/Y

I did some more research (with the help of an agent) and found this in the FF sources:

Event::GetPrimaryFrameOfEventTarget() applies the root-SVG compatibility behavior when the target frame has NS_FRAME_SVG_LAYOUT.

However, Gecko constructs <tspan> using NS_NewInlineFrame. SVG text descendants are tracked separately using NS_FRAME_IS_SVG_TEXT / IsInSVGTextSubtree().

This looks like <tspan> may simply fall through the SVG compatibility special case.

This is the related material that was found during the research - most importantly there is an existing WebCompat report that is still open, that is basically the same report (last):

Relevant specs:
CSSOM View: https://drafts.csswg.org/cssom-view/#dom-mouseevent-offsetx
CSSWG SVG offset discussion: https://github.com/w3c/csswg-drafts/issues/1508
Firefox bug 1684973: https://bugzilla.mozilla.org/show_bug.cgi?id=1684973 (where work was done to harmonize this exact behavior on other SVG elements)
Existing WPT: css/cssom-view/mouseEvent-offsetXY-svg.html (tests rect only, but misses tspan)
Existing WebCompat report showing the same misbehavior for Firefox 124.0.2: https://webcompat.com/issues/135876

The Bugbug bot thinks this bug should belong to the 'Core::SVG' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → SVG
Product: Firefox → Core
Assignee: nobody → longsonr
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

The research was quite helpful, thanks.

Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/62179 for changes under testing/web-platform/tests

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 156 Branch

Upstream PR merged by moz-wptsync-bot

Upstream PR was closed without merging

QA Whiteboard: [qa-triage-done-c157/b156]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: