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

Side by Side Diff: ui/message_center/views/bounded_label.cc

Issue 273223002: views: Make view::Views::GetPreferredSize() const. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/message_center/views/bounded_label.h" 5 #include "ui/message_center/views/bounded_label.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 gfx::Size BoundedLabel::GetSizeForWidthAndLines(int width, int lines) { 320 gfx::Size BoundedLabel::GetSizeForWidthAndLines(int width, int lines) {
321 return visible() ? 321 return visible() ?
322 label_->GetSizeForWidthAndLines(width, lines) : gfx::Size(); 322 label_->GetSizeForWidthAndLines(width, lines) : gfx::Size();
323 } 323 }
324 324
325 int BoundedLabel::GetBaseline() const { 325 int BoundedLabel::GetBaseline() const {
326 return label_->GetBaseline(); 326 return label_->GetBaseline();
327 } 327 }
328 328
329 gfx::Size BoundedLabel::GetPreferredSize() { 329 gfx::Size BoundedLabel::GetPreferredSize() const {
330 return visible() ? label_->GetSizeForWidthAndLines(-1, -1) : gfx::Size(); 330 return visible() ? label_->GetSizeForWidthAndLines(-1, -1) : gfx::Size();
331 } 331 }
332 332
333 int BoundedLabel::GetHeightForWidth(int width) { 333 int BoundedLabel::GetHeightForWidth(int width) const {
334 return visible() ? 334 return visible() ?
335 label_->GetSizeForWidthAndLines(width, line_limit_).height() : 0; 335 label_->GetSizeForWidthAndLines(width, line_limit_).height() : 0;
336 } 336 }
337 337
338 void BoundedLabel::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) { 338 void BoundedLabel::Paint(gfx::Canvas* canvas, const views::CullSet& cull_set) {
339 if (visible()) 339 if (visible())
340 label_->Paint(canvas, cull_set); 340 label_->Paint(canvas, cull_set);
341 } 341 }
342 342
343 bool BoundedLabel::HitTestRect(const gfx::Rect& rect) const { 343 bool BoundedLabel::HitTestRect(const gfx::Rect& rect) const {
(...skipping 11 matching lines...) Expand all
355 355
356 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) { 356 void BoundedLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) {
357 label_->SetNativeTheme(theme); 357 label_->SetNativeTheme(theme);
358 } 358 }
359 359
360 base::string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) { 360 base::string16 BoundedLabel::GetWrappedTextForTest(int width, int lines) {
361 return JoinString(label_->GetWrappedText(width, lines), '\n'); 361 return JoinString(label_->GetWrappedText(width, lines), '\n');
362 } 362 }
363 363
364 } // namespace message_center 364 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698