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

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: fixed a nit and updated comment 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 next_paint_flags_(0), 492 next_paint_flags_(0),
493 auto_resize_mode_(false), 493 auto_resize_mode_(false),
494 need_update_rect_for_auto_resize_(false), 494 need_update_rect_for_auto_resize_(false),
495 did_show_(false), 495 did_show_(false),
496 is_hidden_(hidden), 496 is_hidden_(hidden),
497 compositor_never_visible_(never_visible), 497 compositor_never_visible_(never_visible),
498 is_fullscreen_granted_(false), 498 is_fullscreen_granted_(false),
499 display_mode_(blink::WebDisplayModeUndefined), 499 display_mode_(blink::WebDisplayModeUndefined),
500 handling_input_event_(false), 500 handling_input_event_(false),
501 handling_event_overscroll_(nullptr), 501 handling_event_overscroll_(nullptr),
502 handling_ime_event_(false), 502 ime_event_guard_(nullptr),
503 handling_event_type_(WebInputEvent::Undefined), 503 handling_event_type_(WebInputEvent::Undefined),
504 ignore_ack_for_mouse_move_from_debugger_(false), 504 ignore_ack_for_mouse_move_from_debugger_(false),
505 closing_(false), 505 closing_(false),
506 host_closing_(false), 506 host_closing_(false),
507 is_swapped_out_(swapped_out), 507 is_swapped_out_(swapped_out),
508 for_oopif_(false), 508 for_oopif_(false),
509 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 509 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
510 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 510 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
511 text_input_flags_(0), 511 text_input_flags_(0),
512 can_compose_inline_(true), 512 can_compose_inline_(true),
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 &handling_event_type_, input_event->type); 1077 &handling_event_type_, input_event->type);
1078 1078
1079 // Calls into |didOverscroll()| while handling this event will populate 1079 // Calls into |didOverscroll()| while handling this event will populate
1080 // |event_overscroll|, which in turn will be bundled with the event ack. 1080 // |event_overscroll|, which in turn will be bundled with the event ack.
1081 scoped_ptr<DidOverscrollParams> event_overscroll; 1081 scoped_ptr<DidOverscrollParams> event_overscroll;
1082 base::AutoReset<scoped_ptr<DidOverscrollParams>*> 1082 base::AutoReset<scoped_ptr<DidOverscrollParams>*>
1083 handling_event_overscroll_resetter(&handling_event_overscroll_, 1083 handling_event_overscroll_resetter(&handling_event_overscroll_,
1084 &event_overscroll); 1084 &event_overscroll);
1085 1085
1086 #if defined(OS_ANDROID) 1086 #if defined(OS_ANDROID)
1087 // On Android, when a key is pressed or sent from the Keyboard using IME, 1087 const bool is_keyboard_event =
1088 // |AdapterInputConnection| generates input key events to make sure all JS 1088 WebInputEvent::isKeyboardEventType(input_event->type);
1089 // listeners that monitor KeyUp and KeyDown events receive the proper key 1089
1090 // code. Since this input key event comes from IME, we need to set the 1090 // For non-keyboard events, we want the change source to be FROM_NON_IME.
1091 // IME event guard here to make sure it does not interfere with other IME 1091 ImeEventGuard guard(this, false, is_keyboard_event);
1092 // events.
1093 scoped_ptr<ImeEventGuard> ime_event_guard_maybe;
1094 if (WebInputEvent::isKeyboardEventType(input_event->type)) {
1095 const WebKeyboardEvent& key_event =
1096 *static_cast<const WebKeyboardEvent*>(input_event);
1097 // Some keys are special and it's essential that no events get blocked.
1098 if (key_event.nativeKeyCode != AKEYCODE_TAB &&
1099 key_event.nativeKeyCode != AKEYCODE_DPAD_CENTER &&
1100 key_event.nativeKeyCode != AKEYCODE_DPAD_LEFT &&
1101 key_event.nativeKeyCode != AKEYCODE_DPAD_RIGHT &&
1102 key_event.nativeKeyCode != AKEYCODE_DPAD_UP &&
1103 key_event.nativeKeyCode != AKEYCODE_DPAD_DOWN)
1104 ime_event_guard_maybe.reset(new ImeEventGuard(this));
1105 }
1106 #endif 1092 #endif
1107 1093
1108 base::TimeTicks start_time; 1094 base::TimeTicks start_time;
1109 if (base::TimeTicks::IsHighResolution()) 1095 if (base::TimeTicks::IsHighResolution())
1110 start_time = base::TimeTicks::Now(); 1096 start_time = base::TimeTicks::Now();
1111 1097
1112 TRACE_EVENT1("renderer,benchmark", "RenderWidget::OnHandleInputEvent", 1098 TRACE_EVENT1("renderer,benchmark", "RenderWidget::OnHandleInputEvent",
1113 "event", WebInputEventTraits::GetName(input_event->type)); 1099 "event", WebInputEventTraits::GetName(input_event->type));
1114 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent"); 1100 TRACE_EVENT_SYNTHETIC_DELAY_BEGIN("blink.HandleInputEvent");
1115 TRACE_EVENT_WITH_FLOW1("input,benchmark", 1101 TRACE_EVENT_WITH_FLOW1("input,benchmark",
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 1870
1885 static bool IsDateTimeInput(ui::TextInputType type) { 1871 static bool IsDateTimeInput(ui::TextInputType type) {
1886 return type == ui::TEXT_INPUT_TYPE_DATE || 1872 return type == ui::TEXT_INPUT_TYPE_DATE ||
1887 type == ui::TEXT_INPUT_TYPE_DATE_TIME || 1873 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
1888 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || 1874 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
1889 type == ui::TEXT_INPUT_TYPE_MONTH || 1875 type == ui::TEXT_INPUT_TYPE_MONTH ||
1890 type == ui::TEXT_INPUT_TYPE_TIME || 1876 type == ui::TEXT_INPUT_TYPE_TIME ||
1891 type == ui::TEXT_INPUT_TYPE_WEEK; 1877 type == ui::TEXT_INPUT_TYPE_WEEK;
1892 } 1878 }
1893 1879
1894 1880 void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) {
1895 void RenderWidget::StartHandlingImeEvent() { 1881 if (!ime_event_guard_)
1896 DCHECK(!handling_ime_event_); 1882 ime_event_guard_ = guard;
1897 handling_ime_event_ = true;
1898 } 1883 }
1899 1884
1900 void RenderWidget::FinishHandlingImeEvent() { 1885 void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
1901 DCHECK(handling_ime_event_); 1886 if (ime_event_guard_ != guard) {
1902 handling_ime_event_ = false; 1887 #if defined(OS_ANDROID)
1888 // In case a from-IME event (e.g. touch) ends up in not-from-IME event
1889 // (e.g. long press gesture), we want to treat it as not-from-IME event
1890 // so that AdapterInputConnection can make changes to its Editable model.
1891 // Therefore, we want to mark this text state update as 'from IME' only
1892 // when all the nested events are all originating from IME.
1893 ime_event_guard_->set_from_ime(
1894 ime_event_guard_->from_ime() && guard->from_ime());
1895 #endif
1896 return;
1897 }
1898 ime_event_guard_ = nullptr;
1899
1903 // While handling an ime event, text input state and selection bounds updates 1900 // While handling an ime event, text input state and selection bounds updates
1904 // are ignored. These must explicitly be updated once finished handling the 1901 // are ignored. These must explicitly be updated once finished handling the
1905 // ime event. 1902 // ime event.
1906 UpdateSelectionBounds(); 1903 UpdateSelectionBounds();
1907 #if defined(OS_ANDROID) 1904 #if defined(OS_ANDROID)
1908 UpdateTextInputState(NO_SHOW_IME, FROM_IME); 1905 UpdateTextInputState(
1906 guard->show_ime() ? SHOW_IME_IF_NEEDED : NO_SHOW_IME,
1907 guard->from_ime() ? FROM_IME : FROM_NON_IME);
1909 #endif 1908 #endif
1910 } 1909 }
1911 1910
1912 void RenderWidget::UpdateTextInputState(ShowIme show_ime, 1911 void RenderWidget::UpdateTextInputState(ShowIme show_ime,
1913 ChangeSource change_source) { 1912 ChangeSource change_source) {
1914 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); 1913 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
1915 if (handling_ime_event_) 1914 if (ime_event_guard_) {
1915 // show_ime should still be effective even if it was set inside the IME
1916 // event guard.
1917 if (show_ime == SHOW_IME_IF_NEEDED) {
1918 ime_event_guard_->set_show_ime(true);
1919 }
1916 return; 1920 return;
1921 }
1922
1917 ui::TextInputType new_type = GetTextInputType(); 1923 ui::TextInputType new_type = GetTextInputType();
1918 if (IsDateTimeInput(new_type)) 1924 if (IsDateTimeInput(new_type))
1919 return; // Not considered as a text input field in WebKit/Chromium. 1925 return; // Not considered as a text input field in WebKit/Chromium.
1920 1926
1921 blink::WebTextInputInfo new_info; 1927 blink::WebTextInputInfo new_info;
1922 if (webwidget_) 1928 if (webwidget_)
1923 new_info = webwidget_->textInputInfo(); 1929 new_info = webwidget_->textInputInfo();
1924 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); 1930 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode);
1925 1931
1926 bool new_can_compose_inline = CanComposeInline(); 1932 bool new_can_compose_inline = CanComposeInline();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 WebRect anchor_webrect; 1978 WebRect anchor_webrect;
1973 webwidget_->selectionBounds(focus_webrect, anchor_webrect); 1979 webwidget_->selectionBounds(focus_webrect, anchor_webrect);
1974 *focus = focus_webrect; 1980 *focus = focus_webrect;
1975 *anchor = anchor_webrect; 1981 *anchor = anchor_webrect;
1976 } 1982 }
1977 1983
1978 void RenderWidget::UpdateSelectionBounds() { 1984 void RenderWidget::UpdateSelectionBounds() {
1979 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); 1985 TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds");
1980 if (!webwidget_) 1986 if (!webwidget_)
1981 return; 1987 return;
1982 if (handling_ime_event_) 1988 if (ime_event_guard_)
1983 return; 1989 return;
1984 1990
1985 #if defined(USE_AURA) 1991 #if defined(USE_AURA)
1986 // TODO(mohsen): For now, always send explicit selection IPC notifications for 1992 // TODO(mohsen): For now, always send explicit selection IPC notifications for
1987 // Aura beucause composited selection updates are not working for webview tags 1993 // Aura beucause composited selection updates are not working for webview tags
1988 // which regresses IME inside webview. Remove this when composited selection 1994 // which regresses IME inside webview. Remove this when composited selection
1989 // updates are fixed for webviews. See, http://crbug.com/510568. 1995 // updates are fixed for webviews. See, http://crbug.com/510568.
1990 bool send_ipc = true; 1996 bool send_ipc = true;
1991 #else 1997 #else
1992 // With composited selection updates, the selection bounds will be reported 1998 // With composited selection updates, the selection bounds will be reported
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
2411 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { 2417 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) {
2412 video_hole_frames_.AddObserver(frame); 2418 video_hole_frames_.AddObserver(frame);
2413 } 2419 }
2414 2420
2415 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { 2421 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) {
2416 video_hole_frames_.RemoveObserver(frame); 2422 video_hole_frames_.RemoveObserver(frame);
2417 } 2423 }
2418 #endif // defined(VIDEO_HOLE) 2424 #endif // defined(VIDEO_HOLE)
2419 2425
2420 } // namespace content 2426 } // 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