OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
11 #include "app/gfx/font.h" | 11 #include "app/gfx/font.h" |
12 #include "app/l10n_util.h" | 12 #include "app/l10n_util.h" |
13 #include "app/resource_bundle.h" | 13 #include "app/resource_bundle.h" |
14 #include "app/text_elider.h" | 14 #include "app/text_elider.h" |
| 15 #include "base/i18n/rtl.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "gfx/color_utils.h" | 18 #include "gfx/color_utils.h" |
18 #include "gfx/insets.h" | 19 #include "gfx/insets.h" |
19 #include "views/background.h" | 20 #include "views/background.h" |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 | 23 |
23 // static | 24 // static |
24 const char Label::kViewClassName[] = "views/Label"; | 25 const char Label::kViewClassName[] = "views/Label"; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 142 |
142 // An URLs is always treated as an LTR text and therefore we should | 143 // An URLs is always treated as an LTR text and therefore we should |
143 // explicitly mark it as such if the locale is RTL so that URLs containing | 144 // explicitly mark it as such if the locale is RTL so that URLs containing |
144 // Hebrew or Arabic characters are displayed correctly. | 145 // Hebrew or Arabic characters are displayed correctly. |
145 // | 146 // |
146 // Note that we don't check the View's UI layout setting in order to | 147 // Note that we don't check the View's UI layout setting in order to |
147 // determine whether or not to insert the special Unicode formatting | 148 // determine whether or not to insert the special Unicode formatting |
148 // characters. We use the locale settings because an URL is always treated | 149 // characters. We use the locale settings because an URL is always treated |
149 // as an LTR string, even if its containing view does not use an RTL UI | 150 // as an LTR string, even if its containing view does not use an RTL UI |
150 // layout. | 151 // layout. |
151 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 152 if (base::i18n::IsRTL()) |
152 l10n_util::WrapStringWithLTRFormatting(paint_text); | 153 base::i18n::WrapStringWithLTRFormatting(paint_text); |
153 } else { | 154 } else { |
154 *paint_text = text_; | 155 *paint_text = text_; |
155 } | 156 } |
156 | 157 |
157 if (is_multi_line_) { | 158 if (is_multi_line_) { |
158 gfx::Insets insets = GetInsets(); | 159 gfx::Insets insets = GetInsets(); |
159 text_bounds->SetRect(insets.left(), | 160 text_bounds->SetRect(insets.left(), |
160 insets.top(), | 161 insets.top(), |
161 width() - insets.width(), | 162 width() - insets.width(), |
162 height() - insets.height()); | 163 height() - insets.height()); |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 501 } |
501 | 502 |
502 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { | 503 bool Label::GetAccessibleState(AccessibilityTypes::State* state) { |
503 DCHECK(state); | 504 DCHECK(state); |
504 | 505 |
505 *state = AccessibilityTypes::STATE_READONLY; | 506 *state = AccessibilityTypes::STATE_READONLY; |
506 return true; | 507 return true; |
507 } | 508 } |
508 | 509 |
509 } // namespace views | 510 } // namespace views |
OLD | NEW |