[Webkit-unassigned] [Bug 42815] getBoundingClientRect Broken for SVG Elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jul 22 04:18:30 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=42815





--- Comment #1 from Nikolas Zimmermann <zimmermann at kde.org>  2010-07-22 04:18:30 PST ---
getBoundingClientRect() operates on RenderBoxModelObjects, see:

PassRefPtr<ClientRect> Element::getBoundingClientRect() const
{
    document()->updateLayoutIgnorePendingStylesheets();
    RenderBoxModelObject* renderBoxModelObject = this->renderBoxModelObject();

This will always be zero for SVG elements. I was not aware of this method to retrieve the bounding box of a SVG element, as SVG provides it's own getBBox() function.

Just reading http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclient, which says:

If the element does not have an associated CSS layout box and is in the http://www.w3.org/2000/svg namespace return a ClientRectList object containing a single ClientRect object that describes the bounding box of the element as defined by SVG specification. [SVG]

So it might be as easy as:
if (isSVGElement()) {
    SVGElement* svgElement = static_cast<SVGElement*>(this);
    if (svgElement->isStyledLocatable())
        return ClientRect::create(static_cast<SVGStyledLocatableElement*>(svgElement)->getBBox());
}

Just noticed that ClientRect stores a FloatRect internally, but only has an IntRect constructor, so after adding a ClientRect(const FloatRect&) constructor, the code above should work as is.

Someone interessted in implementing? I'm quite busy atm.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list