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

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

Issue 1500973002: This patch adds NextSibling() to FrameTreeNode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and addressed comment. Created 4 years, 7 months 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_node.h" 5 #include "content/browser/frame_host/frame_tree_node.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 for (FrameTreeNode* node = parent(); node; node = node->parent()) { 271 for (FrameTreeNode* node = parent(); node; node = node->parent()) {
272 if (node == other) 272 if (node == other)
273 return true; 273 return true;
274 } 274 }
275 275
276 return false; 276 return false;
277 } 277 }
278 278
279 FrameTreeNode* FrameTreeNode::PreviousSibling() const { 279 FrameTreeNode* FrameTreeNode::PreviousSibling() const {
280 if (!parent_) 280 return GetSibling(-1);
281 return nullptr; 281 }
282 282
283 for (size_t i = 0; i < parent_->child_count(); ++i) { 283 FrameTreeNode* FrameTreeNode::NextSibling() const {
284 if (parent_->child_at(i) == this) 284 return GetSibling(1);
285 return (i == 0) ? nullptr : parent_->child_at(i - 1);
286 }
287
288 NOTREACHED() << "FrameTreeNode not found in its parent's children.";
289 return nullptr;
290 } 285 }
291 286
292 bool FrameTreeNode::IsLoading() const { 287 bool FrameTreeNode::IsLoading() const {
293 RenderFrameHostImpl* current_frame_host = 288 RenderFrameHostImpl* current_frame_host =
294 render_manager_.current_frame_host(); 289 render_manager_.current_frame_host();
295 RenderFrameHostImpl* pending_frame_host = 290 RenderFrameHostImpl* pending_frame_host =
296 render_manager_.pending_frame_host(); 291 render_manager_.pending_frame_host();
297 292
298 DCHECK(current_frame_host); 293 DCHECK(current_frame_host);
299 294
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 482
488 void FrameTreeNode::TraceSnapshot() const { 483 void FrameTreeNode::TraceSnapshot() const {
489 DCHECK_CURRENTLY_ON(BrowserThread::UI); 484 DCHECK_CURRENTLY_ON(BrowserThread::UI);
490 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 485 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
491 "navigation", "FrameTreeNode", 486 "navigation", "FrameTreeNode",
492 TRACE_ID_WITH_SCOPE("FrameTreeNode", frame_tree_node_id_), 487 TRACE_ID_WITH_SCOPE("FrameTreeNode", frame_tree_node_id_),
493 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>( 488 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>(
494 new TracedFrameTreeNode(*this))); 489 new TracedFrameTreeNode(*this)));
495 } 490 }
496 491
492 FrameTreeNode* FrameTreeNode::GetSibling(int relative_offset) const {
493 if (!parent_)
494 return nullptr;
495
496 for (size_t i = 0; i < parent_->child_count(); ++i) {
497 if (parent_->child_at(i) == this) {
498 if ((relative_offset < 0 && static_cast<size_t>(-relative_offset) > i) ||
499 i + relative_offset >= parent_->child_count()) {
500 return nullptr;
501 }
502 return parent_->child_at(i + relative_offset);
503 }
504 }
505
506 NOTREACHED() << "FrameTreeNode not found in its parent's children.";
507 return nullptr;
508 }
509
497 } // namespace content 510 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node.h ('k') | content/browser/frame_host/frame_tree_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698