| 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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 EventHandlerRegistry::EventHandlerRegistry(FrameHost& frameHost) | 46 EventHandlerRegistry::EventHandlerRegistry(FrameHost& frameHost) |
| 47 : m_frameHost(&frameHost) | 47 : m_frameHost(&frameHost) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 EventHandlerRegistry::~EventHandlerRegistry() | 51 EventHandlerRegistry::~EventHandlerRegistry() |
| 52 { | 52 { |
| 53 checkConsistency(); | 53 checkConsistency(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const
EventListenerOptions& options, EventHandlerClass* result) | 56 bool EventHandlerRegistry::eventTypeToClass(const AtomicString& eventType, const
AddEventListenerOptions& options, EventHandlerClass* result) |
| 57 { | 57 { |
| 58 if (eventType == EventTypeNames::scroll) { | 58 if (eventType == EventTypeNames::scroll) { |
| 59 *result = ScrollEvent; | 59 *result = ScrollEvent; |
| 60 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames
::mousewheel) { | 60 } else if (eventType == EventTypeNames::wheel || eventType == EventTypeNames
::mousewheel) { |
| 61 *result = options.passive() ? WheelEventPassive : WheelEventBlocking; | 61 *result = options.passive() ? WheelEventPassive : WheelEventBlocking; |
| 62 } else if (eventType == EventTypeNames::touchend || eventType == EventTypeNa
mes::touchcancel) { | 62 } else if (eventType == EventTypeNames::touchend || eventType == EventTypeNa
mes::touchcancel) { |
| 63 *result = options.passive() ? TouchEndOrCancelEventPassive : TouchEndOrC
ancelEventBlocking; | 63 *result = options.passive() ? TouchEndOrCancelEventPassive : TouchEndOrC
ancelEventBlocking; |
| 64 } else if (eventType == EventTypeNames::touchstart || eventType == EventType
Names::touchmove) { | 64 } else if (eventType == EventTypeNames::touchstart || eventType == EventType
Names::touchmove) { |
| 65 *result = options.passive() ? TouchStartOrMoveEventPassive : TouchStartO
rMoveEventBlocking; | 65 *result = options.passive() ? TouchStartOrMoveEventPassive : TouchStartO
rMoveEventBlocking; |
| 66 } else if (isPointerEventType(eventType)) { | 66 } else if (isPointerEventType(eventType)) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 bool targetSetChanged = updateEventHandlerTargets(op, handlerClass, target); | 122 bool targetSetChanged = updateEventHandlerTargets(op, handlerClass, target); |
| 123 bool hasHandlers = m_targets[handlerClass].size(); | 123 bool hasHandlers = m_targets[handlerClass].size(); |
| 124 | 124 |
| 125 if (hadHandlers != hasHandlers) | 125 if (hadHandlers != hasHandlers) |
| 126 notifyHasHandlersChanged(handlerClass, hasHandlers); | 126 notifyHasHandlersChanged(handlerClass, hasHandlers); |
| 127 | 127 |
| 128 if (targetSetChanged) | 128 if (targetSetChanged) |
| 129 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); | 129 notifyDidAddOrRemoveEventHandlerTarget(handlerClass); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void EventHandlerRegistry::updateEventHandlerOfType(ChangeOperation op, const At
omicString& eventType, const EventListenerOptions& options, EventTarget* target) | 132 void EventHandlerRegistry::updateEventHandlerOfType(ChangeOperation op, const At
omicString& eventType, const AddEventListenerOptions& options, EventTarget* targ
et) |
| 133 { | 133 { |
| 134 EventHandlerClass handlerClass; | 134 EventHandlerClass handlerClass; |
| 135 if (!eventTypeToClass(eventType, options, &handlerClass)) | 135 if (!eventTypeToClass(eventType, options, &handlerClass)) |
| 136 return; | 136 return; |
| 137 updateEventHandlerInternal(op, handlerClass, target); | 137 updateEventHandlerInternal(op, handlerClass, target); |
| 138 } | 138 } |
| 139 | 139 |
| 140 void EventHandlerRegistry::didAddEventHandler(EventTarget& target, const AtomicS
tring& eventType, const EventListenerOptions& options) | 140 void EventHandlerRegistry::didAddEventHandler(EventTarget& target, const AtomicS
tring& eventType, const AddEventListenerOptions& options) |
| 141 { | 141 { |
| 142 updateEventHandlerOfType(Add, eventType, options, &target); | 142 updateEventHandlerOfType(Add, eventType, options, &target); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void EventHandlerRegistry::didRemoveEventHandler(EventTarget& target, const Atom
icString& eventType, const EventListenerOptions& options) | 145 void EventHandlerRegistry::didRemoveEventHandler(EventTarget& target, const Atom
icString& eventType, const AddEventListenerOptions& options) |
| 146 { | 146 { |
| 147 updateEventHandlerOfType(Remove, eventType, options, &target); | 147 updateEventHandlerOfType(Remove, eventType, options, &target); |
| 148 } | 148 } |
| 149 | 149 |
| 150 void EventHandlerRegistry::didAddEventHandler(EventTarget& target, EventHandlerC
lass handlerClass) | 150 void EventHandlerRegistry::didAddEventHandler(EventTarget& target, EventHandlerC
lass handlerClass) |
| 151 { | 151 { |
| 152 updateEventHandlerInternal(Add, handlerClass, &target); | 152 updateEventHandlerInternal(Add, handlerClass, &target); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void EventHandlerRegistry::didRemoveEventHandler(EventTarget& target, EventHandl
erClass handlerClass) | 155 void EventHandlerRegistry::didRemoveEventHandler(EventTarget& target, EventHandl
erClass handlerClass) |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 ASSERT(window->frame()); | 308 ASSERT(window->frame()); |
| 309 ASSERT(window->frame()->host()); | 309 ASSERT(window->frame()->host()); |
| 310 ASSERT(window->frame()->host() == m_frameHost); | 310 ASSERT(window->frame()->host() == m_frameHost); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 #endif // ENABLE(ASSERT) | 314 #endif // ENABLE(ASSERT) |
| 315 } | 315 } |
| 316 | 316 |
| 317 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |