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 ReplicaInputConnection. |
214 if (WebInputEvent::isKeyboardEventType(input_event.type)) { | 218 if (!use_ime_thread && 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); |
217 // TODO(changwan): this if-condition is a stop-gap solution to update IME | 221 // TODO(changwan): this if-condition is a stop-gap solution to update IME |
218 // states in AdapterInputConnection when using DPAD navigation. This is not | 222 // states in ReplicaInputConnection when using DPAD navigation. This is not |
219 // a correct solution because InputConnection#getTextBeforeCursor() | 223 // a correct solution because InputConnection#getTextBeforeCursor() |
220 // immediately after InputConnection#sendKeyEvent() will not return the | 224 // immediately after InputConnection#sendKeyEvent() will not return the |
221 // correct value. The correct solution is either redesign the architecture | 225 // correct value. The correct solution is either redesign the architecture |
222 // or emulate the DPAD behavior in AdapterInputConnection, either is | 226 // or emulate the DPAD behavior in ReplicaInputConnection, either is |
223 // non-trivial. | 227 // non-trivial. |
224 if (key_event.nativeKeyCode != AKEYCODE_TAB && | 228 if (key_event.nativeKeyCode != AKEYCODE_TAB && |
225 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && | 229 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && |
226 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && | 230 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && |
227 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && | 231 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && |
228 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && | 232 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && |
229 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) | 233 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) { |
230 from_ime = true; | 234 from_ime = true; |
| 235 } |
231 } | 236 } |
232 | 237 |
233 ImeEventGuard guard(widget_, false, from_ime); | 238 ImeEventGuard guard(widget_); |
| 239 guard.set_from_ime(from_ime); |
234 #endif | 240 #endif |
235 | 241 |
236 base::TimeTicks start_time; | 242 base::TimeTicks start_time; |
237 if (base::TimeTicks::IsHighResolution()) | 243 if (base::TimeTicks::IsHighResolution()) |
238 start_time = base::TimeTicks::Now(); | 244 start_time = base::TimeTicks::Now(); |
239 | 245 |
240 TRACE_EVENT1("renderer,benchmark", | 246 TRACE_EVENT1("renderer,benchmark", |
241 "RenderWidgetInputHandler::OnHandleInputEvent", "event", | 247 "RenderWidgetInputHandler::OnHandleInputEvent", "event", |
242 WebInputEventTraits::GetName(input_event.type)); | 248 WebInputEventTraits::GetName(input_event.type)); |
243 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 249 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (pending_input_event_ack_) { | 518 if (pending_input_event_ack_) { |
513 TRACE_EVENT_ASYNC_END0("input", | 519 TRACE_EVENT_ASYNC_END0("input", |
514 "RenderWidgetInputHandler::ThrottledInputEventAck", | 520 "RenderWidgetInputHandler::ThrottledInputEventAck", |
515 pending_input_event_ack_.get()); | 521 pending_input_event_ack_.get()); |
516 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 522 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
517 } | 523 } |
518 total_input_handling_time_this_frame_ = base::TimeDelta(); | 524 total_input_handling_time_this_frame_ = base::TimeDelta(); |
519 } | 525 } |
520 | 526 |
521 } // namespace content | 527 } // namespace content |
OLD | NEW |