Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: ui/gfx/render_text.cc

Issue 10387121: Revert 136996 - ui: Move NativeTheme files into ui/base/native_theme/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gfx/native_theme_win_unittest.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "third_party/skia/include/core/SkColorFilter.h" 13 #include "third_party/skia/include/core/SkColorFilter.h"
14 #include "third_party/skia/include/core/SkTypeface.h" 14 #include "third_party/skia/include/core/SkTypeface.h"
15 #include "third_party/skia/include/effects/SkBlurMaskFilter.h" 15 #include "third_party/skia/include/effects/SkBlurMaskFilter.h"
16 #include "third_party/skia/include/effects/SkGradientShader.h" 16 #include "third_party/skia/include/effects/SkGradientShader.h"
17 #include "third_party/skia/include/effects/SkLayerDrawLooper.h" 17 #include "third_party/skia/include/effects/SkLayerDrawLooper.h"
18 #include "ui/base/native_theme/native_theme.h"
19 #include "ui/base/text/utf16_indexing.h" 18 #include "ui/base/text/utf16_indexing.h"
20 #include "ui/gfx/canvas.h" 19 #include "ui/gfx/canvas.h"
21 #include "ui/gfx/insets.h" 20 #include "ui/gfx/insets.h"
21 #include "ui/gfx/skia_util.h"
22 #include "ui/gfx/shadow_value.h" 22 #include "ui/gfx/shadow_value.h"
23 #include "ui/gfx/skia_util.h"
24 23
25 namespace { 24 namespace {
26 25
27 // All chars are replaced by this char when the password style is set. 26 // All chars are replaced by this char when the password style is set.
28 // TODO(benrg): GTK uses the first of U+25CF, U+2022, U+2731, U+273A, '*' 27 // TODO(benrg): GTK uses the first of U+25CF, U+2022, U+2731, U+273A, '*'
29 // that's available in the font (find_invisible_char() in gtkentry.c). 28 // that's available in the font (find_invisible_char() in gtkentry.c).
30 const char16 kPasswordReplacementChar = '*'; 29 const char16 kPasswordReplacementChar = '*';
31 30
32 // Default color used for the cursor. 31 // Default color used for the cursor.
33 const SkColor kDefaultCursorColor = SK_ColorBLACK; 32 const SkColor kDefaultCursorColor = SK_ColorBLACK;
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // Apply a composition style override to a copy of the style ranges. 730 // Apply a composition style override to a copy of the style ranges.
732 if (composition_range_.IsValid() && !composition_range_.is_empty()) { 731 if (composition_range_.IsValid() && !composition_range_.is_empty()) {
733 StyleRange composition_style(default_style_); 732 StyleRange composition_style(default_style_);
734 composition_style.underline = true; 733 composition_style.underline = true;
735 composition_style.range = composition_range_; 734 composition_style.range = composition_range_;
736 ApplyStyleRangeImpl(style_ranges, composition_style); 735 ApplyStyleRangeImpl(style_ranges, composition_style);
737 } 736 }
738 // Apply a selection style override to a copy of the style ranges. 737 // Apply a selection style override to a copy of the style ranges.
739 if (!selection().is_empty()) { 738 if (!selection().is_empty()) {
740 StyleRange selection_style(default_style_); 739 StyleRange selection_style(default_style_);
741 <<<<<<< HEAD
742 selection_style.foreground = selection_color_; 740 selection_style.foreground = selection_color_;
743 =======
744 selection_style.foreground = ui::NativeTheme::instance()->GetSystemColor(
745 ui::NativeTheme::kColorId_TextfieldSelectionColor);
746 >>>>>>> ui: Move NativeTheme files into ui/base/native_theme/ directory.
747 selection_style.range = ui::Range(selection().GetMin(), 741 selection_style.range = ui::Range(selection().GetMin(),
748 selection().GetMax()); 742 selection().GetMax());
749 ApplyStyleRangeImpl(style_ranges, selection_style); 743 ApplyStyleRangeImpl(style_ranges, selection_style);
750 } 744 }
751 // Apply replacement-mode style override to a copy of the style ranges. 745 // Apply replacement-mode style override to a copy of the style ranges.
752 // 746 //
753 // TODO(xji): NEED TO FIX FOR WINDOWS ASAP. Windows call this function (to 747 // TODO(xji): NEED TO FIX FOR WINDOWS ASAP. Windows call this function (to
754 // apply styles) in ItemizeLogicalText(). In order for the cursor's underline 748 // apply styles) in ItemizeLogicalText(). In order for the cursor's underline
755 // character to be drawn correctly, we will need to re-layout the text. It's 749 // character to be drawn correctly, we will need to re-layout the text. It's
756 // not practical to do layout on every cursor blink. We need to fix Windows 750 // not practical to do layout on every cursor blink. We need to fix Windows
757 // port to apply styles during drawing phase like Linux port does. 751 // port to apply styles during drawing phase like Linux port does.
758 // http://crbug.com/110109 752 // http://crbug.com/110109
759 if (!insert_mode_ && cursor_visible() && focused()) { 753 if (!insert_mode_ && cursor_visible() && focused()) {
760 StyleRange replacement_mode_style(default_style_); 754 StyleRange replacement_mode_style(default_style_);
761 <<<<<<< HEAD
762 replacement_mode_style.foreground = selection_color_; 755 replacement_mode_style.foreground = selection_color_;
763 =======
764 replacement_mode_style.foreground =
765 ui::NativeTheme::instance()->GetSystemColor(
766 ui::NativeTheme::kColorId_TextfieldSelectionColor);
767 >>>>>>> ui: Move NativeTheme files into ui/base/native_theme/ directory.
768 size_t cursor = cursor_position(); 756 size_t cursor = cursor_position();
769 replacement_mode_style.range.set_start(cursor); 757 replacement_mode_style.range.set_start(cursor);
770 replacement_mode_style.range.set_end( 758 replacement_mode_style.range.set_end(
771 IndexOfAdjacentGrapheme(cursor, CURSOR_FORWARD)); 759 IndexOfAdjacentGrapheme(cursor, CURSOR_FORWARD));
772 ApplyStyleRangeImpl(style_ranges, replacement_mode_style); 760 ApplyStyleRangeImpl(style_ranges, replacement_mode_style);
773 } 761 }
774 } 762 }
775 763
776 Point RenderText::GetTextOrigin() { 764 Point RenderText::GetTextOrigin() {
777 Point origin = display_rect().origin(); 765 Point origin = display_rect().origin();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 const int offset = negate_rtl * display_offset_.x(); 943 const int offset = negate_rtl * display_offset_.x();
956 if (display_width > (content_width + offset)) 944 if (display_width > (content_width + offset))
957 delta_offset = negate_rtl * (display_width - (content_width + offset)); 945 delta_offset = negate_rtl * (display_width - (content_width + offset));
958 } 946 }
959 947
960 display_offset_.Offset(delta_offset, 0); 948 display_offset_.Offset(delta_offset, 0);
961 cursor_bounds_.Offset(delta_offset, 0); 949 cursor_bounds_.Offset(delta_offset, 0);
962 } 950 }
963 951
964 void RenderText::DrawSelection(Canvas* canvas) { 952 void RenderText::DrawSelection(Canvas* canvas) {
965 <<<<<<< HEAD
966 const SkColor color = focused() ? selection_background_focused_color_ : 953 const SkColor color = focused() ? selection_background_focused_color_ :
967 selection_background_unfocused_color_; 954 selection_background_unfocused_color_;
968 const std::vector<Rect> sel = GetSubstringBounds(selection()); 955 const std::vector<Rect> sel = GetSubstringBounds(selection());
969 =======
970 std::vector<Rect> sel = GetSubstringBounds(selection());
971 ui::NativeTheme::ColorId color_id = focused() ?
972 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused :
973 ui::NativeTheme::kColorId_TextfieldSelectionBackgroundUnfocused;
974 SkColor color = ui::NativeTheme::instance()->GetSystemColor(color_id);
975 >>>>>>> ui: Move NativeTheme files into ui/base/native_theme/ directory.
976 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i) 956 for (std::vector<Rect>::const_iterator i = sel.begin(); i < sel.end(); ++i)
977 canvas->FillRect(*i, color); 957 canvas->FillRect(*i, color);
978 } 958 }
979 959
980 void RenderText::DrawCursor(Canvas* canvas) { 960 void RenderText::DrawCursor(Canvas* canvas) {
981 // Paint cursor. Replace cursor is drawn as rectangle for now. 961 // Paint cursor. Replace cursor is drawn as rectangle for now.
982 // TODO(msw): Draw a better cursor with a better indication of association. 962 // TODO(msw): Draw a better cursor with a better indication of association.
983 if (cursor_enabled() && cursor_visible() && focused()) { 963 if (cursor_enabled() && cursor_visible() && focused()) {
984 const Rect& bounds = GetUpdatedCursorBounds(); 964 const Rect& bounds = GetUpdatedCursorBounds();
985 if (bounds.width() != 0) 965 if (bounds.width() != 0)
986 canvas->FillRect(bounds, cursor_color_); 966 canvas->FillRect(bounds, cursor_color_);
987 else 967 else
988 canvas->DrawRect(bounds, cursor_color_); 968 canvas->DrawRect(bounds, cursor_color_);
989 } 969 }
990 } 970 }
991 971
992 } // namespace gfx 972 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/native_theme_win_unittest.cc ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698