diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-22 20:50:36 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-22 20:50:36 +0000 |
commit | 2a2caa0c24fb2adb2a889d24c85f120f55efac52 (patch) | |
tree | 40f6803189fb0bbdb7af69c114377b8ae448d99b /content | |
parent | f47621b16b748a2cb828e2f28b39f717c48ab65d (diff) | |
download | chromium_src-2a2caa0c24fb2adb2a889d24c85f120f55efac52.zip chromium_src-2a2caa0c24fb2adb2a889d24c85f120f55efac52.tar.gz chromium_src-2a2caa0c24fb2adb2a889d24c85f120f55efac52.tar.bz2 |
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.
- Because of that, added a few of NULL checking to RenderWidgetHostViewAura. (Other methods NULL checked Window::GetRootWindow(), but there were a few that didn't and relied on the old NULL means lookup in the StackingClient behaviour.)
BUG=161882
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=177182
Review URL: https://codereview.chromium.org/11829040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 54 | ||||
-rw-r--r-- | content/browser/web_contents/web_contents_view_aura.cc | 16 | ||||
-rw-r--r-- | content/content_shell.gypi | 4 | ||||
-rw-r--r-- | content/shell/minimal_ash.cc | 53 | ||||
-rw-r--r-- | content/shell/minimal_ash.h (renamed from content/shell/shell_stacking_client_ash.h) | 14 | ||||
-rw-r--r-- | content/shell/shell.h | 15 | ||||
-rw-r--r-- | content/shell/shell_aura.cc | 27 | ||||
-rw-r--r-- | content/shell/shell_stacking_client_ash.cc | 56 |
8 files changed, 134 insertions, 105 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 81d3a4e..a7dd91b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -467,11 +467,13 @@ gfx::NativeView RenderWidgetHostViewAura::GetNativeView() const { gfx::NativeViewId RenderWidgetHostViewAura::GetNativeViewId() const { #if defined(OS_WIN) - HWND window = window_->GetRootWindow()->GetAcceleratedWidget(); - return reinterpret_cast<gfx::NativeViewId>(window); -#else - return static_cast<gfx::NativeViewId>(NULL); + aura::RootWindow* root_window = window_->GetRootWindow(); + if (root_window) { + HWND window = root_window->GetAcceleratedWidget(); + return reinterpret_cast<gfx::NativeViewId>(window); + } #endif + return static_cast<gfx::NativeViewId>(NULL); } gfx::NativeViewAccessible RenderWidgetHostViewAura::GetNativeViewAccessible() { @@ -624,6 +626,9 @@ void RenderWidgetHostViewAura::DidUpdateBackingStore( if (!scroll_rect.IsEmpty()) SchedulePaintIfNotInClip(scroll_rect, clip_rect); +#if defined(OS_WIN) + aura::RootWindow* root_window = window_->GetRootWindow(); +#endif for (size_t i = 0; i < copy_rects.size(); ++i) { gfx::Rect rect = gfx::SubtractRects(copy_rects[i], scroll_rect); if (rect.IsEmpty()) @@ -632,12 +637,14 @@ void RenderWidgetHostViewAura::DidUpdateBackingStore( SchedulePaintIfNotInClip(rect, clip_rect); #if defined(OS_WIN) - // Send the invalid rect in screen coordinates. - gfx::Rect screen_rect = GetViewBounds(); - gfx::Rect invalid_screen_rect(rect); - invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); - HWND hwnd = window_->GetRootWindow()->GetAcceleratedWidget(); - PaintPluginWindowsHelper(hwnd, invalid_screen_rect); + if (root_window) { + // Send the invalid rect in screen coordinates. + gfx::Rect screen_rect = GetViewBounds(); + gfx::Rect invalid_screen_rect(rect); + invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); + HWND hwnd = root_window->GetAcceleratedWidget(); + PaintPluginWindowsHelper(hwnd, invalid_screen_rect); + } #endif // defined(OS_WIN) } } @@ -1020,7 +1027,7 @@ void RenderWidgetHostViewAura::SetBackground(const SkBitmap& background) { } void RenderWidgetHostViewAura::GetScreenInfo(WebScreenInfo* results) { - GetScreenInfoForWindow(results, window_); + GetScreenInfoForWindow(results, window_->GetRootWindow() ? window_ : NULL); } gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() { @@ -1183,14 +1190,18 @@ gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(const gfx::Rect& rect) { gfx::Point end = gfx::Point(rect.right(), rect.bottom()); aura::RootWindow* root_window = window_->GetRootWindow(); - aura::client::ScreenPositionClient* screen_position_client = - aura::client::GetScreenPositionClient(root_window); - screen_position_client->ConvertPointToScreen(window_, &origin); - screen_position_client->ConvertPointToScreen(window_, &end); - return gfx::Rect(origin.x(), - origin.y(), - end.x() - origin.x(), - end.y() - origin.y()); + if (root_window) { + aura::client::ScreenPositionClient* screen_position_client = + aura::client::GetScreenPositionClient(root_window); + screen_position_client->ConvertPointToScreen(window_, &origin); + screen_position_client->ConvertPointToScreen(window_, &end); + return gfx::Rect(origin.x(), + origin.y(), + end.x() - origin.x(), + end.y() - origin.y()); + } + + return rect; } gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() { @@ -1682,7 +1693,10 @@ void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: bool RenderWidgetHostViewAura::ShouldActivate() const { - const ui::Event* event = window_->GetRootWindow()->current_event(); + aura::RootWindow* root_window = window_->GetRootWindow(); + if (!root_window) + return true; + const ui::Event* event = root_window->current_event(); if (!event) return true; return is_fullscreen_; diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc index b7c98b1..cee09c3 100644 --- a/content/browser/web_contents/web_contents_view_aura.cc +++ b/content/browser/web_contents/web_contents_view_aura.cc @@ -741,10 +741,18 @@ void WebContentsViewAura::CreateView( window_->SetType(aura::client::WINDOW_TYPE_CONTROL); window_->SetTransparent(false); window_->Init(ui::LAYER_NOT_DRAWN); - // TODO(mukai, erg): Should use a non-NULL value later when the DCHECK is - // turned on in SetDefaultParentByRootWindow(). - aura::RootWindow* target_root = context ? context->GetRootWindow() : NULL; - window_->SetDefaultParentByRootWindow(target_root, gfx::Rect()); + if (context) { + // There are places where there is no context currently because object + // hierarchies are built before they're attached to a Widget. (See + // views::WebView as an example; GetWidget() returns NULL at the point + // where we are created.) + // + // It should be OK to not set a default parent since such users will + // explicitly add this WebContentsViewAura to their tree after they create + // us. + window_->SetDefaultParentByRootWindow(context->GetRootWindow(), + gfx::Rect()); + } window_->layer()->SetMasksToBounds(true); window_->SetName("WebContentsViewAura"); diff --git a/content/content_shell.gypi b/content/content_shell.gypi index 309c075..ec3452d 100644 --- a/content/content_shell.gypi +++ b/content/content_shell.gypi @@ -55,6 +55,8 @@ 'sources': [ 'shell/geolocation/shell_access_token_store.cc', 'shell/geolocation/shell_access_token_store.h', + 'shell/minimal_ash.cc', + 'shell/minimal_ash.h', 'shell/paths_mac.h', 'shell/paths_mac.mm', 'shell/shell.cc', @@ -105,8 +107,6 @@ 'shell/shell_resource_context.h', 'shell/shell_resource_dispatcher_host_delegate.cc', 'shell/shell_resource_dispatcher_host_delegate.h', - 'shell/shell_stacking_client_ash.cc', - 'shell/shell_stacking_client_ash.h', 'shell/shell_switches.cc', 'shell/shell_switches.h', 'shell/shell_url_request_context_getter.cc', diff --git a/content/shell/minimal_ash.cc b/content/shell/minimal_ash.cc new file mode 100644 index 0000000..e1ff94a --- /dev/null +++ b/content/shell/minimal_ash.cc @@ -0,0 +1,53 @@ +// 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 "content/shell/minimal_ash.h" + +#include "ui/aura/client/default_capture_client.h" +#include "ui/aura/focus_manager.h" +#include "ui/aura/root_window.h" +#include "ui/aura/test/test_activation_client.h" +#include "ui/views/corewm/compound_event_filter.h" +#include "ui/views/corewm/input_method_event_filter.h" + +namespace content { + +MinimalAsh::MinimalAsh() { + root_window_.reset(new aura::RootWindow( + aura::RootWindow::CreateParams(gfx::Rect(100, 100)))); + root_window_->Init(); + aura::client::SetStackingClient(root_window_.get(), this); + + focus_client_.reset(new aura::FocusManager); + aura::client::SetFocusClient(root_window_.get(), focus_client_.get()); + + root_window_event_filter_ = new views::corewm::CompoundEventFilter; + // Pass ownership of the filter to the root_window. + root_window_->SetEventFilter(root_window_event_filter_); + + input_method_filter_.reset(new views::corewm::InputMethodEventFilter( + root_window_->GetAcceleratedWidget())); + input_method_filter_->SetInputMethodPropertyInRootWindow( + root_window_.get()); + root_window_event_filter_->AddHandler(input_method_filter_.get()); + + test_activation_client_.reset( + new aura::test::TestActivationClient(root_window_.get())); + + capture_client_.reset( + new aura::client::DefaultCaptureClient(root_window_.get())); +} + +MinimalAsh::~MinimalAsh() { + root_window_event_filter_->RemoveHandler(input_method_filter_.get()); +} + +aura::Window* MinimalAsh::GetDefaultParent( + aura::Window* context, + aura::Window* window, + const gfx::Rect& bounds) { + return root_window_.get(); +} + +} // namespace content diff --git a/content/shell/shell_stacking_client_ash.h b/content/shell/minimal_ash.h index de169c4..f3ec43b 100644 --- a/content/shell/shell_stacking_client_ash.h +++ b/content/shell/minimal_ash.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_ -#define CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_ +#ifndef CONTENT_SHELL_MINIMAL_ASH_H_ +#define CONTENT_SHELL_MINIMAL_ASH_H_ #include "base/compiler_specific.h" #include "base/memory/scoped_ptr.h" @@ -37,10 +37,10 @@ namespace content { // Creates a minimal environment for running the shell. We can't pull in all of // ash here, but we can create attach several of the same things we'd find in // the ash parts of the code. -class ShellStackingClientAsh : public aura::client::StackingClient { +class MinimalAsh : public aura::client::StackingClient { public: - ShellStackingClientAsh(); - virtual ~ShellStackingClientAsh(); + MinimalAsh(); + virtual ~MinimalAsh(); // Overridden from client::StackingClient: virtual aura::Window* GetDefaultParent(aura::Window* context, @@ -58,9 +58,9 @@ class ShellStackingClientAsh : public aura::client::StackingClient { scoped_ptr<aura::test::TestActivationClient> test_activation_client_; scoped_ptr<aura::client::FocusClient> focus_client_; - DISALLOW_COPY_AND_ASSIGN(ShellStackingClientAsh); + DISALLOW_COPY_AND_ASSIGN(MinimalAsh); }; } // namespace content; -#endif // CONTENT_SHELL_SHELL_STACKING_CLIENT_ASH_H_ +#endif // CONTENT_SHELL_MINIMAL_ASH_H_ diff --git a/content/shell/shell.h b/content/shell/shell.h index 82e2a6a..e2162e8 100644 --- a/content/shell/shell.h +++ b/content/shell/shell.h @@ -1,7 +1,6 @@ // 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 CONTENT_SHELL_SHELL_H_ #define CONTENT_SHELL_SHELL_H_ @@ -27,15 +26,15 @@ typedef struct _GtkToolItem GtkToolItem; #elif defined(OS_ANDROID) #include "base/android/scoped_java_ref.h" #elif defined(USE_AURA) +#if defined(OS_CHROMEOS) +namespace content { +class MinimalAsh; +} +#endif namespace views { class Widget; class ViewsDelegate; } -namespace aura { -namespace client { -class StackingClient; -} -} #endif class GURL; @@ -237,7 +236,9 @@ class Shell : public WebContentsDelegate, #elif defined(OS_ANDROID) base::android::ScopedJavaGlobalRef<jobject> java_object_; #elif defined(USE_AURA) - static aura::client::StackingClient* stacking_client_; +#if defined(OS_CHROMEOS) + static content::MinimalAsh* minimal_ash_; +#endif static views::ViewsDelegate* views_delegate_; views::Widget* window_widget_; diff --git a/content/shell/shell_aura.cc b/content/shell/shell_aura.cc index a0986c4..6641cda 100644 --- a/content/shell/shell_aura.cc +++ b/content/shell/shell_aura.cc @@ -29,10 +29,8 @@ #if defined(OS_CHROMEOS) #include "chromeos/dbus/dbus_thread_manager.h" -#include "content/shell/shell_stacking_client_ash.h" +#include "content/shell/minimal_ash.h" #include "ui/aura/test/test_screen.h" -#else -#include "ui/views/widget/desktop_aura/desktop_stacking_client.h" #endif // ViewDelegate implementation for aura content shell @@ -274,7 +272,9 @@ using views::ShellWindowDelegateView; namespace content { -aura::client::StackingClient* Shell::stacking_client_ = NULL; +#if defined(OS_CHROMEOS) +MinimalAsh* Shell::minimal_ash_ = NULL; +#endif views::ViewsDelegate* Shell::views_delegate_ = NULL; // static @@ -283,21 +283,21 @@ void Shell::PlatformInitialize() { chromeos::DBusThreadManager::Initialize(); #endif #if defined(OS_CHROMEOS) - stacking_client_ = new content::ShellStackingClientAsh(); gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, new aura::TestScreen); + minimal_ash_ = new content::MinimalAsh(); #else - stacking_client_ = new views::DesktopStackingClient(); gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); #endif - aura::client::SetStackingClient(stacking_client_); views_delegate_ = new ShellViewsDelegateAura(); } void Shell::PlatformExit() { - if (stacking_client_) - delete stacking_client_; +#if defined(OS_CHROMEOS) + if (minimal_ash_) + delete minimal_ash_; +#endif if (views_delegate_) delete views_delegate_; #if defined(OS_CHROMEOS) @@ -334,9 +334,18 @@ void Shell::PlatformSetIsLoading(bool loading) { } void Shell::PlatformCreateWindow(int width, int height) { +#if defined(OS_CHROMEOS) + window_widget_ = + views::Widget::CreateWindowWithContextAndBounds( + new ShellWindowDelegateView(this), + minimal_ash_->GetDefaultParent(NULL, NULL, gfx::Rect()), + gfx::Rect(0, 0, width, height)); +#else window_widget_ = views::Widget::CreateWindowWithBounds(new ShellWindowDelegateView(this), gfx::Rect(0, 0, width, height)); +#endif + window_ = window_widget_->GetNativeWindow(); window_widget_->Show(); } diff --git a/content/shell/shell_stacking_client_ash.cc b/content/shell/shell_stacking_client_ash.cc deleted file mode 100644 index f9e7c0a..0000000 --- a/content/shell/shell_stacking_client_ash.cc +++ /dev/null @@ -1,56 +0,0 @@ -// 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 "content/shell/shell_stacking_client_ash.h" - -#include "ui/aura/client/default_capture_client.h" -#include "ui/aura/focus_manager.h" -#include "ui/aura/root_window.h" -#include "ui/aura/test/test_activation_client.h" -#include "ui/views/corewm/compound_event_filter.h" -#include "ui/views/corewm/input_method_event_filter.h" - -namespace content { - -ShellStackingClientAsh::ShellStackingClientAsh() { -} - -ShellStackingClientAsh::~ShellStackingClientAsh() { - if (root_window_.get()) - root_window_event_filter_->RemoveHandler(input_method_filter_.get()); - - aura::client::SetStackingClient(NULL); -} - -aura::Window* ShellStackingClientAsh::GetDefaultParent( - aura::Window* context, - aura::Window* window, - const gfx::Rect& bounds) { - if (!root_window_.get()) { - root_window_.reset(new aura::RootWindow( - aura::RootWindow::CreateParams(gfx::Rect(100, 100)))); - root_window_->Init(); - focus_client_.reset(new aura::FocusManager); - aura::client::SetFocusClient(root_window_.get(), focus_client_.get()); - - root_window_event_filter_ = new views::corewm::CompoundEventFilter; - // Pass ownership of the filter to the root_window. - root_window_->SetEventFilter(root_window_event_filter_); - - input_method_filter_.reset(new views::corewm::InputMethodEventFilter( - root_window_->GetAcceleratedWidget())); - input_method_filter_->SetInputMethodPropertyInRootWindow( - root_window_.get()); - root_window_event_filter_->AddHandler(input_method_filter_.get()); - - test_activation_client_.reset( - new aura::test::TestActivationClient(root_window_.get())); - - capture_client_.reset( - new aura::client::DefaultCaptureClient(root_window_.get())); - } - return root_window_.get(); -} - -} // namespace content |