Chromium Code Reviews| 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 69c0285241dd88a71e726ed7bb3c5e512362f0e2..2535b2ff965fd6f05f7d16376822a6938d453dd8 100644 |
| --- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
| +++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp |
| @@ -1643,6 +1643,7 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
| node = host; |
| } |
| } |
| + const EphemeralRange activeMatchRange(activeMatch); |
| if (node) { |
| for (Node& runner : NodeTraversal::inclusiveAncestorsOf(*node)) { |
| if (!runner.isElementNode()) |
| @@ -1651,7 +1652,7 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
| 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()->selection().setSelection(VisibleSelection(activeMatchRange)); |
| frame()->document()->setFocusedElement(&element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| return; |
| } |
| @@ -1661,13 +1662,12 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
| // Iterate over all the nodes in the range until we find a focusable node. |
| // This, for example, sets focus to the first link if you search for |
| // text and text that is within one or more links. |
| - node = activeMatch->firstNode(); |
| - for (; node && node != activeMatch->pastLastNode(); node = NodeTraversal::next(*node)) { |
| - if (!node->isElementNode()) |
| + for (Node& n : activeMatchRange.nodes()) { |
|
yosin_UTC9
2016/08/18 02:11:09
nit: Could you avoid to use one letter variable na
Andrey Kraynov
2016/08/18 10:16:33
Done.
|
| + if (!n.isElementNode()) |
| continue; |
| - Element* element = toElement(node); |
| - if (element->isFocusable()) { |
| - frame()->document()->setFocusedElement(element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| + Element& element = toElement(n); |
| + if (element.isFocusable()) { |
| + frame()->document()->setFocusedElement(&element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr)); |
| return; |
| } |
| } |
| @@ -1677,7 +1677,7 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection() |
| // you'll have the last thing you found highlighted) and make sure that |
| // we have nothing focused (otherwise you might have text selected but |
| // a link focused, which is weird). |
| - frame()->selection().setSelection(VisibleSelection(EphemeralRange(activeMatch))); |
| + frame()->selection().setSelection(VisibleSelection(activeMatchRange)); |
| frame()->document()->clearFocusedElement(); |
| // Finally clear the active match, for two reasons: |