| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 ("Event.Touch.TargetAndDispatchResult2", | 193 ("Event.Touch.TargetAndDispatchResult2", |
| 194 kTouchTargetAndDispatchResultTypeMax)); | 194 kTouchTargetAndDispatchResultTypeMax)); |
| 195 root_document_listener_histogram.Count( | 195 root_document_listener_histogram.Count( |
| 196 static_cast<TouchTargetAndDispatchResultType>(result)); | 196 static_cast<TouchTargetAndDispatchResultType>(result)); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace | 199 } // namespace |
| 200 | 200 |
| 201 TouchEvent::TouchEvent() | 201 TouchEvent::TouchEvent() |
| 202 : default_prevented_before_current_target_(false), | 202 : default_prevented_before_current_target_(false), |
| 203 current_touch_action_(kTouchActionAuto) {} | 203 current_touch_action_(TouchAction::kTouchActionAuto) {} |
| 204 | 204 |
| 205 TouchEvent::TouchEvent(const WebTouchEvent& event, | 205 TouchEvent::TouchEvent(const WebTouchEvent& event, |
| 206 TouchList* touches, | 206 TouchList* touches, |
| 207 TouchList* target_touches, | 207 TouchList* target_touches, |
| 208 TouchList* changed_touches, | 208 TouchList* changed_touches, |
| 209 const AtomicString& type, | 209 const AtomicString& type, |
| 210 AbstractView* view, | 210 AbstractView* view, |
| 211 TouchAction current_touch_action) | 211 TouchAction current_touch_action) |
| 212 // Pass a sourceCapabilities including the ability to fire touchevents when | 212 // Pass a sourceCapabilities including the ability to fire touchevents when |
| 213 // creating this touchevent, which is always created from input device | 213 // creating this touchevent, which is always created from input device |
| (...skipping 15 matching lines...) Expand all Loading... |
| 229 current_touch_action_(current_touch_action) { | 229 current_touch_action_(current_touch_action) { |
| 230 native_event_.reset(new WebTouchEvent(event)); | 230 native_event_.reset(new WebTouchEvent(event)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 TouchEvent::TouchEvent(const AtomicString& type, | 233 TouchEvent::TouchEvent(const AtomicString& type, |
| 234 const TouchEventInit& initializer) | 234 const TouchEventInit& initializer) |
| 235 : UIEventWithKeyState(type, initializer), | 235 : UIEventWithKeyState(type, initializer), |
| 236 touches_(TouchList::Create(initializer.touches())), | 236 touches_(TouchList::Create(initializer.touches())), |
| 237 target_touches_(TouchList::Create(initializer.targetTouches())), | 237 target_touches_(TouchList::Create(initializer.targetTouches())), |
| 238 changed_touches_(TouchList::Create(initializer.changedTouches())), | 238 changed_touches_(TouchList::Create(initializer.changedTouches())), |
| 239 current_touch_action_(kTouchActionAuto) {} | 239 current_touch_action_(TouchAction::kTouchActionAuto) {} |
| 240 | 240 |
| 241 TouchEvent::~TouchEvent() {} | 241 TouchEvent::~TouchEvent() {} |
| 242 | 242 |
| 243 const AtomicString& TouchEvent::InterfaceName() const { | 243 const AtomicString& TouchEvent::InterfaceName() const { |
| 244 return EventNames::TouchEvent; | 244 return EventNames::TouchEvent; |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool TouchEvent::IsTouchEvent() const { | 247 bool TouchEvent::IsTouchEvent() const { |
| 248 return true; | 248 return true; |
| 249 } | 249 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 " event with cancelable=false, for example " | 289 " event with cancelable=false, for example " |
| 290 "because scrolling is in progress and " | 290 "because scrolling is in progress and " |
| 291 "cannot be interrupted."; | 291 "cannot be interrupted."; |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 break; | 294 break; |
| 295 case PassiveMode::kPassiveForcedDocumentLevel: | 295 case PassiveMode::kPassiveForcedDocumentLevel: |
| 296 // Only enable the warning when the current touch action is auto because | 296 // Only enable the warning when the current touch action is auto because |
| 297 // an author may use touch action but call preventDefault for interop with | 297 // an author may use touch action but call preventDefault for interop with |
| 298 // browsers that don't support touch-action. | 298 // browsers that don't support touch-action. |
| 299 if (current_touch_action_ == kTouchActionAuto) { | 299 if (current_touch_action_ == TouchAction::kTouchActionAuto) { |
| 300 message_source = kInterventionMessageSource; | 300 message_source = kInterventionMessageSource; |
| 301 warning_message = | 301 warning_message = |
| 302 "Unable to preventDefault inside passive event listener due to " | 302 "Unable to preventDefault inside passive event listener due to " |
| 303 "target being treated as passive. See " | 303 "target being treated as passive. See " |
| 304 "https://www.chromestatus.com/features/5093566007214080"; | 304 "https://www.chromestatus.com/features/5093566007214080"; |
| 305 } | 305 } |
| 306 break; | 306 break; |
| 307 default: | 307 default: |
| 308 break; | 308 break; |
| 309 } | 309 } |
| 310 | 310 |
| 311 if (!warning_message.IsEmpty() && view() && view()->IsLocalDOMWindow() && | 311 if (!warning_message.IsEmpty() && view() && view()->IsLocalDOMWindow() && |
| 312 view()->GetFrame()) { | 312 view()->GetFrame()) { |
| 313 ToLocalDOMWindow(view())->GetFrame()->Console().AddMessage( | 313 ToLocalDOMWindow(view())->GetFrame()->Console().AddMessage( |
| 314 ConsoleMessage::Create(message_source, kWarningMessageLevel, | 314 ConsoleMessage::Create(message_source, kWarningMessageLevel, |
| 315 warning_message)); | 315 warning_message)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 if ((type() == EventTypeNames::touchstart || | 318 if ((type() == EventTypeNames::touchstart || |
| 319 type() == EventTypeNames::touchmove) && | 319 type() == EventTypeNames::touchmove) && |
| 320 view() && view()->GetFrame() && | 320 view() && view()->GetFrame() && |
| 321 current_touch_action_ == kTouchActionAuto) { | 321 current_touch_action_ == TouchAction::kTouchActionAuto) { |
| 322 switch (HandlingPassive()) { | 322 switch (HandlingPassive()) { |
| 323 case PassiveMode::kNotPassiveDefault: | 323 case PassiveMode::kNotPassiveDefault: |
| 324 UseCounter::Count(view()->GetFrame(), | 324 UseCounter::Count(view()->GetFrame(), |
| 325 UseCounter::kTouchEventPreventedNoTouchAction); | 325 UseCounter::kTouchEventPreventedNoTouchAction); |
| 326 break; | 326 break; |
| 327 case PassiveMode::kPassiveForcedDocumentLevel: | 327 case PassiveMode::kPassiveForcedDocumentLevel: |
| 328 UseCounter::Count( | 328 UseCounter::Count( |
| 329 view()->GetFrame(), | 329 view()->GetFrame(), |
| 330 UseCounter::kTouchEventPreventedForcedDocumentPassiveNoTouchAction); | 330 UseCounter::kTouchEventPreventedForcedDocumentPassiveNoTouchAction); |
| 331 break; | 331 break; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 return ToTouchEvent(EventDispatchMediator::GetEvent()); | 378 return ToTouchEvent(EventDispatchMediator::GetEvent()); |
| 379 } | 379 } |
| 380 | 380 |
| 381 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( | 381 DispatchEventResult TouchEventDispatchMediator::DispatchEvent( |
| 382 EventDispatcher& dispatcher) const { | 382 EventDispatcher& dispatcher) const { |
| 383 Event().GetEventPath().AdjustForTouchEvent(Event()); | 383 Event().GetEventPath().AdjustForTouchEvent(Event()); |
| 384 return dispatcher.Dispatch(); | 384 return dispatcher.Dispatch(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 } // namespace blink | 387 } // namespace blink |
| OLD | NEW |