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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 } | 836 } |
837 | 837 |
838 void RenderText::DrawSelection(Canvas* canvas) { | 838 void RenderText::DrawSelection(Canvas* canvas) { |
839 std::vector<Rect> sel = GetSubstringBounds( | 839 std::vector<Rect> sel = GetSubstringBounds( |
840 GetSelectionStart(), GetCursorPosition()); | 840 GetSelectionStart(), GetCursorPosition()); |
841 NativeTheme::ColorId color_id = focused() ? | 841 NativeTheme::ColorId color_id = focused() ? |
842 NativeTheme::kColorId_TextfieldSelectionBackgroundFocused : | 842 NativeTheme::kColorId_TextfieldSelectionBackgroundFocused : |
843 NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused; | 843 NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused; |
844 SkColor color = NativeTheme::instance()->GetSystemColor(color_id); | 844 SkColor color = NativeTheme::instance()->GetSystemColor(color_id); |
845 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) | 845 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) |
846 canvas->FillRect(color, *i); | 846 canvas->FillRect(*i, color); |
847 } | 847 } |
848 | 848 |
849 void RenderText::DrawCursor(Canvas* canvas) { | 849 void RenderText::DrawCursor(Canvas* canvas) { |
850 // Paint cursor. Replace cursor is drawn as rectangle for now. | 850 // Paint cursor. Replace cursor is drawn as rectangle for now. |
851 // TODO(msw): Draw a better cursor with a better indication of association. | 851 // TODO(msw): Draw a better cursor with a better indication of association. |
852 if (cursor_enabled() && cursor_visible() && focused()) { | 852 if (cursor_enabled() && cursor_visible() && focused()) { |
853 const Rect& bounds = GetUpdatedCursorBounds(); | 853 const Rect& bounds = GetUpdatedCursorBounds(); |
854 if (bounds.width() != 0) | 854 if (bounds.width() != 0) |
855 canvas->FillRect(kCursorColor, bounds); | 855 canvas->FillRect(bounds, kCursorColor); |
856 else | 856 else |
857 canvas->DrawRect(bounds, kCursorColor); | 857 canvas->DrawRect(bounds, kCursorColor); |
858 } | 858 } |
859 } | 859 } |
860 | 860 |
861 } // namespace gfx | 861 } // namespace gfx |
OLD | NEW |