| 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/view_text_utils.h" | 5 #include "ui/views/view_text_utils.h" |
| 6 | 6 |
| 7 #include "base/i18n/bidi_line_iterator.h" | 7 #include "base/i18n/bidi_line_iterator.h" |
| 8 #include "base/i18n/break_iterator.h" | 8 #include "base/i18n/break_iterator.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // iterate to the next line breaking opportunity. | 104 // iterate to the next line breaking opportunity. |
| 105 while (iter.Advance()) { | 105 while (iter.Advance()) { |
| 106 // Get the word and figure out the dimensions. | 106 // Get the word and figure out the dimensions. |
| 107 string16 word; | 107 string16 word; |
| 108 if (!ltr_within_rtl) | 108 if (!ltr_within_rtl) |
| 109 word = iter.GetString(); // Get the next word. | 109 word = iter.GetString(); // Get the next word. |
| 110 else | 110 else |
| 111 word = text; // Draw the whole text at once. | 111 word = text; // Draw the whole text at once. |
| 112 | 112 |
| 113 int w = 0, h = 0; | 113 int w = 0, h = 0; |
| 114 gfx::Canvas::SizeStringInt(word, font, &w, &h, flags); | 114 gfx::Canvas::SizeStringInt(word, font, &w, &h, 0, flags); |
| 115 | 115 |
| 116 // If we exceed the boundaries, we need to wrap. | 116 // If we exceed the boundaries, we need to wrap. |
| 117 WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds); | 117 WrapIfWordDoesntFit(w, font.GetHeight(), position, bounds); |
| 118 | 118 |
| 119 int x = label->GetMirroredXInView(position->width()) + bounds.x(); | 119 int x = label->GetMirroredXInView(position->width()) + bounds.x(); |
| 120 if (text_direction_is_rtl) { | 120 if (text_direction_is_rtl) { |
| 121 x -= w; | 121 x -= w; |
| 122 // When drawing LTR strings inside RTL text we need to make sure we | 122 // When drawing LTR strings inside RTL text we need to make sure we |
| 123 // draw the trailing space (if one exists after the LTR text) to the | 123 // draw the trailing space (if one exists after the LTR text) to the |
| 124 // left of the LTR string. | 124 // left of the LTR string. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 149 int font_height, | 149 int font_height, |
| 150 gfx::Size* position, | 150 gfx::Size* position, |
| 151 const gfx::Rect& bounds) { | 151 const gfx::Rect& bounds) { |
| 152 if (position->width() + word_width > bounds.right()) { | 152 if (position->width() + word_width > bounds.right()) { |
| 153 position->set_width(0); | 153 position->set_width(0); |
| 154 position->Enlarge(0, font_height); | 154 position->Enlarge(0, font_height); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace view_text_utils | 158 } // namespace view_text_utils |
| OLD | NEW |