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

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

Issue 1388283002: Fix OSK flickering issue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 5 years, 1 month 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 next_paint_flags_(0), 491 next_paint_flags_(0),
492 auto_resize_mode_(false), 492 auto_resize_mode_(false),
493 need_update_rect_for_auto_resize_(false), 493 need_update_rect_for_auto_resize_(false),
494 did_show_(false), 494 did_show_(false),
495 is_hidden_(hidden), 495 is_hidden_(hidden),
496 compositor_never_visible_(never_visible), 496 compositor_never_visible_(never_visible),
497 is_fullscreen_granted_(false), 497 is_fullscreen_granted_(false),
498 display_mode_(blink::WebDisplayModeUndefined), 498 display_mode_(blink::WebDisplayModeUndefined),
499 handling_input_event_(false), 499 handling_input_event_(false),
500 handling_event_overscroll_(nullptr), 500 handling_event_overscroll_(nullptr),
501 handling_ime_event_(false), 501 ime_guard_count_(0),
502 pending_show_ime_if_needed_(false),
502 handling_event_type_(WebInputEvent::Undefined), 503 handling_event_type_(WebInputEvent::Undefined),
503 ignore_ack_for_mouse_move_from_debugger_(false), 504 ignore_ack_for_mouse_move_from_debugger_(false),
504 closing_(false), 505 closing_(false),
505 host_closing_(false), 506 host_closing_(false),
506 is_swapped_out_(swapped_out), 507 is_swapped_out_(swapped_out),
507 for_oopif_(false), 508 for_oopif_(false),
508 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 509 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
509 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 510 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
510 text_input_flags_(0), 511 text_input_flags_(0),
511 can_compose_inline_(true), 512 can_compose_inline_(true),
512 popup_type_(popup_type), 513 popup_type_(popup_type),
513 pending_window_rect_count_(0), 514 pending_window_rect_count_(0),
514 suppress_next_char_events_(false), 515 suppress_next_char_events_(false),
515 screen_info_(screen_info), 516 screen_info_(screen_info),
516 device_scale_factor_(screen_info_.deviceScaleFactor), 517 device_scale_factor_(screen_info_.deviceScaleFactor),
517 next_output_surface_id_(0), 518 next_output_surface_id_(0),
518 #if defined(OS_ANDROID) 519 #if defined(OS_ANDROID)
519 text_field_is_dirty_(false), 520 text_field_is_dirty_(false),
521 pending_update_from_non_ime_(false),
520 #endif 522 #endif
521 popup_origin_scale_for_emulation_(0.f), 523 popup_origin_scale_for_emulation_(0.f),
522 frame_swap_message_queue_(new FrameSwapMessageQueue()), 524 frame_swap_message_queue_(new FrameSwapMessageQueue()),
523 resizing_mode_selector_(new ResizingModeSelector()), 525 resizing_mode_selector_(new ResizingModeSelector()),
524 context_menu_source_type_(ui::MENU_SOURCE_MOUSE), 526 context_menu_source_type_(ui::MENU_SOURCE_MOUSE),
525 has_host_context_menu_location_(false) { 527 has_host_context_menu_location_(false) {
526 if (!swapped_out) 528 if (!swapped_out)
527 RenderProcess::current()->AddRefProcess(); 529 RenderProcess::current()->AddRefProcess();
528 DCHECK(RenderThread::Get()); 530 DCHECK(RenderThread::Get());
529 device_color_profile_.push_back('0'); 531 device_color_profile_.push_back('0');
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 &handling_event_type_, input_event->type); 1065 &handling_event_type_, input_event->type);
1064 1066
1065 // Calls into |didOverscroll()| while handling this event will populate 1067 // Calls into |didOverscroll()| while handling this event will populate
1066 // |event_overscroll|, which in turn will be bundled with the event ack. 1068 // |event_overscroll|, which in turn will be bundled with the event ack.
1067 scoped_ptr<DidOverscrollParams> event_overscroll; 1069 scoped_ptr<DidOverscrollParams> event_overscroll;
1068 base::AutoReset<scoped_ptr<DidOverscrollParams>*> 1070 base::AutoReset<scoped_ptr<DidOverscrollParams>*>
1069 handling_event_overscroll_resetter(&handling_event_overscroll_, 1071 handling_event_overscroll_resetter(&handling_event_overscroll_,
1070 &event_overscroll); 1072 &event_overscroll);
1071 1073
1072 #if defined(OS_ANDROID) 1074 #if defined(OS_ANDROID)
1073 // On Android, when a key is pressed or sent from the Keyboard using IME, 1075 const bool is_keyboard_event =
1074 // |AdapterInputConnection| generates input key events to make sure all JS 1076 WebInputEvent::isKeyboardEventType(input_event->type);
1075 // listeners that monitor KeyUp and KeyDown events receive the proper key 1077
1076 // code. Since this input key event comes from IME, we need to set the 1078 // For non-keyboard events, we want the change source to be FROM_NON_IME.
1077 // IME event guard here to make sure it does not interfere with other IME 1079 ImeEventGuard guard(this, !is_keyboard_event);
1078 // events.
1079 scoped_ptr<ImeEventGuard> ime_event_guard_maybe;
1080 if (WebInputEvent::isKeyboardEventType(input_event->type)) {
1081 const WebKeyboardEvent& key_event =
1082 *static_cast<const WebKeyboardEvent*>(input_event);
1083 // Some keys are special and it's essential that no events get blocked.
1084 if (key_event.nativeKeyCode != AKEYCODE_TAB &&
1085 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER &&
1086 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT &&
1087 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT &&
1088 key_event.nativeKeyCode != AKEYCODE_DPAD_UP &&
1089 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN)
1090 ime_event_guard_maybe.reset(new ImeEventGuard(this));
1091 }
1092 #endif 1080 #endif
1093 1081
1094 base::TimeTicks start_time; 1082 base::TimeTicks start_time;
1095 if (base::TimeTicks::IsHighResolution()) 1083 if (base::TimeTicks::IsHighResolution())
1096 start_time = base::TimeTicks::Now(); 1084 start_time = base::TimeTicks::Now();
1097 1085
1098 TRACE_EVENT1("renderer,benchmark", "RenderWidget::OnHandleInputEvent", 1086 TRACE_EVENT1("renderer,benchmark", "RenderWidget::OnHandleInputEvent",
1099 "event", WebInputEventTraits::GetName(input_event->type)); 1087 "event", WebInputEventTraits::GetName(input_event->type));
1100 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); 1088 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent");
1101 TRACE_EVENT_WITH_FLOW1("input,benchmark", 1089 TRACE_EVENT_WITH_FLOW1("input,benchmark",
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 1858
1871 static bool IsDateTimeInput(ui::TextInputType type) { 1859 static bool IsDateTimeInput(ui::TextInputType type) {
1872 return type == ui::TEXT_INPUT_TYPE_DATE || 1860 return type == ui::TEXT_INPUT_TYPE_DATE ||
1873 type == ui::TEXT_INPUT_TYPE_DATE_TIME || 1861 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
1874 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || 1862 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
1875 type == ui::TEXT_INPUT_TYPE_MONTH || 1863 type == ui::TEXT_INPUT_TYPE_MONTH ||
1876 type == ui::TEXT_INPUT_TYPE_TIME || 1864 type == ui::TEXT_INPUT_TYPE_TIME ||
1877 type == ui::TEXT_INPUT_TYPE_WEEK; 1865 type == ui::TEXT_INPUT_TYPE_WEEK;
1878 } 1866 }
1879 1867
1880 1868 void RenderWidget::OnImeEventGuardStart() {
1881 void RenderWidget::StartHandlingImeEvent() { 1869 ++ime_guard_count_;
1882 DCHECK(!handling_ime_event_);
1883 handling_ime_event_ = true;
1884 } 1870 }
1885 1871
1886 void RenderWidget::FinishHandlingImeEvent() { 1872 void RenderWidget::OnImeEventGuardFinish(bool from_non_ime) {
1887 DCHECK(handling_ime_event_); 1873 --ime_guard_count_;
1888 handling_ime_event_ = false; 1874 CHECK_GE(ime_guard_count_, 0);
1875 #if defined(OS_ANDROID)
1876 pending_update_from_non_ime_ |= from_non_ime;
no sievers 2015/10/26 20:13:12 Since we already have the guard class, it'd be nic
Changwan Ryu 2015/10/28 05:17:07 Hmm... The lifetime of one ImeEventGuard may be ne
Changwan Ryu 2015/10/28 16:25:51 My bad. Overlapping is not a possible scenario her
1877 #endif
1878 if (ime_guard_count_ > 0)
1879 return;
1880
1889 // While handling an ime event, text input state and selection bounds updates 1881 // While handling an ime event, text input state and selection bounds updates
1890 // are ignored. These must explicitly be updated once finished handling the 1882 // are ignored. These must explicitly be updated once finished handling the
1891 // ime event. 1883 // ime event.
1892 UpdateSelectionBounds(); 1884 UpdateSelectionBounds();
1893 #if defined(OS_ANDROID) 1885 #if defined(OS_ANDROID)
1894 UpdateTextInputState(NO_SHOW_IME, FROM_IME); 1886 UpdateTextInputState(NO_SHOW_IME,
1887 pending_update_from_non_ime_ ? FROM_NON_IME : FROM_IME);
1888 pending_update_from_non_ime_ = false;
1895 #endif 1889 #endif
1896 } 1890 }
1897 1891
1898 void RenderWidget::UpdateTextInputState(ShowIme show_ime, 1892 void RenderWidget::UpdateTextInputState(ShowIme show_ime,
1899 ChangeSource change_source) { 1893 ChangeSource change_source) {
1900 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); 1894 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
1901 if (handling_ime_event_) 1895 if (ime_guard_count_ > 0) {
1896 if (show_ime == SHOW_IME_IF_NEEDED)
1897 pending_show_ime_if_needed_ = true;
1898
1902 return; 1899 return;
1900 }
1901
1902 if (pending_show_ime_if_needed_) {
1903 show_ime = SHOW_IME_IF_NEEDED;
1904 pending_show_ime_if_needed_ = false;
1905 }
1906
1903 ui::TextInputType new_type = GetTextInputType(); 1907 ui::TextInputType new_type = GetTextInputType();
1904 if (IsDateTimeInput(new_type)) 1908 if (IsDateTimeInput(new_type))
1905 return; // Not considered as a text input field in WebKit/Chromium. 1909 return; // Not considered as a text input field in WebKit/Chromium.
1906 1910
1907 blink::WebTextInputInfo new_info; 1911 blink::WebTextInputInfo new_info;
1908 if (webwidget_) 1912 if (webwidget_)
1909 new_info = webwidget_->textInputInfo(); 1913 new_info = webwidget_->textInputInfo();
1910 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); 1914 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
1911 1915
1912 bool new_can_compose_inline = CanComposeInline(); 1916 bool new_can_compose_inline = CanComposeInline();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1958 WebRect anchor_webrect; 1962 WebRect anchor_webrect;
1959 webwidget_->selectionBounds(focus_webrect, anchor_webrect); 1963 webwidget_->selectionBounds(focus_webrect, anchor_webrect);
1960 *focus = focus_webrect; 1964 *focus = focus_webrect;
1961 *anchor = anchor_webrect; 1965 *anchor = anchor_webrect;
1962 } 1966 }
1963 1967
1964 void RenderWidget::UpdateSelectionBounds() { 1968 void RenderWidget::UpdateSelectionBounds() {
1965 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); 1969 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds");
1966 if (!webwidget_) 1970 if (!webwidget_)
1967 return; 1971 return;
1968 if (handling_ime_event_) 1972 if (ime_guard_count_ > 0)
1969 return; 1973 return;
1970 1974
1971 #if defined(USE_AURA) 1975 #if defined(USE_AURA)
1972 // TODO(mohsen): For now, always send explicit selection IPC notifications for 1976 // TODO(mohsen): For now, always send explicit selection IPC notifications for
1973 // Aura beucause composited selection updates are not working for webview tags 1977 // Aura beucause composited selection updates are not working for webview tags
1974 // which regresses IME inside webview. Remove this when composited selection 1978 // which regresses IME inside webview. Remove this when composited selection
1975 // updates are fixed for webviews. See, http://crbug.com/510568. 1979 // updates are fixed for webviews. See, http://crbug.com/510568.
1976 bool send_ipc = true; 1980 bool send_ipc = true;
1977 #else 1981 #else
1978 // With composited selection updates, the selection bounds will be reported 1982 // With composited selection updates, the selection bounds will be reported
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2401 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2398 video_hole_frames_.AddObserver(frame); 2402 video_hole_frames_.AddObserver(frame);
2399 } 2403 }
2400 2404
2401 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2405 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2402 video_hole_frames_.RemoveObserver(frame); 2406 video_hole_frames_.RemoveObserver(frame);
2403 } 2407 }
2404 #endif // defined(VIDEO_HOLE) 2408 #endif // defined(VIDEO_HOLE)
2405 2409
2406 } // namespace content 2410 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698