diff options
Diffstat (limited to 'chromium/ui/message_center/views')
6 files changed, 25 insertions, 40 deletions
diff --git a/chromium/ui/message_center/views/bounded_label.cc b/chromium/ui/message_center/views/bounded_label.cc index e9b0f65efd4..5bf6f151eec 100644 --- a/chromium/ui/message_center/views/bounded_label.cc +++ b/chromium/ui/message_center/views/bounded_label.cc @@ -44,7 +44,7 @@ class InnerBoundedLabel : public views::Label { std::vector<base::string16> GetWrappedText(int width, int lines); // Overridden from views::Label. - void SetText(const base::string16& text) override; + void SetText(const base::string16& new_text) override; void OnPaint(gfx::Canvas* canvas) override; protected: @@ -187,8 +187,10 @@ void InnerBoundedLabel::OnPaint(gfx::Canvas* canvas) { } } -void InnerBoundedLabel::SetText(const base::string16& text) { - views::Label::SetText(text); +void InnerBoundedLabel::SetText(const base::string16& new_text) { + if (text() == new_text) + return; + views::Label::SetText(new_text); ClearCaches(); } diff --git a/chromium/ui/message_center/views/bounded_label_unittest.cc b/chromium/ui/message_center/views/bounded_label_unittest.cc index 9744aee6df8..7c3a6a6bf1f 100644 --- a/chromium/ui/message_center/views/bounded_label_unittest.cc +++ b/chromium/ui/message_center/views/bounded_label_unittest.cc @@ -38,7 +38,7 @@ class BoundedLabelTest : public testing::Test { const char kPeriods[] = "..."; const char kEllipses[] = "\xE2\x80\xA6"; std::string result = string; - ReplaceSubstringsAfterOffset(&result, 0, kPeriods, kEllipses); + base::ReplaceSubstringsAfterOffset(&result, 0, kPeriods, kEllipses); return base::UTF8ToUTF16(result); } diff --git a/chromium/ui/message_center/views/message_list_view.cc b/chromium/ui/message_center/views/message_list_view.cc index 5148a2a0608..8c1ef3fc056 100644 --- a/chromium/ui/message_center/views/message_list_view.cc +++ b/chromium/ui/message_center/views/message_list_view.cc @@ -55,7 +55,7 @@ MessageListView::~MessageListView() { } void MessageListView::Layout() { - if (animator_.get()) + if (animator_.get() && animator_->IsAnimating()) return; gfx::Rect child_area = GetContentsBounds(); diff --git a/chromium/ui/message_center/views/message_popup_collection.cc b/chromium/ui/message_center/views/message_popup_collection.cc index 3f0bc2ae7e3..a021eb740da 100644 --- a/chromium/ui/message_center/views/message_popup_collection.cc +++ b/chromium/ui/message_center/views/message_popup_collection.cc @@ -171,8 +171,8 @@ void MessagePopupCollection::UpdateWidgets() { else base -= view_height + kToastMarginY; - if (views::ViewsDelegate::views_delegate) { - views::ViewsDelegate::views_delegate->NotifyAccessibilityEvent( + if (views::ViewsDelegate::GetInstance()) { + views::ViewsDelegate::GetInstance()->NotifyAccessibilityEvent( toast, ui::AX_EVENT_ALERT); } diff --git a/chromium/ui/message_center/views/message_popup_collection_unittest.cc b/chromium/ui/message_center/views/message_popup_collection_unittest.cc index 466181b5725..74934dd59a4 100644 --- a/chromium/ui/message_center/views/message_popup_collection_unittest.cc +++ b/chromium/ui/message_center/views/message_popup_collection_unittest.cc @@ -168,6 +168,8 @@ TEST_F(MessagePopupCollectionTest, ShutdownDuringShowing) { // See crbug.com/236448 GetWidget(id1)->CloseNow(); collection()->OnMouseExited(GetToast(id2)); + + GetWidget(id2)->CloseNow(); } TEST_F(MessagePopupCollectionTest, DefaultPositioning) { @@ -206,6 +208,7 @@ TEST_F(MessagePopupCollectionTest, DefaultPositioning) { CloseAllToasts(); EXPECT_EQ(0u, GetToastCounts()); + WaitForTransitionsDone(); } TEST_F(MessagePopupCollectionTest, DefaultPositioningWithRightTaskbar) { @@ -236,6 +239,8 @@ TEST_F(MessagePopupCollectionTest, DefaultPositioningWithRightTaskbar) { // Restore simulated taskbar position to bottom. SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area. gfx::Rect(0, 0, 600, 400)); // Display-bounds. + + WaitForTransitionsDone(); } TEST_F(MessagePopupCollectionTest, TopDownPositioningWithTopTaskbar) { @@ -260,6 +265,7 @@ TEST_F(MessagePopupCollectionTest, TopDownPositioningWithTopTaskbar) { CloseAllToasts(); EXPECT_EQ(0u, GetToastCounts()); + WaitForTransitionsDone(); // Restore simulated taskbar position to bottom. SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area. @@ -291,6 +297,7 @@ TEST_F(MessagePopupCollectionTest, TopDownPositioningWithLeftAndTopTaskbar) { CloseAllToasts(); EXPECT_EQ(0u, GetToastCounts()); + WaitForTransitionsDone(); // Restore simulated taskbar position to bottom. SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area. @@ -322,6 +329,7 @@ TEST_F(MessagePopupCollectionTest, TopDownPositioningWithBottomAndTopTaskbar) { CloseAllToasts(); EXPECT_EQ(0u, GetToastCounts()); + WaitForTransitionsDone(); // Restore simulated taskbar position to bottom. SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area. @@ -353,6 +361,7 @@ TEST_F(MessagePopupCollectionTest, LeftPositioningWithLeftTaskbar) { CloseAllToasts(); EXPECT_EQ(0u, GetToastCounts()); + WaitForTransitionsDone(); // Restore simulated taskbar position to bottom. SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area. @@ -387,9 +396,9 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHover) { EXPECT_TRUE(MouseInCollection()); toast1->OnMouseEntered(event); EXPECT_TRUE(MouseInCollection()); - toast0->WindowClosing(); + toast0->GetWidget()->CloseNow(); EXPECT_TRUE(MouseInCollection()); - toast1->WindowClosing(); + toast1->GetWidget()->CloseNow(); EXPECT_FALSE(MouseInCollection()); } @@ -417,6 +426,9 @@ TEST_F(MessagePopupCollectionTest, DetectMouseHoverWithUserClose) { WaitForTransitionsDone(); views::WidgetDelegateView* toast2 = GetToast(id2); EXPECT_TRUE(toast2 != NULL); + + CloseAllToasts(); + WaitForTransitionsDone(); } diff --git a/chromium/ui/message_center/views/message_view.cc b/chromium/ui/message_center/views/message_view.cc index ef527a6de40..62e29935c68 100644 --- a/chromium/ui/message_center/views/message_view.cc +++ b/chromium/ui/message_center/views/message_view.cc @@ -10,7 +10,6 @@ #include "ui/base/ui_base_switches_util.h" #include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/gfx/canvas.h" -#include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/shadow_value.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_style.h" @@ -33,31 +32,6 @@ const int kCloseIconRightPadding = 5; const int kShadowOffset = 1; const int kShadowBlur = 4; -const gfx::ImageSkia CreateImage(int width, int height, SkColor color) { - SkBitmap bitmap; - bitmap.allocN32Pixels(width, height); - bitmap.eraseColor(color); - return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); -} - -// Take the alpha channel of small_image, mask it with the foreground, -// then add the masked foreground on top of the background -const gfx::ImageSkia GetMaskedSmallImage(const gfx::ImageSkia& small_image) { - int width = small_image.width(); - int height = small_image.height(); - - // Background color grey - const gfx::ImageSkia background = CreateImage( - width, height, message_center::kSmallImageMaskBackgroundColor); - // Foreground color white - const gfx::ImageSkia foreground = CreateImage( - width, height, message_center::kSmallImageMaskForegroundColor); - const gfx::ImageSkia masked_small_image = - gfx::ImageSkiaOperations::CreateMaskedImage(foreground, small_image); - return gfx::ImageSkiaOperations::CreateSuperimposedImage(background, - masked_small_image); -} - } // namespace namespace message_center { @@ -81,9 +55,8 @@ MessageView::MessageView(MessageViewController* controller, views::Background::CreateSolidBackground(kNotificationBackgroundColor)); AddChildView(background_view_); - const gfx::ImageSkia masked_small_image = GetMaskedSmallImage(small_image); views::ImageView* small_image_view = new views::ImageView(); - small_image_view->SetImage(masked_small_image); + small_image_view->SetImage(small_image); small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); // The small image view should be added to view hierarchy by the derived // class. This ensures that it is on top of other views. @@ -112,9 +85,7 @@ MessageView::~MessageView() { } void MessageView::UpdateWithNotification(const Notification& notification) { - const gfx::ImageSkia masked_small_image = - GetMaskedSmallImage(notification.small_image().AsImageSkia()); - small_image_view_->SetImage(masked_small_image); + small_image_view_->SetImage(notification.small_image().AsImageSkia()); display_source_ = notification.display_source(); } |