[webkit-dev] Mouse event position related to actual element content
byelozyorov at cs.uni-saarland.de
Thu Mar 3 04:50:32 PST 2011
I develop an extension to WebKit which adds support for
For mouse events on XML3D element I have created custom event type
XML3DMouseEvent that inherits from MouseEvent. In addition to normal
coordinates it also has 3D position and normal of the element under the
cursor. In order to avoid massive changes into WebKit I have decided to
convert existing event from MouseEvent into XML3DMouseEvent when going
though overloaded XML3DElement::dispatchEvent which allows me to create
custom event class only for XML3D elements.
There I also need to perform picking again to actually receive normal and
position. However at this stage I don't have actual coordinates where mouse
was relative to the actual rendered image (line x, y, tx and ty in
RenderObject::nodeAtPoint). All I get is MouseEvent with all it's parameters
and the element itself.
Originally I tried using pageX and pageY and deducted offsetTop and
offsetLeft from them, but this does not take borders and padding into
account. I have tried accessing computedStyle to get border and padding
width, but the value in there has type Length and I am not sure how to
convert it to actual pixels.
Please let me know how can mouse event position relative to element content
(not to border or padding). If there is a nicer and more straitforward way
to implement XML3DMouseEvent I would be happy to hear them.
Computer Graphics Chair
Universitat des Saarlandes
Tel.: +49 (681) 302-3837
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the webkit-dev