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/events/event.h" | 8 #include "ui/base/events/event.h" |
9 #include "ui/base/events/event_constants.h" | 9 #include "ui/base/events/event_constants.h" |
10 #include "ui/base/events/event_utils.h" | 10 #include "ui/base/events/event_utils.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 if (IsTextInputTypeNone()) | 172 if (IsTextInputTypeNone()) |
173 return 0; | 173 return 0; |
174 | 174 |
175 if (!GetTextInputClient()) | 175 if (!GetTextInputClient()) |
176 return 0; | 176 return 0; |
177 | 177 |
178 // Shows the dead character as a composition text, so that the user can know | 178 // Shows the dead character as a composition text, so that the user can know |
179 // what dead key was pressed. | 179 // what dead key was pressed. |
180 ui::CompositionText composition; | 180 ui::CompositionText composition; |
181 composition.text.assign(1, static_cast<char16>(wparam)); | 181 composition.text.assign(1, static_cast<char16>(wparam)); |
182 composition.selection = ui::Range(0, 1); | 182 composition.selection = gfx::Range(0, 1); |
183 composition.underlines.push_back( | 183 composition.underlines.push_back( |
184 ui::CompositionUnderline(0, 1, SK_ColorBLACK, false)); | 184 ui::CompositionUnderline(0, 1, SK_ColorBLACK, false)); |
185 GetTextInputClient()->SetCompositionText(composition); | 185 GetTextInputClient()->SetCompositionText(composition); |
186 return 0; | 186 return 0; |
187 } | 187 } |
188 | 188 |
189 LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING* reconv) { | 189 LRESULT InputMethodWin::OnDocumentFeed(RECONVERTSTRING* reconv) { |
190 ui::TextInputClient* client = GetTextInputClient(); | 190 ui::TextInputClient* client = GetTextInputClient(); |
191 if (!client) | 191 if (!client) |
192 return 0; | 192 return 0; |
193 | 193 |
194 ui::Range text_range; | 194 gfx::Range text_range; |
195 if (!client->GetTextRange(&text_range) || text_range.is_empty()) | 195 if (!client->GetTextRange(&text_range) || text_range.is_empty()) |
196 return 0; | 196 return 0; |
197 | 197 |
198 bool result = false; | 198 bool result = false; |
199 ui::Range target_range; | 199 gfx::Range target_range; |
200 if (client->HasCompositionText()) | 200 if (client->HasCompositionText()) |
201 result = client->GetCompositionTextRange(&target_range); | 201 result = client->GetCompositionTextRange(&target_range); |
202 | 202 |
203 if (!result || target_range.is_empty()) { | 203 if (!result || target_range.is_empty()) { |
204 if (!client->GetSelectionRange(&target_range) || | 204 if (!client->GetSelectionRange(&target_range) || |
205 !target_range.IsValid()) { | 205 !target_range.IsValid()) { |
206 return 0; | 206 return 0; |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 | 251 |
252 LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING* reconv) { | 252 LRESULT InputMethodWin::OnReconvertString(RECONVERTSTRING* reconv) { |
253 ui::TextInputClient* client = GetTextInputClient(); | 253 ui::TextInputClient* client = GetTextInputClient(); |
254 if (!client) | 254 if (!client) |
255 return 0; | 255 return 0; |
256 | 256 |
257 // If there is a composition string already, we don't allow reconversion. | 257 // If there is a composition string already, we don't allow reconversion. |
258 if (client->HasCompositionText()) | 258 if (client->HasCompositionText()) |
259 return 0; | 259 return 0; |
260 | 260 |
261 ui::Range text_range; | 261 gfx::Range text_range; |
262 if (!client->GetTextRange(&text_range) || text_range.is_empty()) | 262 if (!client->GetTextRange(&text_range) || text_range.is_empty()) |
263 return 0; | 263 return 0; |
264 | 264 |
265 ui::Range selection_range; | 265 gfx::Range selection_range; |
266 if (!client->GetSelectionRange(&selection_range) || | 266 if (!client->GetSelectionRange(&selection_range) || |
267 selection_range.is_empty()) { | 267 selection_range.is_empty()) { |
268 return 0; | 268 return 0; |
269 } | 269 } |
270 | 270 |
271 DCHECK(text_range.Contains(selection_range)); | 271 DCHECK(text_range.Contains(selection_range)); |
272 | 272 |
273 size_t len = selection_range.length(); | 273 size_t len = selection_range.length(); |
274 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); | 274 size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR); |
275 | 275 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 #else | 345 #else |
346 // On Non-Aura environment, TextInputClient::GetAttachedWindow() returns | 346 // On Non-Aura environment, TextInputClient::GetAttachedWindow() returns |
347 // window handle to which each input method is bound. | 347 // window handle to which each input method is bound. |
348 if (!text_input_client) | 348 if (!text_input_client) |
349 return NULL; | 349 return NULL; |
350 return text_input_client->GetAttachedWindow(); | 350 return text_input_client->GetAttachedWindow(); |
351 #endif | 351 #endif |
352 } | 352 } |
353 | 353 |
354 } // namespace ui | 354 } // namespace ui |
OLD | NEW |