OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/renderer/input/render_widget_input_handler.h" | 5 #include "content/renderer/input/render_widget_input_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
12 #include "base/command_line.h" | |
12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
13 #include "base/trace_event/trace_event_synthetic_delay.h" | 14 #include "base/trace_event/trace_event_synthetic_delay.h" |
14 #include "build/build_config.h" | 15 #include "build/build_config.h" |
15 #include "cc/trees/swap_promise_monitor.h" | 16 #include "cc/trees/swap_promise_monitor.h" |
16 #include "components/scheduler/renderer/renderer_scheduler.h" | 17 #include "components/scheduler/renderer/renderer_scheduler.h" |
17 #include "content/common/input/input_event_ack.h" | 18 #include "content/common/input/input_event_ack.h" |
18 #include "content/common/input/input_event_ack_state.h" | 19 #include "content/common/input/input_event_ack_state.h" |
19 #include "content/common/input/web_input_event_traits.h" | 20 #include "content/common/input/web_input_event_traits.h" |
21 #include "content/public/common/content_switches.h" | |
20 #include "content/renderer/gpu/render_widget_compositor.h" | 22 #include "content/renderer/gpu/render_widget_compositor.h" |
21 #include "content/renderer/ime_event_guard.h" | 23 #include "content/renderer/ime_event_guard.h" |
22 #include "content/renderer/input/render_widget_input_handler_delegate.h" | 24 #include "content/renderer/input/render_widget_input_handler_delegate.h" |
23 #include "content/renderer/render_thread_impl.h" | 25 #include "content/renderer/render_thread_impl.h" |
24 #include "content/renderer/render_widget.h" | 26 #include "content/renderer/render_widget.h" |
25 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 27 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
26 #include "third_party/WebKit/public/platform/WebFloatSize.h" | 28 #include "third_party/WebKit/public/platform/WebFloatSize.h" |
27 #include "ui/events/latency_info.h" | 29 #include "ui/events/latency_info.h" |
28 #include "ui/gfx/geometry/point_conversions.h" | 30 #include "ui/gfx/geometry/point_conversions.h" |
29 | 31 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 | 203 |
202 // Calls into |didOverscroll()| while handling this event will populate | 204 // Calls into |didOverscroll()| while handling this event will populate |
203 // |event_overscroll|, which in turn will be bundled with the event ack. | 205 // |event_overscroll|, which in turn will be bundled with the event ack. |
204 scoped_ptr<DidOverscrollParams> event_overscroll; | 206 scoped_ptr<DidOverscrollParams> event_overscroll; |
205 base::AutoReset<scoped_ptr<DidOverscrollParams>*> | 207 base::AutoReset<scoped_ptr<DidOverscrollParams>*> |
206 handling_event_overscroll_resetter(&handling_event_overscroll_, | 208 handling_event_overscroll_resetter(&handling_event_overscroll_, |
207 &event_overscroll); | 209 &event_overscroll); |
208 | 210 |
209 #if defined(OS_ANDROID) | 211 #if defined(OS_ANDROID) |
210 bool from_ime = false; | 212 bool from_ime = false; |
213 bool use_ime_thread = base::CommandLine::ForCurrentProcess()->HasSwitch( | |
214 switches::kUseImeThread); | |
211 | 215 |
212 // For most keyboard events, we want the change source to be FROM_IME because | 216 // For most keyboard events, we want the change source to be FROM_IME because |
213 // we don't need to update IME states in AdapterInputConnection. | 217 // we don't need to update IME states in AdapterInputConnection. |
214 if (WebInputEvent::isKeyboardEventType(input_event.type)) { | 218 if (WebInputEvent::isKeyboardEventType(input_event.type)) { |
215 const WebKeyboardEvent& key_event = | 219 const WebKeyboardEvent& key_event = |
216 *static_cast<const WebKeyboardEvent*>(&input_event); | 220 *static_cast<const WebKeyboardEvent*>(&input_event); |
221 if (use_ime_thread) { | |
222 // We do not send state update for synthetic keys that accompany | |
223 // setComposingText / commitText. | |
224 from_ime = key_event.nativeKeyCode != 229; | |
aelias_OOO_until_Jul13
2016/01/21 07:43:05
But this line implies you're still setting FROM_IM
Changwan Ryu
2016/01/22 10:22:17
Done. Thanks for finding it! Fixed as suggested!
| |
217 // TODO(changwan): this if-condition is a stop-gap solution to update IME | 225 // TODO(changwan): this if-condition is a stop-gap solution to update IME |
218 // states in AdapterInputConnection when using DPAD navigation. This is not | 226 // states in AdapterInputConnection when using DPAD navigation. This is not |
219 // a correct solution because InputConnection#getTextBeforeCursor() | 227 // a correct solution because InputConnection#getTextBeforeCursor() |
220 // immediately after InputConnection#sendKeyEvent() will not return the | 228 // immediately after InputConnection#sendKeyEvent() will not return the |
221 // correct value. The correct solution is either redesign the architecture | 229 // correct value. The correct solution is either redesign the architecture |
222 // or emulate the DPAD behavior in AdapterInputConnection, either is | 230 // or emulate the DPAD behavior in AdapterInputConnection, either is |
223 // non-trivial. | 231 // non-trivial. |
224 if (key_event.nativeKeyCode != AKEYCODE_TAB && | 232 } else if (key_event.nativeKeyCode != AKEYCODE_TAB && |
225 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && | 233 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && |
226 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && | 234 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && |
227 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && | 235 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && |
228 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && | 236 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && |
229 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) | 237 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) { |
230 from_ime = true; | 238 from_ime = true; |
239 } | |
231 } | 240 } |
232 | 241 |
233 ImeEventGuard guard(widget_, false, from_ime); | 242 ImeEventGuard guard(widget_, false, from_ime); |
234 #endif | 243 #endif |
235 | 244 |
236 base::TimeTicks start_time; | 245 base::TimeTicks start_time; |
237 if (base::TimeTicks::IsHighResolution()) | 246 if (base::TimeTicks::IsHighResolution()) |
238 start_time = base::TimeTicks::Now(); | 247 start_time = base::TimeTicks::Now(); |
239 | 248 |
240 TRACE_EVENT1("renderer,benchmark", | 249 TRACE_EVENT1("renderer,benchmark", |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
506 if (pending_input_event_ack_) { | 515 if (pending_input_event_ack_) { |
507 TRACE_EVENT_ASYNC_END0("input", | 516 TRACE_EVENT_ASYNC_END0("input", |
508 "RenderWidgetInputHandler::ThrottledInputEventAck", | 517 "RenderWidgetInputHandler::ThrottledInputEventAck", |
509 pending_input_event_ack_.get()); | 518 pending_input_event_ack_.get()); |
510 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 519 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
511 } | 520 } |
512 total_input_handling_time_this_frame_ = base::TimeDelta(); | 521 total_input_handling_time_this_frame_ = base::TimeDelta(); |
513 } | 522 } |
514 | 523 |
515 } // namespace content | 524 } // namespace content |
OLD | NEW |