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

Side by Side Diff: ui/base/ime/composition_text_util_pango.cc

Issue 313053007: Passing BackgroundColorSpan and UnderlineSpan from Clank to Blink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Putting back import java.lang.CharSequence for android_aosp. Created 6 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/base/ime/composition_text_util_pango.h" 5 #include "ui/base/ime/composition_text_util_pango.h"
6 6
7 #include <pango/pango-attributes.h> 7 #include <pango/pango-attributes.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/i18n/char_iterator.h" 10 #include "base/i18n/char_iterator.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (start >= end) 68 if (start >= end)
69 continue; 69 continue;
70 70
71 PangoAttribute* background_attr = 71 PangoAttribute* background_attr =
72 pango_attr_iterator_get(iter, PANGO_ATTR_BACKGROUND); 72 pango_attr_iterator_get(iter, PANGO_ATTR_BACKGROUND);
73 PangoAttribute* underline_attr = 73 PangoAttribute* underline_attr =
74 pango_attr_iterator_get(iter, PANGO_ATTR_UNDERLINE); 74 pango_attr_iterator_get(iter, PANGO_ATTR_UNDERLINE);
75 75
76 if (background_attr || underline_attr) { 76 if (background_attr || underline_attr) {
77 // Use a black thin underline by default. 77 // Use a black thin underline by default.
78 CompositionUnderline underline( 78 CompositionUnderline underline(char16_offsets[start],
79 char16_offsets[start], char16_offsets[end], SK_ColorBLACK, false); 79 char16_offsets[end],
80 SK_ColorBLACK,
81 false,
82 SK_ColorTRANSPARENT);
80 83
81 // Always use thick underline for a range with background color, which 84 // Always use thick underline for a range with background color, which
82 // is usually the selection range. 85 // is usually the selection range.
83 if (background_attr) { 86 if (background_attr) {
84 underline.thick = true; 87 underline.thick = true;
85 // If the cursor is at start or end of this underline, then we treat 88 // If the cursor is at start or end of this underline, then we treat
86 // it as the selection range as well, but make sure to set the cursor 89 // it as the selection range as well, but make sure to set the cursor
87 // position to the selection end. 90 // position to the selection end.
88 if (underline.start_offset == cursor_offset) { 91 if (underline.start_offset == cursor_offset) {
89 composition->selection.set_start(underline.end_offset); 92 composition->selection.set_start(underline.end_offset);
(...skipping 11 matching lines...) Expand all
101 underline.color = SK_ColorRED; 104 underline.color = SK_ColorRED;
102 } 105 }
103 composition->underlines.push_back(underline); 106 composition->underlines.push_back(underline);
104 } 107 }
105 } while (pango_attr_iterator_next(iter)); 108 } while (pango_attr_iterator_next(iter));
106 pango_attr_iterator_destroy(iter); 109 pango_attr_iterator_destroy(iter);
107 } 110 }
108 111
109 // Use a black thin underline by default. 112 // Use a black thin underline by default.
110 if (composition->underlines.empty()) { 113 if (composition->underlines.empty()) {
111 composition->underlines.push_back( 114 composition->underlines.push_back(CompositionUnderline(
112 CompositionUnderline(0, length, SK_ColorBLACK, false)); 115 0, length, SK_ColorBLACK, false, SK_ColorTRANSPARENT));
113 } 116 }
114 } 117 }
115 118
116 } // namespace ui 119 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/remote_window_tree_host_win.cc ('k') | ui/base/ime/composition_text_util_pango_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698