| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHistogram, | 190 DEFINE_STATIC_LOCAL(EnumerationHistogram, rootDocumentListenerHistogram, |
| 191 ("Event.Touch.TargetAndDispatchResult2", | 191 ("Event.Touch.TargetAndDispatchResult2", |
| 192 TouchTargetAndDispatchResultTypeMax)); | 192 TouchTargetAndDispatchResultTypeMax)); |
| 193 rootDocumentListenerHistogram.count( | 193 rootDocumentListenerHistogram.count( |
| 194 static_cast<TouchTargetAndDispatchResultType>(result)); | 194 static_cast<TouchTargetAndDispatchResultType>(result)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace | 197 } // namespace |
| 198 | 198 |
| 199 TouchEvent::TouchEvent() | 199 TouchEvent::TouchEvent() |
| 200 : m_causesScrollingIfUncanceled(false), | 200 : m_defaultPreventedBeforeCurrentTarget(false), |
| 201 m_firstTouchMoveOrStart(false), | |
| 202 m_defaultPreventedBeforeCurrentTarget(false), | |
| 203 m_currentTouchAction(TouchActionAuto) {} | 201 m_currentTouchAction(TouchActionAuto) {} |
| 204 | 202 |
| 205 TouchEvent::TouchEvent(TouchList* touches, | 203 TouchEvent::TouchEvent(const WebTouchEvent& event, |
| 204 TouchList* touches, |
| 206 TouchList* targetTouches, | 205 TouchList* targetTouches, |
| 207 TouchList* changedTouches, | 206 TouchList* changedTouches, |
| 208 const AtomicString& type, | 207 const AtomicString& type, |
| 209 AbstractView* view, | 208 AbstractView* view, |
| 210 PlatformEvent::Modifiers modifiers, | 209 TouchAction currentTouchAction) |
| 211 bool cancelable, | |
| 212 bool causesScrollingIfUncanceled, | |
| 213 bool firstTouchMoveOrStart, | |
| 214 TimeTicks platformTimeStamp, | |
| 215 TouchAction currentTouchAction, | |
| 216 WebPointerProperties::PointerType pointerType) | |
| 217 // Pass a sourceCapabilities including the ability to fire touchevents when | 210 // Pass a sourceCapabilities including the ability to fire touchevents when |
| 218 // creating this touchevent, which is always created from input device | 211 // creating this touchevent, which is always created from input device |
| 219 // capabilities from EventHandler. | 212 // capabilities from EventHandler. |
| 220 : UIEventWithKeyState( | 213 : UIEventWithKeyState( |
| 221 type, | 214 type, |
| 222 true, | 215 true, |
| 223 cancelable, | 216 event.isCancelable(), |
| 224 view, | 217 view, |
| 225 0, | 218 0, |
| 226 modifiers, | 219 static_cast<PlatformEvent::Modifiers>(event.modifiers()), |
| 227 platformTimeStamp, | 220 TimeTicks::FromSeconds(event.timeStampSeconds()), |
| 228 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), | 221 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), |
| 229 m_touches(touches), | 222 m_touches(touches), |
| 230 m_targetTouches(targetTouches), | 223 m_targetTouches(targetTouches), |
| 231 m_changedTouches(changedTouches), | 224 m_changedTouches(changedTouches), |
| 232 m_causesScrollingIfUncanceled(causesScrollingIfUncanceled), | |
| 233 m_firstTouchMoveOrStart(firstTouchMoveOrStart), | |
| 234 m_defaultPreventedBeforeCurrentTarget(false), | 225 m_defaultPreventedBeforeCurrentTarget(false), |
| 235 m_currentTouchAction(currentTouchAction), | 226 m_currentTouchAction(currentTouchAction) { |
| 236 m_pointerType(pointerType) {} | 227 m_nativeEvent.reset(new WebTouchEvent(event)); |
| 228 } |
| 237 | 229 |
| 238 TouchEvent::TouchEvent(const AtomicString& type, | 230 TouchEvent::TouchEvent(const AtomicString& type, |
| 239 const TouchEventInit& initializer) | 231 const TouchEventInit& initializer) |
| 240 : UIEventWithKeyState(type, initializer), | 232 : UIEventWithKeyState(type, initializer), |
| 241 m_touches(TouchList::create(initializer.touches())), | 233 m_touches(TouchList::create(initializer.touches())), |
| 242 m_targetTouches(TouchList::create(initializer.targetTouches())), | 234 m_targetTouches(TouchList::create(initializer.targetTouches())), |
| 243 m_changedTouches(TouchList::create(initializer.changedTouches())), | 235 m_changedTouches(TouchList::create(initializer.changedTouches())), |
| 244 m_causesScrollingIfUncanceled(false), | 236 m_currentTouchAction(TouchActionAuto) {} |
| 245 m_firstTouchMoveOrStart(false), | |
| 246 m_defaultPreventedBeforeCurrentTarget(false), | |
| 247 m_currentTouchAction(TouchActionAuto), | |
| 248 m_pointerType(WebPointerProperties::PointerType::Unknown) {} | |
| 249 | 237 |
| 250 TouchEvent::~TouchEvent() {} | 238 TouchEvent::~TouchEvent() {} |
| 251 | 239 |
| 252 const AtomicString& TouchEvent::interfaceName() const { | 240 const AtomicString& TouchEvent::interfaceName() const { |
| 253 return EventNames::TouchEvent; | 241 return EventNames::TouchEvent; |
| 254 } | 242 } |
| 255 | 243 |
| 256 bool TouchEvent::isTouchEvent() const { | 244 bool TouchEvent::isTouchEvent() const { |
| 257 return true; | 245 return true; |
| 258 } | 246 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 UseCounter::count( | 296 UseCounter::count( |
| 309 view()->frame(), | 297 view()->frame(), |
| 310 UseCounter::TouchEventPreventedForcedDocumentPassiveNoTouchAction); | 298 UseCounter::TouchEventPreventedForcedDocumentPassiveNoTouchAction); |
| 311 break; | 299 break; |
| 312 default: | 300 default: |
| 313 break; | 301 break; |
| 314 } | 302 } |
| 315 } | 303 } |
| 316 } | 304 } |
| 317 | 305 |
| 306 bool TouchEvent::isTouchStartOrFirstTouchMove() const { |
| 307 if (!m_nativeEvent) |
| 308 return false; |
| 309 return m_nativeEvent->touchStartOrFirstTouchMove; |
| 310 } |
| 311 |
| 318 void TouchEvent::doneDispatchingEventAtCurrentTarget() { | 312 void TouchEvent::doneDispatchingEventAtCurrentTarget() { |
| 319 // Do not log for non-cancelable events, events that don't block | 313 // Do not log for non-cancelable events, events that don't block |
| 320 // scrolling, have more than one touch point or aren't on the main frame. | 314 // scrolling, have more than one touch point or aren't on the main frame. |
| 321 if (!cancelable() || !m_firstTouchMoveOrStart || | 315 if (!cancelable() || !isTouchStartOrFirstTouchMove() || |
| 322 !(m_touches && m_touches->length() == 1) || | 316 !(m_touches && m_touches->length() == 1) || |
| 323 !(view() && view()->frame() && view()->frame()->isMainFrame())) | 317 !(view() && view()->frame() && view()->frame()->isMainFrame())) |
| 324 return; | 318 return; |
| 325 | 319 |
| 326 bool canceled = defaultPrevented(); | 320 bool canceled = defaultPrevented(); |
| 327 logTouchTargetHistogram(currentTarget(), eventPhase(), | 321 logTouchTargetHistogram(currentTarget(), eventPhase(), |
| 328 m_defaultPreventedBeforeCurrentTarget, canceled); | 322 m_defaultPreventedBeforeCurrentTarget, canceled); |
| 329 m_defaultPreventedBeforeCurrentTarget = canceled; | 323 m_defaultPreventedBeforeCurrentTarget = canceled; |
| 330 } | 324 } |
| 331 | 325 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 352 return toTouchEvent(EventDispatchMediator::event()); | 346 return toTouchEvent(EventDispatchMediator::event()); |
| 353 } | 347 } |
| 354 | 348 |
| 355 DispatchEventResult TouchEventDispatchMediator::dispatchEvent( | 349 DispatchEventResult TouchEventDispatchMediator::dispatchEvent( |
| 356 EventDispatcher& dispatcher) const { | 350 EventDispatcher& dispatcher) const { |
| 357 event().eventPath().adjustForTouchEvent(event()); | 351 event().eventPath().adjustForTouchEvent(event()); |
| 358 return dispatcher.dispatch(); | 352 return dispatcher.dispatch(); |
| 359 } | 353 } |
| 360 | 354 |
| 361 } // namespace blink | 355 } // namespace blink |
| OLD | NEW |