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