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

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: Created 7 years, 2 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 pending_window_rect_count_(0), 348 pending_window_rect_count_(0),
349 suppress_next_char_events_(false), 349 suppress_next_char_events_(false),
350 is_accelerated_compositing_active_(false), 350 is_accelerated_compositing_active_(false),
351 was_accelerated_compositing_ever_active_(false), 351 was_accelerated_compositing_ever_active_(false),
352 animation_update_pending_(false), 352 animation_update_pending_(false),
353 invalidation_task_posted_(false), 353 invalidation_task_posted_(false),
354 screen_info_(screen_info), 354 screen_info_(screen_info),
355 device_scale_factor_(screen_info_.deviceScaleFactor), 355 device_scale_factor_(screen_info_.deviceScaleFactor),
356 is_threaded_compositing_enabled_(false), 356 is_threaded_compositing_enabled_(false),
357 next_output_surface_id_(0), 357 next_output_surface_id_(0),
358 #if defined(OS_ANDROID) 358 #if defined(OS_ANDROID) || defined(USE_AURA)
359 outstanding_ime_acks_(0), 359 outstanding_ime_acks_(0),
360 #endif 360 #endif
361 popup_origin_scale_for_emulation_(0.f), 361 popup_origin_scale_for_emulation_(0.f),
362 weak_ptr_factory_(this) { 362 weak_ptr_factory_(this) {
363 if (!swapped_out) 363 if (!swapped_out)
364 RenderProcess::current()->AddRefProcess(); 364 RenderProcess::current()->AddRefProcess();
365 DCHECK(RenderThread::Get()); 365 DCHECK(RenderThread::Get());
366 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( 366 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch(
367 switches::kDisableGpuVsync); 367 switches::kDisableGpuVsync);
368 is_threaded_compositing_enabled_ = 368 is_threaded_compositing_enabled_ =
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) 590 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition)
591 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) 591 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize)
592 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) 592 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint)
593 IPC_MESSAGE_HANDLER(ViewMsg_SyntheticGestureCompleted, 593 IPC_MESSAGE_HANDLER(ViewMsg_SyntheticGestureCompleted,
594 OnSyntheticGestureCompleted) 594 OnSyntheticGestureCompleted)
595 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) 595 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
596 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) 596 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
597 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) 597 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects)
598 #if defined(OS_ANDROID) 598 #if defined(OS_ANDROID)
599 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) 599 IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
600 #endif
601 #if defined(OS_ANDROID) || defined(USE_AURA)
600 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck) 602 IPC_MESSAGE_HANDLER(ViewMsg_ImeEventAck, OnImeEventAck)
601 #endif 603 #endif
602 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) 604 IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot)
603 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats, 605 IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats,
604 OnSetBrowserRenderingStats) 606 OnSetBrowserRenderingStats)
605 IPC_MESSAGE_UNHANDLED(handled = false) 607 IPC_MESSAGE_UNHANDLED(handled = false)
606 IPC_END_MESSAGE_MAP() 608 IPC_END_MESSAGE_MAP()
607 return handled; 609 return handled;
608 } 610 }
609 611
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 // send us the same kind of event we are delaying the ack for. 1130 // send us the same kind of event we are delaying the ack for.
1129 Send(pending_input_event_ack_.release()); 1131 Send(pending_input_event_ack_.release());
1130 } 1132 }
1131 pending_input_event_ack_.reset(response); 1133 pending_input_event_ack_.reset(response);
1132 if (compositor_) 1134 if (compositor_)
1133 compositor_->NotifyInputThrottledUntilCommit(); 1135 compositor_->NotifyInputThrottledUntilCommit();
1134 } else { 1136 } else {
1135 Send(response); 1137 Send(response);
1136 } 1138 }
1137 1139
1138 #if defined(OS_ANDROID) 1140 #if defined(OS_ANDROID) || defined(USE_AURA)
1139 // Allow the IME to be shown when the focus changes as a consequence 1141 // Allow the IME to be shown when the focus changes as a consequence
1140 // of a processed touch end event. 1142 // of a processed touch end event.
1141 if (input_event->type == WebInputEvent::TouchEnd && processed) 1143 if (input_event->type == WebInputEvent::TouchEnd && processed)
1142 UpdateTextInputState(true, true); 1144 UpdateTextInputState(true, true);
1143 #endif 1145 #endif
1146 #if defined(USE_AURA)
1147 if (input_event->type == WebInputEvent::MouseUp && processed)
1148 UpdateTextInputState(true, true);
1149 #endif
1144 1150
1145 handling_input_event_ = false; 1151 handling_input_event_ = false;
1146 1152
1147 if (!prevent_default) { 1153 if (!prevent_default) {
1148 if (WebInputEvent::isKeyboardEventType(input_event->type)) 1154 if (WebInputEvent::isKeyboardEventType(input_event->type))
1149 DidHandleKeyEvent(); 1155 DidHandleKeyEvent();
1150 if (WebInputEvent::isMouseEventType(input_event->type)) 1156 if (WebInputEvent::isMouseEventType(input_event->type))
1151 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event))); 1157 DidHandleMouseEvent(*(static_cast<const WebMouseEvent*>(input_event)));
1152 if (WebInputEvent::isTouchEventType(input_event->type)) 1158 if (WebInputEvent::isTouchEventType(input_event->type))
1153 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event))); 1159 DidHandleTouchEvent(*(static_cast<const WebTouchEvent*>(input_event)));
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 1814
1809 void RenderWidget::willBeginCompositorFrame() { 1815 void RenderWidget::willBeginCompositorFrame() {
1810 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1816 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1811 1817
1812 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); 1818 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get());
1813 1819
1814 // The following two can result in further layout and possibly 1820 // The following two can result in further layout and possibly
1815 // enable GPU acceleration so they need to be called before any painting 1821 // enable GPU acceleration so they need to be called before any painting
1816 // is done. 1822 // is done.
1817 UpdateTextInputType(); 1823 UpdateTextInputType();
1818 #if defined(OS_ANDROID) 1824 #if defined(OS_ANDROID) || defined(USE_AURA)
1819 UpdateTextInputState(false, true); 1825 UpdateTextInputState(false, true);
1820 #endif 1826 #endif
1821 UpdateSelectionBounds(); 1827 UpdateSelectionBounds();
1822 } 1828 }
1823 1829
1824 void RenderWidget::didBecomeReadyForAdditionalInput() { 1830 void RenderWidget::didBecomeReadyForAdditionalInput() {
1825 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); 1831 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput");
1826 if (pending_input_event_ack_) 1832 if (pending_input_event_ack_)
1827 Send(pending_input_event_ack_.release()); 1833 Send(pending_input_event_ack_.release());
1828 } 1834 }
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 view_screen_rect_ = view_screen_rect; 2241 view_screen_rect_ = view_screen_rect;
2236 window_screen_rect_ = window_screen_rect; 2242 window_screen_rect_ = window_screen_rect;
2237 } 2243 }
2238 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); 2244 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id()));
2239 } 2245 }
2240 2246
2241 #if defined(OS_ANDROID) 2247 #if defined(OS_ANDROID)
2242 void RenderWidget::OnShowImeIfNeeded() { 2248 void RenderWidget::OnShowImeIfNeeded() {
2243 UpdateTextInputState(true, true); 2249 UpdateTextInputState(true, true);
2244 } 2250 }
2251 #endif
2245 2252
2253 #if defined(OS_ANDROID) || defined(USE_AURA)
2246 void RenderWidget::IncrementOutstandingImeEventAcks() { 2254 void RenderWidget::IncrementOutstandingImeEventAcks() {
2247 ++outstanding_ime_acks_; 2255 ++outstanding_ime_acks_;
2248 } 2256 }
2249 2257
2250 void RenderWidget::OnImeEventAck() { 2258 void RenderWidget::OnImeEventAck() {
2251 --outstanding_ime_acks_; 2259 --outstanding_ime_acks_;
2252 DCHECK(outstanding_ime_acks_ >= 0); 2260 DCHECK(outstanding_ime_acks_ >= 0);
2253 } 2261 }
2254 #endif 2262 #endif
2255 2263
2256 bool RenderWidget::ShouldHandleImeEvent() { 2264 bool RenderWidget::ShouldHandleImeEvent() {
2257 #if defined(OS_ANDROID) 2265 #if defined(OS_ANDROID) || defined(USE_AURA)
2258 return !!webwidget_ && outstanding_ime_acks_ == 0; 2266 return !!webwidget_ && outstanding_ime_acks_ == 0;
2259 #else 2267 #else
2260 return !!webwidget_; 2268 return !!webwidget_;
2261 #endif 2269 #endif
2262 } 2270 }
2263 2271
2264 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { 2272 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
2265 if (device_scale_factor_ == device_scale_factor) 2273 if (device_scale_factor_ == device_scale_factor)
2266 return; 2274 return;
2267 2275
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 handling_ime_event_ = true; 2373 handling_ime_event_ = true;
2366 } 2374 }
2367 2375
2368 void RenderWidget::FinishHandlingImeEvent() { 2376 void RenderWidget::FinishHandlingImeEvent() {
2369 DCHECK(handling_ime_event_); 2377 DCHECK(handling_ime_event_);
2370 handling_ime_event_ = false; 2378 handling_ime_event_ = false;
2371 // While handling an ime event, text input state and selection bounds updates 2379 // While handling an ime event, text input state and selection bounds updates
2372 // are ignored. These must explicitly be updated once finished handling the 2380 // are ignored. These must explicitly be updated once finished handling the
2373 // ime event. 2381 // ime event.
2374 UpdateSelectionBounds(); 2382 UpdateSelectionBounds();
2375 #if defined(OS_ANDROID) 2383 #if defined(OS_ANDROID) || defined(USE_AURA)
2376 UpdateTextInputState(false, false); 2384 UpdateTextInputState(false, false);
2377 #endif 2385 #endif
2378 } 2386 }
2379 2387
2380 void RenderWidget::UpdateTextInputType() { 2388 void RenderWidget::UpdateTextInputType() {
2381 // On Windows, not only an IME but also an on-screen keyboard relies on the 2389 // On Windows, not only an IME but also an on-screen keyboard relies on the
2382 // latest TextInputType to optimize its layout and functionality. Thus 2390 // latest TextInputType to optimize its layout and functionality. Thus
2383 // |input_method_is_active_| is no longer an appropriate condition to suppress 2391 // |input_method_is_active_| is no longer an appropriate condition to suppress
2384 // TextInputTypeChanged IPC on Windows. 2392 // TextInputTypeChanged IPC on Windows.
2385 // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_| 2393 // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_|
(...skipping 20 matching lines...) Expand all
2406 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), 2414 Send(new ViewHostMsg_TextInputTypeChanged(routing_id(),
2407 new_type, 2415 new_type,
2408 new_mode, 2416 new_mode,
2409 new_can_compose_inline)); 2417 new_can_compose_inline));
2410 text_input_type_ = new_type; 2418 text_input_type_ = new_type;
2411 can_compose_inline_ = new_can_compose_inline; 2419 can_compose_inline_ = new_can_compose_inline;
2412 text_input_mode_ = new_mode; 2420 text_input_mode_ = new_mode;
2413 } 2421 }
2414 } 2422 }
2415 2423
2416 #if defined(OS_ANDROID) 2424 #if defined(OS_ANDROID) || defined(USE_AURA)
2417 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed, 2425 void RenderWidget::UpdateTextInputState(bool show_ime_if_needed,
2418 bool send_ime_ack) { 2426 bool send_ime_ack) {
2419 if (handling_ime_event_) 2427 if (handling_ime_event_)
2420 return; 2428 return;
2421 if (!show_ime_if_needed && !input_method_is_active_) 2429 if (!show_ime_if_needed && !input_method_is_active_)
2422 return; 2430 return;
2423 ui::TextInputType new_type = GetTextInputType(); 2431 ui::TextInputType new_type = GetTextInputType();
2424 if (IsDateTimeInput(new_type)) 2432 if (IsDateTimeInput(new_type))
2425 return; // Not considered as a text input field in WebKit/Chromium. 2433 return; // Not considered as a text input field in WebKit/Chromium.
2426 2434
2427 WebKit::WebTextInputInfo new_info; 2435 WebKit::WebTextInputInfo new_info;
2428 if (webwidget_) 2436 if (webwidget_)
2429 new_info = webwidget_->textInputInfo(); 2437 new_info = webwidget_->textInputInfo();
2430 2438
2439 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
2431 bool new_can_compose_inline = CanComposeInline(); 2440 bool new_can_compose_inline = CanComposeInline();
2432 2441
2433 // Only sends text input params if they are changed or if the ime should be 2442 // Only sends text input params if they are changed or if the ime should be
2434 // shown. 2443 // shown.
2435 if (show_ime_if_needed || (text_input_type_ != new_type 2444 if (show_ime_if_needed || (text_input_type_ != new_type
2436 || text_input_info_ != new_info 2445 || text_input_info_ != new_info
2437 || can_compose_inline_ != new_can_compose_inline)) { 2446 || can_compose_inline_ != new_can_compose_inline)) {
2438 ViewHostMsg_TextInputState_Params p; 2447 ViewHostMsg_TextInputState_Params p;
2439 p.type = new_type; 2448 p.type = new_type;
2449 p.mode = new_mode;
2440 p.value = new_info.value.utf8(); 2450 p.value = new_info.value.utf8();
2441 p.selection_start = new_info.selectionStart; 2451 p.selection_start = new_info.selectionStart;
2442 p.selection_end = new_info.selectionEnd; 2452 p.selection_end = new_info.selectionEnd;
2443 p.composition_start = new_info.compositionStart; 2453 p.composition_start = new_info.compositionStart;
2444 p.composition_end = new_info.compositionEnd; 2454 p.composition_end = new_info.compositionEnd;
2445 p.can_compose_inline = new_can_compose_inline; 2455 p.can_compose_inline = new_can_compose_inline;
2446 p.show_ime_if_needed = show_ime_if_needed; 2456 p.show_ime_if_needed = show_ime_if_needed;
2447 p.require_ack = send_ime_ack; 2457 p.require_ack = send_ime_ack;
2448 if (p.require_ack) 2458 if (p.require_ack)
2449 IncrementOutstandingImeEventAcks(); 2459 IncrementOutstandingImeEventAcks();
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2615 } 2625 }
2616 2626
2617 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA) 2627 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(USE_AURA)
2618 UpdateCompositionInfo(true); 2628 UpdateCompositionInfo(true);
2619 #endif 2629 #endif
2620 } 2630 }
2621 2631
2622 void RenderWidget::didHandleGestureEvent( 2632 void RenderWidget::didHandleGestureEvent(
2623 const WebGestureEvent& event, 2633 const WebGestureEvent& event,
2624 bool event_cancelled) { 2634 bool event_cancelled) {
2625 #if defined(OS_ANDROID) 2635 #if defined(OS_ANDROID) || defined(USE_AURA)
2626 if (event_cancelled) 2636 if (event_cancelled)
2627 return; 2637 return;
2628 if (event.type == WebInputEvent::GestureTap || 2638 if (event.type == WebInputEvent::GestureTap ||
2629 event.type == WebInputEvent::GestureLongPress) { 2639 event.type == WebInputEvent::GestureLongPress) {
2630 UpdateTextInputState(true, true); 2640 UpdateTextInputState(true, true);
2631 } 2641 }
2632 #endif 2642 #endif
2633 } 2643 }
2634 2644
2635 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { 2645 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 kDefaultCommandBufferSize, 2803 kDefaultCommandBufferSize,
2794 kDefaultStartTransferBufferSize, 2804 kDefaultStartTransferBufferSize,
2795 kDefaultMinTransferBufferSize, 2805 kDefaultMinTransferBufferSize,
2796 kDefaultMaxTransferBufferSize, 2806 kDefaultMaxTransferBufferSize,
2797 mapped_memory_reclaim_limit)) 2807 mapped_memory_reclaim_limit))
2798 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); 2808 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>();
2799 return context.Pass(); 2809 return context.Pass();
2800 } 2810 }
2801 2811
2802 } // namespace content 2812 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698