Chromium Code Reviews| 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; |
| } |