OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 } else { | 1191 } else { |
1192 Send(response.release()); | 1192 Send(response.release()); |
1193 } | 1193 } |
1194 } | 1194 } |
1195 | 1195 |
1196 #if defined(OS_ANDROID) | 1196 #if defined(OS_ANDROID) |
1197 // Allow the IME to be shown when the focus changes as a consequence | 1197 // Allow the IME to be shown when the focus changes as a consequence |
1198 // of a processed touch end event. | 1198 // of a processed touch end event. |
1199 if (input_event->type == WebInputEvent::TouchEnd && processed) | 1199 if (input_event->type == WebInputEvent::TouchEnd && processed) |
1200 UpdateTextInputState(true, true); | 1200 UpdateTextInputState(true, true); |
| 1201 #elif defined(USE_AURA) |
| 1202 // Show the virtual keyboard if enabled and a user gesture triggers a focus |
| 1203 // change. |
| 1204 if (processed && (input_event->type == WebInputEvent::TouchEnd || |
| 1205 input_event->type == WebInputEvent::MouseUp)) |
| 1206 UpdateTextInputState(true, false); |
1201 #endif | 1207 #endif |
1202 | 1208 |
1203 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); | 1209 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); |
1204 handling_input_event_ = false; | 1210 handling_input_event_ = false; |
1205 | 1211 |
1206 if (!prevent_default) { | 1212 if (!prevent_default) { |
1207 if (WebInputEvent::isKeyboardEventType(input_event->type)) | 1213 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
1208 DidHandleKeyEvent(); | 1214 DidHandleKeyEvent(); |
1209 if (WebInputEvent::isMouseEventType(input_event->type)) | 1215 if (WebInputEvent::isMouseEventType(input_event->type)) |
1210 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); | 1216 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | 2502 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), |
2497 new_type, | 2503 new_type, |
2498 new_mode, | 2504 new_mode, |
2499 new_can_compose_inline)); | 2505 new_can_compose_inline)); |
2500 text_input_type_ = new_type; | 2506 text_input_type_ = new_type; |
2501 can_compose_inline_ = new_can_compose_inline; | 2507 can_compose_inline_ = new_can_compose_inline; |
2502 text_input_mode_ = new_mode; | 2508 text_input_mode_ = new_mode; |
2503 } | 2509 } |
2504 } | 2510 } |
2505 | 2511 |
2506 #if defined(OS_ANDROID) | 2512 #if defined(OS_ANDROID) || defined(USE_AURA) |
2507 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed, | 2513 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed, |
2508 bool send_ime_ack) { | 2514 bool send_ime_ack) { |
2509 if (handling_ime_event_) | 2515 if (handling_ime_event_) |
2510 return; | 2516 return; |
2511 if (!show_ime_if_needed && !input_method_is_active_) | 2517 if (!show_ime_if_needed && !input_method_is_active_) |
2512 return; | 2518 return; |
2513 ui::TextInputType new_type = GetTextInputType(); | 2519 ui::TextInputType new_type = GetTextInputType(); |
2514 if (IsDateTimeInput(new_type)) | 2520 if (IsDateTimeInput(new_type)) |
2515 return; // Not considered as a text input field in WebKit/Chromium. | 2521 return; // Not considered as a text input field in WebKit/Chromium. |
2516 | 2522 |
2517 blink::WebTextInputInfo new_info; | 2523 blink::WebTextInputInfo new_info; |
2518 if (webwidget_) | 2524 if (webwidget_) |
2519 new_info = webwidget_->textInputInfo(); | 2525 new_info = webwidget_->textInputInfo(); |
2520 | 2526 |
2521 bool new_can_compose_inline = CanComposeInline(); | 2527 bool new_can_compose_inline = CanComposeInline(); |
2522 | 2528 |
2523 // Only sends text input params if they are changed or if the ime should be | 2529 // Only sends text input params if they are changed or if the ime should be |
2524 // shown. | 2530 // shown. |
2525 if (show_ime_if_needed || (text_input_type_ != new_type | 2531 if (show_ime_if_needed || (text_input_type_ != new_type |
2526 || text_input_info_ != new_info | 2532 || text_input_info_ != new_info |
2527 || can_compose_inline_ != new_can_compose_inline)) { | 2533 || can_compose_inline_ != new_can_compose_inline)) { |
2528 ViewHostMsg_TextInputState_Params p; | 2534 ViewHostMsg_TextInputState_Params p; |
| 2535 #if defined(USE_AURA) |
| 2536 p.require_ack = false; |
| 2537 #endif |
2529 p.type = new_type; | 2538 p.type = new_type; |
2530 p.value = new_info.value.utf8(); | 2539 p.value = new_info.value.utf8(); |
2531 p.selection_start = new_info.selectionStart; | 2540 p.selection_start = new_info.selectionStart; |
2532 p.selection_end = new_info.selectionEnd; | 2541 p.selection_end = new_info.selectionEnd; |
2533 p.composition_start = new_info.compositionStart; | 2542 p.composition_start = new_info.compositionStart; |
2534 p.composition_end = new_info.compositionEnd; | 2543 p.composition_end = new_info.compositionEnd; |
2535 p.can_compose_inline = new_can_compose_inline; | 2544 p.can_compose_inline = new_can_compose_inline; |
2536 p.show_ime_if_needed = show_ime_if_needed; | 2545 p.show_ime_if_needed = show_ime_if_needed; |
| 2546 #if defined(OS_ANDROID) |
2537 p.require_ack = send_ime_ack; | 2547 p.require_ack = send_ime_ack; |
2538 if (p.require_ack) | 2548 if (p.require_ack) |
2539 IncrementOutstandingImeEventAcks(); | 2549 IncrementOutstandingImeEventAcks(); |
| 2550 #endif |
2540 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); | 2551 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
2541 | 2552 |
2542 text_input_info_ = new_info; | 2553 text_input_info_ = new_info; |
2543 text_input_type_ = new_type; | 2554 text_input_type_ = new_type; |
2544 can_compose_inline_ = new_can_compose_inline; | 2555 can_compose_inline_ = new_can_compose_inline; |
2545 } | 2556 } |
2546 } | 2557 } |
2547 #endif | 2558 #endif |
2548 | 2559 |
2549 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 2560 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 } | 2716 } |
2706 | 2717 |
2707 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 2718 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
2708 UpdateCompositionInfo(true); | 2719 UpdateCompositionInfo(true); |
2709 #endif | 2720 #endif |
2710 } | 2721 } |
2711 | 2722 |
2712 void RenderWidget::didHandleGestureEvent( | 2723 void RenderWidget::didHandleGestureEvent( |
2713 const WebGestureEvent& event, | 2724 const WebGestureEvent& event, |
2714 bool event_cancelled) { | 2725 bool event_cancelled) { |
2715 #if defined(OS_ANDROID) | 2726 #if defined(OS_ANDROID) || defined(USE_AURA) |
2716 if (event_cancelled) | 2727 if (event_cancelled) |
2717 return; | 2728 return; |
2718 if (event.type == WebInputEvent::GestureTap || | 2729 if (event.type == WebInputEvent::GestureTap || |
2719 event.type == WebInputEvent::GestureLongPress) { | 2730 event.type == WebInputEvent::GestureLongPress) { |
2720 UpdateTextInputState(true, true); | 2731 UpdateTextInputState(true, true); |
2721 } | 2732 } |
2722 #endif | 2733 #endif |
2723 } | 2734 } |
2724 | 2735 |
2725 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { | 2736 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 surface_id(), | 2884 surface_id(), |
2874 GetURLForGraphicsContext3D(), | 2885 GetURLForGraphicsContext3D(), |
2875 gpu_channel_host.get(), | 2886 gpu_channel_host.get(), |
2876 attributes, | 2887 attributes, |
2877 false /* bind generates resources */, | 2888 false /* bind generates resources */, |
2878 limits)); | 2889 limits)); |
2879 return context.Pass(); | 2890 return context.Pass(); |
2880 } | 2891 } |
2881 | 2892 |
2882 } // namespace content | 2893 } // namespace content |
OLD | NEW |