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

Unified Diff: third_party/WebKit/Source/core/dom/TreeScope.cpp

Issue 1921853004: Move the ScriptForbiddenScope in TreeScope::adoptIfNeeded to the top of the function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/TreeScope.cpp
diff --git a/third_party/WebKit/Source/core/dom/TreeScope.cpp b/third_party/WebKit/Source/core/dom/TreeScope.cpp
index 2d1a1b6ee5785db7a5b02c61938eccb91f118cdc..970dec9c3b36bb0c836f55ffb0e899177932d9cf 100644
--- a/third_party/WebKit/Source/core/dom/TreeScope.cpp
+++ b/third_party/WebKit/Source/core/dom/TreeScope.cpp
@@ -370,13 +370,14 @@ Element* TreeScope::findAnchor(const String& name)
void TreeScope::adoptIfNeeded(Node& node)
{
+ // Script is forbidden to protect against event handlers firing in the middle of rescoping
+ // in |didMoveToNewDocument| callbacks. See https://crbug.com/605766 and https://crbug.com/606651.
+ ScriptForbiddenScope forbidScript;
DCHECK(this);
DCHECK(!node.isDocumentNode());
TreeScopeAdopter adopter(node, *this);
- if (adopter.needsScopeChange()) {
- ScriptForbiddenScope forbidScript;
+ if (adopter.needsScopeChange())
adopter.execute();
- }
}
Element* TreeScope::retarget(const Element& target) const

Powered by Google App Engine
This is Rietveld 408576698