| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // behavior is to just show the IME and don't propagate the key. | 271 // behavior is to just show the IME and don't propagate the key. |
| 272 // A typical use case is a web form: the DPAD_CENTER should bring up the IME | 272 // A typical use case is a web form: the DPAD_CENTER should bring up the IME |
| 273 // when clicked on an input text field and cause the form submit if clicked | 273 // when clicked on an input text field and cause the form submit if clicked |
| 274 // when the submit button is focused, but not vice-versa. | 274 // when the submit button is focused, but not vice-versa. |
| 275 // The UI layer takes care of translating DPAD_CENTER into a RETURN key, | 275 // The UI layer takes care of translating DPAD_CENTER into a RETURN key, |
| 276 // but at this point we have to swallow the event for the scenario (2). | 276 // but at this point we have to swallow the event for the scenario (2). |
| 277 const WebKeyboardEvent& key_event = | 277 const WebKeyboardEvent& key_event = |
| 278 static_cast<const WebKeyboardEvent&>(input_event); | 278 static_cast<const WebKeyboardEvent&>(input_event); |
| 279 if (key_event.nativeKeyCode == AKEYCODE_DPAD_CENTER && | 279 if (key_event.nativeKeyCode == AKEYCODE_DPAD_CENTER && |
| 280 widget_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { | 280 widget_->GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE) { |
| 281 widget_->showImeIfNeeded(); | 281 widget_->showVirtualKeyboard(); |
| 282 prevent_default = true; | 282 prevent_default = true; |
| 283 } | 283 } |
| 284 #endif | 284 #endif |
| 285 } | 285 } |
| 286 | 286 |
| 287 if (WebInputEvent::isGestureEventType(input_event.type)) { | 287 if (WebInputEvent::isGestureEventType(input_event.type)) { |
| 288 const WebGestureEvent& gesture_event = | 288 const WebGestureEvent& gesture_event = |
| 289 static_cast<const WebGestureEvent&>(input_event); | 289 static_cast<const WebGestureEvent&>(input_event); |
| 290 if (input_event.type == WebInputEvent::GestureLongPress) { | 290 if (input_event.type == WebInputEvent::GestureLongPress) { |
| 291 context_menu_source_type_ = ui::MENU_SOURCE_LONG_PRESS; | 291 context_menu_source_type_ = ui::MENU_SOURCE_LONG_PRESS; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 RenderThreadImpl::current() | 406 RenderThreadImpl::current() |
| 407 ->GetRendererScheduler() | 407 ->GetRendererScheduler() |
| 408 ->DidHandleInputEventOnMainThread(input_event); | 408 ->DidHandleInputEventOnMainThread(input_event); |
| 409 } | 409 } |
| 410 | 410 |
| 411 #if defined(OS_ANDROID) | 411 #if defined(OS_ANDROID) |
| 412 // Allow the IME to be shown when the focus changes as a consequence | 412 // Allow the IME to be shown when the focus changes as a consequence |
| 413 // of a processed touch end event. | 413 // of a processed touch end event. |
| 414 if (input_event.type == WebInputEvent::TouchEnd && | 414 if (input_event.type == WebInputEvent::TouchEnd && |
| 415 processed != WebInputEventResult::NotHandled) { | 415 processed != WebInputEventResult::NotHandled) { |
| 416 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, | 416 delegate_->ShowVirtualKeyboard(); |
| 417 ChangeSource::FROM_NON_IME); | |
| 418 } | 417 } |
| 419 #elif defined(USE_AURA) | 418 #elif defined(USE_AURA) |
| 420 // Show the virtual keyboard if enabled and a user gesture triggers a focus | 419 // Show the virtual keyboard if enabled and a user gesture triggers a focus |
| 421 // change. | 420 // change. |
| 422 if (processed != WebInputEventResult::NotHandled && | 421 if (processed != WebInputEventResult::NotHandled && |
| 423 (input_event.type == WebInputEvent::TouchEnd || | 422 (input_event.type == WebInputEvent::TouchEnd || |
| 424 input_event.type == WebInputEvent::MouseUp)) { | 423 input_event.type == WebInputEvent::MouseUp)) { |
| 425 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, ChangeSource::FROM_IME); | 424 delegate_->ShowVirtualKeyboard(); |
| 426 } | 425 } |
| 427 #endif | 426 #endif |
| 428 | 427 |
| 429 if (!prevent_default && WebInputEvent::isKeyboardEventType(input_event.type)) | 428 if (!prevent_default && WebInputEvent::isKeyboardEventType(input_event.type)) |
| 430 delegate_->OnDidHandleKeyEvent(); | 429 delegate_->OnDidHandleKeyEvent(); |
| 431 | 430 |
| 432 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with | 431 // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with |
| 433 // virtual keyboard. | 432 // virtual keyboard. |
| 434 #if !defined(OS_ANDROID) | 433 #if !defined(OS_ANDROID) |
| 435 // Virtual keyboard is not supported, so react to focus change immediately. | 434 // Virtual keyboard is not supported, so react to focus change immediately. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 459 // it can be bundled in the event ack. | 458 // it can be bundled in the event ack. |
| 460 if (handling_event_overscroll_) { | 459 if (handling_event_overscroll_) { |
| 461 *handling_event_overscroll_ = std::move(params); | 460 *handling_event_overscroll_ = std::move(params); |
| 462 return; | 461 return; |
| 463 } | 462 } |
| 464 | 463 |
| 465 delegate_->OnDidOverscroll(*params); | 464 delegate_->OnDidOverscroll(*params); |
| 466 } | 465 } |
| 467 | 466 |
| 468 } // namespace content | 467 } // namespace content |
| OLD | NEW |