Closed Bug 1426594 Opened 6 years ago Closed 5 years ago

getBoundingClientRect returns the wrong result for an SVG <tspan>

Categories

(Core :: SVG, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla68
Tracking Status
firefox59 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- verified

People

(Reporter: birtles, Assigned: violet.bugreport)

References

Details

Attachments

(7 files)

Attached file Test case
See attached test case which draws a red box over the area returned by getBoundingClientRect() when called in the <tspan> corresponding to DEF in that text run.

This is similar to bug 1052356, but not the same, because in this test case I see incorrect results for a grandchild (the <tspan>), but more-or-less correct results for a child (the <text>) of the root <svg>.
Also, the test case uses Element.getBoundingClientRect() but I see the same result for Range.getBoundingClientRect().
Seems about right for me on Firefox 57 on a Mac.
Attached image Screenshot
This is what I see.

(Sorry about the excessively large screenshot -- still need to find image editing software for this computer.)
What version of Firefox and what Operating System are you on here? Is this a regression at all?
Flags: needinfo?(bbirtles)
Nightly Firefox / Ubuntu 16.04. No idea if it's a regression -- I don't have any other versions of Firefox on this computer.
Flags: needinfo?(bbirtles)
Priority: -- → P3

I couldn't reproduce the bug on Ubuntu with latest Firefox, thus I mark it as WFM. Feel free to modify if anyone has more precise info.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → WORKSFORME

Still reproduces for me on Nightly on Linux.

Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---

That's strange, my test was also on Ubuntu (Ubuntu 18.04) but it's fine. Is it a Ubuntu version problem or some particular setting on your machine?

I'm also on Ubuntu 18.04.2 LTS but the fonts we're getting are clearly different. I'm getting DejaVu Sans but you're getting some sort of serif font. I don't suppose you have any non-standard font settings? I checked mine but couldn't find anything obvious and running on a clean profile I still get DejaVu Sans.

I don't suppose you have any non-standard font settings?

I don't have non-standard settings. But I don't think that's relevant, since I still can't reproduce even if I add font-family: DejaVu Sans; on a new profile with nightly.

Is it possible that your system font was corrupted somehow? Probably we can ask qa to test whether it works on their Ubuntu machine.

Attached image Windows result

I can reproduce on Windows too using Meiryo.

Judging by the offset and dimensions of the misaligned rects, I wonder if it's a simple scaling difference due to display density. Both the Linux and Windows machines I am testing on have high dpi screens.

Assignee: nobody → violet.bugreport
Status: REOPENED → ASSIGNED

We need device pixel, but TransformFramePointToTextChild returns in css pixel,
thus a scaling is necessary.

Pushed by violet.bugreport@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/5c98e7a25bc0
Should convert rect from TransformFramePointToTextChild to device pixel r=longsonr
Status: ASSIGNED → RESOLVED
Closed: 5 years ago5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla68

I just noticed you used the .1f multiplication trick here too. Could you replace that with float() instead please. r=me on that.

(In reply to Robert Longson [:longsonr] from comment #20)

I just noticed you used the .1f multiplication trick here too. Could you replace that with float() instead please. r=me on that.

Ok. Filed a new bug since I've also used that in other places (I personally found it more readable, but it's just some stylistic stuff ...)

Thanks for fixing this. Confirmed that it works for me now!

Flags: qe-verify+

The TestCase works for me, I verified using Firefox 68.0b7 on Win 10 x64, macOS 10.13.6 and Ubuntu 18.04 x64.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: