Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "ui/views/controls/label.h" | 5 #include "ui/views/controls/label.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 result.append(lines_[0]->GetDisplayText()); | 206 result.append(lines_[0]->GetDisplayText()); |
| 207 for (size_t i = 1; i < lines_.size(); ++i) { | 207 for (size_t i = 1; i < lines_.size(); ++i) { |
| 208 result.append(1, '\n'); | 208 result.append(1, '\n'); |
| 209 result.append(lines_[i]->GetDisplayText()); | 209 result.append(lines_[i]->GetDisplayText()); |
| 210 } | 210 } |
| 211 return result; | 211 return result; |
| 212 } | 212 } |
| 213 | 213 |
| 214 gfx::Insets Label::GetInsets() const { | 214 gfx::Insets Label::GetInsets() const { |
| 215 gfx::Insets insets = View::GetInsets(); | 215 gfx::Insets insets = View::GetInsets(); |
| 216 if (focusable()) { | 216 if (focusable() || accessibility_focusable()) { |
|
tapted
2016/04/20 06:05:58
oh butts - how many things call View::focusable()?
karandeepb
2016/05/03 02:54:12
Replaced this with focus_behavior() check. These a
| |
| 217 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, | 217 insets += gfx::Insets(kFocusBorderPadding, kFocusBorderPadding, |
| 218 kFocusBorderPadding, kFocusBorderPadding); | 218 kFocusBorderPadding, kFocusBorderPadding); |
| 219 } | 219 } |
| 220 return insets; | 220 return insets; |
| 221 } | 221 } |
| 222 | 222 |
| 223 int Label::GetBaseline() const { | 223 int Label::GetBaseline() const { |
| 224 return GetInsets().top() + font_list().GetBaseline(); | 224 return GetInsets().top() + font_list().GetBaseline(); |
| 225 } | 225 } |
| 226 | 226 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 PreferredSizeChanged(); | 428 PreferredSizeChanged(); |
| 429 SchedulePaint(); | 429 SchedulePaint(); |
| 430 lines_.clear(); | 430 lines_.clear(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void Label::MaybeBuildRenderTextLines() { | 433 void Label::MaybeBuildRenderTextLines() { |
| 434 if (!lines_.empty()) | 434 if (!lines_.empty()) |
| 435 return; | 435 return; |
| 436 | 436 |
| 437 gfx::Rect rect = GetContentsBounds(); | 437 gfx::Rect rect = GetContentsBounds(); |
| 438 if (focusable()) | 438 if (focusable() || accessibility_focusable()) |
| 439 rect.Inset(kFocusBorderPadding, kFocusBorderPadding); | 439 rect.Inset(kFocusBorderPadding, kFocusBorderPadding); |
| 440 if (rect.IsEmpty()) | 440 if (rect.IsEmpty()) |
| 441 return; | 441 return; |
| 442 rect.Inset(-gfx::ShadowValue::GetMargin(shadows())); | 442 rect.Inset(-gfx::ShadowValue::GetMargin(shadows())); |
| 443 | 443 |
| 444 gfx::HorizontalAlignment alignment = horizontal_alignment(); | 444 gfx::HorizontalAlignment alignment = horizontal_alignment(); |
| 445 gfx::DirectionalityMode directionality = render_text_->directionality_mode(); | 445 gfx::DirectionalityMode directionality = render_text_->directionality_mode(); |
| 446 if (multi_line()) { | 446 if (multi_line()) { |
| 447 // Force the directionality and alignment of the first line on other lines. | 447 // Force the directionality and alignment of the first line on other lines. |
| 448 bool rtl = | 448 bool rtl = |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 } | 587 } |
| 588 | 588 |
| 589 bool Label::ShouldShowDefaultTooltip() const { | 589 bool Label::ShouldShowDefaultTooltip() const { |
| 590 const gfx::Size text_size = GetTextSize(); | 590 const gfx::Size text_size = GetTextSize(); |
| 591 const gfx::Size size = GetContentsBounds().size(); | 591 const gfx::Size size = GetContentsBounds().size(); |
| 592 return !obscured() && (text_size.width() > size.width() || | 592 return !obscured() && (text_size.width() > size.width() || |
| 593 (multi_line() && text_size.height() > size.height())); | 593 (multi_line() && text_size.height() > size.height())); |
| 594 } | 594 } |
| 595 | 595 |
| 596 } // namespace views | 596 } // namespace views |
| OLD | NEW |