| Index: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| index 2baa0920fbaf765e7f5b7b761280d412f670c0fd..fbf81a31461d8f647faf3b6d12fab1a4be09aa4c 100644
|
| --- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| +++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
|
| @@ -1651,16 +1651,18 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection()
|
| node = host;
|
| }
|
| }
|
| - for (; node; node = node->parentNode()) {
|
| - if (!node->isElementNode())
|
| - continue;
|
| - Element* element = toElement(node);
|
| - if (element->isFocusable()) {
|
| - // Found a focusable parent node. Set the active match as the
|
| - // selection and focus to the focusable node.
|
| - frame()->selection().setSelection(VisibleSelection(EphemeralRange(activeMatch)));
|
| - frame()->document()->setFocusedElement(element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
|
| - return;
|
| + if (node) {
|
| + for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) {
|
| + if (!runner.isElementNode())
|
| + continue;
|
| + Element& element = toElement(runner);
|
| + if (element.isFocusable()) {
|
| + // Found a focusable parent node. Set the active match as the
|
| + // selection and focus to the focusable node.
|
| + frame()->selection().setSelection(VisibleSelection(EphemeralRange(activeMatch)));
|
| + frame()->document()->setFocusedElement(&element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
|
| + return;
|
| + }
|
| }
|
| }
|
|
|
|
|