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

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: Addressing comments + a whitespace fix 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/image-adoption-events-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8cd9b55c0c6594d1f5f6431034aad64b078585bc 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/events/image-adoption-events-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698