| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/controls/label.h" | 5 #include "views/controls/label.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/color_utils.h" | 10 #include "app/gfx/color_utils.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 | 257 |
| 258 const GURL Label::GetURL() const { | 258 const GURL Label::GetURL() const { |
| 259 if (url_set_) | 259 if (url_set_) |
| 260 return url_; | 260 return url_; |
| 261 else | 261 else |
| 262 return GURL(WideToUTF8(text_)); | 262 return GURL(WideToUTF8(text_)); |
| 263 } | 263 } |
| 264 | 264 |
| 265 gfx::Size Label::GetTextSize() { | 265 gfx::Size Label::GetTextSize() { |
| 266 if (!text_size_valid_) { | 266 if (!text_size_valid_) { |
| 267 int w = 0, h = 0; | 267 text_size_.SetSize(font_.GetStringWidth(text_), font_.height()); |
| 268 gfx::Canvas cc(0, 0, true); | |
| 269 int flags = is_multi_line_ ? ComputeMultiLineFlags() : 0; | |
| 270 | |
| 271 cc.SizeStringInt(text_, font_, &w, &h, flags); | |
| 272 text_size_.SetSize(w, h); | |
| 273 if (highlighted_) | 268 if (highlighted_) |
| 274 text_size_.Enlarge(1, 1); | 269 text_size_.Enlarge(1, 1); |
| 275 text_size_valid_ = true; | 270 text_size_valid_ = true; |
| 276 } | 271 } |
| 277 | 272 |
| 278 return text_size_; | 273 return text_size_; |
| 279 } | 274 } |
| 280 | 275 |
| 281 int Label::GetHeightForWidth(int w) { | 276 int Label::GetHeightForWidth(int w) { |
| 282 if (is_multi_line_) { | 277 if (is_multi_line_) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 } | 488 } |
| 494 | 489 |
| 495 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { | 490 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { |
| 496 DCHECK(state); | 491 DCHECK(state); |
| 497 | 492 |
| 498 *state = AccessibilityTypes::STATE_READONLY; | 493 *state = AccessibilityTypes::STATE_READONLY; |
| 499 return true; | 494 return true; |
| 500 } | 495 } |
| 501 | 496 |
| 502 } // namespace views | 497 } // namespace views |
| OLD | NEW |