Closed Bug 755187 Opened 12 years ago Closed 10 years ago

External stylesheet in SVG interferes with object sizing

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: birtles, Unassigned)

References

Details

Attachments

(5 files)

If an <object> element references an SVG file without specifying a width/height we use the intrinsic size of the SVG file which may be specified by the width/height attributes on the root <svg> element.

However, if the referenced SVG file contains an external stylesheet such as:

  <?xml-stylesheet href="style.css" type="text/css"?>

Then we appear to give up that process. Perhaps we have some limit to how far we read into the file to get the width and height?

Testcase forthcoming.
With the attached test case, two SVG files are referenced using <object> elements without width/height specified.

The two SVG files are identical except that the second one includes an <?xml-stylesheet?> PI that causes the circle to be blue.

Expected behaviour: The two circles have the same size

Actual behaviour: The circle with the stylesheet (the blue one) is smaller
How do we ask for the intrinsic size?  Are we asking the DOM, or layout?  The stylesheet load there may well block layout, but shouldn't block DOM construction, iirc...
I had a brief look into this but haven't got to the bottom of it yet. The intrinsic size is calculated in layout (nsSVGOuterSVGFrame) but it doesn't seem to get called for the SVG with the stylesheet.
CC'ing jwatt since he left comments in nsSVGOuterSVGFrame::GetIntrinsicSize :)

I had a quick look and basically, nsSubDocumentFrame::ObtainIntrinsicSizeFrame will return null for the case when we have an external stylesheet since nsIPresShell::GetRootScrollFrameAsScrollable returns null.

Looking at nsSVGOuterSVGFrame::GetIntrinsicSize, it seems like it should be possible to calculate the intrinsic size by just querying the DOM as noted by Boris. The exception being when width/height are specified by style (as noted by jwatt in the comment there).
Fixed by bug 1063073
Blocks: 1063073
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: