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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 TouchEvent::TouchEvent(TouchList* touches, | 204 TouchEvent::TouchEvent(TouchList* touches, |
205 TouchList* targetTouches, | 205 TouchList* targetTouches, |
206 TouchList* changedTouches, | 206 TouchList* changedTouches, |
207 const AtomicString& type, | 207 const AtomicString& type, |
208 AbstractView* view, | 208 AbstractView* view, |
209 PlatformEvent::Modifiers modifiers, | 209 PlatformEvent::Modifiers modifiers, |
210 bool cancelable, | 210 bool cancelable, |
211 bool causesScrollingIfUncanceled, | 211 bool causesScrollingIfUncanceled, |
212 bool firstTouchMoveOrStart, | 212 bool firstTouchMoveOrStart, |
213 double platformTimeStamp) | 213 double platformTimeStamp, |
| 214 TouchAction currentTouchAction) |
214 // Pass a sourceCapabilities including the ability to fire touchevents when | 215 // Pass a sourceCapabilities including the ability to fire touchevents when |
215 // creating this touchevent, which is always created from input device | 216 // creating this touchevent, which is always created from input device |
216 // capabilities from EventHandler. | 217 // capabilities from EventHandler. |
217 : UIEventWithKeyState( | 218 : UIEventWithKeyState( |
218 type, | 219 type, |
219 true, | 220 true, |
220 cancelable, | 221 cancelable, |
221 view, | 222 view, |
222 0, | 223 0, |
223 modifiers, | 224 modifiers, |
224 platformTimeStamp, | 225 platformTimeStamp, |
225 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), | 226 InputDeviceCapabilities::firesTouchEventsSourceCapabilities()), |
226 m_touches(touches), | 227 m_touches(touches), |
227 m_targetTouches(targetTouches), | 228 m_targetTouches(targetTouches), |
228 m_changedTouches(changedTouches), | 229 m_changedTouches(changedTouches), |
229 m_causesScrollingIfUncanceled(causesScrollingIfUncanceled), | 230 m_causesScrollingIfUncanceled(causesScrollingIfUncanceled), |
230 m_firstTouchMoveOrStart(firstTouchMoveOrStart), | 231 m_firstTouchMoveOrStart(firstTouchMoveOrStart), |
231 m_defaultPreventedBeforeCurrentTarget(false) {} | 232 m_defaultPreventedBeforeCurrentTarget(false), |
| 233 m_currentTouchAction(currentTouchAction) {} |
232 | 234 |
233 TouchEvent::TouchEvent(const AtomicString& type, | 235 TouchEvent::TouchEvent(const AtomicString& type, |
234 const TouchEventInit& initializer) | 236 const TouchEventInit& initializer) |
235 : UIEventWithKeyState(type, initializer), | 237 : UIEventWithKeyState(type, initializer), |
236 m_touches(TouchList::create(initializer.touches())), | 238 m_touches(TouchList::create(initializer.touches())), |
237 m_targetTouches(TouchList::create(initializer.targetTouches())), | 239 m_targetTouches(TouchList::create(initializer.targetTouches())), |
238 m_changedTouches(TouchList::create(initializer.changedTouches())), | 240 m_changedTouches(TouchList::create(initializer.changedTouches())), |
239 m_causesScrollingIfUncanceled(false), | 241 m_causesScrollingIfUncanceled(false), |
240 m_firstTouchMoveOrStart(false), | 242 m_firstTouchMoveOrStart(false), |
241 m_defaultPreventedBeforeCurrentTarget(false) {} | 243 m_defaultPreventedBeforeCurrentTarget(false) {} |
(...skipping 16 matching lines...) Expand all Loading... |
258 // event is uncancelable. | 260 // event is uncancelable. |
259 if (!cancelable() && handlingPassive() == PassiveMode::NotPassive && view() && | 261 if (!cancelable() && handlingPassive() == PassiveMode::NotPassive && view() && |
260 view()->isLocalDOMWindow() && view()->frame()) { | 262 view()->isLocalDOMWindow() && view()->frame()) { |
261 toLocalDOMWindow(view())->frame()->console().addMessage( | 263 toLocalDOMWindow(view())->frame()->console().addMessage( |
262 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, | 264 ConsoleMessage::create(JSMessageSource, WarningMessageLevel, |
263 "Ignored attempt to cancel a " + type() + | 265 "Ignored attempt to cancel a " + type() + |
264 " event with cancelable=false, for example " | 266 " event with cancelable=false, for example " |
265 "because scrolling is in progress and " | 267 "because scrolling is in progress and " |
266 "cannot be interrupted.")); | 268 "cannot be interrupted.")); |
267 } | 269 } |
| 270 |
| 271 if ((type() == EventTypeNames::touchstart || |
| 272 type() == EventTypeNames::touchmove) && |
| 273 view()->frame() && m_currentTouchAction == TouchActionAuto) { |
| 274 switch (handlingPassive()) { |
| 275 case PassiveMode::NotPassiveDefault: |
| 276 UseCounter::count(view()->frame(), |
| 277 UseCounter::TouchEventPreventedNoTouchAction); |
| 278 break; |
| 279 case PassiveMode::PassiveForcedDocumentLevel: |
| 280 UseCounter::count( |
| 281 view()->frame(), |
| 282 UseCounter::TouchEventPreventedForcedDocumentPassiveNoTouchAction); |
| 283 break; |
| 284 default: |
| 285 break; |
| 286 } |
| 287 } |
268 } | 288 } |
269 | 289 |
270 void TouchEvent::doneDispatchingEventAtCurrentTarget() { | 290 void TouchEvent::doneDispatchingEventAtCurrentTarget() { |
271 // Do not log for non-cancelable events, events that don't block | 291 // Do not log for non-cancelable events, events that don't block |
272 // scrolling, have more than one touch point or aren't on the main frame. | 292 // scrolling, have more than one touch point or aren't on the main frame. |
273 if (!cancelable() || !m_firstTouchMoveOrStart || | 293 if (!cancelable() || !m_firstTouchMoveOrStart || |
274 !(m_touches && m_touches->length() == 1) || | 294 !(m_touches && m_touches->length() == 1) || |
275 !(view() && view()->frame() && view()->frame()->isMainFrame())) | 295 !(view() && view()->frame() && view()->frame()->isMainFrame())) |
276 return; | 296 return; |
277 | 297 |
(...skipping 26 matching lines...) Expand all Loading... |
304 return toTouchEvent(EventDispatchMediator::event()); | 324 return toTouchEvent(EventDispatchMediator::event()); |
305 } | 325 } |
306 | 326 |
307 DispatchEventResult TouchEventDispatchMediator::dispatchEvent( | 327 DispatchEventResult TouchEventDispatchMediator::dispatchEvent( |
308 EventDispatcher& dispatcher) const { | 328 EventDispatcher& dispatcher) const { |
309 event().eventPath().adjustForTouchEvent(event()); | 329 event().eventPath().adjustForTouchEvent(event()); |
310 return dispatcher.dispatch(); | 330 return dispatcher.dispatch(); |
311 } | 331 } |
312 | 332 |
313 } // namespace blink | 333 } // namespace blink |
OLD | NEW |