| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // |event_overscroll|, which in turn will be bundled with the event ack. | 204 // |event_overscroll|, which in turn will be bundled with the event ack. |
| 203 scoped_ptr<DidOverscrollParams> event_overscroll; | 205 scoped_ptr<DidOverscrollParams> event_overscroll; |
| 204 base::AutoReset<scoped_ptr<DidOverscrollParams>*> | 206 base::AutoReset<scoped_ptr<DidOverscrollParams>*> |
| 205 handling_event_overscroll_resetter(&handling_event_overscroll_, | 207 handling_event_overscroll_resetter(&handling_event_overscroll_, |
| 206 &event_overscroll); | 208 &event_overscroll); |
| 207 | 209 |
| 208 #if defined(OS_ANDROID) | 210 #if defined(OS_ANDROID) |
| 209 bool from_ime = false; | 211 bool from_ime = false; |
| 210 | 212 |
| 211 // For most keyboard events, we want the change source to be FROM_IME because | 213 // For most keyboard events, we want the change source to be FROM_IME because |
| 212 // we don't need to update IME states in AdapterInputConnection. | 214 // we don't need to update IME states in ReplicaInputConnection. |
| 213 if (WebInputEvent::isKeyboardEventType(input_event.type)) { | 215 if (!widget_->IsUsingImeThread() && |
| 216 WebInputEvent::isKeyboardEventType(input_event.type)) { |
| 214 const WebKeyboardEvent& key_event = | 217 const WebKeyboardEvent& key_event = |
| 215 *static_cast<const WebKeyboardEvent*>(&input_event); | 218 *static_cast<const WebKeyboardEvent*>(&input_event); |
| 216 // TODO(changwan): this if-condition is a stop-gap solution to update IME | 219 // TODO(changwan): this if-condition is a stop-gap solution to update IME |
| 217 // states in AdapterInputConnection when using DPAD navigation. This is not | 220 // states in ReplicaInputConnection when using DPAD navigation. This is not |
| 218 // a correct solution because InputConnection#getTextBeforeCursor() | 221 // a correct solution because InputConnection#getTextBeforeCursor() |
| 219 // immediately after InputConnection#sendKeyEvent() will not return the | 222 // immediately after InputConnection#sendKeyEvent() will not return the |
| 220 // correct value. The correct solution is either redesign the architecture | 223 // correct value. The correct solution is either redesign the architecture |
| 221 // or emulate the DPAD behavior in AdapterInputConnection, either is | 224 // or emulate the DPAD behavior in ReplicaInputConnection, either is |
| 222 // non-trivial. | 225 // non-trivial. |
| 223 if (key_event.nativeKeyCode != AKEYCODE_TAB && | 226 if (key_event.nativeKeyCode != AKEYCODE_TAB && |
| 224 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && | 227 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && |
| 225 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && | 228 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && |
| 226 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && | 229 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && |
| 227 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && | 230 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && |
| 228 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) | 231 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) { |
| 229 from_ime = true; | 232 from_ime = true; |
| 233 } |
| 230 } | 234 } |
| 231 | 235 |
| 232 ImeEventGuard guard(widget_, false, from_ime); | 236 ImeEventGuard guard(widget_); |
| 237 guard.set_from_ime(from_ime); |
| 233 #endif | 238 #endif |
| 234 | 239 |
| 235 base::TimeTicks start_time; | 240 base::TimeTicks start_time; |
| 236 if (base::TimeTicks::IsHighResolution()) | 241 if (base::TimeTicks::IsHighResolution()) |
| 237 start_time = base::TimeTicks::Now(); | 242 start_time = base::TimeTicks::Now(); |
| 238 | 243 |
| 239 TRACE_EVENT1("renderer,benchmark", | 244 TRACE_EVENT1("renderer,benchmark", |
| 240 "RenderWidgetInputHandler::OnHandleInputEvent", "event", | 245 "RenderWidgetInputHandler::OnHandleInputEvent", "event", |
| 241 WebInputEventTraits::GetName(input_event.type)); | 246 WebInputEventTraits::GetName(input_event.type)); |
| 242 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 247 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 if (pending_input_event_ack_) { | 527 if (pending_input_event_ack_) { |
| 523 TRACE_EVENT_ASYNC_END0("input", | 528 TRACE_EVENT_ASYNC_END0("input", |
| 524 "RenderWidgetInputHandler::ThrottledInputEventAck", | 529 "RenderWidgetInputHandler::ThrottledInputEventAck", |
| 525 pending_input_event_ack_.get()); | 530 pending_input_event_ack_.get()); |
| 526 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); | 531 delegate_->OnInputEventAck(std::move(pending_input_event_ack_)); |
| 527 } | 532 } |
| 528 total_input_handling_time_this_frame_ = base::TimeDelta(); | 533 total_input_handling_time_this_frame_ = base::TimeDelta(); |
| 529 } | 534 } |
| 530 | 535 |
| 531 } // namespace content | 536 } // namespace content |
| OLD | NEW |