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

Side by Side Diff: ui/base/gtk/gtk_im_context_util.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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/app_list/search_result.h ('k') | ui/base/ime/composition_text.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gtk/gtk_im_context_util.h" 5 #include "ui/base/gtk/gtk_im_context_util.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/i18n/char_iterator.h" 8 #include "base/i18n/char_iterator.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 22 matching lines...) Expand all
33 } while (char_iterator.Advance()); 33 } while (char_iterator.Advance());
34 34
35 // The text length in Unicode characters. 35 // The text length in Unicode characters.
36 int char_length = static_cast<int>(char16_offsets.size()); 36 int char_length = static_cast<int>(char16_offsets.size());
37 // Make sure we can convert the value of |char_length| as well. 37 // Make sure we can convert the value of |char_length| as well.
38 char16_offsets.push_back(length); 38 char16_offsets.push_back(length);
39 39
40 size_t cursor_offset = 40 size_t cursor_offset =
41 char16_offsets[std::max(0, std::min(char_length, cursor_position))]; 41 char16_offsets[std::max(0, std::min(char_length, cursor_position))];
42 42
43 composition->selection = ui::Range(cursor_offset); 43 composition->selection = gfx::Range(cursor_offset);
44 44
45 if (attrs) { 45 if (attrs) {
46 int utf8_length = strlen(utf8_text); 46 int utf8_length = strlen(utf8_text);
47 PangoAttrIterator* iter = pango_attr_list_get_iterator(attrs); 47 PangoAttrIterator* iter = pango_attr_list_get_iterator(attrs);
48 48
49 // We only care about underline and background attributes and convert 49 // We only care about underline and background attributes and convert
50 // background attribute into selection if possible. 50 // background attribute into selection if possible.
51 do { 51 do {
52 gint start, end; 52 gint start, end;
53 pango_attr_iterator_range(iter, &start, &end); 53 pango_attr_iterator_range(iter, &start, &end);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 105 }
106 106
107 // Use a black thin underline by default. 107 // Use a black thin underline by default.
108 if (composition->underlines.empty()) { 108 if (composition->underlines.empty()) {
109 composition->underlines.push_back( 109 composition->underlines.push_back(
110 CompositionUnderline(0, length, SK_ColorBLACK, false)); 110 CompositionUnderline(0, length, SK_ColorBLACK, false));
111 } 111 }
112 } 112 }
113 113
114 } // namespace ui 114 } // namespace ui
OLDNEW
« no previous file with comments | « ui/app_list/search_result.h ('k') | ui/base/ime/composition_text.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698