Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Use a black thin underline by default. | 139 // Use a black thin underline by default. |
| 140 if (composition_.underlines.empty()) { | 140 if (composition_.underlines.empty()) { |
| 141 composition_.underlines.push_back( | 141 composition_.underlines.push_back( |
| 142 ui::CompositionUnderline(0, composition_.text.length(), SK_ColorBLACK, | 142 ui::CompositionUnderline(0, composition_.text.length(), SK_ColorBLACK, |
| 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. However, if trying to clear the |
| 150 if (input_context && !handling_key_event_) { | 150 // composition, do UpdateCompositionText at once. |
| 151 if ((input_context && !handling_key_event_) || composition_.text.empty()) { | |
| 151 input_context->UpdateCompositionText(composition_, cursor_pos, is_visible); | 152 input_context->UpdateCompositionText(composition_, cursor_pos, is_visible); |
|
Azure Wei
2016/11/23 07:53:42
In UpdateCompositionText(), we would send a faked
Shu Chen
2016/11/24 02:57:57
Done.
| |
| 152 composition_.Clear(); | 153 composition_.Clear(); |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 void InputMethodEngine::CommitTextToInputContext(int context_id, | 157 void InputMethodEngine::CommitTextToInputContext(int context_id, |
| 157 const std::string& text) { | 158 const std::string& text) { |
| 158 // Append the text to the buffer, as it allows committing text multiple times | 159 // Append the text to the buffer, as it allows committing text multiple times |
| 159 // when processing a key event. | 160 // when processing a key event. |
| 160 text_ += text; | 161 text_ += text; |
| 161 | 162 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 } | 271 } |
| 271 | 272 |
| 272 // Whitelists Backspace key and arrow keys. | 273 // Whitelists Backspace key and arrow keys. |
| 273 std::vector<ui::KeyboardCode> whitelist_keycodes{ | 274 std::vector<ui::KeyboardCode> whitelist_keycodes{ |
| 274 ui::VKEY_BACK, ui::VKEY_LEFT, ui::VKEY_RIGHT, ui::VKEY_UP, ui::VKEY_DOWN}; | 275 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(), | 276 return std::find(whitelist_keycodes.begin(), whitelist_keycodes.end(), |
| 276 ui_event->key_code()) != whitelist_keycodes.end(); | 277 ui_event->key_code()) != whitelist_keycodes.end(); |
| 277 } | 278 } |
| 278 | 279 |
| 279 } // namespace input_method | 280 } // namespace input_method |
| OLD | NEW |