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/logging.h" | 10 #include "base/logging.h" |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1188 } else { | 1188 } else { |
1189 Send(response.release()); | 1189 Send(response.release()); |
1190 } | 1190 } |
1191 } | 1191 } |
1192 | 1192 |
1193 #if defined(OS_ANDROID) | 1193 #if defined(OS_ANDROID) |
1194 // Allow the IME to be shown when the focus changes as a consequence | 1194 // Allow the IME to be shown when the focus changes as a consequence |
1195 // of a processed touch end event. | 1195 // of a processed touch end event. |
1196 if (input_event->type == WebInputEvent::TouchEnd && processed) | 1196 if (input_event->type == WebInputEvent::TouchEnd && processed) |
1197 UpdateTextInputState(true, true); | 1197 UpdateTextInputState(true, true); |
1198 #elif defined(USE_AURA) | |
1199 // Show the virtual keyboard if enabled and a user gesture triggers a focus | |
1200 // change. | |
1201 if (processed && (input_event->type == WebInputEvent::TouchEnd || | |
1202 input_event->type == WebInputEvent::MouseUp)) | |
1203 UpdateTextInputState(true, false); | |
1198 #endif | 1204 #endif |
1199 | 1205 |
1200 handling_input_event_ = false; | 1206 handling_input_event_ = false; |
1201 | 1207 |
1202 if (!prevent_default) { | 1208 if (!prevent_default) { |
1203 if (WebInputEvent::isKeyboardEventType(input_event->type)) | 1209 if (WebInputEvent::isKeyboardEventType(input_event->type)) |
1204 DidHandleKeyEvent(); | 1210 DidHandleKeyEvent(); |
1205 if (WebInputEvent::isMouseEventType(input_event->type)) | 1211 if (WebInputEvent::isMouseEventType(input_event->type)) |
1206 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); | 1212 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); |
1207 if (WebInputEvent::isTouchEventType(input_event->type)) | 1213 if (WebInputEvent::isTouchEventType(input_event->type)) |
(...skipping 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2490 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), | 2496 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), |
2491 new_type, | 2497 new_type, |
2492 new_mode, | 2498 new_mode, |
2493 new_can_compose_inline)); | 2499 new_can_compose_inline)); |
2494 text_input_type_ = new_type; | 2500 text_input_type_ = new_type; |
2495 can_compose_inline_ = new_can_compose_inline; | 2501 can_compose_inline_ = new_can_compose_inline; |
2496 text_input_mode_ = new_mode; | 2502 text_input_mode_ = new_mode; |
2497 } | 2503 } |
2498 } | 2504 } |
2499 | 2505 |
2500 #if defined(OS_ANDROID) | 2506 #if defined(OS_ANDROID) || defined(USE_AURA) |
2501 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed, | 2507 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed, |
2502 bool send_ime_ack) { | 2508 bool send_ime_ack) { |
2503 if (handling_ime_event_) | 2509 if (handling_ime_event_) |
2504 return; | 2510 return; |
2505 if (!show_ime_if_needed && !input_method_is_active_) | 2511 if (!show_ime_if_needed && !input_method_is_active_) |
2506 return; | 2512 return; |
2507 ui::TextInputType new_type = GetTextInputType(); | 2513 ui::TextInputType new_type = GetTextInputType(); |
2508 if (IsDateTimeInput(new_type)) | 2514 if (IsDateTimeInput(new_type)) |
2509 return; // Not considered as a text input field in WebKit/Chromium. | 2515 return; // Not considered as a text input field in WebKit/Chromium. |
2510 | 2516 |
2511 blink::WebTextInputInfo new_info; | 2517 blink::WebTextInputInfo new_info; |
2512 if (webwidget_) | 2518 if (webwidget_) |
2513 new_info = webwidget_->textInputInfo(); | 2519 new_info = webwidget_->textInputInfo(); |
2514 | 2520 |
2515 bool new_can_compose_inline = CanComposeInline(); | 2521 bool new_can_compose_inline = CanComposeInline(); |
2516 | 2522 |
2517 // Only sends text input params if they are changed or if the ime should be | 2523 // Only sends text input params if they are changed or if the ime should be |
2518 // shown. | 2524 // shown. |
2519 if (show_ime_if_needed || (text_input_type_ != new_type | 2525 if (show_ime_if_needed || (text_input_type_ != new_type |
2520 || text_input_info_ != new_info | 2526 || text_input_info_ != new_info |
2521 || can_compose_inline_ != new_can_compose_inline)) { | 2527 || can_compose_inline_ != new_can_compose_inline)) { |
2522 ViewHostMsg_TextInputState_Params p; | 2528 ViewHostMsg_TextInputState_Params p; |
2529 #if defined(USE_AURA) | |
2530 p.require_ack = false; | |
jamesr
2014/01/14 21:12:53
nit: can you move this down to be next to the plac
kevers
2014/01/14 22:16:45
This block was originally implemented as an #else
| |
2531 #endif | |
2523 p.type = new_type; | 2532 p.type = new_type; |
2524 p.value = new_info.value.utf8(); | 2533 p.value = new_info.value.utf8(); |
2525 p.selection_start = new_info.selectionStart; | 2534 p.selection_start = new_info.selectionStart; |
2526 p.selection_end = new_info.selectionEnd; | 2535 p.selection_end = new_info.selectionEnd; |
2527 p.composition_start = new_info.compositionStart; | 2536 p.composition_start = new_info.compositionStart; |
2528 p.composition_end = new_info.compositionEnd; | 2537 p.composition_end = new_info.compositionEnd; |
2529 p.can_compose_inline = new_can_compose_inline; | 2538 p.can_compose_inline = new_can_compose_inline; |
2530 p.show_ime_if_needed = show_ime_if_needed; | 2539 p.show_ime_if_needed = show_ime_if_needed; |
2540 #if defined(OS_ANDROID) | |
2531 p.require_ack = send_ime_ack; | 2541 p.require_ack = send_ime_ack; |
2532 if (p.require_ack) | 2542 if (p.require_ack) |
2533 IncrementOutstandingImeEventAcks(); | 2543 IncrementOutstandingImeEventAcks(); |
jamesr
2014/01/14 21:12:53
why do you not need this logic for USE_AURA ?
kevers
2014/01/14 22:16:45
From the render widget host view side, IME is hand
| |
2544 #endif | |
2534 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); | 2545 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
2535 | 2546 |
2536 text_input_info_ = new_info; | 2547 text_input_info_ = new_info; |
2537 text_input_type_ = new_type; | 2548 text_input_type_ = new_type; |
2538 can_compose_inline_ = new_can_compose_inline; | 2549 can_compose_inline_ = new_can_compose_inline; |
2539 } | 2550 } |
2540 } | 2551 } |
2541 #endif | 2552 #endif |
2542 | 2553 |
2543 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { | 2554 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2699 } | 2710 } |
2700 | 2711 |
2701 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) | 2712 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) |
2702 UpdateCompositionInfo(true); | 2713 UpdateCompositionInfo(true); |
2703 #endif | 2714 #endif |
2704 } | 2715 } |
2705 | 2716 |
2706 void RenderWidget::didHandleGestureEvent( | 2717 void RenderWidget::didHandleGestureEvent( |
2707 const WebGestureEvent& event, | 2718 const WebGestureEvent& event, |
2708 bool event_cancelled) { | 2719 bool event_cancelled) { |
2709 #if defined(OS_ANDROID) | 2720 #if defined(OS_ANDROID) || defined(USE_AURA) |
2710 if (event_cancelled) | 2721 if (event_cancelled) |
2711 return; | 2722 return; |
2712 if (event.type == WebInputEvent::GestureTap || | 2723 if (event.type == WebInputEvent::GestureTap || |
2713 event.type == WebInputEvent::GestureLongPress) { | 2724 event.type == WebInputEvent::GestureLongPress) { |
2714 UpdateTextInputState(true, true); | 2725 UpdateTextInputState(true, true); |
2715 } | 2726 } |
2716 #endif | 2727 #endif |
2717 } | 2728 } |
2718 | 2729 |
2719 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { | 2730 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2867 surface_id(), | 2878 surface_id(), |
2868 GetURLForGraphicsContext3D(), | 2879 GetURLForGraphicsContext3D(), |
2869 gpu_channel_host.get(), | 2880 gpu_channel_host.get(), |
2870 attributes, | 2881 attributes, |
2871 false /* bind generates resources */, | 2882 false /* bind generates resources */, |
2872 limits)); | 2883 limits)); |
2873 return context.Pass(); | 2884 return context.Pass(); |
2874 } | 2885 } |
2875 | 2886 |
2876 } // namespace content | 2887 } // namespace content |
OLD | NEW |