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

Unified Diff: ui/message_center/views/message_center_view.cc

Issue 2696523002: Stop notifications from being clipped on resize. (Closed)
Patch Set: Add additional comments. Created 3 years, 10 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/message_center/views/message_center_view.cc
diff --git a/ui/message_center/views/message_center_view.cc b/ui/message_center/views/message_center_view.cc
index 60cce9d757bab5c6d3eff133f9273ee054356836..478bbeebd1c649852823d1495d69c573e65d396a 100644
--- a/ui/message_center/views/message_center_view.cc
+++ b/ui/message_center/views/message_center_view.cc
@@ -366,25 +366,30 @@ void MessageCenterView::OnNotificationRemoved(const std::string& id,
Update(true /* animate */);
}
-void MessageCenterView::OnNotificationUpdated(const std::string& id) {
- NotificationViewsMap::const_iterator view_iter = notification_views_.find(id);
- if (view_iter == notification_views_.end())
- return;
-
+// This is a separate function so we can override it in tests.
+bool MessageCenterView::SetRepositionTarget() {
// Set the item on the mouse cursor as the reposition target so that it
// should stick to the current position over the update.
- bool set = false;
if (message_list_view_->IsMouseHovered()) {
for (const auto& hover_id_view : notification_views_) {
MessageView* hover_view = hover_id_view.second;
if (hover_view->IsMouseHovered()) {
message_list_view_->SetRepositionTarget(hover_view->bounds());
- set = true;
- break;
+ return true;
}
}
}
- if (!set)
+ return false;
+}
+
+void MessageCenterView::OnNotificationUpdated(const std::string& id) {
+ NotificationViewsMap::const_iterator view_iter = notification_views_.find(id);
+ if (view_iter == notification_views_.end())
+ return;
+
+ // If there is no reposition target anymore, make sure to reset the reposition
+ // session.
+ if (!SetRepositionTarget())
message_list_view_->ResetRepositionSession();
// TODO(dimich): add MessageCenter::GetVisibleNotificationById(id)
« no previous file with comments | « ui/message_center/views/message_center_view.h ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698