[Webkit-unassigned] [Bug 71819] New: getBoundingClientRect() yields global coordinates for XHTML elements embedded in SVG

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Nov 8 08:11:00 PST 2011


           Summary: getBoundingClientRect() yields global coordinates for
                    XHTML elements embedded in SVG
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: All
               URL: http://phrogz.net/SVG/getBoundingClientRect.svg
        OS/Version: All
            Status: UNCONFIRMED
          Severity: Major
          Priority: P2
         Component: SVG
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: gavin at phrogz.net
                CC: zimmermann at kde.org

Created an attachment (id=114073)
 --> (https://bugs.webkit.org/attachment.cgi?id=114073&action=review)
Test case with four foreignObjects in an SVG and displaying script output

Given an SVG document with XHTML content embedded via <foreignObject>, the getBoundingClientRect() method should return the coordinates of the element with respect to foreignObject's coordinate space. Instead, it currently is returning the bounding box for object transformed into the web browser viewport.

In the attachment (or hosted URL) the return value for getBoundingClientRect() should be the same for all four cases, always showing: {left:0, top:0, right:16, bottom:16}.

The CSSOM View Module spec[1] for getBoundingClientRect() says:

> The getClientRects() and getBoundingClientRect() methods provide information about the
> position of the border box edges of an element relative to the viewport.

…and elsewhere[2] explicitly defines _viewport_ as:

> [...] defined by CSS 2.1 unless there is an ancestor `foreignObject` element in the
> http://www.w3.org/2000/svg namespace in which case that element acts as viewport and
> initial containing block.

The current behavior is understandable, as it makes code like this[3] work more easily.
However the current behavior is
* …wrong, per the spec
* …different from Firefox v7 (which gets this right), and
* …less useful than the spec (scripter transformations can identify all four real screen
  corners of a rotated object, not the screen-aligned bounding box).

[1] http://www.w3.org/TR/cssom-view/#the-getclientrects-and-getboundingclientrect-methods
[2] http://www.w3.org/TR/cssom-view/#terminology
[3] http://phrogz.net/SVG/html_location_in_svg.svg

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