summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 19:25:41 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-16 19:25:41 +0000
commit984522c27db175de6fc1835fb6ef2d4327aa7657 (patch)
treeafcd1b6e5e459c82b5e7246da297fb74147903bf /ui
parentc115677e34ec8c23b604570e546b1881091fbcf6 (diff)
downloadchromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.zip
chromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.tar.gz
chromium_src-984522c27db175de6fc1835fb6ef2d4327aa7657.tar.bz2
Revert 177182 - ViewTest.ChangeNativeViewHierarchyFindRoots failure
> Finally rip the global StackingClient bandaid off. > > - Removes the aura::client::SetStackingClient(StackingClient*) interface. > - Moves the ash StackingController from a singleton owned by ash::Shell to one StackingController per RootWindow owned by the ash::RootWindowController. (Also removes a spurious delegate method, where every implementation creates the same object, including tests.) > - Removes the global DesktopStackingClient and related interfaces. > - Fix the ChromeViewsDelegate so that it still sets context in chromeos builds. > - Rename content::ShellStackingClientAsh to content::MinimalAsh to reflect what it really does. > > In addition, the following fix ups apply: > > - Previously, WebContentsViewAura asserted that it needed a context window. Now if no context window is provided, it isn't added to an aura hierarchy. There are times when that context doesn't exist: various chromeos dialogs that directly invoke WebView and toplevel extension/app windows that are created from background pages that don't have contexts. > > BUG=161882 > > Review URL: https://codereview.chromium.org/11829040 TBR=erg@chromium.org Review URL: https://codereview.chromium.org/11962021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/client/stacking_client.cc36
-rw-r--r--ui/aura/client/stacking_client.h4
-rw-r--r--ui/aura/demo/demo_main.cc4
-rw-r--r--ui/aura/env.cc3
-rw-r--r--ui/aura/env.h7
-rw-r--r--ui/aura/test/test_stacking_client.cc4
-rw-r--r--ui/aura/window.cc3
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.cc4
-rw-r--r--ui/views/examples/content_client/examples_browser_main_parts.h9
-rw-r--r--ui/views/views.gyp2
-rw-r--r--ui/views/widget/desktop_aura/desktop_stacking_client.cc64
-rw-r--r--ui/views/widget/desktop_aura/desktop_stacking_client.h65
-rw-r--r--ui/views/widget/native_widget_aura.cc11
-rw-r--r--ui/views/widget/widget.cc13
14 files changed, 202 insertions, 27 deletions
diff --git a/ui/aura/client/stacking_client.cc b/ui/aura/client/stacking_client.cc
index 5d93d98..2bab521 100644
--- a/ui/aura/client/stacking_client.cc
+++ b/ui/aura/client/stacking_client.cc
@@ -16,22 +16,34 @@ namespace client {
DEFINE_WINDOW_PROPERTY_KEY(
StackingClient*, kRootWindowStackingClientKey, NULL);
-void SetStackingClient(Window* window, StackingClient* stacking_client) {
- DCHECK(window);
+void SetStackingClient(StackingClient* stacking_client) {
+ Env::GetInstance()->set_stacking_client(stacking_client);
+}
- RootWindow* root_window = window->GetRootWindow();
- DCHECK(root_window);
- root_window->SetProperty(kRootWindowStackingClientKey, stacking_client);
+StackingClient* GetStackingClient() {
+ return Env::GetInstance()->stacking_client();
+}
+
+void SetStackingClient(Window* window, StackingClient* stacking_client) {
+ if (window) {
+ RootWindow* root_window = window->GetRootWindow();
+ DCHECK(root_window);
+ root_window->SetProperty(kRootWindowStackingClientKey, stacking_client);
+ } else {
+ SetStackingClient(stacking_client);
+ }
}
StackingClient* GetStackingClient(Window* window) {
- DCHECK(window);
- RootWindow* root_window = window->GetRootWindow();
- DCHECK(root_window);
- StackingClient* root_window_stacking_client =
- root_window->GetProperty(kRootWindowStackingClientKey);
- DCHECK(root_window_stacking_client);
- return root_window_stacking_client;
+ if (window) {
+ RootWindow* root_window = window->GetRootWindow();
+ DCHECK(root_window);
+ StackingClient* root_window_stacking_client =
+ root_window->GetProperty(kRootWindowStackingClientKey);
+ if (root_window_stacking_client)
+ return root_window_stacking_client;
+ }
+ return GetStackingClient();
}
} // namespace client
diff --git a/ui/aura/client/stacking_client.h b/ui/aura/client/stacking_client.h
index 89f83eb..6c0aa59 100644
--- a/ui/aura/client/stacking_client.h
+++ b/ui/aura/client/stacking_client.h
@@ -35,6 +35,10 @@ class AURA_EXPORT StackingClient {
const gfx::Rect& bounds) = 0;
};
+// Set/Get the default stacking client.
+AURA_EXPORT void SetStackingClient(StackingClient* stacking_client);
+StackingClient* GetStackingClient();
+
// Set/Get a stacking client for a specific window. Setting the stacking client
// sets the stacking client on the window's RootWindow, not the window itself.
// Likewise getting obtains it from the window's RootWindow. If |window| is
diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc
index 4d27b50..b688e45 100644
--- a/ui/aura/demo/demo_main.cc
+++ b/ui/aura/demo/demo_main.cc
@@ -81,11 +81,11 @@ class DemoStackingClient : public aura::client::StackingClient {
public:
explicit DemoStackingClient(aura::RootWindow* root_window)
: root_window_(root_window) {
- aura::client::SetStackingClient(root_window_, this);
+ aura::client::SetStackingClient(this);
}
virtual ~DemoStackingClient() {
- aura::client::SetStackingClient(root_window_, NULL);
+ aura::client::SetStackingClient(NULL);
}
// Overridden from aura::client::StackingClient:
diff --git a/ui/aura/env.cc b/ui/aura/env.cc
index ecccaf1..bd094c0 100644
--- a/ui/aura/env.cc
+++ b/ui/aura/env.cc
@@ -26,7 +26,8 @@ Env* Env::instance_ = NULL;
Env::Env()
: mouse_button_flags_(0),
is_touch_down_(false),
- render_white_bg_(true) {
+ render_white_bg_(true),
+ stacking_client_(NULL) {
}
Env::~Env() {
diff --git a/ui/aura/env.h b/ui/aura/env.h
index ae4f1a6..24d7f4f 100644
--- a/ui/aura/env.h
+++ b/ui/aura/env.h
@@ -9,6 +9,7 @@
#include "base/message_loop.h"
#include "base/observer_list.h"
#include "ui/aura/aura_export.h"
+#include "ui/aura/client/stacking_client.h"
#include "ui/base/events/event_handler.h"
#include "ui/base/events/event_target.h"
#include "ui/gfx/point.h"
@@ -63,6 +64,11 @@ class AURA_EXPORT Env : public ui::EventTarget {
bool render_white_bg() const { return render_white_bg_; }
void set_render_white_bg(bool value) { render_white_bg_ = value; }
+ client::StackingClient* stacking_client() { return stacking_client_; }
+ void set_stacking_client(client::StackingClient* stacking_client) {
+ stacking_client_ = stacking_client;
+ }
+
// Returns the native event dispatcher. The result should only be passed to
// base::RunLoop(dispatcher), or used to dispatch an event by
// |Dispatch(const NativeEvent&)| on it. It must never be stored.
@@ -96,6 +102,7 @@ class AURA_EXPORT Env : public ui::EventTarget {
gfx::Point last_mouse_location_;
bool is_touch_down_;
bool render_white_bg_;
+ client::StackingClient* stacking_client_;
#if defined(USE_X11)
DeviceListUpdaterAuraX11 device_list_updater_aurax11_;
diff --git a/ui/aura/test/test_stacking_client.cc b/ui/aura/test/test_stacking_client.cc
index 746ad6c..6dd5dcf 100644
--- a/ui/aura/test/test_stacking_client.cc
+++ b/ui/aura/test/test_stacking_client.cc
@@ -11,11 +11,11 @@ namespace test {
TestStackingClient::TestStackingClient(RootWindow* root_window)
: root_window_(root_window) {
- client::SetStackingClient(root_window_, this);
+ client::SetStackingClient(this);
}
TestStackingClient::~TestStackingClient() {
- client::SetStackingClient(root_window_, NULL);
+ client::SetStackingClient(NULL);
}
Window* TestStackingClient::GetDefaultParent(Window* context,
diff --git a/ui/aura/window.cc b/ui/aura/window.cc
index 5999290..9eec35c 100644
--- a/ui/aura/window.cc
+++ b/ui/aura/window.cc
@@ -320,7 +320,8 @@ void Window::SetExternalTexture(ui::Texture* texture) {
void Window::SetDefaultParentByRootWindow(RootWindow* root_window,
const gfx::Rect& bounds_in_screen) {
- DCHECK(root_window);
+ // TODO(erg): Enable this DCHECK once it is safe.
+ // DCHECK(root_window);
// Stacking clients are mandatory on RootWindow objects.
client::StackingClient* client = client::GetStackingClient(root_window);
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.cc b/ui/views/examples/content_client/examples_browser_main_parts.cc
index 1714922a..e353b57 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.cc
+++ b/ui/views/examples/content_client/examples_browser_main_parts.cc
@@ -22,6 +22,7 @@
#include "ui/aura/env.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
#include "ui/views/widget/native_widget_aura.h"
#endif
@@ -39,6 +40,8 @@ void ExamplesBrowserMainParts::PreMainMessageLoopRun() {
browser_context_.reset(new content::ShellBrowserContext(false));
#if !defined(OS_CHROMEOS) && defined(USE_AURA)
+ stacking_client_.reset(new DesktopStackingClient);
+ aura::client::SetStackingClient(stacking_client_.get());
gfx::Screen::SetScreenInstance(
gfx::SCREEN_TYPE_NATIVE, CreateDesktopScreen());
#endif
@@ -51,6 +54,7 @@ void ExamplesBrowserMainParts::PostMainMessageLoopRun() {
browser_context_.reset();
views_delegate_.reset();
#if defined(USE_AURA)
+ stacking_client_.reset();
aura::Env::DeleteInstance();
#endif
}
diff --git a/ui/views/examples/content_client/examples_browser_main_parts.h b/ui/views/examples/content_client/examples_browser_main_parts.h
index 932ed72..ec76226 100644
--- a/ui/views/examples/content_client/examples_browser_main_parts.h
+++ b/ui/views/examples/content_client/examples_browser_main_parts.h
@@ -9,6 +9,12 @@
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/browser_main_parts.h"
+namespace aura {
+namespace client {
+class StackingClient;
+}
+}
+
namespace content {
class ShellBrowserContext;
struct MainFunctionParams;
@@ -38,6 +44,9 @@ class ExamplesBrowserMainParts : public content::BrowserMainParts {
scoped_ptr<content::ShellBrowserContext> browser_context_;
scoped_ptr<ViewsDelegate> views_delegate_;
+#if defined(USE_AURA)
+ scoped_ptr<aura::client::StackingClient> stacking_client_;
+#endif
DISALLOW_COPY_AND_ASSIGN(ExamplesBrowserMainParts);
};
diff --git a/ui/views/views.gyp b/ui/views/views.gyp
index d4a6806..8a100fd 100644
--- a/ui/views/views.gyp
+++ b/ui/views/views.gyp
@@ -372,6 +372,8 @@
'widget/desktop_aura/desktop_screen_win.cc',
'widget/desktop_aura/desktop_screen_win.h',
'widget/desktop_aura/desktop_screen_x11.cc',
+ 'widget/desktop_aura/desktop_stacking_client.cc',
+ 'widget/desktop_aura/desktop_stacking_client.h',
'widget/desktop_aura/x11_desktop_handler.cc',
'widget/desktop_aura/x11_desktop_handler.h',
'widget/desktop_aura/x11_desktop_window_move_client.cc',
diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.cc b/ui/views/widget/desktop_aura/desktop_stacking_client.cc
new file mode 100644
index 0000000..fc7ecb0
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_stacking_client.cc
@@ -0,0 +1,64 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/views/widget/desktop_aura/desktop_stacking_client.h"
+
+#include "ui/aura/client/activation_client.h"
+#include "ui/aura/client/default_capture_client.h"
+#include "ui/aura/focus_manager.h"
+#include "ui/aura/root_window.h"
+#include "ui/aura/window.h"
+#include "ui/views/corewm/compound_event_filter.h"
+#include "ui/views/corewm/input_method_event_filter.h"
+#include "ui/views/widget/desktop_aura/desktop_activation_client.h"
+
+namespace views {
+
+DesktopStackingClient::DesktopStackingClient()
+ : window_event_filter_(NULL) {
+ aura::client::SetStackingClient(this);
+}
+
+DesktopStackingClient::~DesktopStackingClient() {
+ if (window_event_filter_)
+ window_event_filter_->RemoveHandler(input_method_filter_.get());
+
+ aura::client::SetStackingClient(NULL);
+}
+
+aura::Window* DesktopStackingClient::GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) {
+ if (!null_parent_.get())
+ CreateNULLParent();
+
+ return null_parent_.get();
+}
+
+void DesktopStackingClient::CreateNULLParent() {
+ focus_client_.reset(new aura::FocusManager);
+
+ null_parent_.reset(new aura::RootWindow(
+ aura::RootWindow::CreateParams(gfx::Rect(100, 100))));
+ null_parent_->Init();
+ aura::client::SetFocusClient(null_parent_.get(), focus_client_.get());
+
+ activation_client_.reset(new DesktopActivationClient(null_parent_.get()));
+
+ window_event_filter_ = new corewm::CompoundEventFilter;
+ null_parent_->SetEventFilter(window_event_filter_);
+
+ input_method_filter_.reset(new corewm::InputMethodEventFilter(
+ null_parent_->GetAcceleratedWidget()));
+ input_method_filter_->SetInputMethodPropertyInRootWindow(null_parent_.get());
+ window_event_filter_->AddHandler(input_method_filter_.get());
+
+ capture_client_.reset(
+ new aura::client::DefaultCaptureClient(null_parent_.get()));
+
+ // Hide the window so we don't attempt to draw to it and what not.
+ null_parent_->Hide();
+}
+
+} // namespace views
diff --git a/ui/views/widget/desktop_aura/desktop_stacking_client.h b/ui/views/widget/desktop_aura/desktop_stacking_client.h
new file mode 100644
index 0000000..56abc60
--- /dev/null
+++ b/ui/views/widget/desktop_aura/desktop_stacking_client.h
@@ -0,0 +1,65 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
+#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
+
+#include "ui/aura/client/stacking_client.h"
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/views/views_export.h"
+
+namespace aura {
+class RootWindow;
+class Window;
+namespace client {
+class DefaultCaptureClient;
+class FocusClient;
+}
+}
+
+namespace views {
+class DesktopActivationClient;
+namespace corewm {
+class CompoundEventFilter;
+class InputMethodEventFilter;
+}
+
+// A stacking client for the desktop; always sets the default parent to the
+// RootWindow of the passed in Window.
+class VIEWS_EXPORT DesktopStackingClient : public aura::client::StackingClient {
+ public:
+ DesktopStackingClient();
+ virtual ~DesktopStackingClient();
+
+ // Overridden from aura::client::StackingClient:
+ virtual aura::Window* GetDefaultParent(aura::Window* context,
+ aura::Window* window,
+ const gfx::Rect& bounds) OVERRIDE;
+
+ private:
+ void CreateNULLParent();
+
+ // Windows with NULL parents are parented to this.
+ scoped_ptr<aura::RootWindow> null_parent_;
+
+ // All the member variables below are necessary for the NULL parent root
+ // window to function.
+ scoped_ptr<aura::client::FocusClient> focus_client_;
+ // Depends on focus_manager_.
+ scoped_ptr<DesktopActivationClient> activation_client_;
+
+ scoped_ptr<corewm::InputMethodEventFilter> input_method_filter_;
+ corewm::CompoundEventFilter* window_event_filter_;
+
+ scoped_ptr<aura::client::DefaultCaptureClient> capture_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(DesktopStackingClient);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_STACKING_CLIENT_H_
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 1888378..5089485 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -136,8 +136,15 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
if (parent) {
parent->AddChild(window_);
} else {
- window_->SetDefaultParentByRootWindow(context->GetRootWindow(),
- window_bounds);
+ // TODO(erg): Once I've threaded context through chrome, uncomment this
+ // check, which currently fails on the NULL == NULL case.
+ //
+ // DCHECK_NE(params.GetParent(), params.context);
+
+ // TODO(erg): Remove this NULL check once we've made everything in views
+ // actually pass us a context.
+ aura::RootWindow* root_window = context ? context->GetRootWindow() : NULL;
+ window_->SetDefaultParentByRootWindow(root_window, window_bounds);
}
// Wait to set the bounds until we have a parent. That way we can know our
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 8194e5a..8a1923d 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -221,15 +221,8 @@ Widget::~Widget() {
// static
Widget* Widget::CreateWindow(WidgetDelegate* delegate) {
- return CreateWindowWithBounds(delegate, gfx::Rect());
-}
-
-// static
-Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
- const gfx::Rect& bounds) {
Widget* widget = new Widget;
Widget::InitParams params;
- params.bounds = bounds;
params.delegate = delegate;
params.top_level = true;
widget->Init(params);
@@ -237,6 +230,12 @@ Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
}
// static
+Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate,
+ const gfx::Rect& bounds) {
+ return CreateWindowWithParentAndBounds(delegate, NULL, bounds);
+}
+
+// static
Widget* Widget::CreateWindowWithParent(WidgetDelegate* delegate,
gfx::NativeWindow parent) {
return CreateWindowWithParentAndBounds(delegate, parent, gfx::Rect());