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_win.h" | 5 #include "ui/base/ime/input_method_win.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "ui/base/ime/text_input_client.h" | 8 #include "ui/base/ime/text_input_client.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_constants.h" | 10 #include "ui/events/event_constants.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 203 |
204 size_t len = text_range.length(); | 204 size_t len = text_range.length(); |
205 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); | 205 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); |
206 | 206 |
207 if (!reconv) | 207 if (!reconv) |
208 return need_size; | 208 return need_size; |
209 | 209 |
210 if (reconv->dwSize < need_size) | 210 if (reconv->dwSize < need_size) |
211 return 0; | 211 return 0; |
212 | 212 |
213 string16 text; | 213 base::string16 text; |
214 if (!GetTextInputClient()->GetTextFromRange(text_range, &text)) | 214 if (!GetTextInputClient()->GetTextFromRange(text_range, &text)) |
215 return 0; | 215 return 0; |
216 DCHECK_EQ(text_range.length(), text.length()); | 216 DCHECK_EQ(text_range.length(), text.length()); |
217 | 217 |
218 reconv->dwVersion = 0; | 218 reconv->dwVersion = 0; |
219 reconv->dwStrLen = len; | 219 reconv->dwStrLen = len; |
220 reconv->dwStrOffset = sizeof(RECONVERTSTRING); | 220 reconv->dwStrOffset = sizeof(RECONVERTSTRING); |
221 reconv->dwCompStrLen = | 221 reconv->dwCompStrLen = |
222 client->HasCompositionText() ? target_range.length() : 0; | 222 client->HasCompositionText() ? target_range.length() : 0; |
223 reconv->dwCompStrOffset = | 223 reconv->dwCompStrOffset = |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); | 259 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); |
260 | 260 |
261 if (!reconv) | 261 if (!reconv) |
262 return need_size; | 262 return need_size; |
263 | 263 |
264 if (reconv->dwSize < need_size) | 264 if (reconv->dwSize < need_size) |
265 return 0; | 265 return 0; |
266 | 266 |
267 // TODO(penghuang): Return some extra context to help improve IME's | 267 // TODO(penghuang): Return some extra context to help improve IME's |
268 // reconversion accuracy. | 268 // reconversion accuracy. |
269 string16 text; | 269 base::string16 text; |
270 if (!GetTextInputClient()->GetTextFromRange(selection_range, &text)) | 270 if (!GetTextInputClient()->GetTextFromRange(selection_range, &text)) |
271 return 0; | 271 return 0; |
272 DCHECK_EQ(selection_range.length(), text.length()); | 272 DCHECK_EQ(selection_range.length(), text.length()); |
273 | 273 |
274 reconv->dwVersion = 0; | 274 reconv->dwVersion = 0; |
275 reconv->dwStrLen = len; | 275 reconv->dwStrLen = len; |
276 reconv->dwStrOffset = sizeof(RECONVERTSTRING); | 276 reconv->dwStrOffset = sizeof(RECONVERTSTRING); |
277 reconv->dwCompStrLen = len; | 277 reconv->dwCompStrLen = len; |
278 reconv->dwCompStrOffset = 0; | 278 reconv->dwCompStrOffset = 0; |
279 reconv->dwTargetStrLen = len; | 279 reconv->dwTargetStrLen = len; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 if (GetTextInputClient()) { | 361 if (GetTextInputClient()) { |
362 GetTextInputClient()->InsertChar(event.key_code(), | 362 GetTextInputClient()->InsertChar(event.key_code(), |
363 ui::GetModifiersFromKeyState()); | 363 ui::GetModifiersFromKeyState()); |
364 return true; | 364 return true; |
365 } | 365 } |
366 } | 366 } |
367 return DispatchKeyEventPostIME(event); | 367 return DispatchKeyEventPostIME(event); |
368 } | 368 } |
369 | 369 |
370 } // namespace ui | 370 } // namespace ui |
OLD | NEW |