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

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-28T18:38:12 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/modules/accessibility/AXLayoutObject.cpp ('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/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;
+ }
}
}
« no previous file with comments | « third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698