Index: Source/core/page/EventHandlerRegistry.h |
diff --git a/Source/core/dom/EventHandlerRegistry.h b/Source/core/page/EventHandlerRegistry.h |
similarity index 72% |
rename from Source/core/dom/EventHandlerRegistry.h |
rename to Source/core/page/EventHandlerRegistry.h |
index dde20641c428ccdc74705796c5dd65ab488f28c9..5698cce4344e37fa5c59bd0d99b6a654f23307f5 100644 |
--- a/Source/core/dom/EventHandlerRegistry.h |
+++ b/Source/core/page/EventHandlerRegistry.h |
@@ -5,18 +5,16 @@ |
#ifndef EventHandlerRegistry_h |
#define EventHandlerRegistry_h |
-#include "core/dom/DocumentSupplementable.h" |
#include "core/events/Event.h" |
+#include "core/page/Page.h" |
#include "wtf/HashCountedSet.h" |
namespace WebCore { |
typedef HashCountedSet<EventTarget*> EventTargetSet; |
-// Registry for keeping track of event handlers. Handlers can either be |
-// associated with an EventTarget or be "external" handlers which live outside |
-// the DOM (e.g., WebViewImpl). |
-class EventHandlerRegistry FINAL : public DocumentSupplement { |
+// Registry for keeping track of event handlers. |
+class EventHandlerRegistry FINAL : public Supplement<Page> { |
public: |
virtual ~EventHandlerRegistry(); |
@@ -24,20 +22,20 @@ public: |
// multiple event types. |
enum EventHandlerClass { |
ScrollEvent, |
+#if ASSERT_ENABLED |
+ // Additional event categories for verifying handler tracking logic. |
+ EventsForTesting, |
+#endif |
EventHandlerClassCount, // Must be the last entry. |
}; |
static const char* supplementName(); |
- static EventHandlerRegistry* from(Document&); |
+ static EventHandlerRegistry* from(Page&); |
- // Returns true if the host Document or any child documents have any |
- // registered event handlers of the class. |
+ // Returns true if the page has event handlers of the specified class. |
bool hasEventHandlers(EventHandlerClass) const; |
- // Returns a set of EventTargets which have registered handlers of the |
- // given class. Only contains targets directly in this document; all |
- // handlers in a child Document are collapsed to a single respective |
- // Document instance in the set. |
+ // Returns a set of EventTargets which have registered handlers of the given class. |
const EventTargetSet* eventHandlerTargets(EventHandlerClass) const; |
// Registration and management of event handlers attached to EventTargets. |
@@ -45,13 +43,16 @@ public: |
void didAddEventHandler(EventTarget&, EventHandlerClass); |
void didRemoveEventHandler(EventTarget&, const AtomicString& eventType); |
void didRemoveEventHandler(EventTarget&, EventHandlerClass); |
- void didMoveFromOtherDocument(EventTarget&, Document& oldDocument); |
void didRemoveAllEventHandlers(EventTarget&); |
+ void didMoveIntoPage(EventTarget&); |
+ void didMoveOutOfPage(EventTarget&); |
+ |
+ void documentDetached(Document&); |
Rick Byers
2014/04/30 17:28:50
Please add a comment saying that we require didMov
Sami
2014/05/01 13:29:34
That's right, better be explicit about it. I've ad
|
virtual void trace(Visitor*) OVERRIDE { } |
private: |
- explicit EventHandlerRegistry(Document&); |
+ explicit EventHandlerRegistry(Page&); |
enum ChangeOperation { |
Add, // Add a new event handler. |
@@ -78,15 +79,12 @@ private: |
void updateEventHandlerInternal(ChangeOperation, EventHandlerClass, EventTarget*); |
- struct HandlerState { |
- HandlerState(); |
- ~HandlerState(); |
+ void updateAllEventHandlers(ChangeOperation, EventTarget&); |
- OwnPtr<EventTargetSet> targets; |
- }; |
+ void checkConsistency() const; |
- Document& m_document; |
- HandlerState m_eventHandlers[EventHandlerClassCount]; |
+ Page& m_page; |
+ EventTargetSet m_targets[EventHandlerClassCount]; |
}; |
} // namespace WebCore |