Chromium Code Reviews| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 } | 244 } |
| 245 | 245 |
| 246 FrameTreeNode* FrameTree::GetFocusedFrame() { | 246 FrameTreeNode* FrameTree::GetFocusedFrame() { |
| 247 return FindByID(focused_frame_tree_node_id_); | 247 return FindByID(focused_frame_tree_node_id_); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void FrameTree::SetFocusedFrame(FrameTreeNode* node, SiteInstance* source) { | 250 void FrameTree::SetFocusedFrame(FrameTreeNode* node, SiteInstance* source) { |
| 251 if (node == GetFocusedFrame()) | 251 if (node == GetFocusedFrame()) |
| 252 return; | 252 return; |
| 253 | 253 |
| 254 if (node == nullptr) { | |
| 255 if (GetFocusedFrame()) | |
| 256 GetFocusedFrame()->current_frame_host()->UnsetFocusedFrame(); | |
|
alexmos
2016/05/12 20:28:39
Do proxies need to be notified also? E.g., suppos
avallee
2016/05/16 20:26:43
Agreed that they would need to be notified.
Howev
alexmos
2016/05/19 00:08:08
I brought this up on site isolation chat, and inde
| |
| 257 focused_frame_tree_node_id_ = FrameTreeNode::kFrameTreeNodeInvalidId; | |
| 258 | |
| 259 // TODO(avallee): https://crbug.com/610795 This line is not sufficient to | |
|
dmazzoni
2016/05/12 02:58:56
I'm okay with landing this change as-is and fixing
avallee
2016/05/16 20:26:41
Thanks for the follow up dmazzoni.
I have an idea
| |
| 260 // make the test pass. There seems to be no focus change events generated. | |
| 261 root()->current_frame_host()->UpdateAXTreeData(); | |
| 262 return; | |
| 263 } | |
| 264 | |
| 254 std::set<SiteInstance*> frame_tree_site_instances = | 265 std::set<SiteInstance*> frame_tree_site_instances = |
| 255 CollectSiteInstances(this); | 266 CollectSiteInstances(this); |
| 256 | 267 |
| 257 SiteInstance* current_instance = | 268 SiteInstance* current_instance = |
| 258 node->current_frame_host()->GetSiteInstance(); | 269 node->current_frame_host()->GetSiteInstance(); |
| 259 | 270 |
| 260 // Update the focused frame in all other SiteInstances. If focus changes to | 271 // Update the focused frame in all other SiteInstances. If focus changes to |
| 261 // a cross-process frame, this allows the old focused frame's renderer | 272 // a cross-process frame, this allows the old focused frame's renderer |
| 262 // process to clear focus from that frame and fire blur events. It also | 273 // process to clear focus from that frame and fire blur events. It also |
| 263 // ensures that the latest focused frame is available in all renderers to | 274 // ensures that the latest focused frame is available in all renderers to |
| 264 // compute document.activeElement. | 275 // compute document.activeElement. |
| 265 // | 276 // |
| 266 // We do not notify the |source| SiteInstance because it already knows the | 277 // We do not notify the |source| SiteInstance because it already knows the |
| 267 // new focused frame (since it initiated the focus change), and we notify the | 278 // new focused frame (since it initiated the focus change), and we notify the |
| 268 // new focused frame's SiteInstance (if it differs from |source|) separately | 279 // new focused frame's SiteInstance (if it differs from |source|) separately |
| 269 // below. | 280 // below. |
| 270 for (const auto& instance : frame_tree_site_instances) { | 281 for (const auto& instance : frame_tree_site_instances) { |
| 271 if (instance != source && instance != current_instance) { | 282 if (instance != source && instance != current_instance) { |
| 272 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); | 283 DCHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible()); |
| 273 RenderFrameProxyHost* proxy = | 284 RenderFrameProxyHost* proxy = |
| 274 node->render_manager()->GetRenderFrameProxyHost(instance); | 285 node->render_manager()->GetRenderFrameProxyHost(instance); |
| 275 proxy->SetFocusedFrame(); | 286 if (proxy) |
|
alexmos
2016/05/12 20:28:39
Why is adding this check necessary?
avallee
2016/05/16 20:26:41
I don't think this is necessary anymore, but was i
| |
| 287 proxy->SetFocusedFrame(); | |
| 276 } | 288 } |
| 277 } | 289 } |
| 278 | 290 |
| 279 // If |node| was focused from a cross-process frame (i.e., via | 291 // If |node| was focused from a cross-process frame (i.e., via |
| 280 // window.focus()), tell its RenderFrame that it should focus. | 292 // window.focus()), tell its RenderFrame that it should focus. |
| 281 if (current_instance != source) | 293 if (current_instance && current_instance != source) |
|
alexmos
2016/05/12 20:28:39
Similar question here. I can't see how this can b
avallee
2016/05/16 20:26:41
Removed.
| |
| 282 node->current_frame_host()->SetFocusedFrame(); | 294 node->current_frame_host()->SetFocusedFrame(); |
| 283 | 295 |
| 284 focused_frame_tree_node_id_ = node->frame_tree_node_id(); | 296 focused_frame_tree_node_id_ = node->frame_tree_node_id(); |
| 285 node->DidFocus(); | 297 node->DidFocus(); |
| 286 | 298 |
| 287 // The accessibility tree data for the root of the frame tree keeps | 299 // The accessibility tree data for the root of the frame tree keeps |
| 288 // track of the focused frame too, so update that every time the | 300 // track of the focused frame too, so update that every time the |
| 289 // focused frame changes. | 301 // focused frame changes. |
| 290 root()->current_frame_host()->UpdateAXTreeData(); | 302 root()->current_frame_host()->UpdateAXTreeData(); |
| 291 } | 303 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 // This is only used to set page-level focus in cross-process subframes, and | 438 // This is only used to set page-level focus in cross-process subframes, and |
| 427 // requests to set focus in main frame's SiteInstance are ignored. | 439 // requests to set focus in main frame's SiteInstance are ignored. |
| 428 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 440 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
| 429 RenderFrameProxyHost* proxy = | 441 RenderFrameProxyHost* proxy = |
| 430 root_manager->GetRenderFrameProxyHost(instance); | 442 root_manager->GetRenderFrameProxyHost(instance); |
| 431 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 443 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
| 432 } | 444 } |
| 433 } | 445 } |
| 434 | 446 |
| 435 } // namespace content | 447 } // namespace content |
| OLD | NEW |