| 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/dom/DocumentSupplementable.h" | 8 #include "core/dom/DocumentSupplementable.h" |
| 9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
| 10 #include "wtf/HashCountedSet.h" | 10 #include "wtf/HashCountedSet.h" |
| 11 | 11 |
| 12 namespace WebCore { | 12 namespace WebCore { |
| 13 | 13 |
| 14 typedef HashCountedSet<EventTarget*> EventTargetSet; | 14 typedef HashCountedSet<EventTarget*> EventTargetSet; |
| 15 | 15 |
| 16 // Registry for keeping track of event handlers. Handlers can either be | 16 // Registry for keeping track of event handlers. Handlers can either be |
| 17 // associated with an EventTarget or be "external" handlers which live outside | 17 // associated with an EventTarget or be "external" handlers which live outside |
| 18 // the DOM (e.g., WebViewImpl). | 18 // the DOM (e.g., WebViewImpl). |
| 19 class EventHandlerRegistry FINAL : public DocumentSupplement { | 19 class EventHandlerRegistry FINAL : public NoBaseWillBeGarbageCollectedFinalized<
EventHandlerRegistry>, public DocumentSupplement { |
| 20 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(EventHandlerRegistry); |
| 20 public: | 21 public: |
| 21 virtual ~EventHandlerRegistry(); | 22 virtual ~EventHandlerRegistry(); |
| 22 | 23 |
| 23 // Supported event handler classes. Note that each one may correspond to | 24 // Supported event handler classes. Note that each one may correspond to |
| 24 // multiple event types. | 25 // multiple event types. |
| 25 enum EventHandlerClass { | 26 enum EventHandlerClass { |
| 26 ScrollEvent, | 27 ScrollEvent, |
| 27 EventHandlerClassCount, // Must be the last entry. | 28 EventHandlerClassCount, // Must be the last entry. |
| 28 }; | 29 }; |
| 29 | 30 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 const EventTargetSet* eventHandlerTargets(EventHandlerClass) const; | 42 const EventTargetSet* eventHandlerTargets(EventHandlerClass) const; |
| 42 | 43 |
| 43 // Registration and management of event handlers attached to EventTargets. | 44 // Registration and management of event handlers attached to EventTargets. |
| 44 void didAddEventHandler(EventTarget&, const AtomicString& eventType); | 45 void didAddEventHandler(EventTarget&, const AtomicString& eventType); |
| 45 void didAddEventHandler(EventTarget&, EventHandlerClass); | 46 void didAddEventHandler(EventTarget&, EventHandlerClass); |
| 46 void didRemoveEventHandler(EventTarget&, const AtomicString& eventType); | 47 void didRemoveEventHandler(EventTarget&, const AtomicString& eventType); |
| 47 void didRemoveEventHandler(EventTarget&, EventHandlerClass); | 48 void didRemoveEventHandler(EventTarget&, EventHandlerClass); |
| 48 void didMoveFromOtherDocument(EventTarget&, Document& oldDocument); | 49 void didMoveFromOtherDocument(EventTarget&, Document& oldDocument); |
| 49 void didRemoveAllEventHandlers(EventTarget&); | 50 void didRemoveAllEventHandlers(EventTarget&); |
| 50 | 51 |
| 51 virtual void trace(Visitor*) OVERRIDE { } | 52 virtual void trace(Visitor*) OVERRIDE; |
| 52 void clearWeakMembers(Visitor*); | 53 void clearWeakMembers(Visitor*); |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 explicit EventHandlerRegistry(Document&); | 56 explicit EventHandlerRegistry(Document&); |
| 56 | 57 |
| 57 enum ChangeOperation { | 58 enum ChangeOperation { |
| 58 Add, // Add a new event handler. | 59 Add, // Add a new event handler. |
| 59 Remove, // Remove an existing event handler. | 60 Remove, // Remove an existing event handler. |
| 60 RemoveAll // Remove any and all existing event handlers for a given targ
et. | 61 RemoveAll // Remove any and all existing event handlers for a given targ
et. |
| 61 }; | 62 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 86 OwnPtr<EventTargetSet> targets; | 87 OwnPtr<EventTargetSet> targets; |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 Document& m_document; | 90 Document& m_document; |
| 90 HandlerState m_eventHandlers[EventHandlerClassCount]; | 91 HandlerState m_eventHandlers[EventHandlerClassCount]; |
| 91 }; | 92 }; |
| 92 | 93 |
| 93 } // namespace WebCore | 94 } // namespace WebCore |
| 94 | 95 |
| 95 #endif // EventHandlerRegistry_h | 96 #endif // EventHandlerRegistry_h |
| OLD | NEW |