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