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

Side by Side Diff: chrome/browser/ui/views/notifications/balloon_view_views.cc

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/notifications/balloon_view_views.h" 5 #include "chrome/browser/ui/views/notifications/balloon_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (view) 253 if (view)
254 view->SetSize(contents_rect.size()); 254 view->SetSize(contents_rect.size());
255 } 255 }
256 256
257 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const { 257 gfx::Rect BalloonViewImpl::GetCloseButtonBounds() const {
258 gfx::Rect bounds(GetContentsBounds()); 258 gfx::Rect bounds(GetContentsBounds());
259 bounds.set_height(GetShelfHeight()); 259 bounds.set_height(GetShelfHeight());
260 const gfx::Size& pref_size(close_button_->GetPreferredSize()); 260 const gfx::Size& pref_size(close_button_->GetPreferredSize());
261 bounds.Inset(bounds.width() - kShelfMargin - pref_size.width(), 0, 261 bounds.Inset(bounds.width() - kShelfMargin - pref_size.width(), 0,
262 kShelfMargin, 0); 262 kShelfMargin, 0);
263 return bounds.Center(pref_size); 263 bounds.ClampToCenteredSize(pref_size);
264 return bounds;
264 } 265 }
265 266
266 gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const { 267 gfx::Rect BalloonViewImpl::GetOptionsButtonBounds() const {
267 gfx::Rect bounds(GetContentsBounds()); 268 gfx::Rect bounds(GetContentsBounds());
268 bounds.set_height(GetShelfHeight()); 269 bounds.set_height(GetShelfHeight());
269 const gfx::Size& pref_size(options_menu_button_->GetPreferredSize()); 270 const gfx::Size& pref_size(options_menu_button_->GetPreferredSize());
270 bounds.set_x(GetCloseButtonBounds().x() - kOptionsDismissSpacing - 271 bounds.set_x(GetCloseButtonBounds().x() - kOptionsDismissSpacing -
271 pref_size.width()); 272 pref_size.width());
272 bounds.set_width(pref_size.width()); 273 bounds.set_width(pref_size.width());
273 return bounds.Center(pref_size); 274 bounds.ClampToCenteredSize(pref_size);
275 return bounds;
274 } 276 }
275 277
276 gfx::Rect BalloonViewImpl::GetLabelBounds() const { 278 gfx::Rect BalloonViewImpl::GetLabelBounds() const {
277 gfx::Rect bounds(GetContentsBounds()); 279 gfx::Rect bounds(GetContentsBounds());
278 bounds.set_height(GetShelfHeight()); 280 bounds.set_height(GetShelfHeight());
279 gfx::Size pref_size(source_label_->GetPreferredSize()); 281 gfx::Size pref_size(source_label_->GetPreferredSize());
280 bounds.Inset(kLabelLeftMargin, 0, bounds.width() - 282 bounds.Inset(kLabelLeftMargin, 0, bounds.width() -
281 GetOptionsButtonBounds().x() + kLabelOptionsSpacing, 0); 283 GetOptionsButtonBounds().x() + kLabelOptionsSpacing, 0);
282 pref_size.set_width(bounds.width()); 284 pref_size.set_width(bounds.width());
283 return bounds.Center(pref_size); 285 bounds.ClampToCenteredSize(pref_size);
286 return bounds;
284 } 287 }
285 288
286 void BalloonViewImpl::Show(Balloon* balloon) { 289 void BalloonViewImpl::Show(Balloon* balloon) {
287 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 290 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
288 291
289 balloon_ = balloon; 292 balloon_ = balloon;
290 293
291 const string16 source_label_text = l10n_util::GetStringFUTF16( 294 const string16 source_label_text = l10n_util::GetStringFUTF16(
292 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL, 295 IDS_NOTIFICATION_BALLOON_SOURCE_LABEL,
293 balloon->notification().display_source()); 296 balloon->notification().display_source());
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 return; 529 return;
527 } 530 }
528 531
529 // If the renderer process attached to this balloon is disconnected 532 // If the renderer process attached to this balloon is disconnected
530 // (e.g., because of a crash), we want to close the balloon. 533 // (e.g., because of a crash), we want to close the balloon.
531 notification_registrar_.Remove( 534 notification_registrar_.Remove(
532 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED, 535 this, chrome::NOTIFICATION_NOTIFY_BALLOON_DISCONNECTED,
533 content::Source<Balloon>(balloon_)); 536 content::Source<Balloon>(balloon_));
534 Close(false); 537 Close(false);
535 } 538 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_dialog.cc ('k') | chrome/browser/ui/views/toolbar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698