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

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

Issue 2732913005: <webview>: Add test to confirm the TAB key will escape the view. (Closed)
Patch Set: Fix clearFocusedElement, only if focusing a child frame. Created 3 years, 9 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/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 110d8bf12a8de8c3fa4cf6a7c0088d3b2008b582..c386c9b495af9c8b7811ef9be7e0c5c449acd7af 100644
--- a/third_party/WebKit/Source/core/page/FocusController.cpp
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -783,8 +783,20 @@ void FocusController::focusDocumentView(Frame* frame, bool notifyEmbedder) {
if (focusedFrame && focusedFrame->view()) {
Document* document = focusedFrame->document();
Element* focusedElement = document ? document->focusedElement() : nullptr;
- if (focusedElement)
- dispatchBlurEvent(*document, *focusedElement);
+ if (focusedElement) {
+ bool focusedFrameIsAncestor = false;
alexmos 2017/03/16 17:37:11 I think this is really newFocusedFrameIsDescendant
+ for (Frame* newFrame = frame; newFrame;
+ newFrame = newFrame->client()->parent()) {
alexmos 2017/03/10 07:08:33 Why do we need to walk up the ancestor chain? Is
avallee 2017/03/13 19:18:10 I'm not sure how exiting a frame works. In the top
alexmos 2017/03/16 17:37:11 I was really confused here and what this has to do
alexmos 2017/03/16 17:59:47 I'll also note that at some point, when replicatin
+ if (newFrame == m_focusedFrame.get()) {
+ focusedFrameIsAncestor = true;
+ break;
+ }
+ }
+ if (focusedFrameIsAncestor)
alexmos 2017/03/10 07:08:33 What about the reverse case, where an <input> that
avallee 2017/03/13 19:18:10 This was doing the wrong thing when the browser no
alexmos 2017/03/16 17:37:11 I'm not sure I followed your explanation, but I th
+ document->clearFocusedElement();
alexmos 2017/03/10 07:08:33 Will |frame| always be a RemoteFrame when this is
avallee 2017/03/13 19:18:10 I think the issue would only happen with remote fr
alexmos 2017/03/16 17:37:11 See the big comment above regarding this.
+ else
+ dispatchBlurEvent(*document, *focusedElement);
alexmos 2017/03/10 07:08:33 Just to check, does clearFocusedElement also dispa
avallee 2017/03/13 19:18:10 Yes, it calls setFocusedElement(nullptr, /*some ot
alexmos 2017/03/16 17:37:11 Acknowledged.
+ }
}
LocalFrame* newFocusedFrame =

Powered by Google App Engine
This is Rietveld 408576698