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

Unified Diff: ui/gfx/compositor/layer.cc

Issue 8653005: Make Aura and compositor stacking methods more intuitive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/compositor/layer.cc
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index 26e269951ff3cea37d0acb16d6f7c1e422d6d6a6..67fe01416075af7a82141f87343886fe90c58a88 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -135,22 +135,23 @@ void Layer::StackAbove(Layer* child, Layer* other) {
DCHECK_NE(child, other);
DCHECK_EQ(this, child->parent());
DCHECK_EQ(this, other->parent());
- size_t child_i =
+
+ const size_t child_i =
std::find(children_.begin(), children_.end(), child) - children_.begin();
- size_t other_i =
+ const size_t other_i =
std::find(children_.begin(), children_.end(), other) - children_.begin();
- if (child_i > other_i)
- return; // Already in front of |other|.
+ if (child_i == other_i + 1)
+ return;
- // Reorder children.
+ const size_t dest_i = child_i < other_i ? other_i : other_i + 1;
children_.erase(children_.begin() + child_i);
- children_.insert(children_.begin() + other_i, child);
+ children_.insert(children_.begin() + dest_i, child);
SetNeedsToRecomputeHole();
#if defined(USE_WEBKIT_COMPOSITOR)
child->web_layer_.removeFromParent();
- web_layer_.insertChild(child->web_layer_, other_i);
+ web_layer_.insertChild(child->web_layer_, dest_i);
#endif
}

Powered by Google App Engine
This is Rietveld 408576698