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

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

Issue 1879373002: Move Node::retarget() to TreeScope::retarget() (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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/TreeScope.h ('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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 DCHECK(this); 413 DCHECK(this);
414 DCHECK(!node.isDocumentNode()); 414 DCHECK(!node.isDocumentNode());
415 #if !ENABLE(OILPAN) 415 #if !ENABLE(OILPAN)
416 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun); 416 ASSERT_WITH_SECURITY_IMPLICATION(!node.m_deletionHasBegun);
417 #endif 417 #endif
418 TreeScopeAdopter adopter(node, *this); 418 TreeScopeAdopter adopter(node, *this);
419 if (adopter.needsScopeChange()) 419 if (adopter.needsScopeChange())
420 adopter.execute(); 420 adopter.execute();
421 } 421 }
422 422
423 Element* TreeScope::retarget(const Element& target) const
424 {
425 for (const Element* ancestor = ⌖ ancestor; ancestor = ancestor->shado wHost()) {
426 if (this == ancestor->treeScope())
427 return const_cast<Element*>(ancestor);
428 }
429 return nullptr;
430 }
431
423 Element* TreeScope::adjustedFocusedElement() const 432 Element* TreeScope::adjustedFocusedElement() const
424 { 433 {
425 Document& document = rootNode().document(); 434 Document& document = rootNode().document();
426 Element* element = document.focusedElement(); 435 Element* element = document.focusedElement();
427 if (!element && document.page()) 436 if (!element && document.page())
428 element = document.page()->focusController().focusedFrameOwnerElement(*d ocument.frame()); 437 element = document.page()->focusController().focusedFrameOwnerElement(*d ocument.frame());
429 if (!element) 438 if (!element)
430 return nullptr; 439 return nullptr;
431 440
432 if (rootNode().isInV1ShadowTree()) { 441 if (rootNode().isInV1ShadowTree()) {
433 if (Node* retargeted = rootNode().retarget(*element)) { 442 if (Element* retargeted = retarget(*element)) {
434 DCHECK(retargeted->isElementNode()); 443 return (this == &retargeted->treeScope()) ? retargeted : nullptr;
kochi 2016/04/15 05:40:46 Is there any chance that the result of retarget()
hayato 2016/04/15 07:30:52 Let me leave this as is. I am aware that the curr
435 return this == &retargeted->treeScope() ? toElement(retargeted) : nu llptr;
436 } 444 }
437 return nullptr; 445 return nullptr;
438 } 446 }
439 447
440 EventPath* eventPath = new EventPath(*element); 448 EventPath* eventPath = new EventPath(*element);
441 for (size_t i = 0; i < eventPath->size(); ++i) { 449 for (size_t i = 0; i < eventPath->size(); ++i) {
442 if (eventPath->at(i).node() == rootNode()) { 450 if (eventPath->at(i).node() == rootNode()) {
443 // eventPath->at(i).target() is one of the followings: 451 // eventPath->at(i).target() is one of the followings:
444 // - InsertionPoint 452 // - InsertionPoint
445 // - shadow host 453 // - shadow host
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 visitor->trace(m_idTargetObserverRegistry); 592 visitor->trace(m_idTargetObserverRegistry);
585 visitor->trace(m_selection); 593 visitor->trace(m_selection);
586 visitor->trace(m_elementsById); 594 visitor->trace(m_elementsById);
587 visitor->trace(m_imageMapsByName); 595 visitor->trace(m_imageMapsByName);
588 visitor->trace(m_labelsByForAttribute); 596 visitor->trace(m_labelsByForAttribute);
589 visitor->trace(m_scopedStyleResolver); 597 visitor->trace(m_scopedStyleResolver);
590 visitor->trace(m_radioButtonGroupScope); 598 visitor->trace(m_radioButtonGroupScope);
591 } 599 }
592 600
593 } // namespace blink 601 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/TreeScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698