- From: Thierry Kormann <tkormann@ilog.fr>
- Date: Fri, 11 Jan 2002 06:02:58 -0500 (EST)
- To: www-svg@w3.org
- Cc: www-dom@w3.org
ISSUE: clientX and clientY coordinates in DOM MouseEvents This following issue has been reported by Alex Fritze. I think this is a real problem so I reported this issue as an official one to the SVG WG and the DOM WG. --- The DOM Level 2 specification defines two attributes clientX and clientY for MouseEvents. According to the DOM Level 2 specification, those coordinates are relative to the DOM Implementation's client area. The SVG specification has changed this definition and the clientX and clientY attributes represents viewport coordinates for the coresponding svg element. In a multiple namespaces environment (such as mixing xhtml and svg for example), there is a conflict with the two definitions above. ex: <html:div id="A"> <svg:svg id="B" viewBox="0 0 10000 10000"> <svg:circle id="C" /> ... </svg:svg> </html:div> In that example, according to the DOM spec, clientX and clientY should be relative to DOM Implementation's client area (i.e. the user agent area used to display the whole DOM tree). According to the SVG spec, if a mouse event occured on B or C, clientX and clientY should be relative to the viewport ([0, 0] [10000, 10000]) and this is not what the DOM spec says. The DOM specification clearly says that whatever the EventTarget is, clientX and clientY must be relative to the user agent drawing area. Having the correct behavior for both SVG and DOM is only possible in a plugin environment (two separate DOM tree - two different user agent). RECOMMENDATION: [A] Ask the DOM WG to errate the DOM Level 2 Events module and change the DOM Level 3 Events module saying something like: clientX - The horizontal coordinate at which the event occured relative to coordinate system of the EventTarget. clientY - The horizontal coordinate at which the event occured relative to coordinate system of the EventTarget. Advantage: that will not break any existing SVG content and should work with all existing XML applications that have only one coordinate system: the user agent area's one. Note: Some extra work will be necessary if both informations are needed (mouse coordinates in the EventTarget's coordinate system and in the user agent's area coordinate system) and I believe that both are usefull. [B] Add an errata to the SVG1.0 spec explaining that clientX and clientY have the same behavior than in the DOM specification (and that will break existing SVG content using clientX and clientY - that's to say, most of the dynamic SVG content using scripting). Ask the DOM WG to add two new coordinates 'viewportX' and 'viewportY' to the MouseEvent interface in the DOM Level 3 Events module. SVG1.1 will have to rely on that module. - viewportX The horizontal coordinate at which the event occured relative to coordinate system of the EventTarget. - viewportY The vertical coordinate at which the event occured relative to coordinate system of the EventTarget. Any comments? Thierry.
Received on Friday, 11 January 2002 11:24:25 UTC