Index: Source/core/dom/EventHandlerRegistry.h |
diff --git a/Source/core/dom/EventHandlerRegistry.h b/Source/core/dom/EventHandlerRegistry.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1e761c225f3f6a02758290eeaba6b530a57265b6 |
--- /dev/null |
+++ b/Source/core/dom/EventHandlerRegistry.h |
@@ -0,0 +1,60 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+#ifndef EventHandlerRegistry_h |
+#define EventHandlerRegistry_h |
+ |
+#include "core/dom/DocumentSupplementable.h" |
+#include "core/events/Event.h" |
+#include "core/frame/DOMWindowLifecycleObserver.h" |
+#include "wtf/HashCountedSet.h" |
+ |
+namespace WebCore { |
+ |
+class DOMWindow; |
+ |
+typedef HashCountedSet<Node*> TouchEventTargetSet; |
+ |
+class EventHandlerRegistry FINAL : public DocumentSupplement, public DOMWindowLifecycleObserver { |
Rick Byers
2014/03/24 14:27:59
I really like the fact that you're unifying this e
|
+public: |
+ virtual ~EventHandlerRegistry(); |
+ |
+ static const char* supplementName(); |
+ static EventHandlerRegistry* from(Document&); |
+ |
+ unsigned scrollEventHandlerCount() const { return m_scrollEventHandlerCount; } |
+ unsigned wheelEventHandlerCount() const { return m_wheelEventHandlerCount; } |
+ |
+ // Node: Handlers added/removed from the DOMWindow are reported as the Document. |
+ const TouchEventTargetSet* touchEventTargets() const { return m_touchEventTargets.get(); } |
+ |
+ static void didRemoveAllEventHandlers(Node&); |
+ static void didMoveNodeToNewDocument(Node&, Document& oldDocument); |
+ |
+ void didAddEventHandler(Document&, const AtomicString&, Node*); |
+ void didRemoveEventHandler(Document&, const AtomicString&, Node*); |
+ |
+ // Inherited from DOMWindowLifecycleObserver |
+ virtual void didAddEventListener(DOMWindow*, const AtomicString&) OVERRIDE; |
+ virtual void didRemoveEventListener(DOMWindow*, const AtomicString&) OVERRIDE; |
+ |
+private: |
+ explicit EventHandlerRegistry(Document&); |
+ |
+ void didChangeWheelEventHandlerCount(Document&, int delta); |
+ void didChangeScrollEventHandlerCount(Document&, int delta); |
+ |
+ void didAddTouchEventHandler(Document&, Node&); |
+ void didRemoveTouchEventHandler(Document&, Node&, bool clearAll); |
+ |
+ enum ChangeOperation { Added, Removed, RemovedAll }; |
+ static void didChangeAllEventHandlers(Node&, Document&, ChangeOperation); |
+ |
+ unsigned m_scrollEventHandlerCount; |
+ unsigned m_wheelEventHandlerCount; |
+ OwnPtr<TouchEventTargetSet> m_touchEventTargets; |
+}; |
+ |
+} // namespace WebCore |
+ |
+#endif // EventHandlerRegistry_h |