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/events/Event.h" | 8 #include "core/events/Event.h" |
| 9 #include "core/frame/DOMWindowLifecycleObserver.h" |
9 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
10 #include "wtf/HashCountedSet.h" | 11 #include "wtf/HashCountedSet.h" |
| 12 #include "wtf/HashMap.h" |
11 | 13 |
12 namespace WebCore { | 14 namespace WebCore { |
13 | 15 |
14 typedef HashCountedSet<EventTarget*> EventTargetSet; | 16 typedef HashCountedSet<EventTarget*> EventTargetSet; |
15 | 17 |
16 // Registry for keeping track of event handlers. Note that only handlers on | 18 // Registry for keeping track of event handlers. Note that only handlers on |
17 // documents that can be rendered or can receive input (i.e., are attached to a | 19 // documents that can be rendered or can receive input (i.e., are attached to a |
18 // FrameHost) are registered here. | 20 // FrameHost) are registered here. |
19 class EventHandlerRegistry FINAL : public NoBaseWillBeGarbageCollectedFinalized<
EventHandlerRegistry> { | 21 class EventHandlerRegistry FINAL : public NoBaseWillBeGarbageCollectedFinalized<
EventHandlerRegistry> { |
20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(EventHandlerRegistry); | 22 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(EventHandlerRegistry); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // Record a change operation to a given event handler class and notify any | 82 // Record a change operation to a given event handler class and notify any |
81 // parent registry and other clients accordingly. | 83 // parent registry and other clients accordingly. |
82 void updateEventHandlerOfType(ChangeOperation, const AtomicString& eventType
, EventTarget*); | 84 void updateEventHandlerOfType(ChangeOperation, const AtomicString& eventType
, EventTarget*); |
83 | 85 |
84 void updateEventHandlerInternal(ChangeOperation, EventHandlerClass, EventTar
get*); | 86 void updateEventHandlerInternal(ChangeOperation, EventHandlerClass, EventTar
get*); |
85 | 87 |
86 void updateAllEventHandlers(ChangeOperation, EventTarget&); | 88 void updateAllEventHandlers(ChangeOperation, EventTarget&); |
87 | 89 |
88 void checkConsistency() const; | 90 void checkConsistency() const; |
89 | 91 |
| 92 class WindowObserver: public DOMWindowLifecycleObserver { |
| 93 public: |
| 94 WindowObserver(EventHandlerRegistry&, DOMWindow&); |
| 95 virtual ~WindowObserver(); |
| 96 |
| 97 // Inherited from DOMWindowLifecycleObserver |
| 98 virtual void didAddEventListener(DOMWindow*, const AtomicString&) OVERRI
DE; |
| 99 virtual void didRemoveEventListener(DOMWindow*, const AtomicString&) OVE
RRIDE; |
| 100 virtual void didRemoveAllEventListeners(DOMWindow*) OVERRIDE; |
| 101 |
| 102 private: |
| 103 EventHandlerRegistry& m_registry; |
| 104 }; |
| 105 |
90 FrameHost& m_frameHost; | 106 FrameHost& m_frameHost; |
91 EventTargetSet m_targets[EventHandlerClassCount]; | 107 EventTargetSet m_targets[EventHandlerClassCount]; |
| 108 |
| 109 HashMap<DOMWindow*, OwnPtr<WindowObserver> > m_windowObservers; |
92 }; | 110 }; |
93 | 111 |
94 } // namespace WebCore | 112 } // namespace WebCore |
95 | 113 |
96 #endif // EventHandlerRegistry_h | 114 #endif // EventHandlerRegistry_h |
OLD | NEW |