Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(512)

Side by Side Diff: third_party/WebKit/Source/core/dom/Touch.h

Issue 2507503002: Use touch events to report stylus events (Closed)
Patch Set: fixed unit test Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
28 28
29 #include "bindings/core/v8/ScriptWrappable.h" 29 #include "bindings/core/v8/ScriptWrappable.h"
30 #include "core/CoreExport.h" 30 #include "core/CoreExport.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/dom/TouchInit.h" 32 #include "core/dom/TouchInit.h"
33 #include "core/events/EventTarget.h" 33 #include "core/events/EventTarget.h"
34 #include "platform/geometry/FloatPoint.h" 34 #include "platform/geometry/FloatPoint.h"
35 #include "platform/geometry/FloatSize.h" 35 #include "platform/geometry/FloatSize.h"
36 #include "platform/geometry/LayoutPoint.h" 36 #include "platform/geometry/LayoutPoint.h"
37 #include "platform/heap/Handle.h" 37 #include "platform/heap/Handle.h"
38 #include "public/platform/WebPointerProperties.h"
38 39
39 namespace blink { 40 namespace blink {
40 41
41 class LocalFrame; 42 class LocalFrame;
42 43
43 class CORE_EXPORT Touch final : public GarbageCollectedFinalized<Touch>, 44 class CORE_EXPORT Touch final : public GarbageCollectedFinalized<Touch>,
44 public ScriptWrappable { 45 public ScriptWrappable {
45 DEFINE_WRAPPERTYPEINFO(); 46 DEFINE_WRAPPERTYPEINFO();
46 47
47 public: 48 public:
48 static Touch* create(LocalFrame* frame, 49 static Touch* create(LocalFrame* frame,
49 EventTarget* target, 50 EventTarget* target,
50 int identifier, 51 int identifier,
51 const FloatPoint& screenPos, 52 const FloatPoint& screenPos,
52 const FloatPoint& pagePos, 53 const FloatPoint& pagePos,
53 const FloatSize& radius, 54 const FloatSize& radius,
54 float rotationAngle, 55 float rotationAngle,
55 float force, 56 float force,
56 String region) { 57 String region) {
57 return new Touch(frame, target, identifier, screenPos, pagePos, radius, 58 WebPointerProperties properties;
58 rotationAngle, force, region); 59 properties.id = identifier;
60 properties.force = force;
61 return new Touch(frame, target, screenPos, pagePos, radius, rotationAngle,
62 region, properties);
59 } 63 }
60 64 static Touch* create(LocalFrame* frame,
65 EventTarget* target,
66 const FloatPoint& screenPos,
67 const FloatPoint& pagePos,
68 const FloatSize& radius,
69 float rotationAngle,
70 String region,
71 const WebPointerProperties& properties) {
72 return new Touch(frame, target, screenPos, pagePos, radius, rotationAngle,
73 region, properties);
74 }
61 static Touch* create(const Document& document, const TouchInit& initializer) { 75 static Touch* create(const Document& document, const TouchInit& initializer) {
62 return new Touch(document.frame(), initializer); 76 return new Touch(document.frame(), initializer);
63 } 77 }
64 78
65 // DOM Touch implementation 79 // DOM Touch implementation
66 EventTarget* target() const { return m_target.get(); } 80 EventTarget* target() const { return m_target.get(); }
67 int identifier() const { return m_identifier; } 81 int identifier() const { return m_pointerProperties.id; }
68 double clientX() const { return m_clientPos.x(); } 82 double clientX() const { return m_clientPos.x(); }
69 double clientY() const { return m_clientPos.y(); } 83 double clientY() const { return m_clientPos.y(); }
70 double screenX() const { return m_screenPos.x(); } 84 double screenX() const { return m_screenPos.x(); }
71 double screenY() const { return m_screenPos.y(); } 85 double screenY() const { return m_screenPos.y(); }
72 double pageX() const { return m_pagePos.x(); } 86 double pageX() const { return m_pagePos.x(); }
73 double pageY() const { return m_pagePos.y(); } 87 double pageY() const { return m_pagePos.y(); }
74 float radiusX() const { return m_radius.width(); } 88 float radiusX() const { return m_radius.width(); }
75 float radiusY() const { return m_radius.height(); } 89 float radiusY() const { return m_radius.height(); }
76 float rotationAngle() const { return m_rotationAngle; } 90 float rotationAngle() const { return m_rotationAngle; }
77 float force() const { return m_force; } 91 float force() const { return m_pointerProperties.force; }
78 const String& region() const { return m_region; } 92 const String& region() const { return m_region; }
79 93
80 // Blink-internal methods 94 // Blink-internal methods
81 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; } 95 const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
82 const FloatPoint& screenLocation() const { return m_screenPos; } 96 const FloatPoint& screenLocation() const { return m_screenPos; }
83 Touch* cloneWithNewTarget(EventTarget*) const; 97 Touch* cloneWithNewTarget(EventTarget*) const;
98 const WebPointerProperties& pointerProperties() const {
99 return m_pointerProperties;
100 }
84 101
85 DECLARE_TRACE(); 102 DECLARE_TRACE();
86 103
87 private: 104 private:
88 Touch(LocalFrame*, 105 Touch(LocalFrame*,
89 EventTarget*, 106 EventTarget*,
90 int identifier,
91 const FloatPoint& screenPos, 107 const FloatPoint& screenPos,
92 const FloatPoint& pagePos, 108 const FloatPoint& pagePos,
93 const FloatSize& radius, 109 const FloatSize& radius,
94 float rotationAngle, 110 float rotationAngle,
95 float force, 111 String region,
96 String region); 112 const WebPointerProperties&);
mustaq 2016/11/17 21:24:57 I agree with Navid here: it's better to remove the
denniskempin 2016/11/28 19:40:48 Besides not having hardware that supports this, th
97 113
98 Touch(EventTarget*, 114 Touch(EventTarget*,
99 int identifier,
100 const FloatPoint& clientPos, 115 const FloatPoint& clientPos,
101 const FloatPoint& screenPos, 116 const FloatPoint& screenPos,
102 const FloatPoint& pagePos, 117 const FloatPoint& pagePos,
103 const FloatSize& radius, 118 const FloatSize& radius,
104 float rotationAngle, 119 float rotationAngle,
105 float force,
106 String region, 120 String region,
121 const WebPointerProperties&,
107 LayoutPoint absoluteLocation); 122 LayoutPoint absoluteLocation);
108 123
109 Touch(LocalFrame*, const TouchInit&); 124 Touch(LocalFrame*, const TouchInit&);
110 125
111 Member<EventTarget> m_target; 126 Member<EventTarget> m_target;
112 int m_identifier;
113 // Position relative to the viewport in CSS px. 127 // Position relative to the viewport in CSS px.
114 FloatPoint m_clientPos; 128 FloatPoint m_clientPos;
115 // Position relative to the screen in DIPs. 129 // Position relative to the screen in DIPs.
116 FloatPoint m_screenPos; 130 FloatPoint m_screenPos;
117 // Position relative to the page in CSS px. 131 // Position relative to the page in CSS px.
118 FloatPoint m_pagePos; 132 FloatPoint m_pagePos;
119 // Radius in CSS px. 133 // Radius in CSS px.
120 FloatSize m_radius; 134 FloatSize m_radius;
121 float m_rotationAngle; 135 float m_rotationAngle;
122 float m_force;
123 String m_region; 136 String m_region;
124 // FIXME(rbyers): Shouldn't we be able to migrate callers to relying on 137 // FIXME(rbyers): Shouldn't we be able to migrate callers to relying on
125 // screenPos, pagePos or clientPos? absoluteLocation appears to be the same as 138 // screenPos, pagePos or clientPos? absoluteLocation appears to be the same as
126 // pagePos but without browser scale applied. 139 // pagePos but without browser scale applied.
127 LayoutPoint m_absoluteLocation; 140 LayoutPoint m_absoluteLocation;
141 WebPointerProperties m_pointerProperties;
128 }; 142 };
129 143
130 } // namespace blink 144 } // namespace blink
131 145
132 #endif // Touch_h 146 #endif // Touch_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698