Closed Bug 528969 Opened 15 years ago Closed 15 years ago

Calling .getBBox() on hidden objects results in exception

Categories

(Core :: SVG, defect)

x86
All
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: cityofay, Unassigned)

Details

Attachments

(1 file)

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.
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.
Can you attach your display:none testcase using the Add an Attachment link above please?
Attached patch patchSplinter Review
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)
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.
Will you raise this with w3c to get the spec changed?
Yes, I've brought this up before actually. We'll be going through the interfaces once we get onto SVG 2.0 for real.
Attachment #412690 - Flags: review?(jwatt)
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.

Attachment

General

Created:
Updated:
Size: