| OLD | NEW |
| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // Update the focused frame in all other SiteInstances. If focus changes to | 262 // Update the focused frame in all other SiteInstances. If focus changes to |
| 263 // a cross-process frame, this allows the old focused frame's renderer | 263 // a cross-process frame, this allows the old focused frame's renderer |
| 264 // process to clear focus from that frame and fire blur events. It also | 264 // process to clear focus from that frame and fire blur events. It also |
| 265 // ensures that the latest focused frame is available in all renderers to | 265 // ensures that the latest focused frame is available in all renderers to |
| 266 // compute document.activeElement. | 266 // compute document.activeElement. |
| 267 // | 267 // |
| 268 // We do not notify the |source| SiteInstance because it already knows the | 268 // We do not notify the |source| SiteInstance because it already knows the |
| 269 // new focused frame (since it initiated the focus change), and we notify the | 269 // new focused frame (since it initiated the focus change), and we notify the |
| 270 // new focused frame's SiteInstance (if it differs from |source|) separately | 270 // new focused frame's SiteInstance (if it differs from |source|) separately |
| 271 // below. | 271 // below. |
| 272 for (const auto& instance : frame_tree_site_instances) { | 272 for (auto* instance : frame_tree_site_instances) { |
| 273 if (instance != source && instance != current_instance) { | 273 if (instance != source && instance != current_instance) { |
| 274 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 274 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 275 RenderFrameProxyHost* proxy = | 275 RenderFrameProxyHost* proxy = |
| 276 node->render_manager()->GetRenderFrameProxyHost(instance); | 276 node->render_manager()->GetRenderFrameProxyHost(instance); |
| 277 proxy->SetFocusedFrame(); | 277 proxy->SetFocusedFrame(); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 // If |node| was focused from a cross-process frame (i.e., via | 281 // If |node| was focused from a cross-process frame (i.e., via |
| 282 // window.focus()), tell its RenderFrame that it should focus. | 282 // window.focus()), tell its RenderFrame that it should focus. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 void FrameTree::ReplicatePageFocus(bool is_focused) { | 432 void FrameTree::ReplicatePageFocus(bool is_focused) { |
| 433 std::set<SiteInstance*> frame_tree_site_instances = | 433 std::set<SiteInstance*> frame_tree_site_instances = |
| 434 CollectSiteInstances(this); | 434 CollectSiteInstances(this); |
| 435 | 435 |
| 436 // Send the focus update to main frame's proxies in all SiteInstances of | 436 // Send the focus update to main frame's proxies in all SiteInstances of |
| 437 // other frames in this FrameTree. Note that the main frame might also know | 437 // other frames in this FrameTree. Note that the main frame might also know |
| 438 // about proxies in SiteInstances for frames in a different FrameTree (e.g., | 438 // about proxies in SiteInstances for frames in a different FrameTree (e.g., |
| 439 // for window.open), so we can't just iterate over its proxy_hosts_ in | 439 // for window.open), so we can't just iterate over its proxy_hosts_ in |
| 440 // RenderFrameHostManager. | 440 // RenderFrameHostManager. |
| 441 for (const auto& instance : frame_tree_site_instances) | 441 for (auto* instance : frame_tree_site_instances) |
| 442 SetPageFocus(instance, is_focused); | 442 SetPageFocus(instance, is_focused); |
| 443 } | 443 } |
| 444 | 444 |
| 445 void FrameTree::SetPageFocus(SiteInstance* instance, bool is_focused) { | 445 void FrameTree::SetPageFocus(SiteInstance* instance, bool is_focused) { |
| 446 RenderFrameHostManager* root_manager = root_->render_manager(); | 446 RenderFrameHostManager* root_manager = root_->render_manager(); |
| 447 | 447 |
| 448 // This is only used to set page-level focus in cross-process subframes, and | 448 // This is only used to set page-level focus in cross-process subframes, and |
| 449 // requests to set focus in main frame's SiteInstance are ignored. | 449 // requests to set focus in main frame's SiteInstance are ignored. |
| 450 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 450 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 451 RenderFrameProxyHost* proxy = | 451 RenderFrameProxyHost* proxy = |
| 452 root_manager->GetRenderFrameProxyHost(instance); | 452 root_manager->GetRenderFrameProxyHost(instance); |
| 453 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 453 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 454 } | 454 } |
| 455 } | 455 } |
| 456 | 456 |
| 457 } // namespace content | 457 } // namespace content |
| OLD | NEW |