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

Unified Diff: ui/views/widget/widget.cc

Issue 293833002: Fix Widget::InitParams::activatable logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index d1f92e7f8a5911b6f7cd3e3e24bc6ac093567a57..e53d0af3bffd892fed2602c103e8ba67b9e3e5fe 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -69,9 +69,7 @@ NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
// WidgetDelegate is supplied.
class DefaultWidgetDelegate : public WidgetDelegate {
public:
- DefaultWidgetDelegate(Widget* widget, bool can_activate)
- : widget_(widget),
- can_activate_(can_activate) {
+ explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {
}
virtual ~DefaultWidgetDelegate() {}
@@ -85,9 +83,6 @@ class DefaultWidgetDelegate : public WidgetDelegate {
virtual const Widget* GetWidget() const OVERRIDE {
return widget_;
}
- virtual bool CanActivate() const OVERRIDE {
- return can_activate_;
- }
virtual bool ShouldAdvanceFocusToTopLevelWidget() const OVERRIDE {
// In most situations where a Widget is used without a delegate the Widget
// is used as a container, so that we want focus to advance to the top-level
@@ -97,7 +92,6 @@ class DefaultWidgetDelegate : public WidgetDelegate {
private:
Widget* widget_;
- bool can_activate_;
DISALLOW_COPY_AND_ASSIGN(DefaultWidgetDelegate);
};
@@ -344,20 +338,6 @@ void Widget::Init(const InitParams& in_params) {
params.type != InitParams::TYPE_TOOLTIP);
params.top_level = is_top_level_;
- if (params.activatable != InitParams::ACTIVATABLE_DEFAULT) {
- can_activate_ = (params.activatable == InitParams::ACTIVATABLE_YES);
- } else if (params.type != InitParams::TYPE_CONTROL &&
- params.type != InitParams::TYPE_POPUP &&
- params.type != InitParams::TYPE_MENU &&
- params.type != InitParams::TYPE_TOOLTIP &&
- params.type != InitParams::TYPE_DRAG) {
- can_activate_ = true;
- params.activatable = InitParams::ACTIVATABLE_YES;
- } else {
- can_activate_ = false;
- params.activatable = InitParams::ACTIVATABLE_NO;
- }
-
if (params.opacity == views::Widget::InitParams::INFER_OPACITY &&
params.type != views::Widget::InitParams::TYPE_WINDOW &&
params.type != views::Widget::InitParams::TYPE_PANEL)
@@ -369,8 +349,25 @@ void Widget::Init(const InitParams& in_params) {
if (params.opacity == views::Widget::InitParams::INFER_OPACITY)
params.opacity = views::Widget::InitParams::OPAQUE_WINDOW;
+ bool can_activate = false;
+ if (params.activatable != InitParams::ACTIVATABLE_DEFAULT) {
+ can_activate = (params.activatable == InitParams::ACTIVATABLE_YES);
+ } else if (params.type != InitParams::TYPE_CONTROL &&
+ params.type != InitParams::TYPE_POPUP &&
+ params.type != InitParams::TYPE_MENU &&
+ params.type != InitParams::TYPE_TOOLTIP &&
+ params.type != InitParams::TYPE_DRAG) {
+ can_activate = true;
+ params.activatable = InitParams::ACTIVATABLE_YES;
+ } else {
+ can_activate = false;
+ params.activatable = InitParams::ACTIVATABLE_NO;
+ }
+
widget_delegate_ = params.delegate ?
- params.delegate : new DefaultWidgetDelegate(this, can_activate_);
+ params.delegate : new DefaultWidgetDelegate(this);
+ widget_delegate_->set_default_can_activate(can_activate);
+
ownership_ = params.ownership;
native_widget_ = CreateNativeWidget(params.native_widget, this)->
AsNativeWidgetPrivate();
@@ -1019,7 +1016,7 @@ bool Widget::IsDialogBox() const {
}
bool Widget::CanActivate() const {
- return can_activate_ && widget_delegate_->CanActivate();
+ return widget_delegate_->CanActivate();
}
bool Widget::IsInactiveRenderingDisabled() const {

Powered by Google App Engine
This is Rietveld 408576698