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

Unified Diff: ui/aura/window.cc

Issue 8194004: change the way windows are parented when their parent is set to NULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months 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
Index: ui/aura/window.cc
===================================================================
--- ui/aura/window.cc (revision 104542)
+++ ui/aura/window.cc (working copy)
@@ -8,10 +8,12 @@
#include "base/logging.h"
#include "ui/aura/desktop.h"
+#include "ui/aura/desktop_delegate.h"
#include "ui/aura/event.h"
#include "ui/aura/event_filter.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/window_delegate.h"
+#include "ui/aura/window_types.h"
#include "ui/base/animation/multi_animation.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/compositor/compositor.h"
@@ -23,7 +25,8 @@
using internal::RootWindow;
Window::Window(WindowDelegate* delegate)
- : delegate_(delegate),
+ : type_(kWindowType_Toplevel),
+ delegate_(delegate),
show_state_(ui::SHOW_STATE_NORMAL),
parent_(NULL),
id_(-1),
@@ -68,6 +71,12 @@
layer_->set_delegate(this);
}
+void Window::SetType(int type) {
+ // Cannot change type after the window is initialized.
+ DCHECK(!layer());
+ type_ = type;
+}
+
void Window::Show() {
SetVisible(true);
}
@@ -126,8 +135,10 @@
void Window::SetParent(Window* parent) {
if (parent)
parent->AddChild(this);
+ else if (Desktop::GetInstance()->delegate())
+ Desktop::GetInstance()->delegate()->AddChildToDefaultParent(this);
else
- Desktop::GetInstance()->default_parent()->AddChild(this);
+ NOTREACHED();
}
void Window::Restore() {
@@ -148,10 +159,14 @@
SetBounds(gfx::Screen::GetMonitorAreaNearestWindow(this));
}
-bool Window::IsToplevelWindowContainer() const {
- return false;
+ToplevelWindowContainer* Window::AsToplevelWindowContainer() {
+ return NULL;
}
+const ToplevelWindowContainer* Window::AsToplevelWindowContainer() const {
+ return NULL;
+}
+
void Window::MoveChildToFront(Window* child) {
DCHECK_EQ(child->parent(), this);
const Windows::iterator i(std::find(children_.begin(), children_.end(),
@@ -166,6 +181,10 @@
child->layer()->parent()->MoveToFront(child->layer());
}
+bool Window::CanActivate() const {
+ return IsVisible() && delegate_ && delegate_->ShouldActivate(NULL);
+}
+
void Window::AddChild(Window* child) {
DCHECK(std::find(children_.begin(), children_.end(), child) ==
children_.end());
@@ -185,11 +204,15 @@
}
Window* Window::GetChildById(int id) {
+ return const_cast<Window*>(const_cast<const Window*>(this)->GetChildById(id));
+}
+
+const Window* Window::GetChildById(int id) const {
Windows::const_iterator i;
for (i = children_.begin(); i != children_.end(); ++i) {
if ((*i)->id() == id)
return *i;
- Window* result = (*i)->GetChildById(id);
+ const Window* result = (*i)->GetChildById(id);
if (result)
return result;
}

Powered by Google App Engine
This is Rietveld 408576698