summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandresantoso@chromium.org <andresantoso@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 23:40:11 +0000
committerandresantoso@chromium.org <andresantoso@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-21 23:40:11 +0000
commit10a26c70abb70bc7642bad8f0b48432f38aee219 (patch)
tree470113eeccf071ca346cf2266d08b076092dd560
parent3d0522edd49bff8f404db1490985e74c388e0a12 (diff)
downloadchromium_src-10a26c70abb70bc7642bad8f0b48432f38aee219.zip
chromium_src-10a26c70abb70bc7642bad8f0b48432f38aee219.tar.gz
chromium_src-10a26c70abb70bc7642bad8f0b48432f38aee219.tar.bz2
Refactor menu dependency on aura/wm SetShadowType
We want to run menus without aura for the mac port of views. Add the abstract function widget::SetHasActivationShadow so that SetShadowType invocations can be changed to no longer depend directly on aura/wm. BUG=366007 Review URL: https://codereview.chromium.org/290553002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272016 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/controls/menu/menu_host.cc7
-rw-r--r--ui/views/touchui/touch_selection_controller_impl.cc4
-rw-r--r--ui/views/widget/native_widget_aura.cc5
-rw-r--r--ui/views/widget/widget.cc4
-rw-r--r--ui/views/widget/widget.h11
-rw-r--r--ui/views/widget/widget_hwnd_utils.cc2
-rw-r--r--ui/views/window/dialog_delegate.cc5
7 files changed, 24 insertions, 14 deletions
diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc
index 15ed811..ad7915a 100644
--- a/ui/views/controls/menu/menu_host.cc
+++ b/ui/views/controls/menu/menu_host.cc
@@ -17,7 +17,6 @@
#include "ui/views/round_rect_painter.h"
#include "ui/views/widget/native_widget_private.h"
#include "ui/views/widget/widget.h"
-#include "ui/wm/core/shadow_types.h"
namespace views {
@@ -46,7 +45,8 @@ void MenuHost::InitMenuHost(Widget* parent,
bool rounded_border = menu_controller && menu_config.corner_radius > 0;
bool bubble_border = submenu_->GetScrollViewContainer() &&
submenu_->GetScrollViewContainer()->HasBubbleBorder();
- params.has_dropshadow = !bubble_border;
+ params.shadow_type = bubble_border ? Widget::InitParams::SHADOW_TYPE_NONE
+ : Widget::InitParams::SHADOW_TYPE_DROP;
params.opacity = (bubble_border || rounded_border) ?
Widget::InitParams::TRANSLUCENT_WINDOW :
Widget::InitParams::OPAQUE_WINDOW;
@@ -54,9 +54,6 @@ void MenuHost::InitMenuHost(Widget* parent,
params.bounds = bounds;
Init(params);
- if (bubble_border)
- SetShadowType(GetNativeView(), wm::SHADOW_TYPE_NONE);
-
SetContentsView(contents_view);
if (bubble_border || rounded_border)
SetOpacity(0);
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc
index 1c4af74..3e005a6 100644
--- a/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -9,6 +9,7 @@
#include "grit/ui_strings.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
+#include "ui/aura/window.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image.h"
@@ -18,7 +19,6 @@
#include "ui/gfx/size.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/masked_window_targeter.h"
-#include "ui/wm/core/shadow_types.h"
#include "ui/wm/core/window_animations.h"
namespace {
@@ -75,11 +75,11 @@ views::Widget* CreateTouchSelectionPopupWidget(
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
+ params.shadow_type = views::Widget::InitParams::SHADOW_TYPE_NONE;
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.parent = context;
params.delegate = widget_delegate;
widget->Init(params);
- SetShadowType(widget->GetNativeView(), wm::SHADOW_TYPE_NONE);
return widget;
}
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index 84464b0..0f81fe1 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -36,6 +36,7 @@
#include "ui/views/widget/widget_aura_utils.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/window_reorderer.h"
+#include "ui/wm/core/shadow_types.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
#include "ui/wm/public/drag_drop_client.h"
@@ -108,6 +109,10 @@ void NativeWidgetAura::InitNativeWidget(const Widget::InitParams& params) {
window_->SetTransparent(
params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW);
window_->Init(params.layer_type);
+ if (params.shadow_type == Widget::InitParams::SHADOW_TYPE_NONE)
+ SetShadowType(window_, wm::SHADOW_TYPE_NONE);
+ else if (params.shadow_type == Widget::InitParams::SHADOW_TYPE_DROP)
+ SetShadowType(window_, wm::SHADOW_TYPE_RECTANGULAR);
if (params.type == Widget::InitParams::TYPE_CONTROL)
window_->Show();
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 045845d..a03bae6 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -110,7 +110,7 @@ Widget::InitParams::InitParams()
visible_on_all_workspaces(false),
ownership(NATIVE_WIDGET_OWNS_WIDGET),
mirror_origin_in_rtl(false),
- has_dropshadow(false),
+ shadow_type(SHADOW_TYPE_DEFAULT),
remove_standard_frame(false),
use_system_default_icon(false),
show_state(ui::SHOW_STATE_DEFAULT),
@@ -135,7 +135,7 @@ Widget::InitParams::InitParams(Type type)
visible_on_all_workspaces(false),
ownership(NATIVE_WIDGET_OWNS_WIDGET),
mirror_origin_in_rtl(false),
- has_dropshadow(false),
+ shadow_type(SHADOW_TYPE_DEFAULT),
remove_standard_frame(false),
use_system_default_icon(false),
show_state(ui::SHOW_STATE_DEFAULT),
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index 53912ca..6bdf589 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -180,6 +180,15 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
WIDGET_OWNS_NATIVE_WIDGET
};
+ enum ShadowType {
+ SHADOW_TYPE_DEFAULT, // Use default shadow setting. It will be one of
+ // the settings below depending on InitParams::type
+ // and the native widget's type.
+ SHADOW_TYPE_NONE, // Don't draw any shadow.
+ SHADOW_TYPE_DROP, // Draw a drop shadow that emphasizes Z-order
+ // relationship to other windows.
+ };
+
InitParams();
explicit InitParams(Type type);
~InitParams();
@@ -200,7 +209,7 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
bool visible_on_all_workspaces;
Ownership ownership;
bool mirror_origin_in_rtl;
- bool has_dropshadow;
+ ShadowType shadow_type;
// Specifies that the system default caption and icon should not be
// rendered, and that the client area should be equivalent to the window
// area. Only used on some platforms (Windows and Linux).
diff --git a/ui/views/widget/widget_hwnd_utils.cc b/ui/views/widget/widget_hwnd_utils.cc
index 30e4108..ac313bb 100644
--- a/ui/views/widget/widget_hwnd_utils.cc
+++ b/ui/views/widget/widget_hwnd_utils.cc
@@ -66,7 +66,7 @@ void CalculateWindowStylesFromInitParams(
if (ui::win::IsAeroGlassEnabled())
*ex_style |= WS_EX_COMPOSITED;
}
- if (params.has_dropshadow) {
+ if (params.shadow_type == Widget::InitParams::SHADOW_TYPE_DROP) {
*class_style |= (base::win::GetVersion() < base::win::VERSION_XP) ?
0 : CS_DROPSHADOW;
}
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index c5dcbe7..775b824 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -13,7 +13,6 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"
#include "ui/views/window/dialog_client_view.h"
-#include "ui/wm/core/shadow_types.h"
namespace views {
@@ -37,6 +36,8 @@ 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);
return widget;
}
@@ -162,8 +163,6 @@ NonClientFrameView* DialogDelegate::CreateDialogFrameView(Widget* widget) {
if (titlebar_view)
frame->SetTitlebarExtraView(titlebar_view);
}
- // TODO(msw): Add a matching shadow type and remove the bubble frame border?
- wm::SetShadowType(widget->GetNativeWindow(), wm::SHADOW_TYPE_NONE);
return frame;
}