Closed
Bug 479058
Opened 16 years ago
Closed 16 years ago
getBoundingClientRect returns bogus values for SVG elements
Categories
(Core :: SVG, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 530985
People
(Reporter: marcus, Unassigned)
Details
Attachments
(1 file)
|
563 bytes,
application/xml
|
Details |
User-Agent: Mozilla/5.0 (compatible; Konqueror/4.2; Linux) KHTML/4.2.0 (like Gecko)
Build Identifier: Mozilla/5.0 (X11; U; Linux x86_64; sv-SE; rv:1.9.0.6) Gecko/2009020407 Iceweasel/3.0.6 (Debian-3.0.6-1)
When calling getBoundingClientRect on an SVG element, the resulting box object indicates weird values. Usually its width and height are zero, even though the SVG element has positive width and height attributes.
In a more complex case I have also noticed that the returned coordinates may change unpredictably after the DOM is modified by adding some children to the SVG element (without changing the position or size of the SVG element itself). This happens both in Firefox 3.0 and Firefox 3.1 beta 2, but in the latter case the variation was much greater.
Reproducible: Always
| Reporter | ||
Comment 1•16 years ago
|
||
In FF 3.0 and 3.1b2, this produces:
left=8, right=8, top=8, bottom=8
Comment 2•16 years ago
|
||
Please try a current trunk build.
| Reporter | ||
Comment 3•16 years ago
|
||
It may be noted that document.getBoxObjectFor(), in contrast, appears to return sensible values for SVG elements.
| Reporter | ||
Comment 4•16 years ago
|
||
> left=8, right=8, top=8, bottom=8
Same result on Minefield: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2a1pre) Gecko/20090218 Minefield/3.2a1pre
Comment 5•16 years ago
|
||
getBoundingClientRect gets the area covered by SVG graphic shapes e.g. rect, circle, text etc. There are none here so the bounding box is and should be empty.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
Comment 6•16 years ago
|
||
That wasn't how I thought it really worked, so I looked at http://www.w3.org/TR/cssom-view/#the-getclientrects
I think the relevant sentence is "Return a (static) TextRectangleList object containing a list of (static) TextRectangle objects in content order describing the border boxes, *even if they are empty*, for the element on which it was invoked."
Emphasis mine. So the border box of the <svg> element happens to coincide with the edges of the viewport established by the <svg> in this case since it has no 'border' of 'padding' here. So it would seem to me that it should be returning a non-empty rect, no?
Comment 7•16 years ago
|
||
What do you think roc?
You should refer to this version:
http://dev.w3.org/csswg/cssom-view/
See step 2 of getClientRects:
http://dev.w3.org/csswg/cssom-view/#the-getclientrects-and-getboundingclient
I'm not actually sure what the SVG bbox is in these testcases, off the top of my head. If our code disagrees with the cssom-view draft we should fix it, otherwise if you think the current draft is not what authors want, suggest a better way and we'll fix the draft and our code.
Comment 10•16 years ago
|
||
Okay. I don't have the time to look at this atm, so I'll reopen this to make sure I don't forget about it.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Updated•16 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago → 16 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•