Chromium Code Reviews| 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 |
| 51 EventTarget* target() const { return m_target.get(); } | 53 EventTarget* target() const { return m_target.get(); } |
| 52 unsigned identifier() const { return m_identifier; } | 54 unsigned identifier() const { return m_identifier; } |
| 53 int clientX() const { return m_clientX; } | 55 double clientX() const { return m_clientPos.x(); } |
|
eae
2014/06/06 16:23:53
You might want to use float here instead to avoid
Rick Byers
2014/06/06 17:02:43
Yeah, this is the public API which we defined in t
| |
| 54 int clientY() const { return m_clientY; } | 56 double clientY() const { return m_clientPos.y(); } |
| 55 int screenX() const { return m_screenX; } | 57 double screenX() const { return m_screenPos.x(); } |
| 56 int screenY() const { return m_screenY; } | 58 double screenY() const { return m_screenPos.y(); } |
| 57 int pageX() const { return m_pageX; } | 59 double pageX() const { return m_pagePos.x(); } |
| 58 int pageY() const { return m_pageY; } | 60 double pageY() const { return m_pagePos.y(); } |
| 59 int webkitRadiusX() const { return m_radiusX; } | 61 double webkitRadiusX() const { return m_radius.width(); } |
| 60 int webkitRadiusY() const { return m_radiusY; } | 62 double webkitRadiusY() const { return m_radius.height(); } |
| 61 float webkitRotationAngle() const { return m_rotationAngle; } | 63 float webkitRotationAngle() const { return m_rotationAngle; } |
| 62 float webkitForce() const { return m_force; } | 64 float webkitForce() const { return m_force; } |
| 63 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } | 65 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } |
| 64 PassRefPtrWillBeRawPtr<Touch> cloneWithNewTarget(EventTarget*) const; | 66 PassRefPtrWillBeRawPtr<Touch> cloneWithNewTarget(EventTarget*) const; |
| 65 | 67 |
| 66 void trace(Visitor*); | 68 void trace(Visitor*); |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 Touch(LocalFrame* frame, EventTarget* target, unsigned identifier, | 71 Touch(LocalFrame* frame, EventTarget* target, unsigned identifier, |
| 70 int screenX, int screenY, int pageX, int pageY, | 72 const FloatPoint& screenPos, const FloatPoint& pagePos, |
| 71 int radiusX, int radiusY, float rotationAngle, float force); | 73 const FloatSize& radius, float rotationAngle, float force); |
| 72 | 74 |
| 73 Touch(EventTarget*, unsigned identifier, int clientX, int clientY, | 75 Touch(EventTarget*, unsigned identifier, const FloatPoint& clientPos, |
| 74 int screenX, int screenY, int pageX, int pageY, | 76 const FloatPoint& screenPos, const FloatPoint& pagePos, |
| 75 int radiusX, int radiusY, float rotationAngle, float force, LayoutPoint absoluteLocation); | 77 const FloatSize& radius, float rotationAngle, float force, LayoutPoint a bsoluteLocation); |
| 76 | 78 |
| 77 RefPtrWillBeMember<EventTarget> m_target; | 79 RefPtrWillBeMember<EventTarget> m_target; |
| 78 unsigned m_identifier; | 80 unsigned m_identifier; |
| 79 int m_clientX; | 81 // Position relative to the viewport in CSS px. |
| 80 int m_clientY; | 82 FloatPoint m_clientPos; |
| 81 int m_screenX; | 83 // Position relative to the screen in DIPs. |
| 82 int m_screenY; | 84 FloatPoint m_screenPos; |
| 83 int m_pageX; | 85 // Position relative to the page in CSS px. |
| 84 int m_pageY; | 86 FloatPoint m_pagePos; |
| 85 int m_radiusX; | 87 // Radius in CSS px. |
| 86 int m_radiusY; | 88 FloatSize m_radius; |
| 87 float m_rotationAngle; | 89 float m_rotationAngle; |
| 88 float m_force; | 90 float m_force; |
| 91 // FIXME(rbyers): Shouldn't we be able to migrate callers to relying on scre enPos, pagePos | |
| 92 // or clientPos? absoluteLocation appears to be the same as pagePos but with out browser | |
| 93 // scale applied. | |
| 89 LayoutPoint m_absoluteLocation; | 94 LayoutPoint m_absoluteLocation; |
| 90 }; | 95 }; |
| 91 | 96 |
| 92 } // namespace WebCore | 97 } // namespace WebCore |
| 93 | 98 |
| 94 #endif /* Touch_h */ | 99 #endif /* Touch_h */ |
| OLD | NEW |