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

Side by Side Diff: ui/aura/window.cc

Issue 11421006: Desktop aura: Break aura::Window::SetParent in two. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ash_unittests Created 8 years 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 | « ui/aura/window.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/aura/window_observer.h" 26 #include "ui/aura/window_observer.h"
27 #include "ui/base/animation/multi_animation.h" 27 #include "ui/base/animation/multi_animation.h"
28 #include "ui/compositor/compositor.h" 28 #include "ui/compositor/compositor.h"
29 #include "ui/compositor/layer.h" 29 #include "ui/compositor/layer.h"
30 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
31 #include "ui/gfx/path.h" 31 #include "ui/gfx/path.h"
32 #include "ui/gfx/screen.h" 32 #include "ui/gfx/screen.h"
33 33
34 namespace aura { 34 namespace aura {
35 35
36 namespace {
37
38 Window* GetParentForWindow(Window* window, Window* suggested_parent) {
39 if (suggested_parent)
40 return suggested_parent;
41 if (client::GetStackingClient())
42 return client::GetStackingClient()->GetDefaultParent(
43 window, window, gfx::Rect());
44 return NULL;
45 }
46
47 } // namespace
48
49 Window::TestApi::TestApi(Window* window) : window_(window) {} 36 Window::TestApi::TestApi(Window* window) : window_(window) {}
50 37
51 bool Window::TestApi::OwnsLayer() const { 38 bool Window::TestApi::OwnsLayer() const {
52 return !!window_->layer_owner_.get(); 39 return !!window_->layer_owner_.get();
53 } 40 }
54 41
55 bool Window::TestApi::ContainsMouse() { 42 bool Window::TestApi::ContainsMouse() {
56 return window_->ContainsMouse(); 43 return window_->ContainsMouse();
57 } 44 }
58 45
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 313 }
327 } 314 }
328 315
329 void Window::SetExternalTexture(ui::Texture* texture) { 316 void Window::SetExternalTexture(ui::Texture* texture) {
330 layer_->SetExternalTexture(texture); 317 layer_->SetExternalTexture(texture);
331 gfx::Rect region(bounds().size()); 318 gfx::Rect region(bounds().size());
332 FOR_EACH_OBSERVER( 319 FOR_EACH_OBSERVER(
333 WindowObserver, observers_, OnWindowPaintScheduled(this, region)); 320 WindowObserver, observers_, OnWindowPaintScheduled(this, region));
334 } 321 }
335 322
336 void Window::SetParent(Window* parent) { 323 void Window::SetDefaultParentByRootWindow(RootWindow* root_window,
337 GetParentForWindow(this, parent)->AddChild(this); 324 const gfx::Rect& bounds_in_screen) {
325 // TODO(erg): Enable this DCHECK once it is safe.
326 // DCHECK(root_window);
327
328 // Stacking clients are mandatory on RootWindow objects.
329 client::StackingClient* client = client::GetStackingClient(root_window);
330 DCHECK(client);
331
332 aura::Window* default_parent = client->GetDefaultParent(
333 root_window, this, bounds_in_screen);
334 default_parent->AddChild(this);
338 } 335 }
339 336
340 void Window::StackChildAtTop(Window* child) { 337 void Window::StackChildAtTop(Window* child) {
341 if (children_.size() <= 1 || child == children_.back()) 338 if (children_.size() <= 1 || child == children_.back())
342 return; // In the front already. 339 return; // In the front already.
343 StackChildAbove(child, children_.back()); 340 StackChildAbove(child, children_.back());
344 } 341 }
345 342
346 void Window::StackChildAbove(Window* child, Window* target) { 343 void Window::StackChildAbove(Window* child, Window* target) {
347 StackChildRelativeTo(child, target, STACK_ABOVE); 344 StackChildRelativeTo(child, target, STACK_ABOVE);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 bool contains_mouse = false; 961 bool contains_mouse = false;
965 if (IsVisible()) { 962 if (IsVisible()) {
966 RootWindow* root_window = GetRootWindow(); 963 RootWindow* root_window = GetRootWindow();
967 contains_mouse = root_window && 964 contains_mouse = root_window &&
968 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); 965 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot());
969 } 966 }
970 return contains_mouse; 967 return contains_mouse;
971 } 968 }
972 969
973 } // namespace aura 970 } // namespace aura
OLDNEW
« 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