| 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/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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |