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

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

Issue 2091693003: Correctly fallback to caret bounds when composition_head is not provided (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 5 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (GetEngine()) 173 if (GetEngine())
174 GetEngine()->SetCompositionBounds(GetCompositionBounds(client)); 174 GetEngine()->SetCompositionBounds(GetCompositionBounds(client));
175 175
176 chromeos::IMECandidateWindowHandlerInterface* candidate_window = 176 chromeos::IMECandidateWindowHandlerInterface* candidate_window =
177 ui::IMEBridge::Get()->GetCandidateWindowHandler(); 177 ui::IMEBridge::Get()->GetCandidateWindowHandler();
178 if (!candidate_window) 178 if (!candidate_window)
179 return; 179 return;
180 180
181 const gfx::Rect caret_rect = client->GetCaretBounds(); 181 const gfx::Rect caret_rect = client->GetCaretBounds();
182 182
183 // Pepper doesn't support composition bounds, so fall back to caret bounds to
184 // avoid a bad user experience (the IME window moved to upper left corner).
185 gfx::Rect composition_head; 183 gfx::Rect composition_head;
186 if (client->HasCompositionText()) 184 if (client->HasCompositionText())
187 client->GetCompositionCharacterBounds(0, &composition_head); 185 client->GetCompositionCharacterBounds(0, &composition_head);
188 else 186
187 // Pepper doesn't support composition bounds, so fall back to caret bounds to
188 // avoid a bad user experience (the IME window moved to upper left corner).
189 if (composition_head.IsEmpty())
189 composition_head = caret_rect; 190 composition_head = caret_rect;
190 candidate_window->SetCursorBounds(caret_rect, composition_head); 191 candidate_window->SetCursorBounds(caret_rect, composition_head);
191 192
192 gfx::Range text_range; 193 gfx::Range text_range;
193 gfx::Range selection_range; 194 gfx::Range selection_range;
194 base::string16 surrounding_text; 195 base::string16 surrounding_text;
195 if (!client->GetTextRange(&text_range) || 196 if (!client->GetTextRange(&text_range) ||
196 !client->GetTextFromRange(text_range, &surrounding_text) || 197 !client->GetTextFromRange(text_range, &surrounding_text) ||
197 !client->GetSelectionRange(&selection_range)) { 198 !client->GetSelectionRange(&selection_range)) {
198 previous_surrounding_text_.clear(); 199 previous_surrounding_text_.clear();
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { 637 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() {
637 TextInputType type = GetTextInputType(); 638 TextInputType type = GetTextInputType();
638 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); 639 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD);
639 } 640 }
640 641
641 bool InputMethodChromeOS::IsInputFieldFocused() { 642 bool InputMethodChromeOS::IsInputFieldFocused() {
642 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; 643 return GetTextInputType() != TEXT_INPUT_TYPE_NONE;
643 } 644 }
644 645
645 } // namespace ui 646 } // 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