RESOLVED FIXED 21870
[Transforms] event.offsetX and offsetY are wrong for transformed elements
https://bugs.webkit.org/show_bug.cgi?id=21870
Summary [Transforms] event.offsetX and offsetY are wrong for transformed elements
Simon Fraser (smfr)
Reported 2008-10-24 14:32:41 PDT
event.offsetX and offsetY (which are supposed to be relative to the target element are not computed correctly for transformed elements.
Attachments
Testcase (1.21 KB, text/html)
2008-10-24 14:33 PDT, Simon Fraser (smfr)
no flags
WIP patch (14.09 KB, patch)
2008-10-24 21:30 PDT, Simon Fraser (smfr)
no flags
Patch (14.62 KB, patch)
2008-10-24 23:03 PDT, Simon Fraser (smfr)
hyatt: review-
Implement absoluteToLocal, fix event.offsetX/offsetY (21.23 KB, patch)
2008-11-05 18:03 PST, Simon Fraser (smfr)
hyatt: review+
Testcase in the patch (6.91 KB, text/html)
2008-11-05 18:04 PST, Simon Fraser (smfr)
no flags
Simon Fraser (smfr)
Comment 1 2008-10-24 14:33:02 PDT
Created attachment 24653 [details] Testcase
Simon Fraser (smfr)
Comment 2 2008-10-24 14:34:09 PDT
Note that this breaks some event handling on transformed sliders.
Simon Fraser (smfr)
Comment 3 2008-10-24 21:30:34 PDT
Created attachment 24668 [details] WIP patch Here's a first cut that adds two new methods to RenderObject: + virtual bool objectPointToAbsoluteCoords(FloatPoint&, bool fixed = false) const; + virtual bool absolutePointToObjectCoords(FloatPoint&, bool fixed = false) const; to map points to and from absolute coords, taking transforms into account. Dave, does this look like a reasonable approach? I should note that with this patch, a rotated <input type="range"> works perfectly!
Simon Fraser (smfr)
Comment 4 2008-10-24 23:03:37 PDT
Created attachment 24670 [details] Patch Add two new methods to RenderObject: + virtual bool objectPointToAbsoluteCoords(FloatPoint&, bool fixed = false) const; + virtual bool absolutePointToObjectCoords(FloatPoint&, bool fixed = false) const; which map points between RenderObject and absolute coords taking transforms into account. Factor some RenderBox code into a new offsetFromContainer() method, now called in 3 places. Call absolutePointToObjectCoords() when setting offsetX, offsetY in mouse events. Add some comments, and a convenience expand() method on IntSize.
Simon Fraser (smfr)
Comment 5 2008-10-24 23:05:01 PDT
Hmm, I think offsetX/offsetY will be wrong when there is shadow content
Simon Fraser (smfr)
Comment 6 2008-10-24 23:05:46 PDT
(In reply to comment #5) > Hmm, I think offsetX/offsetY will be wrong when there is shadow content No, it's OK. MouseRelatedEvent::receivedTarget() gets the renderer from the target element.
Dave Hyatt
Comment 7 2008-10-27 12:08:33 PDT
Comment on attachment 24670 [details] Patch It seems like absolutePosition could just be patched rather than adding new code...
Simon Fraser (smfr)
Comment 8 2008-11-05 18:03:55 PST
Created attachment 24928 [details] Implement absoluteToLocal, fix event.offsetX/offsetY
Simon Fraser (smfr)
Comment 9 2008-11-05 18:04:31 PST
Created attachment 24929 [details] Testcase in the patch
Dave Hyatt
Comment 10 2008-11-06 10:12:40 PST
Comment on attachment 24928 [details] Implement absoluteToLocal, fix event.offsetX/offsetY r=me (comments given on IRC).
Simon Fraser (smfr)
Comment 11 2008-11-06 10:15:26 PST
TODO: assert about LayoutState in absoluteToLocal()
Simon Fraser (smfr)
Comment 12 2008-11-06 10:42:47 PST
Committed r38186 M WebCore/rendering/RenderObject.cpp M WebCore/rendering/RenderTableCell.cpp M WebCore/rendering/RenderBox.h M WebCore/rendering/RenderObject.h M WebCore/rendering/RenderBox.cpp M WebCore/rendering/RenderView.cpp M WebCore/rendering/RenderView.h M WebCore/rendering/RenderTableCell.h M WebCore/dom/MouseRelatedEvent.cpp M WebCore/ChangeLog M LayoutTests/ChangeLog A LayoutTests/fast/events/offsetX-offsetY.html A LayoutTests/fast/events/offsetX-offsetY-expected.txt r38186 = 845c2633f46b1eaecab8595b53b2a1cdfb06b7e2 (trunk)
Note You need to log in before you can comment on or make changes to this bug.