| 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/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <climits> | 10 #include <climits> |
| (...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 Rect clip_rect(display_rect()); | 857 Rect clip_rect(display_rect()); |
| 858 clip_rect.Inset(ShadowValue::GetMargin(shadows_)); | 858 clip_rect.Inset(ShadowValue::GetMargin(shadows_)); |
| 859 | 859 |
| 860 canvas->Save(); | 860 canvas->Save(); |
| 861 canvas->ClipRect(clip_rect); | 861 canvas->ClipRect(clip_rect); |
| 862 } | 862 } |
| 863 | 863 |
| 864 if (!text().empty() && focused()) | 864 if (!text().empty() && focused()) |
| 865 DrawSelection(canvas); | 865 DrawSelection(canvas); |
| 866 | 866 |
| 867 if (cursor_enabled() && cursor_visible() && focused()) | |
| 868 DrawCursor(canvas, selection_model_); | |
| 869 | |
| 870 if (!text().empty()) { | 867 if (!text().empty()) { |
| 871 internal::SkiaTextRenderer renderer(canvas); | 868 internal::SkiaTextRenderer renderer(canvas); |
| 872 if (halo_effect()) | 869 if (halo_effect()) |
| 873 renderer.SetHaloEffect(); | 870 renderer.SetHaloEffect(); |
| 874 DrawVisualText(&renderer); | 871 DrawVisualText(&renderer); |
| 875 } | 872 } |
| 876 | 873 |
| 877 if (clip_to_display_rect()) | 874 if (clip_to_display_rect()) |
| 878 canvas->Restore(); | 875 canvas->Restore(); |
| 879 } | 876 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1072 if (range.IsValid() && range.GetMin() < text().length()) | 1069 if (range.IsValid() && range.GetMin() < text().length()) |
| 1073 return text().substr(range.GetMin(), range.length()); | 1070 return text().substr(range.GetMin(), range.length()); |
| 1074 return base::string16(); | 1071 return base::string16(); |
| 1075 } | 1072 } |
| 1076 | 1073 |
| 1077 RenderText::RenderText() | 1074 RenderText::RenderText() |
| 1078 : horizontal_alignment_(base::i18n::IsRTL() ? ALIGN_RIGHT : ALIGN_LEFT), | 1075 : horizontal_alignment_(base::i18n::IsRTL() ? ALIGN_RIGHT : ALIGN_LEFT), |
| 1079 directionality_mode_(DIRECTIONALITY_FROM_TEXT), | 1076 directionality_mode_(DIRECTIONALITY_FROM_TEXT), |
| 1080 text_direction_(base::i18n::UNKNOWN_DIRECTION), | 1077 text_direction_(base::i18n::UNKNOWN_DIRECTION), |
| 1081 cursor_enabled_(true), | 1078 cursor_enabled_(true), |
| 1082 cursor_visible_(false), | |
| 1083 cursor_color_(kDefaultColor), | 1079 cursor_color_(kDefaultColor), |
| 1084 selection_color_(kDefaultColor), | 1080 selection_color_(kDefaultColor), |
| 1085 selection_background_focused_color_(kDefaultSelectionBackgroundColor), | 1081 selection_background_focused_color_(kDefaultSelectionBackgroundColor), |
| 1086 focused_(false), | 1082 focused_(false), |
| 1087 composition_range_(Range::InvalidRange()), | 1083 composition_range_(Range::InvalidRange()), |
| 1088 colors_(kDefaultColor), | 1084 colors_(kDefaultColor), |
| 1089 baselines_(NORMAL_BASELINE), | 1085 baselines_(NORMAL_BASELINE), |
| 1090 weights_(Font::Weight::NORMAL), | 1086 weights_(Font::Weight::NORMAL), |
| 1091 styles_(NUM_TEXT_STYLES), | 1087 styles_(NUM_TEXT_STYLES), |
| 1092 composition_and_selection_styles_applied_(false), | 1088 composition_and_selection_styles_applied_(false), |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 | 1710 |
| 1715 for (; range_max < length; ++range_max) | 1711 for (; range_max < length; ++range_max) |
| 1716 if (iter.IsEndOfWord(range_max) || iter.IsStartOfWord(range_max)) | 1712 if (iter.IsEndOfWord(range_max) || iter.IsStartOfWord(range_max)) |
| 1717 break; | 1713 break; |
| 1718 | 1714 |
| 1719 return range.is_reversed() ? Range(range_max, range_min) | 1715 return range.is_reversed() ? Range(range_max, range_min) |
| 1720 : Range(range_min, range_max); | 1716 : Range(range_min, range_max); |
| 1721 } | 1717 } |
| 1722 | 1718 |
| 1723 } // namespace gfx | 1719 } // namespace gfx |
| OLD | NEW |