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

Side by Side Diff: chrome/browser/ui/input_method/input_method_engine.cc

Issue 2532803002: Makes delay commitText/setComposition can deal with empty text/composition. (Closed)
Patch Set: Created 4 years 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 | chrome/browser/ui/input_method/input_method_engine_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/input_method/input_method_engine.h" 5 #include "chrome/browser/ui/input_method/input_method_engine.h"
6 6
7 #include "chrome/browser/ui/browser_finder.h" 7 #include "chrome/browser/ui/browser_finder.h"
8 #include "chrome/browser/ui/browser_window.h" 8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 9 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 false /* thick */, SK_ColorTRANSPARENT)); 143 false /* thick */, SK_ColorTRANSPARENT));
144 } 144 }
145 145
146 ui::IMEInputContextHandlerInterface* input_context = 146 ui::IMEInputContextHandlerInterface* input_context =
147 ui::IMEBridge::Get()->GetInputContextHandler(); 147 ui::IMEBridge::Get()->GetInputContextHandler();
148 // If the IME extension is handling key event, hold the composition text 148 // If the IME extension is handling key event, hold the composition text
149 // until the key event is handled. 149 // until the key event is handled.
150 if (input_context && !handling_key_event_) { 150 if (input_context && !handling_key_event_) {
151 input_context->UpdateCompositionText(composition_, cursor_pos, is_visible); 151 input_context->UpdateCompositionText(composition_, cursor_pos, is_visible);
152 composition_.Clear(); 152 composition_.Clear();
153 } else {
154 composition_changed_ = true;
153 } 155 }
154 } 156 }
155 157
156 void InputMethodEngine::CommitTextToInputContext(int context_id, 158 void InputMethodEngine::CommitTextToInputContext(int context_id,
157 const std::string& text) { 159 const std::string& text) {
158 // Append the text to the buffer, as it allows committing text multiple times 160 // Append the text to the buffer, as it allows committing text multiple times
159 // when processing a key event. 161 // when processing a key event.
160 text_ += text; 162 text_ += text;
161 163
162 ui::IMEInputContextHandlerInterface* input_context = 164 ui::IMEInputContextHandlerInterface* input_context =
163 ui::IMEBridge::Get()->GetInputContextHandler(); 165 ui::IMEBridge::Get()->GetInputContextHandler();
164 // If the IME extension is handling key event, hold the text until the key 166 // If the IME extension is handling key event, hold the text until the key
165 // event is handled. 167 // event is handled.
166 if (input_context && !handling_key_event_) { 168 if (input_context && !handling_key_event_) {
167 input_context->CommitText(text_); 169 input_context->CommitText(text_);
168 text_ = ""; 170 text_ = "";
171 } else {
172 commit_text_changed_ = true;
169 } 173 }
170 } 174 }
171 175
172 void InputMethodEngine::OnWindowDestroyed(ui::ImeWindow* ime_window) { 176 void InputMethodEngine::OnWindowDestroyed(ui::ImeWindow* ime_window) {
173 if (ime_window == follow_cursor_window_) { 177 if (ime_window == follow_cursor_window_) {
174 follow_cursor_window_ = nullptr; 178 follow_cursor_window_ = nullptr;
175 } else { 179 } else {
176 auto it = std::find( 180 auto it = std::find(
177 normal_windows_.begin(), normal_windows_.end(), ime_window); 181 normal_windows_.begin(), normal_windows_.end(), ime_window);
178 if (it != normal_windows_.end()) 182 if (it != normal_windows_.end())
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 274 }
271 275
272 // Whitelists Backspace key and arrow keys. 276 // Whitelists Backspace key and arrow keys.
273 std::vector<ui::KeyboardCode> whitelist_keycodes{ 277 std::vector<ui::KeyboardCode> whitelist_keycodes{
274 ui::VKEY_BACK, ui::VKEY_LEFT, ui::VKEY_RIGHT, ui::VKEY_UP, ui::VKEY_DOWN}; 278 ui::VKEY_BACK, ui::VKEY_LEFT, ui::VKEY_RIGHT, ui::VKEY_UP, ui::VKEY_DOWN};
275 return std::find(whitelist_keycodes.begin(), whitelist_keycodes.end(), 279 return std::find(whitelist_keycodes.begin(), whitelist_keycodes.end(),
276 ui_event->key_code()) != whitelist_keycodes.end(); 280 ui_event->key_code()) != whitelist_keycodes.end();
277 } 281 }
278 282
279 } // namespace input_method 283 } // namespace input_method
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/input_method/input_method_engine_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698