Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: ui/base/ime/input_method_chromeos.cc

Issue 2089783004: Correctly fallback to caret bounds when composition_head is not provided (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698