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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/TreeScope.h ('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 3ef34953971daa4b38e5226a8930cae4be902b5f..6e7bb65a900cbfaeef7fdda3bd186384e7c9f2fc 100644
--- a/third_party/WebKit/Source/core/dom/TreeScope.cpp
+++ b/third_party/WebKit/Source/core/dom/TreeScope.cpp
@@ -420,6 +420,15 @@ void TreeScope::adoptIfNeeded(Node& node)
adopter.execute();
}
+Element* TreeScope::retarget(const Element& target) const
+{
+ for (const Element* ancestor = ⌖ ancestor; ancestor = ancestor->shadowHost()) {
+ if (this == ancestor->treeScope())
+ return const_cast<Element*>(ancestor);
+ }
+ return nullptr;
+}
+
Element* TreeScope::adjustedFocusedElement() const
{
Document& document = rootNode().document();
@@ -430,9 +439,8 @@ Element* TreeScope::adjustedFocusedElement() const
return nullptr;
if (rootNode().isInV1ShadowTree()) {
- if (Node* retargeted = rootNode().retarget(*element)) {
- DCHECK(retargeted->isElementNode());
- return this == &retargeted->treeScope() ? toElement(retargeted) : nullptr;
+ if (Element* retargeted = retarget(*element)) {
+ 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
}
return nullptr;
}
« 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