diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 19:56:31 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-22 19:56:31 +0000 |
commit | f7e5d9012346f6dd1ce5a4e009b66977d1c69e36 (patch) | |
tree | d651bd3eae2504693fdc1bc54638733df1571f14 | |
parent | 3c69bfdd60bb1c06c2a0508937e8c97727f7ccd3 (diff) | |
download | chromium_src-f7e5d9012346f6dd1ce5a4e009b66977d1c69e36.zip chromium_src-f7e5d9012346f6dd1ce5a4e009b66977d1c69e36.tar.gz chromium_src-f7e5d9012346f6dd1ce5a4e009b66977d1c69e36.tar.bz2 |
Removes unnecessary views::Widget::InitParams::top_level
BUG=353533
TEST=None
R=sky
TBR=benwells (For trivial change to apps/ui/views/native_app_window_views.cc)
Review URL: https://codereview.chromium.org/282133005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272287 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | apps/ui/views/native_app_window_views.cc | 1 | ||||
-rw-r--r-- | ash/shell/content_client/shell_browser_main_parts.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/apps/chrome_native_app_window_views.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/views/chrome_views_delegate.cc | 24 | ||||
-rw-r--r-- | chrome/browser/ui/views/chrome_views_delegate_aura.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/message_center/message_center_widget_delegate.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/screen_capture_notification_ui_views.cc | 1 | ||||
-rw-r--r-- | content/shell/browser/shell_views.cc | 1 | ||||
-rw-r--r-- | ui/app_list/views/app_list_view_unittest.cc | 2 | ||||
-rw-r--r-- | ui/message_center/views/toast_contents_view.cc | 2 | ||||
-rw-r--r-- | ui/views/accessibility/native_view_accessibility_win_unittest.cc | 1 | ||||
-rw-r--r-- | ui/views/examples/examples_window.cc | 1 | ||||
-rw-r--r-- | ui/views/widget/native_widget_unittest.cc | 1 | ||||
-rw-r--r-- | ui/views/widget/widget.cc | 12 | ||||
-rw-r--r-- | ui/views/widget/widget.h | 4 | ||||
-rw-r--r-- | ui/views/widget/widget_unittest.cc | 40 | ||||
-rw-r--r-- | ui/views/window/dialog_delegate.cc | 1 |
17 files changed, 19 insertions, 83 deletions
diff --git a/apps/ui/views/native_app_window_views.cc b/apps/ui/views/native_app_window_views.cc index 08fd92b..62b941d 100644 --- a/apps/ui/views/native_app_window_views.cc +++ b/apps/ui/views/native_app_window_views.cc @@ -59,7 +59,6 @@ void NativeAppWindowViews::InitializeWindow( // Stub implementation. See also ChromeNativeAppWindowViews. views::Widget::InitParams init_params(views::Widget::InitParams::TYPE_WINDOW); init_params.delegate = this; - init_params.top_level = true; init_params.keep_on_top = create_params.always_on_top; widget_->Init(init_params); widget_->CenterWindow( diff --git a/ash/shell/content_client/shell_browser_main_parts.cc b/ash/shell/content_client/shell_browser_main_parts.cc index 8c2a37a..8accc93 100644 --- a/ash/shell/content_client/shell_browser_main_parts.cc +++ b/ash/shell/content_client/shell_browser_main_parts.cc @@ -67,7 +67,7 @@ class ShellViewsDelegate : public views::TestViewsDelegate { if (params->native_widget) return; - if (!params->parent && !params->context && params->top_level) + if (!params->parent && !params->context && !params->child) params->context = Shell::GetPrimaryRootWindow(); } diff --git a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc index c2e202b..1d9dfa4 100644 --- a/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/chrome_native_app_window_views.cc @@ -212,9 +212,6 @@ void ChromeNativeAppWindowViews::InitializeDefaultWindow( init_params.delegate = this; init_params.remove_standard_frame = IsFrameless() || has_frame_color_; init_params.use_system_default_icon = true; - // TODO(erg): Conceptually, these are toplevel windows, but we theoretically - // could plumb context through to here in some cases. - init_params.top_level = true; if (create_params.transparent_background) init_params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; init_params.keep_on_top = create_params.always_on_top; @@ -317,9 +314,6 @@ void ChromeNativeAppWindowViews::InitializePanelWindow( #else params.bounds = gfx::Rect(preferred_size_); #endif - // TODO(erg): Conceptually, these are toplevel windows, but we theoretically - // could plumb context through to here in some cases. - params.top_level = true; widget()->Init(params); widget()->set_focus_on_creation(create_params.focused); diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 591a485..dbd8771 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -268,15 +268,14 @@ void ChromeViewsDelegate::OnBeforeWidgetInit( // On desktop Linux Chrome must run in an environment that supports a variety // of window managers, some of which do not play nicely with parts of our UI // that have specific expectations about window sizing and placement. For this - // reason windows opened as top level (params.top_level) are always - // constrained by the browser frame, so we can position them correctly. This - // has some negative side effects, like dialogs being clipped by the browser - // frame, but the side effects are not as bad as the poor window manager - // interactions. On Windows however these WM interactions are not an issue, so - // we open windows requested as top_level as actual top level windows on the - // desktop. + // reason windows opened as top level (!params.child) are always constrained + // by the browser frame, so we can position them correctly. This has some + // negative side effects, like dialogs being clipped by the browser frame, but + // the side effects are not as bad as the poor window manager interactions. On + // Windows however these WM interactions are not an issue, so we open windows + // requested as top_level as actual top level windows on the desktop. use_non_toplevel_window = use_non_toplevel_window && - (!params->top_level || + (params->child || chrome::GetHostDesktopTypeForNativeView(params->parent) != chrome::HOST_DESKTOP_TYPE_NATIVE); @@ -314,15 +313,18 @@ void ChromeViewsDelegate::OnBeforeWidgetInit( // context. if (params->context) params->context = params->context->GetRootWindow(); - DCHECK(params->parent || params->context || params->top_level) + DCHECK(params->parent || params->context || !params->child) << "Please provide a parent or context for this widget."; if (!params->parent && !params->context) params->context = ash::Shell::GetPrimaryRootWindow(); #elif defined(USE_AURA) // While the majority of the time, context wasn't plumbed through due to the - // existence of a global WindowTreeClient, if this window is a toplevel, it's + // existence of a global WindowTreeClient, if this window is toplevel, it's // possible that there is no contextual state that we can use. - if (params->parent == NULL && params->context == NULL && params->top_level) { + if (params->parent == NULL && + params->context == NULL && + !params->child && + params->type != views::Widget::InitParams::TYPE_TOOLTIP) { // We need to make a decision about where to place this window based on the // desktop type. switch (chrome::GetActiveDesktop()) { diff --git a/chrome/browser/ui/views/chrome_views_delegate_aura.cc b/chrome/browser/ui/views/chrome_views_delegate_aura.cc index c9d7081..0fee65e 100644 --- a/chrome/browser/ui/views/chrome_views_delegate_aura.cc +++ b/chrome/browser/ui/views/chrome_views_delegate_aura.cc @@ -16,7 +16,7 @@ ChromeViewsDelegate::GetOpacityForInitParams( #endif // We want translucent windows when either we are in ASH or we are // a top level window which is not of type TYPE_WINDOW. - if (params.top_level && params.type != views::Widget::InitParams::TYPE_WINDOW) + if (!params.child && params.type != views::Widget::InitParams::TYPE_WINDOW) return views::Widget::InitParams::TRANSLUCENT_WINDOW; return views::Widget::InitParams::OPAQUE_WINDOW; diff --git a/chrome/browser/ui/views/message_center/message_center_widget_delegate.cc b/chrome/browser/ui/views/message_center/message_center_widget_delegate.cc index 82dbf634..666eff95 100644 --- a/chrome/browser/ui/views/message_center/message_center_widget_delegate.cc +++ b/chrome/browser/ui/views/message_center/message_center_widget_delegate.cc @@ -142,7 +142,6 @@ void MessageCenterWidgetDelegate::InitWidget() { params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.delegate = this; params.keep_on_top = true; - params.top_level = true; #if defined(USE_ASH) // This class is not used in Ash; there is another container for the message // center that's used there. So, we must be in a Views + Ash environment. We diff --git a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc index 7df47f4..61e3356 100644 --- a/chrome/browser/ui/views/screen_capture_notification_ui_views.cc +++ b/chrome/browser/ui/views/screen_capture_notification_ui_views.cc @@ -176,7 +176,6 @@ gfx::NativeViewId ScreenCaptureNotificationUIViews::OnStarted( params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.remove_standard_frame = true; params.keep_on_top = true; - params.top_level = true; #if defined(USE_ASH) // TODO(sergeyu): The notification bar must be shown on the monitor that's diff --git a/content/shell/browser/shell_views.cc b/content/shell/browser/shell_views.cc index 4259536..fcc98d7 100644 --- a/content/shell/browser/shell_views.cc +++ b/content/shell/browser/shell_views.cc @@ -496,7 +496,6 @@ void Shell::PlatformCreateWindow(int width, int height) { views::Widget::InitParams params; params.bounds = gfx::Rect(0, 0, width, height); params.delegate = new ShellWindowDelegateView(this); - params.top_level = true; params.remove_standard_frame = true; window_widget_->Init(params); #endif diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc index 62ec3f2..dd72e0b 100644 --- a/ui/app_list/views/app_list_view_unittest.cc +++ b/ui/app_list/views/app_list_view_unittest.cc @@ -227,7 +227,7 @@ void AppListViewTestDesktop::AppListViewTestViewsDelegate::OnBeforeWidgetInit( if (!params->parent && !params->context) params->context = parent_->GetContext(); #elif defined(USE_AURA) - if (params->parent == NULL && params->context == NULL && params->top_level) + if (params->parent == NULL && params->context == NULL && !params->child) params->native_widget = new views::DesktopNativeWidgetAura(delegate); #endif } diff --git a/ui/message_center/views/toast_contents_view.cc b/ui/message_center/views/toast_contents_view.cc index e9ca48e..677405a 100644 --- a/ui/message_center/views/toast_contents_view.cc +++ b/ui/message_center/views/toast_contents_view.cc @@ -334,8 +334,6 @@ void ToastContentsView::CreateWidget(gfx::NativeView parent) { params.keep_on_top = true; if (parent) params.parent = parent; - else - params.top_level = true; params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; params.delegate = this; views::Widget* widget = new views::Widget(); diff --git a/ui/views/accessibility/native_view_accessibility_win_unittest.cc b/ui/views/accessibility/native_view_accessibility_win_unittest.cc index fed7b7f..3edab8e 100644 --- a/ui/views/accessibility/native_view_accessibility_win_unittest.cc +++ b/ui/views/accessibility/native_view_accessibility_win_unittest.cc @@ -128,7 +128,6 @@ TEST_F(NativeViewAcccessibilityWinTest, AuraOwnedWidgets) { Widget::InitParams owned_init_params = CreateParams(Widget::InitParams::TYPE_POPUP); owned_init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - owned_init_params.child = false; owned_init_params.parent = widget.GetNativeView(); owned_widget.Init(owned_init_params); owned_widget.Show(); diff --git a/ui/views/examples/examples_window.cc b/ui/views/examples/examples_window.cc index f22ebf9..8372669 100644 --- a/ui/views/examples/examples_window.cc +++ b/ui/views/examples/examples_window.cc @@ -220,7 +220,6 @@ void ShowExamplesWindow(Operation operation, params.delegate = new ExamplesWindowContents(operation, examples.Pass()); params.context = window_context; params.bounds = gfx::Rect(0, 0, 850, 300); - params.top_level = true; params.remove_standard_frame = true; widget->Init(params); widget->Show(); diff --git a/ui/views/widget/native_widget_unittest.cc b/ui/views/widget/native_widget_unittest.cc index 133f8be0..9002e9d 100644 --- a/ui/views/widget/native_widget_unittest.cc +++ b/ui/views/widget/native_widget_unittest.cc @@ -42,7 +42,6 @@ class NativeWidgetTest : public ViewsTestBase { Widget* widget = new Widget; Widget::InitParams params = CreateParams(type); params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; - params.child = false; // Implicitly set to true by ctor with TYPE_CONTROL. params.bounds = gfx::Rect(10, 10, 200, 200); widget->Init(params); return widget->native_widget_private(); diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc index a03bae6..b2ce42f 100644 --- a/ui/views/widget/widget.cc +++ b/ui/views/widget/widget.cc @@ -118,7 +118,6 @@ Widget::InitParams::InitParams() parent(NULL), native_widget(NULL), desktop_window_tree_host(NULL), - top_level(false), layer_type(aura::WINDOW_LAYER_TEXTURED), context(NULL), force_show_in_taskbar(false) { @@ -127,7 +126,7 @@ Widget::InitParams::InitParams() Widget::InitParams::InitParams(Type type) : type(type), delegate(NULL), - child(type == TYPE_CONTROL), + child(false), opacity(INFER_OPACITY), accept_events(true), activatable(ACTIVATABLE_DEFAULT), @@ -143,7 +142,6 @@ Widget::InitParams::InitParams(Type type) parent(NULL), native_widget(NULL), desktop_window_tree_host(NULL), - top_level(false), layer_type(aura::WINDOW_LAYER_TEXTURED), context(NULL), force_show_in_taskbar(false) { @@ -202,7 +200,6 @@ Widget* Widget::CreateWindowWithBounds(WidgetDelegate* delegate, Widget::InitParams params; params.bounds = bounds; params.delegate = delegate; - params.top_level = true; widget->Init(params); return widget; } @@ -332,11 +329,8 @@ void Widget::Init(const InitParams& in_params) { TRACE_EVENT0("views", "Widget::Init"); InitParams params = in_params; - is_top_level_ = params.top_level || - (!params.child && - params.type != InitParams::TYPE_CONTROL && - params.type != InitParams::TYPE_TOOLTIP); - params.top_level = is_top_level_; + params.child |= (params.type == InitParams::TYPE_CONTROL); + is_top_level_ = (!params.child && params.type != InitParams::TYPE_TOOLTIP); if (params.opacity == views::Widget::InitParams::INFER_OPACITY && params.type != views::Widget::InitParams::TYPE_WINDOW && diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h index 6bdf589..17e1247 100644 --- a/ui/views/widget/widget.h +++ b/ui/views/widget/widget.h @@ -235,10 +235,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // TODO(beng): Figure out if there's a better way to expose this, e.g. get // rid of NW subclasses and do this all via message handling. DesktopWindowTreeHost* desktop_window_tree_host; - // Whether this window is intended to be a toplevel window with no - // attachment to any other window. (This may be a transient window if - // |parent| is set.) - bool top_level; // Only used by NativeWidgetAura. Specifies the type of layer for the // aura::Window. Default is WINDOW_LAYER_TEXTURED. aura::WindowLayerType layer_type; diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc index eb25225..3591781 100644 --- a/ui/views/widget/widget_unittest.cc +++ b/ui/views/widget/widget_unittest.cc @@ -1683,46 +1683,6 @@ TEST_F(WidgetWindowTitleTest, SetWindowTitleChanged_DesktopNativeWidget) { } #endif // !OS_CHROMEOS -// Used by SetTopLevelCorrectly to track calls to OnBeforeWidgetInit(). -class VerifyTopLevelDelegate : public TestViewsDelegate { - public: - VerifyTopLevelDelegate() - : on_before_init_called_(false), - is_top_level_(false) { - } - - bool on_before_init_called() const { return on_before_init_called_; } - bool is_top_level() const { return is_top_level_; } - - virtual void OnBeforeWidgetInit( - Widget::InitParams* params, - internal::NativeWidgetDelegate* delegate) OVERRIDE { - on_before_init_called_ = true; - is_top_level_ = params->top_level; - } - - private: - bool on_before_init_called_; - bool is_top_level_; - - DISALLOW_COPY_AND_ASSIGN(VerifyTopLevelDelegate); -}; - -// Verifies |top_level| is correctly passed to -// ViewsDelegate::OnBeforeWidgetInit(). -TEST_F(WidgetTest, SetTopLevelCorrectly) { - set_views_delegate(NULL); - VerifyTopLevelDelegate* delegate = new VerifyTopLevelDelegate; - set_views_delegate(delegate); // ViewsTestBase takes ownership. - scoped_ptr<Widget> widget(new Widget); - Widget::InitParams params = - CreateParams(views::Widget::InitParams::TYPE_POPUP); - params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - widget->Init(params); - EXPECT_TRUE(delegate->on_before_init_called()); - EXPECT_TRUE(delegate->is_top_level()); -} - TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) { Widget* widget = new Widget; Widget::InitParams params = diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc index 775b824..aabfa6d 100644 --- a/ui/views/window/dialog_delegate.cc +++ b/ui/views/window/dialog_delegate.cc @@ -35,7 +35,6 @@ Widget* DialogDelegate::CreateDialogWidget(DialogDelegate* dialog, } params.context = context; params.parent = parent; - params.top_level = true; // TODO(msw): Add a matching shadow type and remove the bubble frame border? params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE; widget->Init(params); |