OLD | NEW |
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 // Portions based heavily on: | 5 // Portions based heavily on: |
6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp | 6 // third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.cpp |
7 // | 7 // |
8 /* | 8 /* |
9 * Copyright (C) 2006-2011 Google Inc. All rights reserved. | 9 * Copyright (C) 2006-2011 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return 0x0A; | 175 return 0x0A; |
176 // Returns 0 for all other keys to avoid inputting unexpected chars. | 176 // Returns 0 for all other keys to avoid inputting unexpected chars. |
177 default: | 177 default: |
178 break; | 178 break; |
179 } | 179 } |
180 } | 180 } |
181 return 0; | 181 return 0; |
182 } | 182 } |
183 | 183 |
184 WebKit::WebTouchPoint::State TouchPointStateFromEvent( | 184 WebKit::WebTouchPoint::State TouchPointStateFromEvent( |
185 const ui::TouchEventImpl* event) { | 185 const ui::TouchEvent* event) { |
186 switch (event->type()) { | 186 switch (event->type()) { |
187 case ui::ET_TOUCH_PRESSED: | 187 case ui::ET_TOUCH_PRESSED: |
188 return WebKit::WebTouchPoint::StatePressed; | 188 return WebKit::WebTouchPoint::StatePressed; |
189 case ui::ET_TOUCH_RELEASED: | 189 case ui::ET_TOUCH_RELEASED: |
190 return WebKit::WebTouchPoint::StateReleased; | 190 return WebKit::WebTouchPoint::StateReleased; |
191 case ui::ET_TOUCH_MOVED: | 191 case ui::ET_TOUCH_MOVED: |
192 return WebKit::WebTouchPoint::StateMoved; | 192 return WebKit::WebTouchPoint::StateMoved; |
193 case ui::ET_TOUCH_CANCELLED: | 193 case ui::ET_TOUCH_CANCELLED: |
194 return WebKit::WebTouchPoint::StateCancelled; | 194 return WebKit::WebTouchPoint::StateCancelled; |
195 default: | 195 default: |
196 return WebKit::WebTouchPoint::StateUndefined; | 196 return WebKit::WebTouchPoint::StateUndefined; |
197 } | 197 } |
198 } | 198 } |
199 | 199 |
200 WebKit::WebInputEvent::Type TouchEventTypeFromEvent( | 200 WebKit::WebInputEvent::Type TouchEventTypeFromEvent( |
201 const ui::TouchEventImpl* event) { | 201 const ui::TouchEvent* event) { |
202 switch (event->type()) { | 202 switch (event->type()) { |
203 case ui::ET_TOUCH_PRESSED: | 203 case ui::ET_TOUCH_PRESSED: |
204 return WebKit::WebInputEvent::TouchStart; | 204 return WebKit::WebInputEvent::TouchStart; |
205 case ui::ET_TOUCH_RELEASED: | 205 case ui::ET_TOUCH_RELEASED: |
206 return WebKit::WebInputEvent::TouchEnd; | 206 return WebKit::WebInputEvent::TouchEnd; |
207 case ui::ET_TOUCH_MOVED: | 207 case ui::ET_TOUCH_MOVED: |
208 return WebKit::WebInputEvent::TouchMove; | 208 return WebKit::WebInputEvent::TouchMove; |
209 case ui::ET_TOUCH_CANCELLED: | 209 case ui::ET_TOUCH_CANCELLED: |
210 return WebKit::WebInputEvent::TouchCancel; | 210 return WebKit::WebInputEvent::TouchCancel; |
211 default: | 211 default: |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 NOTREACHED() << "Unknown gesture type: " << event->type(); | 415 NOTREACHED() << "Unknown gesture type: " << event->type(); |
416 } | 416 } |
417 | 417 |
418 gesture_event.boundingBox = event->details().bounding_box(); | 418 gesture_event.boundingBox = event->details().bounding_box(); |
419 gesture_event.modifiers = EventFlagsToWebEventModifiers(event->flags()); | 419 gesture_event.modifiers = EventFlagsToWebEventModifiers(event->flags()); |
420 | 420 |
421 return gesture_event; | 421 return gesture_event; |
422 } | 422 } |
423 | 423 |
424 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( | 424 WebKit::WebTouchPoint* UpdateWebTouchEventFromAuraEvent( |
425 ui::TouchEventImpl* event, WebKit::WebTouchEvent* web_event) { | 425 ui::TouchEvent* event, WebKit::WebTouchEvent* web_event) { |
426 WebKit::WebTouchPoint* point = NULL; | 426 WebKit::WebTouchPoint* point = NULL; |
427 switch (event->type()) { | 427 switch (event->type()) { |
428 case ui::ET_TOUCH_PRESSED: | 428 case ui::ET_TOUCH_PRESSED: |
429 // Add a new touch point. | 429 // Add a new touch point. |
430 if (web_event->touchesLength < WebKit::WebTouchEvent::touchesLengthCap) { | 430 if (web_event->touchesLength < WebKit::WebTouchEvent::touchesLengthCap) { |
431 point = &web_event->touches[web_event->touchesLength++]; | 431 point = &web_event->touches[web_event->touchesLength++]; |
432 point->id = event->touch_id(); | 432 point->id = event->touch_id(); |
433 } | 433 } |
434 break; | 434 break; |
435 case ui::ET_TOUCH_RELEASED: | 435 case ui::ET_TOUCH_RELEASED: |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 // Update the type of the touch event. | 487 // Update the type of the touch event. |
488 web_event->type = TouchEventTypeFromEvent(event); | 488 web_event->type = TouchEventTypeFromEvent(event); |
489 web_event->timeStampSeconds = event->time_stamp().InSecondsF(); | 489 web_event->timeStampSeconds = event->time_stamp().InSecondsF(); |
490 web_event->modifiers = EventFlagsToWebEventModifiers(event->flags()); | 490 web_event->modifiers = EventFlagsToWebEventModifiers(event->flags()); |
491 | 491 |
492 return point; | 492 return point; |
493 } | 493 } |
494 | 494 |
495 } // namespace content | 495 } // namespace content |
OLD | NEW |