Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/frame/EventHandlerRegistry.h" | 5 #include "core/frame/EventHandlerRegistry.h" |
| 6 | 6 |
| 7 #include "core/events/EventListenerOptions.h" | 7 #include "core/events/EventListenerOptions.h" |
| 8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 #include "core/html/HTMLFrameOwnerElement.h" | 10 #include "core/html/HTMLFrameOwnerElement.h" |
| 11 #include "core/page/ChromeClient.h" | 11 #include "core/page/ChromeClient.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "core/page/scrolling/ScrollingCoordinator.h" | 13 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 inline bool isTouchEventType(const AtomicString& eventType) | |
| 20 { | |
| 21 return eventType == EventTypeNames::touchstart | |
| 22 || eventType == EventTypeNames::touchmove | |
| 23 || eventType == EventTypeNames::touchend | |
| 24 || eventType == EventTypeNames::touchcancel; | |
| 25 } | |
| 26 | |
| 27 inline bool isPointerEventType(const AtomicString& eventType) | 19 inline bool isPointerEventType(const AtomicString& eventType) |
| 28 { | 20 { |
| 29 return eventType == EventTypeNames::gotpointercapture | 21 return eventType == EventTypeNames::gotpointercapture |
| 30 || eventType == EventTypeNames::lostpointercapture | 22 || eventType == EventTypeNames::lostpointercapture |
| 31 || eventType == EventTypeNames::pointercancel | 23 || eventType == EventTypeNames::pointercancel |
| 32 || eventType == EventTypeNames::pointerdown | 24 || eventType == EventTypeNames::pointerdown |
| 33 || eventType == EventTypeNames::pointerenter | 25 || eventType == EventTypeNames::pointerenter |
| 34 || eventType == EventTypeNames::pointerleave | 26 || eventType == EventTypeNames::pointerleave |
| 35 || eventType == EventTypeNames::pointermove | 27 || eventType == EventTypeNames::pointermove |
| 36 || eventType == EventTypeNames::pointerout | 28 || eventType == EventTypeNames::pointerout |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 60 { | 52 { |
| 61 checkConsistency(); | 53 checkConsistency(); |
| 62 } | 54 } |
| 63 | 55 |
| 64 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const EventListenerOptions& options, EventHandlerClass* result) | 56 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const EventListenerOptions& options, EventHandlerClass* result) |
| 65 { | 57 { |
| 66 if (eventType == EventTypeNames::scroll) { | 58 if (eventType == EventTypeNames::scroll) { |
| 67 *result = ScrollEvent; | 59 *result = ScrollEvent; |
| 68 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames ::mousewheel) { | 60 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames ::mousewheel) { |
| 69 *result = options.passive() ? WheelEventPassive : WheelEventBlocking; | 61 *result = options.passive() ? WheelEventPassive : WheelEventBlocking; |
| 70 } else if (isTouchEventType(eventType)) { | 62 } else if (eventType == EventTypeNames::touchend || eventType == EventTypeNa mes::touchcancel) { |
| 63 *result = options.passive() ? TouchEndOrCancelEventPassive : TouchEndOrC ancelEventBlocking; | |
| 64 } else if (eventType == EventTypeNames::touchstart || eventType == EventType Names::touchmove) { | |
| 71 *result = options.passive() ? TouchEventPassive : TouchEventBlocking; | 65 *result = options.passive() ? TouchEventPassive : TouchEventBlocking; |
| 72 } else if (isPointerEventType(eventType)) { | 66 } else if (isPointerEventType(eventType)) { |
| 73 // The EventHandlerClass is TouchEventPassive since the pointer events | 67 // The EventHandlerClass is TouchEventPassive since the pointer events |
| 74 // never block scrolling and the compositor only needs to know | 68 // never block scrolling and the compositor only needs to know |
| 75 // about the touch listeners. | 69 // about the touch listeners. |
| 76 *result = TouchEventPassive; | 70 *result = TouchEventPassive; |
| 77 #if ENABLE(ASSERT) | 71 #if ENABLE(ASSERT) |
| 78 } else if (eventType == EventTypeNames::load || eventType == EventTypeNames: :mousemove || eventType == EventTypeNames::touchstart) { | 72 } else if (eventType == EventTypeNames::load || eventType == EventTypeNames: :mousemove || eventType == EventTypeNames::touchstart) { |
| 79 *result = EventsForTesting; | 73 *result = EventsForTesting; |
| 80 #endif | 74 #endif |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 case ScrollEvent: | 209 case ScrollEvent: |
| 216 m_frameHost->chromeClient().setHaveScrollEventHandlers(hasActiveHandlers ); | 210 m_frameHost->chromeClient().setHaveScrollEventHandlers(hasActiveHandlers ); |
| 217 break; | 211 break; |
| 218 case WheelEventBlocking: | 212 case WheelEventBlocking: |
| 219 case WheelEventPassive: | 213 case WheelEventPassive: |
| 220 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::MouseWheel, webEventListenerProperties(hasEventHandlers(WheelEventBlocking ), hasEventHandlers(WheelEventPassive))); | 214 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::MouseWheel, webEventListenerProperties(hasEventHandlers(WheelEventBlocking ), hasEventHandlers(WheelEventPassive))); |
| 221 break; | 215 break; |
| 222 case TouchEventBlocking: | 216 case TouchEventBlocking: |
| 223 case TouchEventPassive: | 217 case TouchEventPassive: |
| 224 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::Touch, webEventListenerProperties(hasEventHandlers(TouchEventBlocking), ha sEventHandlers(TouchEventPassive))); | 218 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::Touch, webEventListenerProperties(hasEventHandlers(TouchEventBlocking), ha sEventHandlers(TouchEventPassive))); |
| 219 updateHaveTouchEventListeners(); | |
| 220 break; | |
| 221 case TouchEndOrCancelEventBlocking: | |
| 222 case TouchEndOrCancelEventPassive: | |
| 223 m_frameHost->chromeClient().setEventListenerProperties(WebEventListenerC lass::TouchEndOrCancel, webEventListenerProperties(hasEventHandlers(TouchEndOrCa ncelEventBlocking), hasEventHandlers(TouchEndOrCancelEventPassive))); | |
| 224 updateHaveTouchEventListeners(); | |
| 225 break; | 225 break; |
| 226 #if ENABLE(ASSERT) | 226 #if ENABLE(ASSERT) |
| 227 case EventsForTesting: | 227 case EventsForTesting: |
| 228 break; | 228 break; |
| 229 #endif | 229 #endif |
| 230 default: | 230 default: |
| 231 ASSERT_NOT_REACHED(); | 231 ASSERT_NOT_REACHED(); |
| 232 break; | 232 break; |
| 233 } | 233 } |
| 234 } | 234 } |
| 235 | 235 |
| 236 void EventHandlerRegistry::updateHaveTouchEventListeners() | |
|
tdresser
2016/04/13 16:52:35
updateHasTouchEventListeners - I think we generall
dtapuska
2016/04/13 18:00:15
Will rename. I was trying to be consistent with Ch
| |
| 237 { | |
| 238 m_frameHost->chromeClient().setHaveTouchEventListeners(hasEventHandlers(Touc hEventBlocking) || hasEventHandlers(TouchEventPassive) || hasEventHandlers(Touch EndOrCancelEventBlocking) || hasEventHandlers(TouchEndOrCancelEventPassive)); | |
| 239 } | |
| 240 | |
| 236 void EventHandlerRegistry::notifyDidAddOrRemoveEventHandlerTarget(EventHandlerCl ass handlerClass) | 241 void EventHandlerRegistry::notifyDidAddOrRemoveEventHandlerTarget(EventHandlerCl ass handlerClass) |
| 237 { | 242 { |
| 238 ScrollingCoordinator* scrollingCoordinator = m_frameHost->page().scrollingCo ordinator(); | 243 ScrollingCoordinator* scrollingCoordinator = m_frameHost->page().scrollingCo ordinator(); |
| 239 if (scrollingCoordinator && handlerClass == TouchEventBlocking) | 244 if (scrollingCoordinator && handlerClass == TouchEventBlocking) |
| 240 scrollingCoordinator->touchEventTargetRectsDidChange(); | 245 scrollingCoordinator->touchEventTargetRectsDidChange(); |
| 241 } | 246 } |
| 242 | 247 |
| 243 DEFINE_TRACE(EventHandlerRegistry) | 248 DEFINE_TRACE(EventHandlerRegistry) |
| 244 { | 249 { |
| 245 visitor->trace(m_frameHost); | 250 visitor->trace(m_frameHost); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 ASSERT(window->frame()); | 315 ASSERT(window->frame()); |
| 311 ASSERT(window->frame()->host()); | 316 ASSERT(window->frame()->host()); |
| 312 ASSERT(window->frame()->host() == m_frameHost); | 317 ASSERT(window->frame()->host() == m_frameHost); |
| 313 } | 318 } |
| 314 } | 319 } |
| 315 } | 320 } |
| 316 #endif // ENABLE(ASSERT) | 321 #endif // ENABLE(ASSERT) |
| 317 } | 322 } |
| 318 | 323 |
| 319 } // namespace blink | 324 } // namespace blink |
| OLD | NEW |