| 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 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 &handling_event_type_, input_event.type); | 199 &handling_event_type_, input_event.type); |
| 200 | 200 |
| 201 // Calls into |didOverscroll()| while handling this event will populate | 201 // Calls into |didOverscroll()| while handling this event will populate |
| 202 // |event_overscroll|, which in turn will be bundled with the event ack. | 202 // |event_overscroll|, which in turn will be bundled with the event ack. |
| 203 std::unique_ptr<DidOverscrollParams> event_overscroll; | 203 std::unique_ptr<DidOverscrollParams> event_overscroll; |
| 204 base::AutoReset<std::unique_ptr<DidOverscrollParams>*> | 204 base::AutoReset<std::unique_ptr<DidOverscrollParams>*> |
| 205 handling_event_overscroll_resetter(&handling_event_overscroll_, | 205 handling_event_overscroll_resetter(&handling_event_overscroll_, |
| 206 &event_overscroll); | 206 &event_overscroll); |
| 207 | 207 |
| 208 #if defined(OS_ANDROID) | 208 #if defined(OS_ANDROID) |
| 209 bool from_ime = false; | |
| 210 | |
| 211 // For most keyboard events, we want the change source to be FROM_IME because | |
| 212 // we don't need to update IME states in ReplicaInputConnection. | |
| 213 if (!widget_->IsUsingImeThread() && | |
| 214 WebInputEvent::isKeyboardEventType(input_event.type)) { | |
| 215 const WebKeyboardEvent& key_event = | |
| 216 *static_cast<const WebKeyboardEvent*>(&input_event); | |
| 217 // TODO(changwan): this if-condition is a stop-gap solution to update IME | |
| 218 // states in ReplicaInputConnection when using DPAD navigation. This is not | |
| 219 // a correct solution because InputConnection#getTextBeforeCursor() | |
| 220 // immediately after InputConnection#sendKeyEvent() will not return the | |
| 221 // correct value. The correct solution is either redesign the architecture | |
| 222 // or emulate the DPAD behavior in ReplicaInputConnection, either is | |
| 223 // non-trivial. | |
| 224 if (key_event.nativeKeyCode != AKEYCODE_TAB && | |
| 225 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER && | |
| 226 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT && | |
| 227 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT && | |
| 228 key_event.nativeKeyCode != AKEYCODE_DPAD_UP && | |
| 229 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN) { | |
| 230 from_ime = true; | |
| 231 } | |
| 232 } | |
| 233 | |
| 234 ImeEventGuard guard(widget_); | 209 ImeEventGuard guard(widget_); |
| 235 guard.set_from_ime(from_ime); | |
| 236 #endif | 210 #endif |
| 237 | 211 |
| 238 base::TimeTicks start_time; | 212 base::TimeTicks start_time; |
| 239 if (base::TimeTicks::IsHighResolution()) | 213 if (base::TimeTicks::IsHighResolution()) |
| 240 start_time = base::TimeTicks::Now(); | 214 start_time = base::TimeTicks::Now(); |
| 241 | 215 |
| 242 TRACE_EVENT1("renderer,benchmark,rail", | 216 TRACE_EVENT1("renderer,benchmark,rail", |
| 243 "RenderWidgetInputHandler::OnHandleInputEvent", "event", | 217 "RenderWidgetInputHandler::OnHandleInputEvent", "event", |
| 244 WebInputEvent::GetName(input_event.type)); | 218 WebInputEvent::GetName(input_event.type)); |
| 245 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); | 219 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 // it can be bundled in the event ack. | 444 // it can be bundled in the event ack. |
| 471 if (handling_event_overscroll_) { | 445 if (handling_event_overscroll_) { |
| 472 *handling_event_overscroll_ = std::move(params); | 446 *handling_event_overscroll_ = std::move(params); |
| 473 return; | 447 return; |
| 474 } | 448 } |
| 475 | 449 |
| 476 delegate_->OnDidOverscroll(*params); | 450 delegate_->OnDidOverscroll(*params); |
| 477 } | 451 } |
| 478 | 452 |
| 479 } // namespace content | 453 } // namespace content |
| OLD | NEW |