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

Unified Diff: components/html_viewer/touch_handler.cc

Issue 1362793002: Construct and check for mojo::Event's LocationData as needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also audit wheel_data and brush_data. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: components/html_viewer/touch_handler.cc
diff --git a/components/html_viewer/touch_handler.cc b/components/html_viewer/touch_handler.cc
index 23deaa731e382f171dfdf75833cacd726da740c5..48e20c9d91bbfb0f2fc8e075fb7013e3ec7ea446 100644
--- a/components/html_viewer/touch_handler.cc
+++ b/components/html_viewer/touch_handler.cc
@@ -19,14 +19,19 @@ namespace {
// In phase2, it will be relocated to MUS. Update this code at that time.
void SetPropertiesFromEvent(const mojo::Event& event,
ui::PointerProperties* properties) {
- properties->id = event.pointer_data->pointer_id;
- properties->x = event.pointer_data->location->x;
- properties->y = event.pointer_data->location->y;
- properties->raw_x = event.pointer_data->location->screen_x;
- properties->raw_y = event.pointer_data->location->screen_y;
-
- if (event.pointer_data->kind == mojo::POINTER_KIND_TOUCH ||
- event.pointer_data->kind == mojo::POINTER_KIND_PEN) {
+ if (event.pointer_data) {
+ properties->id = event.pointer_data->pointer_id;
+ if (event.pointer_data->location) {
+ properties->x = event.pointer_data->location->x;
+ properties->y = event.pointer_data->location->y;
+ properties->raw_x = event.pointer_data->location->screen_x;
+ properties->raw_y = event.pointer_data->location->screen_y;
+ }
+ }
+
+ if (event.pointer_data && event.pointer_data->brush_data &&
+ (event.pointer_data->kind == mojo::POINTER_KIND_TOUCH ||
+ event.pointer_data->kind == mojo::POINTER_KIND_PEN)) {
properties->pressure = event.pointer_data->brush_data->pressure;
// TODO(rjkroege): vary orientation for width, height.
@@ -185,9 +190,11 @@ void TouchHandler::SendMotionEventToGestureProvider() {
void TouchHandler::PostProcessMotionEvent(const mojo::Event& event) {
switch (event.action) {
case mojo::EVENT_TYPE_POINTER_UP: {
- const int index = current_motion_event_->FindPointerIndexOfId(
- event.pointer_data->pointer_id);
- current_motion_event_->RemovePointerAt(index);
+ if (event.pointer_data) {
+ const int index = current_motion_event_->FindPointerIndexOfId(
+ event.pointer_data->pointer_id);
+ current_motion_event_->RemovePointerAt(index);
+ }
if (current_motion_event_->GetPointerCount() == 0)
current_motion_event_.reset();
break;

Powered by Google App Engine
This is Rietveld 408576698