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

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 more sensible checks. 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, Document& newDocument) {
1812 if (!oldDocument.frameHost() ||
1813 oldDocument.frameHost() == newDocument.frameHost())
1814 return;
1815
1816 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(*this);
1817 }
1818
1811 void Node::didMoveToNewDocument(Document& oldDocument) { 1819 void Node::didMoveToNewDocument(Document& oldDocument) {
1812 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); 1820 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
1813 1821
1814 if (const EventTargetData* eventTargetData = this->eventTargetData()) { 1822 if (const EventTargetData* eventTargetData = this->eventTargetData()) {
1815 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; 1823 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap;
1816 if (!listenerMap.isEmpty()) { 1824 if (!listenerMap.isEmpty()) {
1817 for (const auto& type : listenerMap.eventTypes()) 1825 for (const auto& type : listenerMap.eventTypes())
1818 document().addListenerTypeIfNeeded(type); 1826 document().addListenerTypeIfNeeded(type);
1819 } 1827 }
1820 } 1828 }
1821 1829
1822 oldDocument.markers().removeMarkers(this); 1830 oldDocument.markers().removeMarkers(this);
1823 if (oldDocument.frameHost() && !document().frameHost()) 1831 if (document().frameHost() &&
1824 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost( 1832 document().frameHost() != oldDocument.frameHost()) {
1825 *this);
1826 else if (document().frameHost() && !oldDocument.frameHost())
1827 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this); 1833 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this);
1828 else if (oldDocument.frameHost() != document().frameHost()) 1834 }
1829 EventHandlerRegistry::didMoveBetweenFrameHosts(
1830 *this, oldDocument.frameHost(), document().frameHost());
1831 1835
1832 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>* 1836 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>*
1833 registry = mutationObserverRegistry()) { 1837 registry = mutationObserverRegistry()) {
1834 for (const auto& registration : *registry) { 1838 for (const auto& registration : *registry) {
1835 document().addMutationObserverTypes(registration->mutationTypes()); 1839 document().addMutationObserverTypes(registration->mutationTypes());
1836 } 1840 }
1837 } 1841 }
1838 1842
1839 if (transientMutationObserverRegistry()) { 1843 if (transientMutationObserverRegistry()) {
1840 for (MutationObserverRegistration* registration : 1844 for (MutationObserverRegistration* registration :
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 if (node) { 2546 if (node) {
2543 std::stringstream stream; 2547 std::stringstream stream;
2544 node->printNodePathTo(stream); 2548 node->printNodePathTo(stream);
2545 LOG(INFO) << stream.str(); 2549 LOG(INFO) << stream.str();
2546 } else { 2550 } else {
2547 LOG(INFO) << "Cannot showNodePath for <null>"; 2551 LOG(INFO) << "Cannot showNodePath for <null>";
2548 } 2552 }
2549 } 2553 }
2550 2554
2551 #endif 2555 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/TreeScopeAdopter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698