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

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

Issue 858303004: Exposes cursor position to IME extension through chrome.inputMethodPrivate.onCompositionBoundsChang… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « chrome/common/extensions/api/input_method_private.json ('k') | 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 <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 if (!IsNonPasswordInputFieldFocused()) 183 if (!IsNonPasswordInputFieldFocused())
184 return; 184 return;
185 185
186 // The current text input type should not be NONE if |context_| is focused. 186 // The current text input type should not be NONE if |context_| is focused.
187 DCHECK(client == GetTextInputClient()); 187 DCHECK(client == GetTextInputClient());
188 DCHECK(!IsTextInputTypeNone()); 188 DCHECK(!IsTextInputTypeNone());
189 const gfx::Rect caret_rect = client->GetCaretBounds(); 189 const gfx::Rect caret_rect = client->GetCaretBounds();
190 190
191 gfx::Rect composition_head; 191 gfx::Rect composition_head;
192 std::vector<gfx::Rect> rects;
192 if (client->HasCompositionText()) { 193 if (client->HasCompositionText()) {
193 std::vector<gfx::Rect> rects;
194 uint32 i = 0; 194 uint32 i = 0;
195 gfx::Rect rect; 195 gfx::Rect rect;
196 while (client->GetCompositionCharacterBounds(i++, &rect)) 196 while (client->GetCompositionCharacterBounds(i++, &rect))
197 rects.push_back(rect); 197 rects.push_back(rect);
198 if (rects.size() > 0) {
199 if (GetEngine())
200 GetEngine()->SetCompositionBounds(rects);
201 composition_head = rects[0];
202 }
203 } else { 198 } else {
204 composition_head = caret_rect; 199 rects.push_back(caret_rect);
200 }
201
202 if (rects.size() > 0) {
203 composition_head = rects[0];
204 if (GetEngine())
205 GetEngine()->SetCompositionBounds(rects);
205 } 206 }
206 207
207 chromeos::IMECandidateWindowHandlerInterface* candidate_window = 208 chromeos::IMECandidateWindowHandlerInterface* candidate_window =
208 chromeos::IMEBridge::Get()->GetCandidateWindowHandler(); 209 chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
209 if (!candidate_window) 210 if (!candidate_window)
210 return; 211 return;
211 candidate_window->SetCursorBounds(caret_rect, composition_head); 212 candidate_window->SetCursorBounds(caret_rect, composition_head);
212 213
213 gfx::Range text_range; 214 gfx::Range text_range;
214 gfx::Range selection_range; 215 gfx::Range selection_range;
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() { 675 bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() {
675 TextInputType type = GetTextInputType(); 676 TextInputType type = GetTextInputType();
676 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD); 677 return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD);
677 } 678 }
678 679
679 bool InputMethodChromeOS::IsInputFieldFocused() { 680 bool InputMethodChromeOS::IsInputFieldFocused() {
680 return GetTextInputType() != TEXT_INPUT_TYPE_NONE; 681 return GetTextInputType() != TEXT_INPUT_TYPE_NONE;
681 } 682 }
682 683
683 } // namespace ui 684 } // namespace ui
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/input_method_private.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698