Re: getBBox() on a <use>

On 1/19/10 10:25 PM, Jeff Schiller wrote:
> In other words, shouldn't the bbox of a<use>  element be defined by
> its x,y,width,height just like a<rect>  or an<image>  ?  No browser
> gives consistent results:
>
> Firefox  :  100, 100, 200, 100
> Opera   :  100, 100, 200, 100

Those seem somewhat consistent to me.... ;)


> WebKit :   300, 300, 200, 100 (huh? clearly a bug!)
>
> What's ASV do?
> What's IE9 do? :)

Here's what SVG 1.1 currently says (at 
http://www.w3.org/TR/SVG11/types.html#InterfaceSVGLocatable ):

  getBBox
      Returns the tight bounding box in current user space (i.e.,
      after application of the transform attribute, if any) on the
      geometry of all contained graphics elements, exclusive of
      stroke-width and filter effects).

Note that this is subtly different from what SVG Tiny 1.2 uDOM says (at 
http://www.w3.org/TR/SVGMobile12/coords.html#BoundingBox ):

   The bounding box (or "bbox") of an element is the tightest fitting
   rectangle aligned with the axes of that element's user coordinate
   system  that entirely encloses it and its descendants.

Looks to me like Gecko and Opera are implementing what SVG 1.1 says.

That said, what would you expect to see if you used <g> instead of 
<use>?  http://www.w3.org/TR/SVG/struct.html#UseElement has this to say:

   A 'use' element has the same visual effect as if the 'use' element
   were replaced by the following generated content:

...

   # Otherwise:
     In the generated content, the 'use' will be replaced by 'g',
     where all attributes from the 'use' element except for x, y,
     width, height and xlink:href are transferred to the generated
    'g' element. An additional transformation translate(x,y) is
     appended to the end (i.e., right-side) of the transform
     attribute on the generated 'g', where x and y represent the
     values of the x and y attributes on the 'use' element.

whatever that means in terms of DOM APIs, since this is talking about 
"visual effect"...

I agree that things are not exactly clear here.

-Boris

Received on Wednesday, 20 January 2010 05:10:25 UTC