| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2008, The Android Open Source Project | 2 * Copyright 2008, The Android Open Source Project |
| 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 3 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above copyright | 10 * * Redistributions in binary form must reproduce the above copyright |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "bindings/core/v8/DOMWrapperWorld.h" | 29 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 30 #include "bindings/core/v8/ScriptState.h" | 30 #include "bindings/core/v8/ScriptState.h" |
| 31 #include "core/events/EventDispatcher.h" | 31 #include "core/events/EventDispatcher.h" |
| 32 #include "core/frame/FrameConsole.h" | 32 #include "core/frame/FrameConsole.h" |
| 33 #include "core/frame/FrameView.h" | 33 #include "core/frame/FrameView.h" |
| 34 #include "core/frame/LocalDOMWindow.h" | 34 #include "core/frame/LocalDOMWindow.h" |
| 35 #include "core/html/HTMLElement.h" | 35 #include "core/html/HTMLElement.h" |
| 36 #include "core/input/InputDeviceCapabilities.h" | 36 #include "core/input/InputDeviceCapabilities.h" |
| 37 #include "core/inspector/ConsoleMessage.h" | 37 #include "core/inspector/ConsoleMessage.h" |
| 38 #include "platform/Histogram.h" | 38 #include "platform/Histogram.h" |
| 39 #include "public/platform/WebCoalescedInputEvent.h" |
| 39 | 40 |
| 40 namespace blink { | 41 namespace blink { |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 // These offsets change indicies into the ListenerHistogram | 45 // These offsets change indicies into the ListenerHistogram |
| 45 // enumeration. The addition of a series of offsets then | 46 // enumeration. The addition of a series of offsets then |
| 46 // produces the resulting ListenerHistogram value. | 47 // produces the resulting ListenerHistogram value. |
| 47 // TODO(dtapuska): Remove all of these histogram counts once | 48 // TODO(dtapuska): Remove all of these histogram counts once |
| 48 // https://crbug.com/599609 is fixed. | 49 // https://crbug.com/599609 is fixed. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 else | 190 else |
| 190 result += kTouchTargetHistogramNotHandledOffset; | 191 result += kTouchTargetHistogramNotHandledOffset; |
| 191 | 192 |
| 192 DEFINE_STATIC_LOCAL(EnumerationHistogram, root_document_listener_histogram, | 193 DEFINE_STATIC_LOCAL(EnumerationHistogram, root_document_listener_histogram, |
| 193 ("Event.Touch.TargetAndDispatchResult2", | 194 ("Event.Touch.TargetAndDispatchResult2", |
| 194 kTouchTargetAndDispatchResultTypeMax)); | 195 kTouchTargetAndDispatchResultTypeMax)); |
| 195 root_document_listener_histogram.Count( | 196 root_document_listener_histogram.Count( |
| 196 static_cast<TouchTargetAndDispatchResultType>(result)); | 197 static_cast<TouchTargetAndDispatchResultType>(result)); |
| 197 } | 198 } |
| 198 | 199 |
| 200 // Helper function to get WebTouchEvent from WebCoalescedInputEvent. |
| 201 const WebTouchEvent* GetWebTouchEvent(const WebCoalescedInputEvent& event) { |
| 202 return static_cast<const WebTouchEvent*>(&event.Event()); |
| 203 } |
| 199 } // namespace | 204 } // namespace |
| 200 | 205 |
| 201 TouchEvent::TouchEvent() | 206 TouchEvent::TouchEvent() |
| 202 : default_prevented_before_current_target_(false), | 207 : default_prevented_before_current_target_(false), |
| 203 current_touch_action_(kTouchActionAuto) {} | 208 current_touch_action_(kTouchActionAuto) {} |
| 204 | 209 |
| 205 TouchEvent::TouchEvent(const WebTouchEvent& event, | 210 TouchEvent::TouchEvent(const WebCoalescedInputEvent& event, |
| 206 TouchList* touches, | 211 TouchList* touches, |
| 207 TouchList* target_touches, | 212 TouchList* target_touches, |
| 208 TouchList* changed_touches, | 213 TouchList* changed_touches, |
| 209 const AtomicString& type, | 214 const AtomicString& type, |
| 210 AbstractView* view, | 215 AbstractView* view, |
| 211 TouchAction current_touch_action) | 216 TouchAction current_touch_action) |
| 212 // Pass a sourceCapabilities including the ability to fire touchevents when | 217 // Pass a sourceCapabilities including the ability to fire touchevents when |
| 213 // creating this touchevent, which is always created from input device | 218 // creating this touchevent, which is always created from input device |
| 214 // capabilities from EventHandler. | 219 // capabilities from EventHandler. |
| 215 : UIEventWithKeyState( | 220 : UIEventWithKeyState( |
| 216 type, | 221 type, |
| 217 true, | 222 true, |
| 218 event.IsCancelable(), | 223 GetWebTouchEvent(event)->IsCancelable(), |
| 219 view, | 224 view, |
| 220 0, | 225 0, |
| 221 static_cast<WebInputEvent::Modifiers>(event.GetModifiers()), | 226 static_cast<WebInputEvent::Modifiers>(event.Event().GetModifiers()), |
| 222 TimeTicks::FromSeconds(event.TimeStampSeconds()), | 227 TimeTicks::FromSeconds(event.Event().TimeStampSeconds()), |
| 223 view ? view->GetInputDeviceCapabilities()->FiresTouchEvents(true) | 228 view ? view->GetInputDeviceCapabilities()->FiresTouchEvents(true) |
| 224 : nullptr), | 229 : nullptr), |
| 225 touches_(touches), | 230 touches_(touches), |
| 226 target_touches_(target_touches), | 231 target_touches_(target_touches), |
| 227 changed_touches_(changed_touches), | 232 changed_touches_(changed_touches), |
| 228 default_prevented_before_current_target_(false), | 233 default_prevented_before_current_target_(false), |
| 229 current_touch_action_(current_touch_action) { | 234 current_touch_action_(current_touch_action) { |
| 230 native_event_.reset(new WebTouchEvent(event)); | 235 native_event_.reset(new WebCoalescedInputEvent(event)); |
| 231 } | 236 } |
| 232 | 237 |
| 233 TouchEvent::TouchEvent(const AtomicString& type, | 238 TouchEvent::TouchEvent(const AtomicString& type, |
| 234 const TouchEventInit& initializer) | 239 const TouchEventInit& initializer) |
| 235 : UIEventWithKeyState(type, initializer), | 240 : UIEventWithKeyState(type, initializer), |
| 236 touches_(TouchList::Create(initializer.touches())), | 241 touches_(TouchList::Create(initializer.touches())), |
| 237 target_touches_(TouchList::Create(initializer.targetTouches())), | 242 target_touches_(TouchList::Create(initializer.targetTouches())), |
| 238 changed_touches_(TouchList::Create(initializer.changedTouches())), | 243 changed_touches_(TouchList::Create(initializer.changedTouches())), |
| 239 current_touch_action_(kTouchActionAuto) {} | 244 current_touch_action_(kTouchActionAuto) {} |
| 240 | 245 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 260 case PassiveMode::kNotPassive: | 265 case PassiveMode::kNotPassive: |
| 261 case PassiveMode::kNotPassiveDefault: | 266 case PassiveMode::kNotPassiveDefault: |
| 262 if (!cancelable()) { | 267 if (!cancelable()) { |
| 263 if (view() && view()->GetFrame()) { | 268 if (view() && view()->GetFrame()) { |
| 264 UseCounter::Count( | 269 UseCounter::Count( |
| 265 view()->GetFrame(), | 270 view()->GetFrame(), |
| 266 UseCounter::kUncancelableTouchEventPreventDefaulted); | 271 UseCounter::kUncancelableTouchEventPreventDefaulted); |
| 267 } | 272 } |
| 268 | 273 |
| 269 if (native_event_ && | 274 if (native_event_ && |
| 270 native_event_->dispatch_type == | 275 GetWebTouchEvent(*native_event_)->dispatch_type == |
| 271 WebInputEvent:: | 276 WebInputEvent:: |
| 272 kListenersForcedNonBlockingDueToMainThreadResponsiveness) { | 277 kListenersForcedNonBlockingDueToMainThreadResponsiveness) { |
| 273 // Non blocking due to main thread responsiveness. | 278 // Non blocking due to main thread responsiveness. |
| 274 if (view() && view()->GetFrame()) { | 279 if (view() && view()->GetFrame()) { |
| 275 UseCounter::Count( | 280 UseCounter::Count( |
| 276 view()->GetFrame(), | 281 view()->GetFrame(), |
| 277 UseCounter:: | 282 UseCounter:: |
| 278 kUncancelableTouchEventDueToMainThreadResponsivenessPreventD
efaulted); | 283 kUncancelableTouchEventDueToMainThreadResponsivenessPreventD
efaulted); |
| 279 } | 284 } |
| 280 message_source = kInterventionMessageSource; | 285 message_source = kInterventionMessageSource; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 break; | 336 break; |
| 332 default: | 337 default: |
| 333 break; | 338 break; |
| 334 } | 339 } |
| 335 } | 340 } |
| 336 } | 341 } |
| 337 | 342 |
| 338 bool TouchEvent::IsTouchStartOrFirstTouchMove() const { | 343 bool TouchEvent::IsTouchStartOrFirstTouchMove() const { |
| 339 if (!native_event_) | 344 if (!native_event_) |
| 340 return false; | 345 return false; |
| 341 return native_event_->touch_start_or_first_touch_move; | 346 return GetWebTouchEvent(*native_event_)->touch_start_or_first_touch_move; |
| 342 } | 347 } |
| 343 | 348 |
| 344 void TouchEvent::DoneDispatchingEventAtCurrentTarget() { | 349 void TouchEvent::DoneDispatchingEventAtCurrentTarget() { |
| 345 // Do not log for non-cancelable events, events that don't block | 350 // Do not log for non-cancelable events, events that don't block |
| 346 // scrolling, have more than one touch point or aren't on the main frame. | 351 // scrolling, have more than one touch point or aren't on the main frame. |
| 347 if (!cancelable() || !IsTouchStartOrFirstTouchMove() || | 352 if (!cancelable() || !IsTouchStartOrFirstTouchMove() || |
| 348 !(touches_ && touches_->length() == 1) || | 353 !(touches_ && touches_->length() == 1) || |
| 349 !(view() && view()->GetFrame() && view()->GetFrame()->IsMainFrame())) | 354 !(view() && view()->GetFrame() && view()->GetFrame()->IsMainFrame())) |
| 350 return; | 355 return; |
| 351 | 356 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 378 return ToTouchEvent(EventDispatchMediator::GetEvent()); | 383 return ToTouchEvent(EventDispatchMediator::GetEvent()); |
| 379 } | 384 } |
| 380 | 385 |
| 381 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( | 386 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( |
| 382 EventDispatcher& dispatcher) const { | 387 EventDispatcher& dispatcher) const { |
| 383 Event().GetEventPath().AdjustForTouchEvent(Event()); | 388 Event().GetEventPath().AdjustForTouchEvent(Event()); |
| 384 return dispatcher.Dispatch(); | 389 return dispatcher.Dispatch(); |
| 385 } | 390 } |
| 386 | 391 |
| 387 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |