Closed
Bug 528969
Opened 15 years ago
Closed 15 years ago
Calling .getBBox() on hidden objects results in exception
Categories
(Core :: SVG, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: cityofay, Unassigned)
Details
Attachments
(1 file)
1.50 KB,
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) AppleWebKit/531.9 (KHTML, like Gecko) Version/4.0.3 Safari/531.9 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2b2) Gecko/20091108 Firefox/3.6b2 Calling .getBBox() on SVG DOM objects hidden with "display:none" results in Firefox throwing an exception. This also happens if a parent object is set to "display:none" as well. Reproducible: Always Steps to Reproduce: 1. Hide an object in the SVG DOM using "display:none". 2. Call .getBBox() on that object or any of it's children. Actual Results: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMSVGLocatable.getBBox]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///Users/Chris/Desktop/Hidden%20BBox/bbox.js :: testBBox :: line 3" data: no] Expected Results: Webkit and Opera both return the bounding box information even if an object is hidden.
Comment 1•15 years ago
|
||
If you want to hide something and get its the bounding box you can make it visibility: hidden instead of display: none.
Additional testing shows that Opera returns the same SVGRect whether "display" is set to "none" or not. Webkit returns a SVGRect with x, y, width and height set to 0 when "display:none" is set. "visibility:hidden" does indeed work. I was using "display:none" because that is what Inkscape uses when it hides objects. However, looking at the W3 recommendation for SVG, it appears that "display:none" should not contribute to the bounding box calculations after all. Should it still throw an exception, or should it return an empty SVGRect as Webkit does.
Comment 3•15 years ago
|
||
Can you attach your display:none testcase using the Add an Attachment link above please?
Comment 4•15 years ago
|
||
Spec says not to throw (http://www.w3.org/TR/SVG/types.html#InterfaceSVGLocatable) so this does what Webkit does.
Assignee: nobody → longsonr
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #412690 -
Flags: review?(jwatt)
Comment 5•15 years ago
|
||
Personally I think it's better to fail with an exception to immediately draw the author's attention to the point of failure. Failing by returning an empty rect makes it more likely the author will spend more time debugging and tracking back to the original point of failure. Of course I'm open to hearing arguments against my reasoning.
Comment 6•15 years ago
|
||
Will you raise this with w3c to get the spec changed?
Comment 7•15 years ago
|
||
Yes, I've brought this up before actually. We'll be going through the interfaces once we get onto SVG 2.0 for real.
Updated•15 years ago
|
Attachment #412690 -
Flags: review?(jwatt)
Comment 8•15 years ago
|
||
We can always reopen this at a later date if necessary.
Assignee: longsonr → nobody
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•