Open Bug 306684 Opened 19 years ago Updated 2 years ago

Viewport relative layout of SVG isn't possible in moz

Categories

(Core :: SVG, defect)

defect

Tracking

()

People

(Reporter: jwatt, Unassigned)

References

(Blocks 1 open bug, )

Details

Attachments

(2 files)

It isn't possible for scripts in SVG content to determine the position and size of their viewport, so they can't position or size parts of their image accordingly. For example you may want to put a menu against the right hand side of the viewport. Furthermore if the size of the viewport changes we don't currently dispatch SVGResize events, so content has no way to correct for these changes.
Assignee: general → jonathan.watt
Priority: -- → P1
Summary: Implement SVGSVGElement's viewport attribute → Viewport relative layout of SVG isn't possible in moz
Comment on attachment 198225 [details] [diff] [review] patch to dispatch SVGResize DOM events Oops. I meant SVGResize DOM events of course.
Attachment #198225 - Attachment description: patch to dispatch SVGScroll DOM events → patch to dispatch SVGResize DOM events
Attachment #198225 - Attachment filename: SVGScroll.diff → SVGResize.diff
Attachment #198225 - Flags: review?
Attachment #198225 - Flags: review? → review?(bugmail)
Comment on attachment 198225 [details] [diff] [review] patch to dispatch SVGResize DOM events Don't you want to only dispatch an event if the size actually changes? I wonder if you should dispatch it on a timer, I know we do that for resize events for the top windows. In any event you probably want to keep track of if there currently is an event pending and not dispatch a new one until it has been handled. You should put the refcount stuff in DestroySVGResizePLEvent rather then HandleSVGResizePLEvent. Right now you'll leak the node if you early-return or if the event gets cancled for one reason or the other. Another solution which IMHO is cleaner is to subclass PLEvent and put an nsCOMPtr as member to do the refcounting for you. See for example http://lxr.mozilla.org/mozilla/source/docshell/shistory/src/nsSHEntry.cpp#685
Attachment #198225 - Flags: review?(bugmail) → review-
*** Bug 320268 has been marked as a duplicate of this bug. ***
Priority: P1 → --
Attachment #304109 - Attachment is patch: true
Attachment #304109 - Attachment mime type: application/octet-stream → text/plain
The x/y values there look wrong for the outer case. Not to mention that the !presshell test is backwards.... Might be worth writing some tests for this.
Also, that's not live, but doing that could be hard.
...and the members of the SVGRect should be readonly. *sigh* Why do the x/y values look wrong for the outer case? I think in this case x and y should be the offset of the <svg>'s content area from its bounding box. Isn't that what GetContentRect gives me?
GetContentRect() gives the rect in the coordinate system of the parent frame. So if you have: <span><svg:svg/></span> it'll give coordinates relative to the span. Assuming that http://www.w3.org/TR/SVGMobile12/svgudom.html#svg__SVGSVGElement_viewport is the right thing to be reading, this text looks relevant: If this SVG document is embedded as part of another document (e.g., via the HTML 'object' element), then the position and size are unitless values in the coordinate system of the parent document. (If the parent uses CSS or XSL layout, then unitless values represent pixel units for the current CSS or XSL viewport, as described in the CSS2 specification.) I'm not sure what to make of that next sentence, though: If the parent element does not have a coordinate system, then the user agent should provide reasonable default values for this attribute. Might want to check with the WG...
Oh, that's where you got the "live" from. I was reading it from the SVG 1.1 section (linked in the URL field of this bug) and therefore thought you'd just implied that it was live from the fact that it's readonly. So your description of GetContentRect is how I understood that method to work, I just misinterpreted the spec. I'm actually not sure how to get the offset of an element from its "CSS viewport". Hmm...
Oh. I'd tried to find that text in 1.1 and failed... Thanks for the pointer! So the 1.1 definition seems to be assuming that there is no inline SVG, ever, right? As I see it, there are three cases to look at: 1) <svg> whose parent is an SVG element (inner SVG). There's no problem here, as far as I can tell: use the coordinate system of that parent. Of course Tiny 1.2 doesn't cover this case. 2) <svg> whose parent is not an SVG element (outer SVG, possibly inside a foreignobject). Not sure what the "right" behavior here is. 3) <svg> which is the root element. There's an embedding <object>. Need to look at that <object>s frame or something? It might be worth asking the WG for clarification here just to make sure we're on the right track.
I should also note that it's not clear that the <object> case would support the use case this bug is filed on, if I understand the spec...
Flags: wanted1.9.2+
QA Contact: ian → general
Blocks: 509795
Assignee: jwatt → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: