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

Side by Side Diff: sky/viewer/converters/input_event_types.cc

Issue 875953004: Add a basic sky-scrollable element that scrolls (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 | « sky/framework/sky-scrollable.sky ('k') | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sky/viewer/converters/input_event_types.h" 5 #include "sky/viewer/converters/input_event_types.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "mojo/services/input_events/public/interfaces/input_event_constants.moj om.h" 9 #include "mojo/services/input_events/public/interfaces/input_event_constants.moj om.h"
10 #include "sky/engine/public/platform/WebInputEvent.h" 10 #include "sky/engine/public/platform/WebInputEvent.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 switch (event->action) { 95 switch (event->action) {
96 case mojo::EVENT_TYPE_GESTURE_SCROLL_BEGIN: 96 case mojo::EVENT_TYPE_GESTURE_SCROLL_BEGIN:
97 web_event->type = blink::WebInputEvent::GestureScrollBegin; 97 web_event->type = blink::WebInputEvent::GestureScrollBegin;
98 break; 98 break;
99 case mojo::EVENT_TYPE_GESTURE_SCROLL_END: 99 case mojo::EVENT_TYPE_GESTURE_SCROLL_END:
100 web_event->type = blink::WebInputEvent::GestureScrollEnd; 100 web_event->type = blink::WebInputEvent::GestureScrollEnd;
101 break; 101 break;
102 case mojo::EVENT_TYPE_GESTURE_SCROLL_UPDATE: 102 case mojo::EVENT_TYPE_GESTURE_SCROLL_UPDATE:
103 web_event->type = blink::WebInputEvent::GestureScrollUpdate; 103 web_event->type = blink::WebInputEvent::GestureScrollUpdate;
104 web_event->data.scrollUpdate.deltaX = event->gesture_data->scroll_x; 104 web_event->data.scrollUpdate.deltaX =
105 web_event->data.scrollUpdate.deltaY = event->gesture_data->scroll_y; 105 event->gesture_data->scroll_x / device_pixel_ratio;
106 web_event->data.scrollUpdate.deltaY =
107 event->gesture_data->scroll_y / device_pixel_ratio;
106 break; 108 break;
107 case mojo::EVENT_TYPE_SCROLL_FLING_START: 109 case mojo::EVENT_TYPE_SCROLL_FLING_START:
108 web_event->type = blink::WebInputEvent::GestureFlingStart; 110 web_event->type = blink::WebInputEvent::GestureFlingStart;
109 web_event->data.flingStart.velocityX = event->gesture_data->velocity_x; 111 web_event->data.flingStart.velocityX =
110 web_event->data.flingStart.velocityY = event->gesture_data->velocity_y; 112 event->gesture_data->velocity_x / device_pixel_ratio;
113 web_event->data.flingStart.velocityY =
114 event->gesture_data->velocity_y / device_pixel_ratio;
111 break; 115 break;
112 case mojo::EVENT_TYPE_SCROLL_FLING_CANCEL: 116 case mojo::EVENT_TYPE_SCROLL_FLING_CANCEL:
113 web_event->type = blink::WebInputEvent::GestureFlingCancel; 117 web_event->type = blink::WebInputEvent::GestureFlingCancel;
114 break; 118 break;
115 case mojo::EVENT_TYPE_GESTURE_SHOW_PRESS: 119 case mojo::EVENT_TYPE_GESTURE_SHOW_PRESS:
116 web_event->type = blink::WebInputEvent::GestureShowPress; 120 web_event->type = blink::WebInputEvent::GestureShowPress;
117 break; 121 break;
118 case mojo::EVENT_TYPE_GESTURE_TAP: 122 case mojo::EVENT_TYPE_GESTURE_TAP:
119 web_event->type = blink::WebInputEvent::GestureTap; 123 web_event->type = blink::WebInputEvent::GestureTap;
120 web_event->data.tap.tapCount = event->gesture_data->tap_count; 124 web_event->data.tap.tapCount = event->gesture_data->tap_count;
(...skipping 22 matching lines...) Expand all
143 web_event->type = blink::WebInputEvent::GestureLongTap; 147 web_event->type = blink::WebInputEvent::GestureLongTap;
144 break; 148 break;
145 case mojo::EVENT_TYPE_GESTURE_PINCH_BEGIN: 149 case mojo::EVENT_TYPE_GESTURE_PINCH_BEGIN:
146 web_event->type = blink::WebInputEvent::GesturePinchBegin; 150 web_event->type = blink::WebInputEvent::GesturePinchBegin;
147 break; 151 break;
148 case mojo::EVENT_TYPE_GESTURE_PINCH_END: 152 case mojo::EVENT_TYPE_GESTURE_PINCH_END:
149 web_event->type = blink::WebInputEvent::GesturePinchEnd; 153 web_event->type = blink::WebInputEvent::GesturePinchEnd;
150 break; 154 break;
151 case mojo::EVENT_TYPE_GESTURE_PINCH_UPDATE: 155 case mojo::EVENT_TYPE_GESTURE_PINCH_UPDATE:
152 web_event->type = blink::WebInputEvent::GesturePinchUpdate; 156 web_event->type = blink::WebInputEvent::GesturePinchUpdate;
153 web_event->data.pinchUpdate.scale = event->gesture_data->scale; 157 web_event->data.pinchUpdate.scale =
158 event->gesture_data->scale / device_pixel_ratio;
154 break; 159 break;
155 default: 160 default:
156 NOTIMPLEMENTED() << "Received unexpected event: " << event->action; 161 NOTIMPLEMENTED() << "Received unexpected event: " << event->action;
157 break; 162 break;
158 } 163 }
159 164
160 web_event->x = event->location_data->in_view_location->x / device_pixel_ratio; 165 web_event->x = event->location_data->in_view_location->x / device_pixel_ratio;
161 web_event->y = event->location_data->in_view_location->y / device_pixel_ratio; 166 web_event->y = event->location_data->in_view_location->y / device_pixel_ratio;
162 167
163 // TODO(erg): Remove this null check as parallel to above. 168 // TODO(erg): Remove this null check as parallel to above.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } else if ((event->action == mojo::EVENT_TYPE_KEY_PRESSED || 241 } else if ((event->action == mojo::EVENT_TYPE_KEY_PRESSED ||
237 event->action == mojo::EVENT_TYPE_KEY_RELEASED) && 242 event->action == mojo::EVENT_TYPE_KEY_RELEASED) &&
238 event->key_data) { 243 event->key_data) {
239 return BuildWebKeyboardEvent(event, device_pixel_ratio); 244 return BuildWebKeyboardEvent(event, device_pixel_ratio);
240 } 245 }
241 246
242 return scoped_ptr<blink::WebInputEvent>(); 247 return scoped_ptr<blink::WebInputEvent>();
243 } 248 }
244 249
245 } // namespace mojo 250 } // namespace mojo
OLDNEW
« no previous file with comments | « sky/framework/sky-scrollable.sky ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698