[Webkit-unassigned] [Bug 27183] REGRESSION: SVG mouse event clientX/Y transformations to SVG space broken using screen CTM

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 23 11:29:57 PDT 2009


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





--- Comment #5 from Glenn Brauen <gbrauen at connect.carleton.ca>  2009-09-23 11:29:57 PDT ---
Created an attachment (id=40007)
 --> (https://bugs.webkit.org/attachment.cgi?id=40007)
SVG file showing workaround

I have attached an SVG file showing a workaround to this bug.  The difference
is shown below and can be summarized as follows:

- The Coordinate Transformation Matrix (CTM) returned by
document.documentElement.getScreenCTM() is wrong.
- Separately applying document.documentElement.currentTranslate,
document.documentElement.currentScal, and a CTM computed from the event target
to the SVG root node produces the correct transformation of the event
clientX/clientY coordinates.

diff ScreenCoordinates.svg ScreenCoordinates_workaround.svg
8a9,16
> 
>       function computeCumulativeCTMFromRoot(el, svgNode) {
>               var ctm = el.getCTM();
>               while ((el = el.parentNode) != svgNode) {
>                       ctm = el.getCTM().multiply(ctm);
>               }
>               return(ctm);
>       }
12c20,21
<                * Apply screen CTM transformation to the evt screenX and
screenY to convert the event
---
>                * Apply screen translate, scale and a CTM transformation
>                * computed from the event target up to the enclosing SVG node to convert the event
16c25,27
<               var m = document.documentElement.getScreenCTM();
---
>               var trans = evt.target.ownerDocument.documentElement.currentTranslate;
>               var scale = evt.target.ownerDocument.documentElement.currentScale;
>               var m = computeCumulativeCTMFromRoot(evt.target, document.getElementById("main"));
18,19c29,30
<               p.x = evt.clientX;
<               p.y = evt.clientY; 
---
>               p.x = (evt.clientX - trans.x) / scale;
>               p.y = (evt.clientY - trans.y) / scale;
20a32
>

-- 
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