Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index 00d4d58cd6bf6c30b708508ef7f373631a6a3afa..0798dda6c5b079fdd35680c844fb3a3dd533d867 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -42,7 +42,6 @@ |
#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" |
@@ -81,6 +80,7 @@ |
#include "core/html/HTMLStyleElement.h" |
#include "core/page/ContextMenuController.h" |
#include "core/page/EventHandler.h" |
+#include "core/page/EventHandlerRegistry.h" |
#include "core/page/Page.h" |
#include "core/frame/Settings.h" |
#include "core/rendering/FlowThreadController.h" |
@@ -304,7 +304,8 @@ void Node::willBeDeletedFromDocument() |
if (hasEventTargetData()) { |
clearEventTargetData(); |
document.didClearTouchEventHandlers(this); |
- EventHandlerRegistry::from(document)->didRemoveAllEventHandlers(*this); |
+ if (document.page()) |
+ EventHandlerRegistry::from(*document.page())->didRemoveAllEventHandlers(*this); |
} |
if (AXObjectCache* cache = document.existingAXObjectCache()) |
@@ -1961,7 +1962,12 @@ void Node::didMoveToNewDocument(Document& oldDocument) |
document().didAddTouchEventHandler(this); |
} |
} |
- EventHandlerRegistry::from(document())->didMoveFromOtherDocument(*this, oldDocument); |
+ if (oldDocument.page() != document().page()) { |
+ if (oldDocument.page()) |
+ EventHandlerRegistry::from(*oldDocument.page())->didMoveOutOfPage(*this); |
+ if (document().page()) |
+ EventHandlerRegistry::from(*document().page())->didMoveIntoPage(*this); |
+ } |
if (WillBeHeapVector<OwnPtrWillBeMember<MutationObserverRegistration> >* registry = mutationObserverRegistry()) { |
for (size_t i = 0; i < registry->size(); ++i) { |
@@ -1987,7 +1993,8 @@ static inline bool tryAddEventListener(Node* targetNode, const AtomicString& eve |
WheelController::from(document)->didAddWheelEventHandler(document); |
else if (isTouchEventType(eventType)) |
document.didAddTouchEventHandler(targetNode); |
- EventHandlerRegistry::from(document)->didAddEventHandler(*targetNode, eventType); |
+ if (document.page()) |
+ EventHandlerRegistry::from(*document.page())->didAddEventHandler(*targetNode, eventType); |
return true; |
} |
@@ -2009,7 +2016,8 @@ static inline bool tryRemoveEventListener(Node* targetNode, const AtomicString& |
WheelController::from(document)->didRemoveWheelEventHandler(document); |
else if (isTouchEventType(eventType)) |
document.didRemoveTouchEventHandler(targetNode); |
- EventHandlerRegistry::from(document)->didRemoveEventHandler(*targetNode, eventType); |
+ if (document.page()) |
+ EventHandlerRegistry::from(*document.page())->didRemoveEventHandler(*targetNode, eventType); |
return true; |
} |
@@ -2021,8 +2029,8 @@ bool Node::removeEventListener(const AtomicString& eventType, EventListener* lis |
void Node::removeAllEventListeners() |
{ |
- if (hasEventListeners()) |
- EventHandlerRegistry::from(document())->didRemoveAllEventHandlers(*this); |
+ if (hasEventListeners() && document().page()) |
+ EventHandlerRegistry::from(*document().page())->didRemoveAllEventHandlers(*this); |
EventTarget::removeAllEventListeners(); |
document().didClearTouchEventHandlers(this); |
} |