W3C home > Mailing lists > Public > www-svg@w3.org > January 2010

getBBox() on a <use>

From: Jeff Schiller <codedread@gmail.com>
Date: Tue, 19 Jan 2010 21:25:32 -0600
Message-ID: <da131fde1001191925l604c3b66ic656b568711de8b8@mail.gmail.com>
To: www-svg <www-svg@w3.org>
Is the following test case correct:

<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" />
  <use id="u" x="200" y="200" width="400" height="200" xlink:href="#r"/>

  <script><![CDATA[
  	var u = document.getElementById("u"),
  		r = document.getElementById("r"),
  		b = u.getBBox();
  	if (console && console.log) console.log([b.x,b.y,b.width,b.height]);
  	if (b.x == 200 && b.y == 200 && b.width == 400 && b.height == 200) ) {
  		r.setAttribute("fill", "green");
  	}
  ]]></script>
</svg>

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
WebKit :   300, 300, 200, 100 (huh? clearly a bug!)

What's ASV do?
What's IE9 do? :)

Thanks,
Jeff
Received on Wednesday, 20 January 2010 03:26:05 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:44 GMT