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_node.h" | 5 #include "content/browser/frame_host/frame_tree_node.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 | 210 |
211 for (FrameTreeNode* node = parent(); node; node = node->parent()) { | 211 for (FrameTreeNode* node = parent(); node; node = node->parent()) { |
212 if (node == other) | 212 if (node == other) |
213 return true; | 213 return true; |
214 } | 214 } |
215 | 215 |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 FrameTreeNode* FrameTreeNode::PreviousSibling() const { | 219 FrameTreeNode* FrameTreeNode::PreviousSibling() const { |
220 if (!parent_) | 220 return GetSibling(-1); |
221 return nullptr; | 221 } |
222 | 222 |
223 for (size_t i = 0; i < parent_->child_count(); ++i) { | 223 FrameTreeNode* FrameTreeNode::NextSibling() const { |
224 if (parent_->child_at(i) == this) | 224 return GetSibling(1); |
225 return (i == 0) ? nullptr : parent_->child_at(i - 1); | |
226 } | |
227 | |
228 NOTREACHED() << "FrameTreeNode not found in its parent's children."; | |
229 return nullptr; | |
230 } | 225 } |
231 | 226 |
232 bool FrameTreeNode::IsLoading() const { | 227 bool FrameTreeNode::IsLoading() const { |
233 RenderFrameHostImpl* current_frame_host = | 228 RenderFrameHostImpl* current_frame_host = |
234 render_manager_.current_frame_host(); | 229 render_manager_.current_frame_host(); |
235 RenderFrameHostImpl* pending_frame_host = | 230 RenderFrameHostImpl* pending_frame_host = |
236 render_manager_.pending_frame_host(); | 231 render_manager_.pending_frame_host(); |
237 | 232 |
238 DCHECK(current_frame_host); | 233 DCHECK(current_frame_host); |
239 | 234 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 | 374 |
380 render_manager_.Stop(); | 375 render_manager_.Stop(); |
381 return true; | 376 return true; |
382 } | 377 } |
383 | 378 |
384 void FrameTreeNode::DidFocus() { | 379 void FrameTreeNode::DidFocus() { |
385 last_focus_time_ = base::TimeTicks::Now(); | 380 last_focus_time_ = base::TimeTicks::Now(); |
386 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this)); | 381 FOR_EACH_OBSERVER(Observer, observers_, OnFrameTreeNodeFocused(this)); |
387 } | 382 } |
388 | 383 |
384 FrameTreeNode* FrameTreeNode::GetSibling(int relative_offset) const { | |
385 if (!parent_) | |
386 return nullptr; | |
387 | |
388 for (size_t i = 0; i < parent_->child_count(); ++i) { | |
389 if (parent_->child_at(i) == this) { | |
390 size_t offset = i + relative_offset; | |
391 return offset >= parent_->child_count() ? nullptr | |
Charlie Reis
2015/12/09 22:29:15
Don't we need to check for less than 0 as well? S
paulmeyer
2015/12/09 22:38:43
I wasn't checking for less than zero specifically
Charlie Reis
2015/12/09 23:49:48
That would preclude any analyses which check for r
paulmeyer
2016/05/13 13:44:15
Okay, done.
| |
392 : parent_->child_at(offset); | |
393 } | |
394 } | |
395 | |
396 NOTREACHED() << "FrameTreeNode not found in its parent's children."; | |
397 return nullptr; | |
398 } | |
399 | |
389 } // namespace content | 400 } // namespace content |
OLD | NEW |