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

Unified 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: Remove some plumbing that should instead be introduced in the window.focus() CL. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.h » ('j') | content/common/frame_messages.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/frame_tree.cc
diff --git a/content/browser/frame_host/frame_tree.cc b/content/browser/frame_host/frame_tree.cc
index 3e94bbebd176f41e619783a5d6cc56e70dd29286..911ae0decc4bb50fcf5d04dbb6ab668349fbc1b1 100644
--- a/content/browser/frame_host/frame_tree.cc
+++ b/content/browser/frame_host/frame_tree.cc
@@ -270,15 +270,21 @@ FrameTreeNode* FrameTree::GetFocusedFrame() {
}
void FrameTree::SetFocusedFrame(FrameTreeNode* node) {
- // If the focused frame changed across processes, send a message to the old
- // focused frame's renderer process to clear focus from that frame and fire
- // blur events.
- FrameTreeNode* oldFocusedFrame = GetFocusedFrame();
- if (oldFocusedFrame &&
- oldFocusedFrame->current_frame_host()->GetSiteInstance() !=
- node->current_frame_host()->GetSiteInstance()) {
- DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
- oldFocusedFrame->current_frame_host()->ClearFocus();
+ std::set<SiteInstance*> frame_tree_site_instances;
+ ForEach(base::Bind(&CollectSiteInstances, &frame_tree_site_instances));
+
+ // Update the focused frame in all other SiteInstances. If focus changes to
+ // a cross-process frame, this allows the old focused frame's renderer
+ // process to clear focus from that frame and fire blur events. It also
+ // ensures that the latest focused frame is available in all renderers to
+ // compute document.activeElement.
+ for (const auto& instance : frame_tree_site_instances) {
alexmos 2015/11/04 21:53:59 The last part of my test illustrates why it's now
Charlie Reis 2015/11/04 22:23:42 Acknowledged.
+ if (instance != node->current_frame_host()->GetSiteInstance()) {
+ DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible());
+ RenderFrameProxyHost* proxy =
+ node->render_manager()->GetRenderFrameProxyHost(instance);
+ proxy->SetFocusedFrame();
+ }
}
node->set_last_focus_time(base::TimeTicks::Now());
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.h » ('j') | content/common/frame_messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698