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

Side by Side Diff: ui/base/ime/input_method_ibus.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/base/ime/input_method_ibus.h ('k') | ui/base/ime/input_method_ibus_unittest.cc » ('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/base/ime/input_method_ibus.h" 5 #include "ui/base/ime/input_method_ibus.h"
6 6
7 #include <X11/X.h> 7 #include <X11/X.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/Xutil.h> 9 #include <X11/Xutil.h>
10 #undef FocusIn 10 #undef FocusIn
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 gfx::Rect composition_head; 268 gfx::Rect composition_head;
269 if (!GetTextInputClient()->GetCompositionCharacterBounds(0, 269 if (!GetTextInputClient()->GetCompositionCharacterBounds(0,
270 &composition_head)) { 270 &composition_head)) {
271 composition_head = rect; 271 composition_head = rect;
272 } 272 }
273 273
274 GetInputContextClient()->SetCursorLocation( 274 GetInputContextClient()->SetCursorLocation(
275 GfxRectToIBusRect(rect), 275 GfxRectToIBusRect(rect),
276 GfxRectToIBusRect(composition_head)); 276 GfxRectToIBusRect(composition_head));
277 277
278 ui::Range text_range; 278 gfx::Range text_range;
279 ui::Range selection_range; 279 gfx::Range selection_range;
280 string16 surrounding_text; 280 string16 surrounding_text;
281 if (!GetTextInputClient()->GetTextRange(&text_range) || 281 if (!GetTextInputClient()->GetTextRange(&text_range) ||
282 !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) || 282 !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) ||
283 !GetTextInputClient()->GetSelectionRange(&selection_range)) { 283 !GetTextInputClient()->GetSelectionRange(&selection_range)) {
284 previous_surrounding_text_.clear(); 284 previous_surrounding_text_.clear();
285 previous_selection_range_ = ui::Range::InvalidRange(); 285 previous_selection_range_ = gfx::Range::InvalidRange();
286 return; 286 return;
287 } 287 }
288 288
289 if (previous_selection_range_ == selection_range && 289 if (previous_selection_range_ == selection_range &&
290 previous_surrounding_text_ == surrounding_text) 290 previous_surrounding_text_ == surrounding_text)
291 return; 291 return;
292 292
293 previous_selection_range_ = selection_range; 293 previous_selection_range_ = selection_range;
294 previous_surrounding_text_ = surrounding_text; 294 previous_surrounding_text_ = surrounding_text;
295 295
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } while (char_iterator.Advance()); 894 } while (char_iterator.Advance());
895 895
896 // The text length in Unicode characters. 896 // The text length in Unicode characters.
897 uint32 char_length = static_cast<uint32>(char16_offsets.size()); 897 uint32 char_length = static_cast<uint32>(char16_offsets.size());
898 // Make sure we can convert the value of |char_length| as well. 898 // Make sure we can convert the value of |char_length| as well.
899 char16_offsets.push_back(length); 899 char16_offsets.push_back(length);
900 900
901 size_t cursor_offset = 901 size_t cursor_offset =
902 char16_offsets[std::min(char_length, cursor_position)]; 902 char16_offsets[std::min(char_length, cursor_position)];
903 903
904 out_composition->selection = Range(cursor_offset); 904 out_composition->selection = gfx::Range(cursor_offset);
905 905
906 const std::vector<chromeos::IBusText::UnderlineAttribute>& 906 const std::vector<chromeos::IBusText::UnderlineAttribute>&
907 underline_attributes = text.underline_attributes(); 907 underline_attributes = text.underline_attributes();
908 const std::vector<chromeos::IBusText::SelectionAttribute>& 908 const std::vector<chromeos::IBusText::SelectionAttribute>&
909 selection_attributes = text.selection_attributes(); 909 selection_attributes = text.selection_attributes();
910 910
911 if (!underline_attributes.empty()) { 911 if (!underline_attributes.empty()) {
912 for (size_t i = 0; i < underline_attributes.size(); ++i) { 912 for (size_t i = 0; i < underline_attributes.size(); ++i) {
913 const uint32 start = underline_attributes[i].start_index; 913 const uint32 start = underline_attributes[i].start_index;
914 const uint32 end = underline_attributes[i].end_index; 914 const uint32 end = underline_attributes[i].end_index;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 } 953 }
954 954
955 // Use a black thin underline by default. 955 // Use a black thin underline by default.
956 if (out_composition->underlines.empty()) { 956 if (out_composition->underlines.empty()) {
957 out_composition->underlines.push_back(CompositionUnderline( 957 out_composition->underlines.push_back(CompositionUnderline(
958 0, length, SK_ColorBLACK, false /* thick */)); 958 0, length, SK_ColorBLACK, false /* thick */));
959 } 959 }
960 } 960 }
961 961
962 } // namespace ui 962 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_ibus.h ('k') | ui/base/ime/input_method_ibus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698