Summary: | [Transforms] event.offsetX and offsetY are wrong for transformed elements | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Simon Fraser (smfr) <simon.fraser> | ||||||||||||
Component: | Layout and Rendering | Assignee: | Simon Fraser (smfr) <simon.fraser> | ||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||
Severity: | Normal | CC: | hyatt, mitz | ||||||||||||
Priority: | P2 | ||||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||
Hardware: | Mac | ||||||||||||||
OS: | OS X 10.5 | ||||||||||||||
Bug Depends on: | 21941 | ||||||||||||||
Bug Blocks: | |||||||||||||||
Attachments: |
|
Description
Simon Fraser (smfr)
2008-10-24 14:32:41 PDT
Created attachment 24653 [details]
Testcase
Note that this breaks some event handling on transformed sliders. 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!
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.
Hmm, I think offsetX/offsetY will be wrong when there is shadow content (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. Comment on attachment 24670 [details]
Patch
It seems like absolutePosition could just be patched rather than adding new code...
Created attachment 24928 [details]
Implement absoluteToLocal, fix event.offsetX/offsetY
Created attachment 24929 [details]
Testcase in the patch
Comment on attachment 24928 [details]
Implement absoluteToLocal, fix event.offsetX/offsetY
r=me (comments given on IRC).
TODO: assert about LayoutState in absoluteToLocal() 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) |