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

Side by Side 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, 7 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
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 Google Inc. All Rights Reserved.
3 * Copyright (C) 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Strict mode, names need to match exactly. 363 // Strict mode, names need to match exactly.
364 if (anchor.name() == name) 364 if (anchor.name() == name)
365 return &anchor; 365 return &anchor;
366 } 366 }
367 } 367 }
368 return nullptr; 368 return nullptr;
369 } 369 }
370 370
371 void TreeScope::adoptIfNeeded(Node& node) 371 void TreeScope::adoptIfNeeded(Node& node)
372 { 372 {
373 // Script is forbidden to protect against event handlers firing in the middl e of rescoping
374 // in |didMoveToNewDocument| callbacks. See https://crbug.com/605766 and htt ps://crbug.com/606651.
375 ScriptForbiddenScope forbidScript;
373 DCHECK(this); 376 DCHECK(this);
374 DCHECK(!node.isDocumentNode()); 377 DCHECK(!node.isDocumentNode());
375 TreeScopeAdopter adopter(node, *this); 378 TreeScopeAdopter adopter(node, *this);
376 if (adopter.needsScopeChange()) { 379 if (adopter.needsScopeChange())
377 ScriptForbiddenScope forbidScript;
378 adopter.execute(); 380 adopter.execute();
379 }
380 } 381 }
381 382
382 Element* TreeScope::retarget(const Element& target) const 383 Element* TreeScope::retarget(const Element& target) const
383 { 384 {
384 for (const Element* ancestor = ⌖ ancestor; ancestor = ancestor->shado wHost()) { 385 for (const Element* ancestor = ⌖ ancestor; ancestor = ancestor->shado wHost()) {
385 if (this == ancestor->treeScope()) 386 if (this == ancestor->treeScope())
386 return const_cast<Element*>(ancestor); 387 return const_cast<Element*>(ancestor);
387 } 388 }
388 return nullptr; 389 return nullptr;
389 } 390 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 visitor->trace(m_idTargetObserverRegistry); 533 visitor->trace(m_idTargetObserverRegistry);
533 visitor->trace(m_selection); 534 visitor->trace(m_selection);
534 visitor->trace(m_elementsById); 535 visitor->trace(m_elementsById);
535 visitor->trace(m_imageMapsByName); 536 visitor->trace(m_imageMapsByName);
536 visitor->trace(m_labelsByForAttribute); 537 visitor->trace(m_labelsByForAttribute);
537 visitor->trace(m_scopedStyleResolver); 538 visitor->trace(m_scopedStyleResolver);
538 visitor->trace(m_radioButtonGroupScope); 539 visitor->trace(m_radioButtonGroupScope);
539 } 540 }
540 541
541 } // namespace blink 542 } // namespace blink
OLDNEW
« 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