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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/aura/window_unittest.cc » ('j') | ui/aura_shell/shadow_controller_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/window.h" 5 #include "ui/aura/window.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 StackChildAbove(child, children_.back()); 189 StackChildAbove(child, children_.back());
190 } 190 }
191 191
192 void Window::StackChildAbove(Window* child, Window* other) { 192 void Window::StackChildAbove(Window* child, Window* other) {
193 DCHECK_NE(child, other); 193 DCHECK_NE(child, other);
194 DCHECK(child); 194 DCHECK(child);
195 DCHECK(other); 195 DCHECK(other);
196 DCHECK_EQ(this, child->parent()); 196 DCHECK_EQ(this, child->parent());
197 DCHECK_EQ(this, other->parent()); 197 DCHECK_EQ(this, other->parent());
198 198
199 size_t child_i = 199 const size_t child_i =
200 std::find(children_.begin(), children_.end(), child) - children_.begin(); 200 std::find(children_.begin(), children_.end(), child) - children_.begin();
201 size_t other_i = 201 const size_t other_i =
202 std::find(children_.begin(), children_.end(), other) - children_.begin(); 202 std::find(children_.begin(), children_.end(), other) - children_.begin();
203 if (child_i > other_i) 203 if (child_i == other_i + 1)
204 return; // Already in front of |other|. 204 return;
205 205
206 // Reorder children. 206 const size_t dest_i = child_i < other_i ? other_i : other_i + 1;
207 children_.erase(children_.begin() + child_i); 207 children_.erase(children_.begin() + child_i);
208 children_.insert(children_.begin() + other_i, child); 208 children_.insert(children_.begin() + dest_i, child);
209 209
210 // Reorder the layer.
211 layer()->StackAbove(child->layer(), other->layer()); 210 layer()->StackAbove(child->layer(), other->layer());
212 211
213 // Stack any transient children that share the same parent to be in front of 212 // Stack any transient children that share the same parent to be in front of
214 // 'child'. 213 // 'child'.
215 Window* last_transient = child; 214 Window* last_transient = child;
216 for (Windows::iterator i = child->transient_children_.begin(); 215 for (Windows::iterator i = child->transient_children_.begin();
217 i != child->transient_children_.end(); ++i) { 216 i != child->transient_children_.end(); ++i) {
218 Window* transient_child = *i; 217 Window* transient_child = *i;
219 if (transient_child->parent_ == this) { 218 if (transient_child->parent_ == this) {
220 StackChildAbove(transient_child, last_transient); 219 StackChildAbove(transient_child, last_transient);
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 void Window::OnStackingChanged() { 532 void Window::OnStackingChanged() {
534 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this)); 533 FOR_EACH_OBSERVER(WindowObserver, observers_, OnWindowStackingChanged(this));
535 } 534 }
536 535
537 void Window::OnPaintLayer(gfx::Canvas* canvas) { 536 void Window::OnPaintLayer(gfx::Canvas* canvas) {
538 if (delegate_) 537 if (delegate_)
539 delegate_->OnPaint(canvas); 538 delegate_->OnPaint(canvas);
540 } 539 }
541 540
542 } // namespace aura 541 } // namespace aura
OLDNEW
« 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