OLD | NEW |
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/chromeos/character_composer.h" | 5 #include "ui/base/ime/chromeos/character_composer.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 const ComposeCheckerWithCompactTable kMainComposeChecker( | 351 const ComposeCheckerWithCompactTable kMainComposeChecker( |
352 gtk_compose_seqs_compact, 5, 24, 6); | 352 gtk_compose_seqs_compact, 5, 24, 6); |
353 if (kMainComposeChecker.CheckSequence(sequence, composed_character)) | 353 if (kMainComposeChecker.CheckSequence(sequence, composed_character)) |
354 return true; | 354 return true; |
355 | 355 |
356 return false; | 356 return false; |
357 } | 357 } |
358 | 358 |
359 // Converts |character| to UTF16 string. | 359 // Converts |character| to UTF16 string. |
360 // Returns false when |character| is not a valid character. | 360 // Returns false when |character| is not a valid character. |
361 bool UTF32CharacterToUTF16(uint32 character, string16* output) { | 361 bool UTF32CharacterToUTF16(uint32 character, base::string16* output) { |
362 output->clear(); | 362 output->clear(); |
363 // Reject invalid character. (e.g. codepoint greater than 0x10ffff) | 363 // Reject invalid character. (e.g. codepoint greater than 0x10ffff) |
364 if (!CBU_IS_UNICODE_CHAR(character)) | 364 if (!CBU_IS_UNICODE_CHAR(character)) |
365 return false; | 365 return false; |
366 if (character) { | 366 if (character) { |
367 output->resize(CBU16_LENGTH(character)); | 367 output->resize(CBU16_LENGTH(character)); |
368 size_t i = 0; | 368 size_t i = 0; |
369 CBU16_APPEND_UNSAFE(&(*output)[0], i, character); | 369 CBU16_APPEND_UNSAFE(&(*output)[0], i, character); |
370 } | 370 } |
371 return true; | 371 return true; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 std::string preedit_string_ascii("u"); | 558 std::string preedit_string_ascii("u"); |
559 for (size_t i = 0; i != compose_buffer_.size(); ++i) { | 559 for (size_t i = 0; i != compose_buffer_.size(); ++i) { |
560 const int digit = compose_buffer_[i]; | 560 const int digit = compose_buffer_[i]; |
561 DCHECK(0 <= digit && digit < 16); | 561 DCHECK(0 <= digit && digit < 16); |
562 preedit_string_ascii += digit <= 9 ? ('0' + digit) : ('a' + (digit - 10)); | 562 preedit_string_ascii += digit <= 9 ? ('0' + digit) : ('a' + (digit - 10)); |
563 } | 563 } |
564 preedit_string_ = ASCIIToUTF16(preedit_string_ascii); | 564 preedit_string_ = ASCIIToUTF16(preedit_string_ascii); |
565 } | 565 } |
566 | 566 |
567 } // namespace ui | 567 } // namespace ui |
OLD | NEW |