- From: Jeff Schiller <codedread@gmail.com>
- Date: Wed, 20 Jan 2010 15:14:37 -0600
- To: Boris Zbarsky <bzbarsky@mit.edu>
- Cc: Dirk Schulze <vbs85@gmx.de>, www-svg <www-svg@w3.org>
Boris,
I agree with your assertion that when you replace the <use x="X"
y="Y"/> with a <g transform="translate(X,Y)"/> that getBBox() make
sense, since it needs to return in the user-coordinate system of the
element (and the transform is not included in that). I actually agree
with what Firefox, Opera have done from the specification point of
view and think this is a bug on WebKit.
But I'm really just questioning the use of such a thing. What I'm
really after is the bbox of the contents of the <use> in the <use>'s
coordinate system considering the x,y translation. In that respect, I
actually *prefer* what WebKit has done.
I wrote another test case:
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<rect id="r" x="100" y="100" width="200" height="100" fill="red" />
<g id="p">
<g id="guse" transform="translate(200,200)">
<rect id="sr" x="100" y="100" width="200" height="100" fill="red" />
</g>
</g>
<g id="up">
<use id="u" x="200" y="200" width="400" height="200" xlink:href="#r"/>
</g>
<script><![CDATA[
var r = document.getElementById("r"),
p = document.getElementById("p"),
guse = document.getElementById("guse"),
sr = document.getElementById("sr"),
up = document.getElementById("up"),
u = document.getElementById("u");
function bbstr(b) { return [b.x,b.y,b.width,b.height].join(','); }
alert( "r=" + bbstr(r.getBBox()) +
"\np=" + bbstr(p.getBBox()) +
"\nguse=" + bbstr(guse.getBBox()) +
"\nsr=" + bbstr(sr.getBBox()) +
"\nup=" + bbstr(up.getBBox()) +
"\nu=" + bbstr(u.getBBox()));
]]></script>
</svg>
If you try this out on a variety of browsers, you can see that the
bbox for 'up' (the <use>'s parent group) is what I'm really after and
is consistent across all browsers. But why should I have to wrap a
<use> in a <g> just to get at the bbox in that coordinate system when
<use> doesn't even have a transform attribute on it in the first
place? And yes, I know the <use> conceptually does have a @transform
on it...
Ok, I'm done ranting :)
Regards,
Jeff
On Wed, Jan 20, 2010 at 2:45 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>
> 100,100 in which coordinate system?
The root coordinate system :), in my simple case, of course
>
> getBBox says that it works in user coordinates of the node it's called on in
> SVG 1.1. The transform attribute creates a new user coordinate system. If
> the language of http://www.w3.org/TR/SVG11/struct.html#UseElement about "A
> 'use' element has the same visual effect as if the 'use' element were
> replaced by the following generated content:" is taken at face value, then
> Jeff's testcase should have behavior equivalent to:
As you say, the same 'visual effect', but that doesn't talk about the
bbox behavior (and the <use> doesn't actually have a transform on it).
Anyway,
Received on Wednesday, 20 January 2010 21:15:10 UTC