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

Side by Side Diff: content/renderer/pepper/event_conversion.cc

Issue 2403313002: pepper: Report proper touch end event for lifting stylus (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/event_conversion.h" 5 #include "content/renderer/pepper/event_conversion.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return mouse_event.pointerType == PointerType::Pen || 92 return mouse_event.pointerType == PointerType::Pen ||
93 mouse_event.pointerType == PointerType::Eraser; 93 mouse_event.pointerType == PointerType::Eraser;
94 } 94 }
95 default: 95 default:
96 return false; 96 return false;
97 } 97 }
98 } 98 }
99 99
100 PP_InputEvent_Type ConvertEventTypes(const WebInputEvent& event) { 100 PP_InputEvent_Type ConvertEventTypes(const WebInputEvent& event) {
101 if (IsStylusEvent(event)) { 101 if (IsStylusEvent(event)) {
102 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
103 if (mouse_event.button != blink::WebMouseEvent::Button::Left &&
104 !(mouse_event.modifiers & blink::WebInputEvent::LeftButtonDown))
105 return PP_INPUTEVENT_TYPE_UNDEFINED;
106
102 switch (event.type) { 107 switch (event.type) {
103 case WebInputEvent::MouseDown: 108 case WebInputEvent::MouseDown:
104 return PP_INPUTEVENT_TYPE_TOUCHSTART; 109 return PP_INPUTEVENT_TYPE_TOUCHSTART;
105 case WebInputEvent::MouseUp: 110 case WebInputEvent::MouseUp:
106 return PP_INPUTEVENT_TYPE_TOUCHEND; 111 return PP_INPUTEVENT_TYPE_TOUCHEND;
107 case WebInputEvent::MouseMove: { 112 case WebInputEvent::MouseMove:
108 const WebMouseEvent& mouse_event = 113 return PP_INPUTEVENT_TYPE_TOUCHMOVE;
109 static_cast<const WebMouseEvent&>(event);
110 return (mouse_event.modifiers & blink::WebInputEvent::LeftButtonDown)
111 ? PP_INPUTEVENT_TYPE_TOUCHMOVE
112 : PP_INPUTEVENT_TYPE_UNDEFINED;
113 }
114 default: 114 default:
115 return PP_INPUTEVENT_TYPE_UNDEFINED; 115 return PP_INPUTEVENT_TYPE_UNDEFINED;
116 } 116 }
117 } 117 }
118 switch (event.type) { 118 switch (event.type) {
119 case WebInputEvent::MouseDown: 119 case WebInputEvent::MouseDown:
120 return PP_INPUTEVENT_TYPE_MOUSEDOWN; 120 return PP_INPUTEVENT_TYPE_MOUSEDOWN;
121 case WebInputEvent::MouseUp: 121 case WebInputEvent::MouseUp:
122 return PP_INPUTEVENT_TYPE_MOUSEUP; 122 return PP_INPUTEVENT_TYPE_MOUSEUP;
123 case WebInputEvent::MouseMove: 123 case WebInputEvent::MouseMove:
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 iter.Advance(); 218 iter.Advance();
219 } 219 }
220 } 220 }
221 221
222 void AppendStylusTouchEvent(const WebInputEvent& event, 222 void AppendStylusTouchEvent(const WebInputEvent& event,
223 std::vector<InputEventData>* result_events) { 223 std::vector<InputEventData>* result_events) {
224 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); 224 const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event);
225 225
226 InputEventData result = GetEventWithCommonFieldsAndType(event); 226 InputEventData result = GetEventWithCommonFieldsAndType(event);
227 result.event_modifiers = ConvertEventModifiers(event.modifiers); 227 result.event_modifiers = ConvertEventModifiers(event.modifiers);
228 if (result.event_type == PP_INPUTEVENT_TYPE_UNDEFINED)
229 return;
228 230
229 if (mouse_event.modifiers & blink::WebInputEvent::LeftButtonDown && 231 PP_TouchPoint touch_point;
230 (mouse_event.type == WebInputEvent::MouseDown || 232 touch_point.id = 0;
231 mouse_event.type == WebInputEvent::MouseMove)) { 233 touch_point.position.x = mouse_event.x;
232 PP_TouchPoint touch_point; 234 touch_point.position.y = mouse_event.y;
233 touch_point.id = 0; 235 touch_point.pressure = mouse_event.force;
234 touch_point.position.x = mouse_event.x;
235 touch_point.position.y = mouse_event.y;
236 touch_point.pressure = mouse_event.force;
237 236
237 result.changed_touches.push_back(touch_point);
238 result.target_touches.push_back(touch_point);
239 if (result.event_type != PP_INPUTEVENT_TYPE_TOUCHEND)
238 result.touches.push_back(touch_point); 240 result.touches.push_back(touch_point);
239 result.changed_touches.push_back(touch_point);
240 result.target_touches.push_back(touch_point);
241 }
242 241
243 if (result.event_type != PP_INPUTEVENT_TYPE_UNDEFINED) 242 result_events->push_back(result);
244 result_events->push_back(result);
245 } 243 }
246 244
247 void AppendMouseEvent(const WebInputEvent& event, 245 void AppendMouseEvent(const WebInputEvent& event,
248 std::vector<InputEventData>* result_events) { 246 std::vector<InputEventData>* result_events) {
249 static_assert(static_cast<int>(WebMouseEvent::Button::NoButton) == 247 static_assert(static_cast<int>(WebMouseEvent::Button::NoButton) ==
250 static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_NONE), 248 static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_NONE),
251 "MouseNone should match"); 249 "MouseNone should match");
252 static_assert(static_cast<int>(WebMouseEvent::Button::Left) == 250 static_assert(static_cast<int>(WebMouseEvent::Button::Left) ==
253 static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_LEFT), 251 static_cast<int>(PP_INPUTEVENT_MOUSEBUTTON_LEFT),
254 "MouseLeft should match"); 252 "MouseLeft should match");
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 return PP_INPUTEVENT_CLASS_TOUCH; 828 return PP_INPUTEVENT_CLASS_TOUCH;
831 case WebInputEvent::TouchScrollStarted: 829 case WebInputEvent::TouchScrollStarted:
832 return PP_InputEvent_Class(0); 830 return PP_InputEvent_Class(0);
833 default: 831 default:
834 CHECK(WebInputEvent::isGestureEventType(event.type)); 832 CHECK(WebInputEvent::isGestureEventType(event.type));
835 return PP_InputEvent_Class(0); 833 return PP_InputEvent_Class(0);
836 } 834 }
837 } 835 }
838 836
839 } // namespace content 837 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698