OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008, The Android Open Source Project | 2 * Copyright 2008, The Android Open Source Project |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef Touch_h | 26 #ifndef Touch_h |
27 #define Touch_h | 27 #define Touch_h |
28 | 28 |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/events/EventTarget.h" | 30 #include "core/events/EventTarget.h" |
| 31 #include "platform/geometry/FloatPoint.h" |
| 32 #include "platform/geometry/FloatSize.h" |
31 #include "platform/geometry/LayoutPoint.h" | 33 #include "platform/geometry/LayoutPoint.h" |
32 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
33 #include "wtf/PassRefPtr.h" | 35 #include "wtf/PassRefPtr.h" |
34 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
35 #include "wtf/RefPtr.h" | 37 #include "wtf/RefPtr.h" |
36 | 38 |
37 namespace WebCore { | 39 namespace WebCore { |
38 | 40 |
39 class LocalFrame; | 41 class LocalFrame; |
40 | 42 |
41 class Touch FINAL : public RefCountedWillBeGarbageCollectedFinalized<Touch>, pub
lic ScriptWrappable { | 43 class Touch FINAL : public RefCountedWillBeGarbageCollectedFinalized<Touch>, pub
lic ScriptWrappable { |
42 public: | 44 public: |
43 static PassRefPtrWillBeRawPtr<Touch> create(LocalFrame* frame, EventTarget*
target, | 45 static PassRefPtrWillBeRawPtr<Touch> create(LocalFrame* frame, EventTarget*
target, |
44 unsigned identifier, int screenX, int screenY, int pageX, int pageY, | 46 unsigned identifier, const FloatPoint& screenPos, const FloatPoint& page
Pos, |
45 int radiusX, int radiusY, float rotationAngle, float force) | 47 const FloatSize& radius, float rotationAngle, float force) |
46 { | 48 { |
47 return adoptRefWillBeNoop(new Touch(frame, target, identifier, screenX, | 49 return adoptRefWillBeNoop( |
48 screenY, pageX, pageY, radiusX, radiusY, rotationAngle, force)); | 50 new Touch(frame, target, identifier, screenPos, pagePos, radius, rot
ationAngle, force)); |
49 } | 51 } |
50 | 52 |
| 53 // DOM Touch implementation |
51 EventTarget* target() const { return m_target.get(); } | 54 EventTarget* target() const { return m_target.get(); } |
52 unsigned identifier() const { return m_identifier; } | 55 unsigned identifier() const { return m_identifier; } |
53 int clientX() const { return m_clientX; } | 56 double clientX() const { return m_clientPos.x(); } |
54 int clientY() const { return m_clientY; } | 57 double clientY() const { return m_clientPos.y(); } |
55 int screenX() const { return m_screenX; } | 58 double screenX() const { return m_screenPos.x(); } |
56 int screenY() const { return m_screenY; } | 59 double screenY() const { return m_screenPos.y(); } |
57 int pageX() const { return m_pageX; } | 60 double pageX() const { return m_pagePos.x(); } |
58 int pageY() const { return m_pageY; } | 61 double pageY() const { return m_pagePos.y(); } |
59 int webkitRadiusX() const { return m_radiusX; } | 62 double webkitRadiusX() const { return m_radius.width(); } |
60 int webkitRadiusY() const { return m_radiusY; } | 63 double webkitRadiusY() const { return m_radius.height(); } |
61 float webkitRotationAngle() const { return m_rotationAngle; } | 64 float webkitRotationAngle() const { return m_rotationAngle; } |
62 float webkitForce() const { return m_force; } | 65 float webkitForce() const { return m_force; } |
| 66 |
| 67 // Blink-internal methods |
63 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } | 68 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } |
| 69 const FloatPoint& screenLocation() const { return m_screenPos; } |
64 PassRefPtrWillBeRawPtr<Touch> cloneWithNewTarget(EventTarget*) const; | 70 PassRefPtrWillBeRawPtr<Touch> cloneWithNewTarget(EventTarget*) const; |
65 | 71 |
66 void trace(Visitor*); | 72 void trace(Visitor*); |
67 | 73 |
68 private: | 74 private: |
69 Touch(LocalFrame* frame, EventTarget* target, unsigned identifier, | 75 Touch(LocalFrame* frame, EventTarget* target, unsigned identifier, |
70 int screenX, int screenY, int pageX, int pageY, | 76 const FloatPoint& screenPos, const FloatPoint& pagePos, |
71 int radiusX, int radiusY, float rotationAngle, float force); | 77 const FloatSize& radius, float rotationAngle, float force); |
72 | 78 |
73 Touch(EventTarget*, unsigned identifier, int clientX, int clientY, | 79 Touch(EventTarget*, unsigned identifier, const FloatPoint& clientPos, |
74 int screenX, int screenY, int pageX, int pageY, | 80 const FloatPoint& screenPos, const FloatPoint& pagePos, |
75 int radiusX, int radiusY, float rotationAngle, float force, LayoutPoint
absoluteLocation); | 81 const FloatSize& radius, float rotationAngle, float force, LayoutPoint a
bsoluteLocation); |
76 | 82 |
77 RefPtrWillBeMember<EventTarget> m_target; | 83 RefPtrWillBeMember<EventTarget> m_target; |
78 unsigned m_identifier; | 84 unsigned m_identifier; |
79 int m_clientX; | 85 // Position relative to the viewport in CSS px. |
80 int m_clientY; | 86 FloatPoint m_clientPos; |
81 int m_screenX; | 87 // Position relative to the screen in DIPs. |
82 int m_screenY; | 88 FloatPoint m_screenPos; |
83 int m_pageX; | 89 // Position relative to the page in CSS px. |
84 int m_pageY; | 90 FloatPoint m_pagePos; |
85 int m_radiusX; | 91 // Radius in CSS px. |
86 int m_radiusY; | 92 FloatSize m_radius; |
87 float m_rotationAngle; | 93 float m_rotationAngle; |
88 float m_force; | 94 float m_force; |
| 95 // FIXME(rbyers): Shouldn't we be able to migrate callers to relying on scre
enPos, pagePos |
| 96 // or clientPos? absoluteLocation appears to be the same as pagePos but with
out browser |
| 97 // scale applied. |
89 LayoutPoint m_absoluteLocation; | 98 LayoutPoint m_absoluteLocation; |
90 }; | 99 }; |
91 | 100 |
92 } // namespace WebCore | 101 } // namespace WebCore |
93 | 102 |
94 #endif /* Touch_h */ | 103 #endif /* Touch_h */ |
OLD | NEW |