| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_chromeos.h" | 5 #include "ui/base/ime/input_method_chromeos.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 if (GetEngine()) | 175 if (GetEngine()) |
| 176 GetEngine()->SetCompositionBounds(GetCompositionBounds(client)); | 176 GetEngine()->SetCompositionBounds(GetCompositionBounds(client)); |
| 177 | 177 |
| 178 chromeos::IMECandidateWindowHandlerInterface* candidate_window = | 178 chromeos::IMECandidateWindowHandlerInterface* candidate_window = |
| 179 ui::IMEBridge::Get()->GetCandidateWindowHandler(); | 179 ui::IMEBridge::Get()->GetCandidateWindowHandler(); |
| 180 if (!candidate_window) | 180 if (!candidate_window) |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 const gfx::Rect caret_rect = client->GetCaretBounds(); | 183 const gfx::Rect caret_rect = client->GetCaretBounds(); |
| 184 | 184 |
| 185 // Pepper doesn't support composition bounds, so fall back to caret bounds to | |
| 186 // avoid a bad user experience (the IME window moved to upper left corner). | |
| 187 gfx::Rect composition_head; | 185 gfx::Rect composition_head; |
| 188 if (client->HasCompositionText()) | 186 if (client->HasCompositionText()) |
| 189 client->GetCompositionCharacterBounds(0, &composition_head); | 187 client->GetCompositionCharacterBounds(0, &composition_head); |
| 190 else | 188 |
| 189 // Pepper doesn't support composition bounds, so fall back to caret bounds to |
| 190 // avoid a bad user experience (the IME window moved to upper left corner). |
| 191 if (composition_head.IsEmpty()) |
| 191 composition_head = caret_rect; | 192 composition_head = caret_rect; |
| 192 candidate_window->SetCursorBounds(caret_rect, composition_head); | 193 candidate_window->SetCursorBounds(caret_rect, composition_head); |
| 193 | 194 |
| 194 gfx::Range text_range; | 195 gfx::Range text_range; |
| 195 gfx::Range selection_range; | 196 gfx::Range selection_range; |
| 196 base::string16 surrounding_text; | 197 base::string16 surrounding_text; |
| 197 if (!client->GetTextRange(&text_range) || | 198 if (!client->GetTextRange(&text_range) || |
| 198 !client->GetTextFromRange(text_range, &surrounding_text) || | 199 !client->GetTextFromRange(text_range, &surrounding_text) || |
| 199 !client->GetSelectionRange(&selection_range)) { | 200 !client->GetSelectionRange(&selection_range)) { |
| 200 previous_surrounding_text_.clear(); | 201 previous_surrounding_text_.clear(); |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { | 639 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { |
| 639 TextInputType type = GetTextInputType(); | 640 TextInputType type = GetTextInputType(); |
| 640 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); | 641 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); |
| 641 } | 642 } |
| 642 | 643 |
| 643 bool InputMethodChromeOS::IsInputFieldFocused() { | 644 bool InputMethodChromeOS::IsInputFieldFocused() { |
| 644 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; | 645 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; |
| 645 } | 646 } |
| 646 | 647 |
| 647 } // namespace ui | 648 } // namespace ui |
| OLD | NEW |