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