summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 20:53:59 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-03-09 20:53:59 +0000
commit970451967309a8ab26faaa370fa54ffccec70e24 (patch)
tree59682eadf710b65237fbc8b01647bcd227371fd8 /ui
parent3f01c469931174046154274c10838f19492efe9d (diff)
downloadchromium_src-970451967309a8ab26faaa370fa54ffccec70e24.zip
chromium_src-970451967309a8ab26faaa370fa54ffccec70e24.tar.gz
chromium_src-970451967309a8ab26faaa370fa54ffccec70e24.tar.bz2
Ash: Correctly initialize transparency flag for windows
Widgets of TYPE_WINDOW have potentially transparent frames on Ash. I was initializing the transparency flag in the wrong place, leading to a subset of dialogs (edit bookmark, app shortcut, restart chrome, etc.) having black pixels at their outside corners and the wrong appearance in the inactive state. Inspection of the Widget::CreateWindow* callers suggests this is the right place to put this. BUG=117411 TEST=visual inspection of bookmark windows Review URL: https://chromiumcodereview.appspot.com/9653011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125894 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/test/test_views_delegate.cc13
-rw-r--r--ui/views/test/test_views_delegate.h6
-rw-r--r--ui/views/views_delegate.h7
-rw-r--r--ui/views/widget/widget.cc7
-rw-r--r--ui/views/widget/widget.h3
-rw-r--r--ui/views/widget/widget_unittest.cc21
6 files changed, 50 insertions, 7 deletions
diff --git a/ui/views/test/test_views_delegate.cc b/ui/views/test/test_views_delegate.cc
index 73eef06..6fa6bb7 100644
--- a/ui/views/test/test_views_delegate.cc
+++ b/ui/views/test/test_views_delegate.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -9,7 +9,8 @@
namespace views {
-TestViewsDelegate::TestViewsDelegate() {
+TestViewsDelegate::TestViewsDelegate()
+ : use_transparent_windows_(false) {
DCHECK(!ViewsDelegate::views_delegate);
ViewsDelegate::views_delegate = this;
}
@@ -18,6 +19,10 @@ TestViewsDelegate::~TestViewsDelegate() {
ViewsDelegate::views_delegate = NULL;
}
+void TestViewsDelegate::SetUseTransparentWindows(bool transparent) {
+ use_transparent_windows_ = transparent;
+}
+
ui::Clipboard* TestViewsDelegate::GetClipboard() const {
if (!clipboard_.get()) {
// Note that we need a MessageLoop for the next call to work.
@@ -44,6 +49,10 @@ NonClientFrameView* TestViewsDelegate::CreateDefaultNonClientFrameView(
return NULL;
}
+bool TestViewsDelegate::UseTransparentWindows() const {
+ return use_transparent_windows_;
+}
+
int TestViewsDelegate::GetDispositionForEvent(int event_flags) {
return 0;
}
diff --git a/ui/views/test/test_views_delegate.h b/ui/views/test/test_views_delegate.h
index 5fa952d..99976a2 100644
--- a/ui/views/test/test_views_delegate.h
+++ b/ui/views/test/test_views_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -25,6 +25,8 @@ class TestViewsDelegate : public ViewsDelegate {
TestViewsDelegate();
virtual ~TestViewsDelegate();
+ void SetUseTransparentWindows(bool transparent);
+
// Overridden from ViewsDelegate:
virtual ui::Clipboard* GetClipboard() const OVERRIDE;
virtual void SaveWindowPlacement(const Widget* window,
@@ -51,6 +53,7 @@ class TestViewsDelegate : public ViewsDelegate {
#endif
virtual NonClientFrameView* CreateDefaultNonClientFrameView(
Widget* widget) OVERRIDE;
+ virtual bool UseTransparentWindows() const OVERRIDE;
virtual void AddRef() OVERRIDE {}
virtual void ReleaseRef() OVERRIDE {}
@@ -58,6 +61,7 @@ class TestViewsDelegate : public ViewsDelegate {
private:
mutable scoped_ptr<ui::Clipboard> clipboard_;
+ bool use_transparent_windows_;
DISALLOW_COPY_AND_ASSIGN(TestViewsDelegate);
};
diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h
index 2544413..af9c665 100644
--- a/ui/views/views_delegate.h
+++ b/ui/views/views_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// 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.
@@ -84,6 +84,11 @@ class VIEWS_EXPORT ViewsDelegate {
virtual NonClientFrameView* CreateDefaultNonClientFrameView(
Widget* widget) = 0;
+ // Returns whether the embedding app wants windows to be created with the
+ // views::Widget marked as transparent. For example, an app may wish to
+ // apply transparent window frames in the NonClientFrameView.
+ virtual bool UseTransparentWindows() const = 0;
+
// AddRef/ReleaseRef are invoked while a menu is visible. They are used to
// ensure we don't attempt to exit while a menu is showing.
virtual void AddRef() = 0;
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 569fd92..33ccda3d 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -113,7 +113,8 @@ Widget::InitParams::InitParams()
delegate(NULL),
child(false),
transient(false),
- transparent(false),
+ transparent(ViewsDelegate::views_delegate &&
+ ViewsDelegate::views_delegate->UseTransparentWindows()),
accept_events(true),
can_activate(true),
keep_on_top(false),
@@ -135,7 +136,9 @@ Widget::InitParams::InitParams(Type type)
delegate(NULL),
child(type == TYPE_CONTROL),
transient(type == TYPE_BUBBLE || type == TYPE_POPUP || type == TYPE_MENU),
- transparent(false),
+ transparent(type == TYPE_WINDOW &&
+ ViewsDelegate::views_delegate &&
+ ViewsDelegate::views_delegate->UseTransparentWindows()),
accept_events(true),
can_activate(
type != TYPE_POPUP && type != TYPE_MENU && type != TYPE_CONTROL),
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index baf7837..a21302b 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -155,7 +155,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
bool transient;
// If true, the widget may be fully or partially transparent. If false,
// we can perform optimizations based on the widget being fully opaque.
- // Defaults to false.
+ // For window widgets, defaults to ViewsDelegate::UseTransparentWindows().
+ // Defaults to false for non-window widgets.
bool transparent;
bool accept_events;
bool can_activate;
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc
index 7be09b0..143c51e 100644
--- a/ui/views/widget/widget_unittest.cc
+++ b/ui/views/widget/widget_unittest.cc
@@ -159,6 +159,27 @@ ui::WindowShowState GetWidgetShowState(const Widget* widget) {
ui::SHOW_STATE_NORMAL;
}
+TEST_F(WidgetTest, WidgetInitParams) {
+ ASSERT_FALSE(views_delegate().UseTransparentWindows());
+
+ // Widgets are not transparent by default.
+ Widget::InitParams init1;
+ EXPECT_FALSE(init1.transparent);
+
+ // Non-window widgets are not transparent either.
+ Widget::InitParams init2(Widget::InitParams::TYPE_MENU);
+ EXPECT_FALSE(init2.transparent);
+
+ // A ViewsDelegate can set windows transparent by default.
+ views_delegate().SetUseTransparentWindows(true);
+ Widget::InitParams init3;
+ EXPECT_TRUE(init3.transparent);
+
+ // Non-window widgets stay opaque.
+ Widget::InitParams init4(Widget::InitParams::TYPE_MENU);
+ EXPECT_FALSE(init4.transparent);
+}
+
////////////////////////////////////////////////////////////////////////////////
// Widget::GetTopLevelWidget tests.