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

Unified Diff: third_party/WebKit/Source/web/WebLocalFrameImpl.cpp

Issue 1932523003: Introduce NodeTraversal::ancestorsOf() and inclusiveAncestors() for range-based for loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-04-28T16:44:17 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
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..3a0093e533d96f9ae2fb83c3bbc9f072a9bf96aa 100644
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
@@ -1651,15 +1651,15 @@ void WebLocalFrameImpl::setFindEndstateFocusAndSelection()
node = host;
}
}
- for (; node; node = node->parentNode()) {
- if (!node->isElementNode())
+ for (Node& runner : NodeTraversal::ancestorsOrSelfOf(node)) {
+ if (!runner.isElementNode())
continue;
- Element* element = toElement(node);
- if (element->isFocusable()) {
+ 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));
+ frame()->document()->setFocusedElement(&element, FocusParams(SelectionBehaviorOnFocus::None, WebFocusTypeNone, nullptr));
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698