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

Side by Side Diff: third_party/WebKit/Source/core/dom/TreeScopeAdopter.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 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Document& oldDocument, 128 Document& oldDocument,
129 Document& newDocument) const { 129 Document& newDocument) const {
130 DCHECK_NE(oldDocument, newDocument); 130 DCHECK_NE(oldDocument, newDocument);
131 131
132 if (node.hasRareData()) { 132 if (node.hasRareData()) {
133 NodeRareData* rareData = node.rareData(); 133 NodeRareData* rareData = node.rareData();
134 if (rareData->nodeLists()) 134 if (rareData->nodeLists())
135 rareData->nodeLists()->adoptDocument(oldDocument, newDocument); 135 rareData->nodeLists()->adoptDocument(oldDocument, newDocument);
136 } 136 }
137 137
138 // TODO(wjmaclean): It seems weird here that oldDocument !=(in general)
139 // node.document(). I'd like to understand why, as it seems clinky passing
140 // oldDocument in the call to node.willMoveToNewDocument().
bokan 2017/01/04 23:33:27 This was the first question I had above, why can't
141 node.willMoveToNewDocument(oldDocument);
138 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument); 142 oldDocument.moveNodeIteratorsToNewDocument(node, newDocument);
139 143
140 if (node.getCustomElementState() == CustomElementState::Custom) { 144 if (node.getCustomElementState() == CustomElementState::Custom) {
141 Element& element = toElement(node); 145 Element& element = toElement(node);
142 CustomElement::enqueueAdoptedCallback(&element, &oldDocument, &newDocument); 146 CustomElement::enqueueAdoptedCallback(&element, &oldDocument, &newDocument);
143 } 147 }
144 148
145 if (node.isShadowRoot()) 149 if (node.isShadowRoot())
146 toShadowRoot(node).setDocument(newDocument); 150 toShadowRoot(node).setDocument(newDocument);
147 151
148 #if DCHECK_IS_ON() 152 #if DCHECK_IS_ON()
149 didMoveToNewDocumentWasCalled = false; 153 didMoveToNewDocumentWasCalled = false;
150 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument; 154 oldDocumentDidMoveToNewDocumentWasCalledWith = &oldDocument;
151 #endif 155 #endif
152 156
153 node.didMoveToNewDocument(oldDocument); 157 node.didMoveToNewDocument(oldDocument);
154 #if DCHECK_IS_ON() 158 #if DCHECK_IS_ON()
155 DCHECK(didMoveToNewDocumentWasCalled); 159 DCHECK(didMoveToNewDocumentWasCalled);
156 #endif 160 #endif
157 } 161 }
158 162
159 } // namespace blink 163 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.cpp ('k') | third_party/WebKit/Source/core/frame/EventHandlerRegistry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698