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

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

Issue 1218663006: Use new WebTouchPoint field names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/i18n/char_iterator.h" 8 #include "base/i18n/char_iterator.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 (touch_point.state == WebTouchPoint::StateReleased || 235 (touch_point.state == WebTouchPoint::StateReleased ||
236 touch_point.state == WebTouchPoint::StateCancelled)) { 236 touch_point.state == WebTouchPoint::StateCancelled)) {
237 continue; 237 continue;
238 } 238 }
239 if (included_types == CHANGED && 239 if (included_types == CHANGED &&
240 (touch_point.state == WebTouchPoint::StateUndefined || 240 (touch_point.state == WebTouchPoint::StateUndefined ||
241 touch_point.state == WebTouchPoint::StateStationary)) { 241 touch_point.state == WebTouchPoint::StateStationary)) {
242 continue; 242 continue;
243 } 243 }
244 PP_TouchPoint pp_pt; 244 PP_TouchPoint pp_pt;
245 pp_pt.id = touch_point.id; 245 pp_pt.id = touch_point.pointerId;
246 pp_pt.position.x = touch_point.position.x; 246 pp_pt.position.x = touch_point.position.x;
247 pp_pt.position.y = touch_point.position.y; 247 pp_pt.position.y = touch_point.position.y;
248 pp_pt.radius.x = touch_point.radiusX; 248 pp_pt.radius.x = touch_point.width;
249 pp_pt.radius.y = touch_point.radiusY; 249 pp_pt.radius.y = touch_point.height;
250 pp_pt.rotation_angle = touch_point.rotationAngle; 250 pp_pt.rotation_angle = touch_point.rotationAngle;
251 pp_pt.pressure = touch_point.force; 251 pp_pt.pressure = touch_point.pressure;
252 result->push_back(pp_pt); 252 result->push_back(pp_pt);
253 } 253 }
254 } 254 }
255 255
256 void AppendTouchEvent(const WebInputEvent& event, 256 void AppendTouchEvent(const WebInputEvent& event,
257 std::vector<InputEventData>* result_events) { 257 std::vector<InputEventData>* result_events) {
258 const WebTouchEvent& touch_event = 258 const WebTouchEvent& touch_event =
259 reinterpret_cast<const WebTouchEvent&>(event); 259 reinterpret_cast<const WebTouchEvent&>(event);
260 260
261 InputEventData result = GetEventWithCommonFieldsAndType(event); 261 InputEventData result = GetEventWithCommonFieldsAndType(event);
262 SetPPTouchPoints( 262 SetPPTouchPoints(
263 touch_event.touches, touch_event.touchesLength, ACTIVE, &result.touches); 263 touch_event.touches, touch_event.touchesLength, ACTIVE, &result.touches);
264 SetPPTouchPoints(touch_event.touches, 264 SetPPTouchPoints(touch_event.touches,
265 touch_event.touchesLength, 265 touch_event.touchesLength,
266 CHANGED, 266 CHANGED,
267 &result.changed_touches); 267 &result.changed_touches);
268 SetPPTouchPoints(touch_event.touches, 268 SetPPTouchPoints(touch_event.touches,
269 touch_event.touchesLength, 269 touch_event.touchesLength,
270 ALL, 270 ALL,
271 &result.target_touches); 271 &result.target_touches);
272 272
273 result_events->push_back(result); 273 result_events->push_back(result);
274 } 274 }
275 275
276 WebTouchPoint CreateWebTouchPoint(const PP_TouchPoint& pp_pt, 276 WebTouchPoint CreateWebTouchPoint(const PP_TouchPoint& pp_pt,
277 WebTouchPoint::State state) { 277 WebTouchPoint::State state) {
278 WebTouchPoint pt; 278 WebTouchPoint pt;
279 pt.id = pp_pt.id; 279 pt.pointerId = pp_pt.id;
280 pt.position.x = pp_pt.position.x; 280 pt.position.x = pp_pt.position.x;
281 pt.position.y = pp_pt.position.y; 281 pt.position.y = pp_pt.position.y;
282 // TODO bug:http://code.google.com/p/chromium/issues/detail?id=93902 282 // TODO bug:http://code.google.com/p/chromium/issues/detail?id=93902
283 pt.screenPosition.x = 0; 283 pt.screenPosition.x = 0;
284 pt.screenPosition.y = 0; 284 pt.screenPosition.y = 0;
285 pt.force = pp_pt.pressure; 285 pt.pressure = pp_pt.pressure;
286 pt.radiusX = pp_pt.radius.x; 286 pt.width = pp_pt.radius.x;
287 pt.radiusY = pp_pt.radius.y; 287 pt.height = pp_pt.radius.y;
288 pt.rotationAngle = pp_pt.rotation_angle; 288 pt.rotationAngle = pp_pt.rotation_angle;
289 pt.state = state; 289 pt.state = state;
290 return pt; 290 return pt;
291 } 291 }
292 292
293 bool HasTouchPointWithId(const WebTouchPoint* web_touches, 293 bool HasTouchPointWithId(const WebTouchPoint* web_touches,
294 uint32_t web_touches_length, 294 uint32_t web_touches_length,
295 uint32_t id) { 295 uint32_t id) {
296 // Note: A brute force search to find the (potentially) existing touch point 296 // Note: A brute force search to find the (potentially) existing touch point
297 // is cheap given the small bound on |WebTouchEvent::touchesLengthCap|. 297 // is cheap given the small bound on |WebTouchEvent::touchesLengthCap|.
298 for (uint32_t i = 0; i < web_touches_length; ++i) { 298 for (uint32_t i = 0; i < web_touches_length; ++i) {
299 if (web_touches[i].id == static_cast<int>(id)) 299 if (web_touches[i].pointerId == static_cast<int>(id))
300 return true; 300 return true;
301 } 301 }
302 return false; 302 return false;
303 } 303 }
304 304
305 void SetWebTouchPointsIfNotYetSet(const std::vector<PP_TouchPoint>& pp_touches, 305 void SetWebTouchPointsIfNotYetSet(const std::vector<PP_TouchPoint>& pp_touches,
306 WebTouchPoint::State state, 306 WebTouchPoint::State state,
307 WebTouchPoint* web_touches, 307 WebTouchPoint* web_touches,
308 uint32_t* web_touches_length) { 308 uint32_t* web_touches_length) {
309 const uint32_t initial_web_touches_length = *web_touches_length; 309 const uint32_t initial_web_touches_length = *web_touches_length;
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 case WebInputEvent::TouchStart: 749 case WebInputEvent::TouchStart:
750 return PP_INPUTEVENT_CLASS_TOUCH; 750 return PP_INPUTEVENT_CLASS_TOUCH;
751 case WebInputEvent::Undefined: 751 case WebInputEvent::Undefined:
752 default: 752 default:
753 CHECK(WebInputEvent::isGestureEventType(type)); 753 CHECK(WebInputEvent::isGestureEventType(type));
754 return PP_InputEvent_Class(0); 754 return PP_InputEvent_Class(0);
755 } 755 }
756 } 756 }
757 757
758 } // namespace content 758 } // namespace content
OLDNEW
« no previous file with comments | « content/common/input/web_input_event_traits_unittest.cc ('k') | content/renderer/pepper/event_conversion_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698