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

Unified Diff: ui/aura/window.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
« no previous file with comments | « no previous file | ui/aura/window_unittest.cc » ('j') | ui/aura_shell/shadow_controller_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window.cc
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index c58205f3ae42af0bc20862ce04c76dabfc53180c..ce127d513c28290b48fa2c0af1f2540080cd6ca2 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -196,18 +196,17 @@ void Window::StackChildAbove(Window* child, Window* 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);
- // Reorder the layer.
layer()->StackAbove(child->layer(), other->layer());
// Stack any transient children that share the same parent to be in front of
« no previous file with comments | « no previous file | ui/aura/window_unittest.cc » ('j') | ui/aura_shell/shadow_controller_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698