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

Side by Side Diff: content/browser/frame_host/frame_tree.cc

Issue 1423053002: Make document.activeElement work with OOPIF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus-preserve-page-focus-on-subframe-navigations
Patch Set: Change plumbing a bit: use focusDocumentView on WebView and remove clearFocus from WebLocalFrame Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/frame_host/frame_tree.h" 5 #include "content/browser/frame_host/frame_tree.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 } 264 }
265 265
266 FrameTreeNode* FrameTree::GetFocusedFrame() { 266 FrameTreeNode* FrameTree::GetFocusedFrame() {
267 return FindByID(focused_frame_tree_node_id_); 267 return FindByID(focused_frame_tree_node_id_);
268 } 268 }
269 269
270 void FrameTree::SetFocusedFrame(FrameTreeNode* node) { 270 void FrameTree::SetFocusedFrame(FrameTreeNode* node) {
271 // If the focused frame changed across processes, send a message to the old 271 // If the focused frame changed across processes, send a message to the old
272 // focused frame's renderer process to clear focus from that frame and fire 272 // focused frame's renderer process to clear focus from that frame and fire
273 // blur events. 273 // blur events.
274 FrameTreeNode* oldFocusedFrame = GetFocusedFrame(); 274 FrameTreeNode* old_focused_frame = GetFocusedFrame();
275 if (oldFocusedFrame && 275 if (old_focused_frame) {
276 oldFocusedFrame->current_frame_host()->GetSiteInstance() != 276 SiteInstance* old_site_instance =
277 node->current_frame_host()->GetSiteInstance()) { 277 old_focused_frame->current_frame_host()->GetSiteInstance();
278 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); 278 if (old_site_instance != node->current_frame_host()->GetSiteInstance()) {
279 oldFocusedFrame->current_frame_host()->ClearFocus(); 279 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
280 RenderFrameProxyHost* proxy =
281 node->render_manager()->GetRenderFrameProxyHost(old_site_instance);
282 proxy->SetFocusedFrame();
283 }
280 } 284 }
281 285
282 node->set_last_focus_time(base::TimeTicks::Now()); 286 node->set_last_focus_time(base::TimeTicks::Now());
283 focused_frame_tree_node_id_ = node->frame_tree_node_id(); 287 focused_frame_tree_node_id_ = node->frame_tree_node_id();
284 } 288 }
285 289
286 void FrameTree::SetFrameRemoveListener( 290 void FrameTree::SetFrameRemoveListener(
287 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) { 291 const base::Callback<void(RenderFrameHost*)>& on_frame_removed) {
288 on_frame_removed_ = on_frame_removed; 292 on_frame_removed_ = on_frame_removed;
289 } 293 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 // This is only used to set page-level focus in cross-process subframes, and 443 // This is only used to set page-level focus in cross-process subframes, and
440 // requests to set focus in main frame's SiteInstance are ignored. 444 // requests to set focus in main frame's SiteInstance are ignored.
441 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { 445 if (instance != root_manager->current_frame_host()->GetSiteInstance()) {
442 RenderFrameProxyHost* proxy = 446 RenderFrameProxyHost* proxy =
443 root_manager->GetRenderFrameProxyHost(instance); 447 root_manager->GetRenderFrameProxyHost(instance);
444 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); 448 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused));
445 } 449 }
446 } 450 }
447 451
448 } // namespace content 452 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698