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

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: Re-add parent finding thing to web_contents_view_aura.cc. I guess it was necessary after all? Created 8 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
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::SetParentTo(Window* parent) {
Ben Goodger (Google) 2012/11/20 23:46:38 Since you're renaming this method, can you just ge
337 GetParentForWindow(this, parent)->AddChild(this); 324 DCHECK(parent);
325 parent->AddChild(this);
326 }
327
328 void Window::SetDefaultParentByTargetRoot(RootWindow* context_root) {
329 // TODO(erg): Enable this DCHECK once it is safe.
330 // DCHECK(context_root);
331
332 // Stacking clients are mandatory on RootWindow objects.
333 client::StackingClient* client = client::GetStackingClient(context_root);
334 DCHECK(client);
335
336 aura::Window* default_parent = client->GetDefaultParent(
337 context_root, this, gfx::Rect());
338 default_parent->AddChild(this);
338 } 339 }
339 340
340 void Window::StackChildAtTop(Window* child) { 341 void Window::StackChildAtTop(Window* child) {
341 if (children_.size() <= 1 || child == children_.back()) 342 if (children_.size() <= 1 || child == children_.back())
342 return; // In the front already. 343 return; // In the front already.
343 StackChildAbove(child, children_.back()); 344 StackChildAbove(child, children_.back());
344 } 345 }
345 346
346 void Window::StackChildAbove(Window* child, Window* target) { 347 void Window::StackChildAbove(Window* child, Window* target) {
347 StackChildRelativeTo(child, target, STACK_ABOVE); 348 StackChildRelativeTo(child, target, STACK_ABOVE);
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 bool contains_mouse = false; 969 bool contains_mouse = false;
969 if (IsVisible()) { 970 if (IsVisible()) {
970 RootWindow* root_window = GetRootWindow(); 971 RootWindow* root_window = GetRootWindow();
971 contains_mouse = root_window && 972 contains_mouse = root_window &&
972 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot()); 973 ContainsPointInRoot(root_window->GetLastMouseLocationInRoot());
973 } 974 }
974 return contains_mouse; 975 return contains_mouse;
975 } 976 }
976 977
977 } // namespace aura 978 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698