| 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 #ifndef EventHandlerRegistry_h | 5 #ifndef EventHandlerRegistry_h |
| 6 #define EventHandlerRegistry_h | 6 #define EventHandlerRegistry_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
| 10 #include "wtf/HashCountedSet.h" | 10 #include "wtf/HashCountedSet.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 class AddEventListenerOptions; | 14 class AddEventListenerOptions; |
| 15 class Document; | 15 class Document; |
| 16 class EventTarget; | 16 class EventTarget; |
| 17 class LocalFrame; |
| 17 | 18 |
| 18 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet; | 19 typedef HashCountedSet<UntracedMember<EventTarget>> EventTargetSet; |
| 19 | 20 |
| 20 // Registry for keeping track of event handlers. Note that only handlers on | 21 // Registry for keeping track of event handlers. Note that only handlers on |
| 21 // documents that can be rendered or can receive input (i.e., are attached to a | 22 // documents that can be rendered or can receive input (i.e., are attached to a |
| 22 // FrameHost) are registered here. | 23 // FrameHost) are registered here. |
| 23 class CORE_EXPORT EventHandlerRegistry final | 24 class CORE_EXPORT EventHandlerRegistry final |
| 24 : public GarbageCollectedFinalized<EventHandlerRegistry> { | 25 : public GarbageCollectedFinalized<EventHandlerRegistry> { |
| 25 public: | 26 public: |
| 26 explicit EventHandlerRegistry(FrameHost&); | 27 explicit EventHandlerRegistry(FrameHost&); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // Returns true if the operation actually added a new target or completely | 92 // Returns true if the operation actually added a new target or completely |
| 92 // removed an existing one. | 93 // removed an existing one. |
| 93 bool updateEventHandlerTargets(ChangeOperation, | 94 bool updateEventHandlerTargets(ChangeOperation, |
| 94 EventHandlerClass, | 95 EventHandlerClass, |
| 95 EventTarget*); | 96 EventTarget*); |
| 96 | 97 |
| 97 // Called on the EventHandlerRegistry of the root Document to notify | 98 // Called on the EventHandlerRegistry of the root Document to notify |
| 98 // clients when we have added the first handler or removed the last one for | 99 // clients when we have added the first handler or removed the last one for |
| 99 // a given event class. |hasActiveHandlers| can be used to distinguish | 100 // a given event class. |hasActiveHandlers| can be used to distinguish |
| 100 // between the two cases. | 101 // between the two cases. |
| 101 void notifyHasHandlersChanged(EventHandlerClass, bool hasActiveHandlers); | 102 void notifyHasHandlersChanged(LocalFrame*, |
| 103 EventHandlerClass, |
| 104 bool hasActiveHandlers); |
| 102 | 105 |
| 103 // Called to notify clients whenever a single event handler target is | 106 // Called to notify clients whenever a single event handler target is |
| 104 // registered or unregistered. If several handlers are registered for the | 107 // registered or unregistered. If several handlers are registered for the |
| 105 // same target, only the first registration will trigger this notification. | 108 // same target, only the first registration will trigger this notification. |
| 106 void notifyDidAddOrRemoveEventHandlerTarget(EventHandlerClass); | 109 void notifyDidAddOrRemoveEventHandlerTarget(EventHandlerClass); |
| 107 | 110 |
| 108 // Record a change operation to a given event handler class and notify any | 111 // Record a change operation to a given event handler class and notify any |
| 109 // parent registry and other clients accordingly. | 112 // parent registry and other clients accordingly. |
| 110 void updateEventHandlerOfType(ChangeOperation, | 113 void updateEventHandlerOfType(ChangeOperation, |
| 111 const AtomicString& eventType, | 114 const AtomicString& eventType, |
| 112 const AddEventListenerOptions&, | 115 const AddEventListenerOptions&, |
| 113 EventTarget*); | 116 EventTarget*); |
| 114 | 117 |
| 115 void updateEventHandlerInternal(ChangeOperation, | 118 void updateEventHandlerInternal(ChangeOperation, |
| 116 EventHandlerClass, | 119 EventHandlerClass, |
| 117 EventTarget*); | 120 EventTarget*); |
| 118 | 121 |
| 119 void updateAllEventHandlers(ChangeOperation, EventTarget&); | 122 void updateAllEventHandlers(ChangeOperation, EventTarget&); |
| 120 | 123 |
| 121 void checkConsistency() const; | 124 void checkConsistency() const; |
| 122 | 125 |
| 123 Member<FrameHost> m_frameHost; | 126 Member<FrameHost> m_frameHost; |
| 124 EventTargetSet m_targets[EventHandlerClassCount]; | 127 EventTargetSet m_targets[EventHandlerClassCount]; |
| 125 }; | 128 }; |
| 126 | 129 |
| 127 } // namespace blink | 130 } // namespace blink |
| 128 | 131 |
| 129 #endif // EventHandlerRegistry_h | 132 #endif // EventHandlerRegistry_h |
| OLD | NEW |