Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(780)

Unified Diff: Source/core/dom/Node.cpp

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added comments. Replaced nullptr with 0 to fix build. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index be65f36a0f211db585a14d9bd15515686da28bfc..3d71ab26c0c822ecf255b2eabe75f5c06d8ce8db 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -42,6 +42,7 @@
#include "core/dom/Element.h"
#include "core/dom/ElementRareData.h"
#include "core/dom/ElementTraversal.h"
+#include "core/dom/EventHandlerRegistry.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/LiveNodeList.h"
#include "core/dom/NodeRareData.h"
@@ -54,7 +55,6 @@
#include "core/dom/Text.h"
#include "core/dom/TreeScopeAdopter.h"
#include "core/dom/UserActionElementSet.h"
-#include "core/dom/WheelController.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/InsertionPoint.h"
#include "core/dom/shadow/ShadowRoot.h"
@@ -290,7 +290,7 @@ void Node::willBeDeletedFromDocument()
if (hasEventTargetData()) {
clearEventTargetData();
- document.didClearTouchEventHandlers(this);
+ EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this);
}
if (AXObjectCache* cache = document.existingAXObjectCache())
@@ -1919,26 +1919,7 @@ void Node::didMoveToNewDocument(Document& oldDocument)
cache->remove(this);
}
- const EventListenerVector& mousewheelListeners = getEventListeners(EventTypeNames::mousewheel);
- WheelController* oldController = WheelController::from(oldDocument);
- WheelController* newController = WheelController::from(document());
- for (size_t i = 0; i < mousewheelListeners.size(); ++i) {
- oldController->didRemoveWheelEventHandler(oldDocument);
- newController->didAddWheelEventHandler(document());
- }
-
- const EventListenerVector& wheelListeners = getEventListeners(EventTypeNames::wheel);
- for (size_t i = 0; i < wheelListeners.size(); ++i) {
- oldController->didRemoveWheelEventHandler(oldDocument);
- newController->didAddWheelEventHandler(document());
- }
-
- if (const TouchEventTargetSet* touchHandlers = oldDocument.touchEventTargets()) {
- while (touchHandlers->contains(this)) {
- oldDocument.didRemoveTouchEventHandler(this);
- document().didAddTouchEventHandler(this);
- }
- }
+ EventHandlerRegistry::from(document())->didMoveFromOtherDocument(*this, oldDocument);
if (Vector<OwnPtr<MutationObserverRegistration> >* registry = mutationObserverRegistry()) {
for (size_t i = 0; i < registry->size(); ++i) {
@@ -1960,10 +1941,7 @@ static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve
Document& document = targetNode->document();
document.addListenerTypeIfNeeded(eventType);
- if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mousewheel)
- WheelController::from(document)->didAddWheelEventHandler(document);
- else if (isTouchEventType(eventType))
- document.didAddTouchEventHandler(targetNode);
+ EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventType);
return true;
}
@@ -1981,10 +1959,7 @@ static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString&
// FIXME: Notify Document that the listener has vanished. We need to keep track of a number of
// listeners for each type, not just a bool - see https://bugs.webkit.org/show_bug.cgi?id=33861
Document& document = targetNode->document();
- if (eventType == EventTypeNames::wheel || eventType == EventTypeNames::mousewheel)
- WheelController::from(document)->didRemoveWheelEventHandler(document);
- else if (isTouchEventType(eventType))
- document.didRemoveTouchEventHandler(targetNode);
+ EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eventType);
return true;
}
@@ -1997,7 +1972,7 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis
void Node::removeAllEventListeners()
{
EventTarget::removeAllEventListeners();
- document().didClearTouchEventHandlers(this);
+ EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this);
}
typedef HashMap<Node*, OwnPtr<EventTargetData> > EventTargetDataMap;

Powered by Google App Engine
This is Rietveld 408576698