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

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

Issue 2585353002: Detach Event Listener Properties before moving Node. (Closed)
Patch Set: Revert to doing update inside moveNodeToNewocument(). 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 == newDocument)
1813 return;
1814
1815 if (oldDocument.frameHost()) {
1816 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost(
1817 *this);
1818 }
1819 }
1820
1811 void Node::didMoveToNewDocument(Document& oldDocument) { 1821 void Node::didMoveToNewDocument(Document& oldDocument) {
1812 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument); 1822 TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
1813 1823
1814 if (const EventTargetData* eventTargetData = this->eventTargetData()) { 1824 if (const EventTargetData* eventTargetData = this->eventTargetData()) {
1815 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap; 1825 const EventListenerMap& listenerMap = eventTargetData->eventListenerMap;
1816 if (!listenerMap.isEmpty()) { 1826 if (!listenerMap.isEmpty()) {
1817 for (const auto& type : listenerMap.eventTypes()) 1827 for (const auto& type : listenerMap.eventTypes())
1818 document().addListenerTypeIfNeeded(type); 1828 document().addListenerTypeIfNeeded(type);
1819 } 1829 }
1820 } 1830 }
1821 1831
1822 oldDocument.markers().removeMarkers(this); 1832 oldDocument.markers().removeMarkers(this);
1823 if (oldDocument.frameHost() && !document().frameHost()) 1833 if (document().frameHost()) {
1824 oldDocument.frameHost()->eventHandlerRegistry().didMoveOutOfFrameHost( 1834 DCHECK_NE(document().frameHost(), oldDocument.frameHost());
bokan 2017/01/13 18:35:10 Can we assume this in general? What if you move be
wjmaclean 2017/01/13 20:04:24 Ha ha ... apparently not according to the bots! B
1825 *this);
1826 else if (document().frameHost() && !oldDocument.frameHost())
1827 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this); 1835 document().frameHost()->eventHandlerRegistry().didMoveIntoFrameHost(*this);
1828 else if (oldDocument.frameHost() != document().frameHost()) 1836 }
1829 EventHandlerRegistry::didMoveBetweenFrameHosts(
1830 *this, oldDocument.frameHost(), document().frameHost());
1831 1837
1832 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>* 1838 if (const HeapVector<TraceWrapperMember<MutationObserverRegistration>>*
1833 registry = mutationObserverRegistry()) { 1839 registry = mutationObserverRegistry()) {
1834 for (const auto& registration : *registry) { 1840 for (const auto& registration : *registry) {
1835 document().addMutationObserverTypes(registration->mutationTypes()); 1841 document().addMutationObserverTypes(registration->mutationTypes());
1836 } 1842 }
1837 } 1843 }
1838 1844
1839 if (transientMutationObserverRegistry()) { 1845 if (transientMutationObserverRegistry()) {
1840 for (MutationObserverRegistration* registration : 1846 for (MutationObserverRegistration* registration :
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 if (node) { 2548 if (node) {
2543 std::stringstream stream; 2549 std::stringstream stream;
2544 node->printNodePathTo(stream); 2550 node->printNodePathTo(stream);
2545 LOG(INFO) << stream.str(); 2551 LOG(INFO) << stream.str();
2546 } else { 2552 } else {
2547 LOG(INFO) << "Cannot showNodePath for <null>"; 2553 LOG(INFO) << "Cannot showNodePath for <null>";
2548 } 2554 }
2549 } 2555 }
2550 2556
2551 #endif 2557 #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