This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The initMouseEvent() method from DOM L3 Events allows for the creation of synthetic mouse events [1]. However, it seems it was defined prior to the existence/standardization of the extensions to MouseEvent [2]. For compatibility reasons, we don't believe we can change the signature of initMouseEvent() to include properties like pageX/pageY. Instead, we suggest calculating these values based on the inputs provided for clientX/clientY. This seems to be what Webkit (and to some extent, Firefox) do. pageX = clientX + scrollLeft (using the values at the time of calling initMouseEvent) pageY = clientY + scrollTop x = clientX y = clientY Prior to calling dispatchEvent() (which indicates a target element for the event)" offsetX = pageX offsetY = pageY After calling dispatchEvent() (e.g. during and after the dispatch of the event): offsetX = the x offset relative to the padding edge of the target element (as reported in the element's coordinate space) offsetY = the y offset relative to the padding edge of the target element (as reported in the element's coordinate space) [1]http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html#events-event-type-initMouseEvent [2]http://dev.w3.org/csswg/cssom-view/#extensions-to-the-mouseevent-interface
reassign to myself; apparently i am not the default assignee for this component
(In reply to comment #0) > pageX = clientX + scrollLeft (using the values at the time of calling > initMouseEvent) > pageY = clientY + scrollTop scrollLeft and scrollTop of what? Do you have test cases in this area I can look at?
Created attachment 1373 [details] Test case for synthetic event pageX/pageY calculation...
In IE/Firefox, this appears to be the scrollLeft/Top of the documentElement (HTML). Chrome's scrollLeft/top for the viewport are on body, but regardless, Chrome does not seem to do this pageX/pageY calculation on dispatch. Attachment included.
Thanks! https://dvcs.w3.org/hg/csswg/rev/39af9667776a
The fix here seems to have caused some other problems, see https://bugzilla.mozilla.org/show_bug.cgi?id=1203404
That's because the fix here didn't match the behavior description in comment 0. From comment 0 again: Prior to calling dispatchEvent() (which indicates a target element for the event)" offsetX = pageX After calling dispatchEvent() (e.g. during and after the dispatch of the event): offsetX = the x offset relative to the padding edge of the target element (as reported in the element's coordinate space) The behavior in the spec doesn't do "during and after the dispatch". It just does "during the dispatch", and goes back to "pageX" after the dispatch.