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

Unified Diff: ui/aura/window.cc

Issue 8477019: Adds Window::MoveChildToFront, with surrounding changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup 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 | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
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 17f1b504446e7752937e3cbf293430b5a2e5b923..3e9d0015c6d231f8139c1a558f655d9ee5477fd4 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -173,24 +173,42 @@ void Window::SetParent(Window* parent) {
}
void Window::MoveChildToFront(Window* child) {
- DCHECK_EQ(child->parent(), this);
- const Windows::iterator i(std::find(children_.begin(), children_.end(),
- child));
- DCHECK(i != children_.end());
- children_.erase(i);
+ if (children_.size() <= 1 || child == children_.back())
+ return; // In the front already.
+ MoveChildAbove(child, children_.back());
+}
+
+void Window::MoveChildAbove(Window* child, Window* other) {
+ DCHECK_NE(child, other);
+ DCHECK(child);
+ DCHECK(other);
+ DCHECK_EQ(this, child->parent());
+ DCHECK_EQ(this, other->parent());
+
+ size_t child_i =
+ std::find(children_.begin(), children_.end(), child) - children_.begin();
+ size_t other_i =
+ std::find(children_.begin(), children_.end(), other) - children_.begin();
+ if (child_i > other_i)
+ return; // Already in front of |other|.
+
+ // Reorder children.
+ children_.erase(children_.begin() + child_i);
+ children_.insert(children_.begin() + other_i, child);
- children_.insert(children_.begin() + children_.size(), child);
- child->layer()->parent()->MoveToFront(child->layer());
- // Repaint the window as active status may have changed.
- SchedulePaintInRect(gfx::Rect());
+ // Reorder the layer.
+ layer()->MoveAbove(child->layer(), other->layer());
// Move any transient children that share the same parent to be in front of
- // us.
+ // 'child'.
+ Window* last_transient = child;
for (Windows::iterator i = child->transient_children_.begin();
i != child->transient_children_.end(); ++i) {
Window* transient_child = *i;
- if (transient_child->parent_ == this)
- MoveChildToFront(transient_child);
+ if (transient_child->parent_ == this) {
+ MoveChildAbove(transient_child, last_transient);
+ last_transient = transient_child;
+ }
}
}
« no previous file with comments | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698