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

Unified Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 2796533002: OOPIF: Enable TabAndMouseFocusNavigation. (Closed)
Patch Set: Address dcheng comments Created 3 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 | « chrome/browser/site_per_process_interactive_browsertest.cc ('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/core/page/FocusController.cpp
diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp
index 383f1623b0b046285b32c9e0537673b3ddb79e4d..6becd697d6e65608d336173a0e3d35f78b13d759 100644
--- a/third_party/WebKit/Source/core/page/FocusController.cpp
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -933,7 +933,11 @@ bool FocusController::advanceFocusAcrossFrames(
start = toHTMLFrameOwnerElement(from->owner());
}
- return advanceFocusInDocumentOrder(to, start, type, false,
+ // If we're coming from a parent frame, we need to restart from the first or
+ // last focusable element.
+ bool initialFocus = to->tree().parent() == from;
+
+ return advanceFocusInDocumentOrder(to, start, type, initialFocus,
sourceCapabilities);
}
@@ -998,7 +1002,11 @@ bool FocusController::advanceFocusInDocumentOrder(
}
if (element == document->focusedElement()) {
- // Focus wrapped around to the same element.
+ // Focus is either coming from a remote frame or has wrapped around.
+ if (focusedFrame() != document->frame()) {
+ setFocusedFrame(document->frame());
+ dispatchFocusEvent(*document, *element);
+ }
return true;
}
@@ -1012,14 +1020,17 @@ bool FocusController::advanceFocusInDocumentOrder(
return false;
document->clearFocusedElement();
- setFocusedFrame(owner->contentFrame());
- // If contentFrame is remote, continue the search for focusable
- // elements in that frame's process.
- // clearFocusedElement() fires events that might detach the
- // contentFrame, hence the need to null-check it again.
+ // If contentFrame is remote, continue the search for focusable elements in
+ // that frame's process. The target contentFrame's process will grab focus
+ // from inside advanceFocusInDocumentOrder().
+ //
+ // clearFocusedElement() fires events that might detach the contentFrame,
+ // hence the need to null-check it again.
if (owner->contentFrame() && owner->contentFrame()->isRemoteFrame())
toRemoteFrame(owner->contentFrame())->advanceFocus(type, frame);
+ else
+ setFocusedFrame(owner->contentFrame());
return true;
}
« no previous file with comments | « chrome/browser/site_per_process_interactive_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698