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

Side by Side Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2585353002: Detach Event Listener Properties before moving Node. (Closed)
Patch Set: Use oldDocument instead of node's document() when deregistering event handlers. Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 1790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 } 1801 }
1802 1802
1803 const AtomicString& Node::interfaceName() const { 1803 const AtomicString& Node::interfaceName() const {
1804 return EventTargetNames::Node; 1804 return EventTargetNames::Node;
1805 } 1805 }
1806 1806
1807 ExecutionContext* Node::getExecutionContext() const { 1807 ExecutionContext* Node::getExecutionContext() const {
1808 return document().contextDocument(); 1808 return document().contextDocument();
1809 } 1809 }
1810 1810
1811 void Node::willMoveToNewDocument(Document& oldDocument) {
1812 if (oldDocument.frameHost()) {
1813 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(
1814 *this);
1815 }
1816 }
1817
1811 void Node::didMoveToNewDocument(Document& oldDocument) { 1818 void Node::didMoveToNewDocument(Document& oldDocument) {
1812 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); 1819 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
1813 1820
1814 if (const EventTargetData* eventTargetData = this->eventTargetData()) { 1821 if (const EventTargetData* eventTargetData = this->eventTargetData()) {
1815 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; 1822 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap;
1816 if (!listenerMap.isEmpty()) { 1823 if (!listenerMap.isEmpty()) {
1817 for (const auto& type : listenerMap.eventTypes()) 1824 for (const auto& type : listenerMap.eventTypes())
1818 document().addListenerTypeIfNeeded(type); 1825 document().addListenerTypeIfNeeded(type);
1819 } 1826 }
1820 } 1827 }
1821 1828
1822 oldDocument.markers().removeMarkers(this); 1829 oldDocument.markers().removeMarkers(this);
1823 if (oldDocument.frameHost() && !document().frameHost()) 1830 if (document().frameHost())
1824 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(
1825 *this);
1826 else if (document().frameHost() && !oldDocument.frameHost())
1827 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this); 1831 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this);
1828 else if (oldDocument.frameHost() != document().frameHost())
1829 EventHandlerRegistry::didMoveBetweenFrameHosts(
1830 *this, oldDocument.frameHost(), document().frameHost());
1831 1832
1832 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>* 1833 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>*
1833 registry = mutationObserverRegistry()) { 1834 registry = mutationObserverRegistry()) {
1834 for (const auto& registration : *registry) { 1835 for (const auto& registration : *registry) {
1835 document().addMutationObserverTypes(registration->mutationTypes()); 1836 document().addMutationObserverTypes(registration->mutationTypes());
1836 } 1837 }
1837 } 1838 }
1838 1839
1839 if (transientMutationObserverRegistry()) { 1840 if (transientMutationObserverRegistry()) {
1840 for (MutationObserverRegistration* registration : 1841 for (MutationObserverRegistration* registration :
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 if (node) { 2543 if (node) {
2543 std::stringstream stream; 2544 std::stringstream stream;
2544 node->printNodePathTo(stream); 2545 node->printNodePathTo(stream);
2545 LOG(INFO) << stream.str(); 2546 LOG(INFO) << stream.str();
2546 } else { 2547 } else {
2547 LOG(INFO) << "Cannot showNodePath for <null>"; 2548 LOG(INFO) << "Cannot showNodePath for <null>";
2548 } 2549 }
2549 } 2550 }
2550 2551
2551 #endif 2552 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698