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 "core/events/EventDispatcher.h" | 29 #include "core/events/EventDispatcher.h" |
30 #include "core/frame/FrameConsole.h" | 30 #include "core/frame/FrameConsole.h" |
31 #include "core/frame/FrameView.h" | 31 #include "core/frame/FrameView.h" |
32 #include "core/frame/LocalDOMWindow.h" | 32 #include "core/frame/LocalDOMWindow.h" |
33 #include "core/html/HTMLElement.h" | 33 #include "core/html/HTMLElement.h" |
34 #include "core/input/InputDeviceCapabilities.h" | 34 #include "core/input/InputDeviceCapabilities.h" |
35 #include "core/inspector/ConsoleMessage.h" | 35 #include "core/inspector/ConsoleMessage.h" |
36 #include "platform/Histogram.h" | 36 #include "platform/Histogram.h" |
37 #include "platform/bindings/DOMWrapperWorld.h" | 37 #include "platform/bindings/DOMWrapperWorld.h" |
38 #include "platform/bindings/ScriptState.h" | 38 #include "platform/bindings/ScriptState.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_(TouchAction::kTouchActionAuto) {} | 208 current_touch_action_(TouchAction::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 DCHECK(WebInputEvent::IsTouchEventType(event.Event().GetType())); |
| 236 native_event_.reset(new WebCoalescedInputEvent(event)); |
231 } | 237 } |
232 | 238 |
233 TouchEvent::TouchEvent(const AtomicString& type, | 239 TouchEvent::TouchEvent(const AtomicString& type, |
234 const TouchEventInit& initializer) | 240 const TouchEventInit& initializer) |
235 : UIEventWithKeyState(type, initializer), | 241 : UIEventWithKeyState(type, initializer), |
236 touches_(TouchList::Create(initializer.touches())), | 242 touches_(TouchList::Create(initializer.touches())), |
237 target_touches_(TouchList::Create(initializer.targetTouches())), | 243 target_touches_(TouchList::Create(initializer.targetTouches())), |
238 changed_touches_(TouchList::Create(initializer.changedTouches())), | 244 changed_touches_(TouchList::Create(initializer.changedTouches())), |
239 current_touch_action_(TouchAction::kTouchActionAuto) {} | 245 current_touch_action_(TouchAction::kTouchActionAuto) {} |
240 | 246 |
(...skipping 19 matching lines...) Expand all Loading... |
260 case PassiveMode::kNotPassive: | 266 case PassiveMode::kNotPassive: |
261 case PassiveMode::kNotPassiveDefault: | 267 case PassiveMode::kNotPassiveDefault: |
262 if (!cancelable()) { | 268 if (!cancelable()) { |
263 if (view() && view()->GetFrame()) { | 269 if (view() && view()->GetFrame()) { |
264 UseCounter::Count( | 270 UseCounter::Count( |
265 view()->GetFrame(), | 271 view()->GetFrame(), |
266 UseCounter::kUncancelableTouchEventPreventDefaulted); | 272 UseCounter::kUncancelableTouchEventPreventDefaulted); |
267 } | 273 } |
268 | 274 |
269 if (native_event_ && | 275 if (native_event_ && |
270 native_event_->dispatch_type == | 276 GetWebTouchEvent(*native_event_)->dispatch_type == |
271 WebInputEvent:: | 277 WebInputEvent:: |
272 kListenersForcedNonBlockingDueToMainThreadResponsiveness) { | 278 kListenersForcedNonBlockingDueToMainThreadResponsiveness) { |
273 // Non blocking due to main thread responsiveness. | 279 // Non blocking due to main thread responsiveness. |
274 if (view() && view()->GetFrame()) { | 280 if (view() && view()->GetFrame()) { |
275 UseCounter::Count( | 281 UseCounter::Count( |
276 view()->GetFrame(), | 282 view()->GetFrame(), |
277 UseCounter:: | 283 UseCounter:: |
278 kUncancelableTouchEventDueToMainThreadResponsivenessPreventD
efaulted); | 284 kUncancelableTouchEventDueToMainThreadResponsivenessPreventD
efaulted); |
279 } | 285 } |
280 message_source = kInterventionMessageSource; | 286 message_source = kInterventionMessageSource; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 break; | 337 break; |
332 default: | 338 default: |
333 break; | 339 break; |
334 } | 340 } |
335 } | 341 } |
336 } | 342 } |
337 | 343 |
338 bool TouchEvent::IsTouchStartOrFirstTouchMove() const { | 344 bool TouchEvent::IsTouchStartOrFirstTouchMove() const { |
339 if (!native_event_) | 345 if (!native_event_) |
340 return false; | 346 return false; |
341 return native_event_->touch_start_or_first_touch_move; | 347 return GetWebTouchEvent(*native_event_)->touch_start_or_first_touch_move; |
342 } | 348 } |
343 | 349 |
344 void TouchEvent::DoneDispatchingEventAtCurrentTarget() { | 350 void TouchEvent::DoneDispatchingEventAtCurrentTarget() { |
345 // Do not log for non-cancelable events, events that don't block | 351 // 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. | 352 // scrolling, have more than one touch point or aren't on the main frame. |
347 if (!cancelable() || !IsTouchStartOrFirstTouchMove() || | 353 if (!cancelable() || !IsTouchStartOrFirstTouchMove() || |
348 !(touches_ && touches_->length() == 1) || | 354 !(touches_ && touches_->length() == 1) || |
349 !(view() && view()->GetFrame() && view()->GetFrame()->IsMainFrame())) | 355 !(view() && view()->GetFrame() && view()->GetFrame()->IsMainFrame())) |
350 return; | 356 return; |
351 | 357 |
(...skipping 26 matching lines...) Expand all Loading... |
378 return ToTouchEvent(EventDispatchMediator::GetEvent()); | 384 return ToTouchEvent(EventDispatchMediator::GetEvent()); |
379 } | 385 } |
380 | 386 |
381 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( | 387 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( |
382 EventDispatcher& dispatcher) const { | 388 EventDispatcher& dispatcher) const { |
383 Event().GetEventPath().AdjustForTouchEvent(Event()); | 389 Event().GetEventPath().AdjustForTouchEvent(Event()); |
384 return dispatcher.Dispatch(); | 390 return dispatcher.Dispatch(); |
385 } | 391 } |
386 | 392 |
387 } // namespace blink | 393 } // namespace blink |
OLD | NEW |