| OLD | NEW |
| 1 // Copyright (c) 2010 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 "webkit/plugins/ppapi/event_conversion.h" | 5 #include "webkit/plugins/ppapi/event_conversion.h" |
| 6 | 6 |
| 7 #include "base/i18n/char_iterator.h" | 7 #include "base/i18n/char_iterator.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // just padded with 0 values for the unused ones, but is not necessarily | 87 // just padded with 0 values for the unused ones, but is not necessarily |
| 88 // null-terminated. | 88 // null-terminated. |
| 89 // | 89 // |
| 90 // Here we see how many UTF-16 characters we have. | 90 // Here we see how many UTF-16 characters we have. |
| 91 size_t utf16_char_count = 0; | 91 size_t utf16_char_count = 0; |
| 92 while (utf16_char_count < WebKeyboardEvent::textLengthCap && | 92 while (utf16_char_count < WebKeyboardEvent::textLengthCap && |
| 93 key_event.text[utf16_char_count]) | 93 key_event.text[utf16_char_count]) |
| 94 utf16_char_count++; | 94 utf16_char_count++; |
| 95 | 95 |
| 96 // Make a separate PP_InputEvent for each Unicode character in the input. | 96 // Make a separate PP_InputEvent for each Unicode character in the input. |
| 97 base::UTF16CharIterator iter(key_event.text, utf16_char_count); | 97 base::i18n::UTF16CharIterator iter(key_event.text, utf16_char_count); |
| 98 while (!iter.end()) { | 98 while (!iter.end()) { |
| 99 PP_InputEvent result = GetPPEventWithCommonFieldsAndType(event); | 99 PP_InputEvent result = GetPPEventWithCommonFieldsAndType(event); |
| 100 result.u.character.modifier = key_event.modifiers; | 100 result.u.character.modifier = key_event.modifiers; |
| 101 | 101 |
| 102 std::string utf8_char; | 102 std::string utf8_char; |
| 103 base::WriteUnicodeCharacter(iter.get(), &utf8_char); | 103 base::WriteUnicodeCharacter(iter.get(), &utf8_char); |
| 104 base::strlcpy(result.u.character.text, utf8_char.c_str(), | 104 base::strlcpy(result.u.character.text, utf8_char.c_str(), |
| 105 sizeof(result.u.character.text)); | 105 sizeof(result.u.character.text)); |
| 106 | 106 |
| 107 pp_events->push_back(result); | 107 pp_events->push_back(result); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 case PP_INPUTEVENT_TYPE_CHAR: | 293 case PP_INPUTEVENT_TYPE_CHAR: |
| 294 web_input_event.reset(BuildCharEvent(event)); | 294 web_input_event.reset(BuildCharEvent(event)); |
| 295 break; | 295 break; |
| 296 } | 296 } |
| 297 | 297 |
| 298 return web_input_event.release(); | 298 return web_input_event.release(); |
| 299 } | 299 } |
| 300 } // namespace ppapi | 300 } // namespace ppapi |
| 301 } // namespace webkit | 301 } // namespace webkit |
| 302 | 302 |
| OLD | NEW |