summaryrefslogtreecommitdiffstats
path: root/chromium/cc/layers/layer_list_iterator.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-07-14 17:41:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2016-08-04 12:37:36 +0000
commit399c965b6064c440ddcf4015f5f8e9d131c7a0a6 (patch)
tree6b06b60ff365abef0e13b3503d593a0df48d20e8 /chromium/cc/layers/layer_list_iterator.cc
parent7366110654eec46f21b6824f302356426f48cd74 (diff)
BASELINE: Update Chromium to 52.0.2743.76 and Ninja to 1.7.1
Change-Id: I382f51b959689505a60f8b707255ecb344f7d8b4 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/cc/layers/layer_list_iterator.cc')
-rw-r--r--chromium/cc/layers/layer_list_iterator.cc75
1 files changed, 44 insertions, 31 deletions
diff --git a/chromium/cc/layers/layer_list_iterator.cc b/chromium/cc/layers/layer_list_iterator.cc
index e71238d6020..ec728993777 100644
--- a/chromium/cc/layers/layer_list_iterator.cc
+++ b/chromium/cc/layers/layer_list_iterator.cc
@@ -4,42 +4,45 @@
#include "cc/layers/layer_list_iterator.h"
+#include "cc/layers/layer.h"
#include "cc/layers/layer_impl.h"
namespace cc {
-LayerListIterator::LayerListIterator(LayerImpl* root_layer)
+template <typename LayerType>
+LayerListIterator<LayerType>::LayerListIterator(LayerType* root_layer)
: current_layer_(root_layer) {
DCHECK(!root_layer || !root_layer->parent());
list_indices_.push_back(0);
}
-LayerListIterator::LayerListIterator(const LayerListIterator& other) = default;
+template <typename LayerType>
+LayerListIterator<LayerType>::LayerListIterator(
+ const LayerListIterator<LayerType>& other) = default;
-LayerListIterator::~LayerListIterator() {}
+template <typename LayerType>
+LayerListIterator<LayerType>::~LayerListIterator() {}
-LayerListIterator& LayerListIterator::operator++() {
+template <typename LayerType>
+LayerListIterator<LayerType>& LayerListIterator<LayerType>::operator++() {
// case 0: done
if (!current_layer_)
return *this;
// case 1: descend.
- const LayerImplList& current_list = current_layer_->children();
- if (!current_list.empty()) {
- current_layer_ = current_list[0];
+ if (!current_layer_->children().empty()) {
+ current_layer_ = current_layer_->child_at(0);
list_indices_.push_back(0);
return *this;
}
- for (LayerImpl* parent = current_layer_->parent(); parent;
+ for (LayerType* parent = current_layer_->parent(); parent;
parent = parent->parent()) {
// We now try and advance in some list of siblings.
- const LayerImplList& sibling_list = parent->children();
-
// case 2: Advance to a sibling.
- if (list_indices_.back() + 1 < sibling_list.size()) {
+ if (list_indices_.back() + 1 < parent->children().size()) {
++list_indices_.back();
- current_layer_ = sibling_list[list_indices_.back()];
+ current_layer_ = parent->child_at(list_indices_.back());
return *this;
}
@@ -51,48 +54,58 @@ LayerListIterator& LayerListIterator::operator++() {
return *this;
}
-LayerListReverseIterator::LayerListReverseIterator(LayerImpl* root_layer)
- : LayerListIterator(root_layer) {
+template <typename LayerType>
+LayerListReverseIterator<LayerType>::LayerListReverseIterator(
+ LayerType* root_layer)
+ : LayerListIterator<LayerType>(root_layer) {
DescendToRightmostInSubtree();
}
-LayerListReverseIterator::~LayerListReverseIterator() {}
+template <typename LayerType>
+LayerListReverseIterator<LayerType>::~LayerListReverseIterator() {}
// We will only support prefix increment.
-LayerListIterator& LayerListReverseIterator::operator++() {
+template <typename LayerType>
+LayerListIterator<LayerType>& LayerListReverseIterator<LayerType>::
+operator++() {
// case 0: done
- if (!current_layer_)
+ if (!current_layer())
return *this;
// case 1: we're the leftmost sibling.
- if (!list_indices_.back()) {
- list_indices_.pop_back();
- current_layer_ = current_layer_->parent();
+ if (!list_indices().back()) {
+ list_indices().pop_back();
+ this->current_layer_ = current_layer()->parent();
return *this;
}
// case 2: we're not the leftmost sibling. In this case, we want to move one
// sibling over, and then descend to the rightmost descendant in that subtree.
- CHECK(current_layer_->parent());
- --list_indices_.back();
- const LayerImplList& parent_list = current_layer_->parent()->children();
- current_layer_ = parent_list[list_indices_.back()];
+ CHECK(current_layer()->parent());
+ --list_indices().back();
+ this->current_layer_ =
+ current_layer()->parent()->child_at(list_indices().back());
DescendToRightmostInSubtree();
return *this;
}
-void LayerListReverseIterator::DescendToRightmostInSubtree() {
- if (!current_layer_)
+template <typename LayerType>
+void LayerListReverseIterator<LayerType>::DescendToRightmostInSubtree() {
+ if (!current_layer())
return;
- const LayerImplList& current_list = current_layer_->children();
- if (current_list.empty())
+ if (current_layer()->children().empty())
return;
- size_t last_index = current_list.size() - 1;
- current_layer_ = current_list[last_index];
- list_indices_.push_back(last_index);
+ size_t last_index = current_layer()->children().size() - 1;
+ this->current_layer_ = current_layer()->child_at(last_index);
+ list_indices().push_back(last_index);
DescendToRightmostInSubtree();
}
+template class LayerListIterator<Layer>;
+template class LayerListIterator<LayerImpl>;
+template class LayerListReverseIterator<Layer>;
+template class LayerListReverseIterator<LayerImpl>;
+
} // namespace cc