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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 if (!frame->parent()) { | 397 if (!frame->parent()) { |
398 CHECK_EQ(frame, root_); | 398 CHECK_EQ(frame, root_); |
399 return; | 399 return; |
400 } | 400 } |
401 | 401 |
402 // Notify observers of the frame removal. | 402 // Notify observers of the frame removal. |
403 if (!on_frame_removed_.is_null()) | 403 if (!on_frame_removed_.is_null()) |
404 on_frame_removed_.Run(frame->current_frame_host()); | 404 on_frame_removed_.Run(frame->current_frame_host()); |
405 } | 405 } |
406 | 406 |
407 void FrameTree::UpdateLoadProgress() { | 407 void FrameTree::UpdateLoadProgress(FrameTreeNode* frame) { |
408 double progress = 0.0; | 408 if (root_ != frame) |
409 int frame_count = 0; | 409 return; |
410 | 410 |
411 for (FrameTreeNode* node : Nodes()) { | 411 double progress = frame->loading_progress(); |
412 // Ignore the current frame if it has not started loading. | |
413 if (!node->has_started_loading()) | |
414 continue; | |
415 | |
416 // Collect progress. | |
417 progress += node->loading_progress(); | |
418 frame_count++; | |
419 } | |
420 | |
421 if (frame_count != 0) | |
422 progress /= frame_count; | |
423 | |
424 if (progress <= load_progress_) | 412 if (progress <= load_progress_) |
425 return; | 413 return; |
426 load_progress_ = progress; | 414 load_progress_ = progress; |
427 | 415 |
428 // Notify the WebContents. | 416 // Notify the WebContents. |
429 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); | 417 root_->navigator()->GetDelegate()->DidChangeLoadProgress(); |
430 } | 418 } |
431 | 419 |
432 void FrameTree::ResetLoadProgress() { | 420 void FrameTree::ResetLoadProgress() { |
433 for (FrameTreeNode* node : Nodes()) | 421 for (FrameTreeNode* node : Nodes()) |
(...skipping 28 matching lines...) Expand all Loading... |
462 // This is only used to set page-level focus in cross-process subframes, and | 450 // This is only used to set page-level focus in cross-process subframes, and |
463 // requests to set focus in main frame's SiteInstance are ignored. | 451 // requests to set focus in main frame's SiteInstance are ignored. |
464 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { | 452 if (instance != root_manager->current_frame_host()->GetSiteInstance()) { |
465 RenderFrameProxyHost* proxy = | 453 RenderFrameProxyHost* proxy = |
466 root_manager->GetRenderFrameProxyHost(instance); | 454 root_manager->GetRenderFrameProxyHost(instance); |
467 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); | 455 proxy->Send(new InputMsg_SetFocus(proxy->GetRoutingID(), is_focused)); |
468 } | 456 } |
469 } | 457 } |
470 | 458 |
471 } // namespace content | 459 } // namespace content |
OLD | NEW |