Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: content/renderer/render_widget.cc

Issue 29943002: Limit display of the virtual keyboard to state changes triggered from a user gesture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit tests for input methods on Windows. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
(...skipping 10 matching lines...) Expand all
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;
2523 p.type = new_type; 2529 p.type = new_type;
2524 p.value = new_info.value.utf8(); 2530 p.value = new_info.value.utf8();
2525 p.selection_start = new_info.selectionStart; 2531 p.selection_start = new_info.selectionStart;
2526 p.selection_end = new_info.selectionEnd; 2532 p.selection_end = new_info.selectionEnd;
2527 p.composition_start = new_info.compositionStart; 2533 p.composition_start = new_info.compositionStart;
2528 p.composition_end = new_info.compositionEnd; 2534 p.composition_end = new_info.compositionEnd;
2529 p.can_compose_inline = new_can_compose_inline; 2535 p.can_compose_inline = new_can_compose_inline;
2530 p.show_ime_if_needed = show_ime_if_needed; 2536 p.show_ime_if_needed = show_ime_if_needed;
2537 #if defined(OS_ANDROID)
2531 p.require_ack = send_ime_ack; 2538 p.require_ack = send_ime_ack;
2532 if (p.require_ack) 2539 if (p.require_ack)
2533 IncrementOutstandingImeEventAcks(); 2540 IncrementOutstandingImeEventAcks();
2541 #else
2542 p.require_ack = false;
2543 #endif
Shu Chen 2014/01/09 04:21:17 This change is unnecessary if pass send_ime_ack co
kevers 2014/01/09 15:29:09 IncrementOutstandingImeEventAcks is Android only.
2534 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); 2544 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p));
2535 2545
2536 text_input_info_ = new_info; 2546 text_input_info_ = new_info;
2537 text_input_type_ = new_type; 2547 text_input_type_ = new_type;
2538 can_compose_inline_ = new_can_compose_inline; 2548 can_compose_inline_ = new_can_compose_inline;
2539 } 2549 }
2540 } 2550 }
2541 #endif 2551 #endif
2542 2552
2543 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { 2553 void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2699 } 2709 }
2700 2710
2701 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) 2711 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
2702 UpdateCompositionInfo(true); 2712 UpdateCompositionInfo(true);
2703 #endif 2713 #endif
2704 } 2714 }
2705 2715
2706 void RenderWidget::didHandleGestureEvent( 2716 void RenderWidget::didHandleGestureEvent(
2707 const WebGestureEvent& event, 2717 const WebGestureEvent& event,
2708 bool event_cancelled) { 2718 bool event_cancelled) {
2709 #if defined(OS_ANDROID) 2719 #if defined(OS_ANDROID) || defined(USE_AURA)
2710 if (event_cancelled) 2720 if (event_cancelled)
2711 return; 2721 return;
2712 if (event.type == WebInputEvent::GestureTap || 2722 if (event.type == WebInputEvent::GestureTap ||
2713 event.type == WebInputEvent::GestureLongPress) { 2723 event.type == WebInputEvent::GestureLongPress) {
2714 UpdateTextInputState(true, true); 2724 UpdateTextInputState(true, true);
Shu Chen 2014/01/09 04:21:17 The 2nd parameter should be false if defined(USE_A
kevers 2014/01/09 15:29:09 Correct. See my comment above.
2715 } 2725 }
2716 #endif 2726 #endif
2717 } 2727 }
2718 2728
2719 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { 2729 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) {
2720 size_t i = 0; 2730 size_t i = 0;
2721 for (; i < plugin_window_moves_.size(); ++i) { 2731 for (; i < plugin_window_moves_.size(); ++i) {
2722 if (plugin_window_moves_[i].window == move.window) { 2732 if (plugin_window_moves_[i].window == move.window) {
2723 if (move.rects_valid) { 2733 if (move.rects_valid) {
2724 plugin_window_moves_[i] = move; 2734 plugin_window_moves_[i] = move;
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
2867 surface_id(), 2877 surface_id(),
2868 GetURLForGraphicsContext3D(), 2878 GetURLForGraphicsContext3D(),
2869 gpu_channel_host.get(), 2879 gpu_channel_host.get(),
2870 attributes, 2880 attributes,
2871 false /* bind generates resources */, 2881 false /* bind generates resources */,
2872 limits)); 2882 limits));
2873 return context.Pass(); 2883 return context.Pass();
2874 } 2884 }
2875 2885
2876 } // namespace content 2886 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698