| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { | 184 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { |
| 185 static TextInputModeMapSingleton* singleton = | 185 static TextInputModeMapSingleton* singleton = |
| 186 TextInputModeMapSingleton::GetInstance(); | 186 TextInputModeMapSingleton::GetInstance(); |
| 187 TextInputModeMap::const_iterator it = | 187 TextInputModeMap::const_iterator it = |
| 188 singleton->map().find(input_mode.utf8()); | 188 singleton->map().find(input_mode.utf8()); |
| 189 if (it == singleton->map().end()) | 189 if (it == singleton->map().end()) |
| 190 return ui::TEXT_INPUT_MODE_DEFAULT; | 190 return ui::TEXT_INPUT_MODE_DEFAULT; |
| 191 return it->second; | 191 return it->second; |
| 192 } | 192 } |
| 193 | 193 |
| 194 bool IsDateTimeInput(ui::TextInputType type) { |
| 195 return type == ui::TEXT_INPUT_TYPE_DATE || |
| 196 type == ui::TEXT_INPUT_TYPE_DATE_TIME || |
| 197 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || |
| 198 type == ui::TEXT_INPUT_TYPE_MONTH || |
| 199 type == ui::TEXT_INPUT_TYPE_TIME || type == ui::TEXT_INPUT_TYPE_WEEK; |
| 200 } |
| 201 |
| 194 content::RenderWidgetInputHandlerDelegate* GetRenderWidgetInputHandlerDelegate( | 202 content::RenderWidgetInputHandlerDelegate* GetRenderWidgetInputHandlerDelegate( |
| 195 content::RenderWidget* widget) { | 203 content::RenderWidget* widget) { |
| 196 #if defined(USE_AURA) | 204 #if defined(USE_AURA) |
| 197 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); | 205 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); |
| 198 if (content::ServiceManagerConnection::GetForProcess() && | 206 if (content::ServiceManagerConnection::GetForProcess() && |
| 199 cmdline.HasSwitch(switches::kUseMusInRenderer)) { | 207 cmdline.HasSwitch(switches::kUseMusInRenderer)) { |
| 200 return content::RenderWidgetMusConnection::GetOrCreate( | 208 return content::RenderWidgetMusConnection::GetOrCreate( |
| 201 widget->routing_id()); | 209 widget->routing_id()); |
| 202 } | 210 } |
| 203 #endif | 211 #endif |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 is_hidden_(hidden), | 245 is_hidden_(hidden), |
| 238 compositor_never_visible_(never_visible), | 246 compositor_never_visible_(never_visible), |
| 239 is_fullscreen_granted_(false), | 247 is_fullscreen_granted_(false), |
| 240 display_mode_(blink::WebDisplayModeUndefined), | 248 display_mode_(blink::WebDisplayModeUndefined), |
| 241 ime_event_guard_(nullptr), | 249 ime_event_guard_(nullptr), |
| 242 ime_in_batch_edit_(false), | 250 ime_in_batch_edit_(false), |
| 243 closing_(false), | 251 closing_(false), |
| 244 host_closing_(false), | 252 host_closing_(false), |
| 245 is_swapped_out_(swapped_out), | 253 is_swapped_out_(swapped_out), |
| 246 for_oopif_(false), | 254 for_oopif_(false), |
| 255 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 247 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 256 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 248 text_input_flags_(0), | 257 text_input_flags_(0), |
| 249 can_compose_inline_(true), | 258 can_compose_inline_(true), |
| 250 composition_range_(gfx::Range::InvalidRange()), | 259 composition_range_(gfx::Range::InvalidRange()), |
| 251 popup_type_(popup_type), | 260 popup_type_(popup_type), |
| 252 pending_window_rect_count_(0), | 261 pending_window_rect_count_(0), |
| 253 screen_info_(screen_info), | 262 screen_info_(screen_info), |
| 254 device_scale_factor_(screen_info_.device_scale_factor), | 263 device_scale_factor_(screen_info_.device_scale_factor), |
| 255 #if defined(OS_ANDROID) | 264 #if defined(OS_ANDROID) |
| 256 text_field_is_dirty_(false), | 265 text_field_is_dirty_(false), |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); | 956 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); |
| 948 if (ime_event_guard_) { | 957 if (ime_event_guard_) { |
| 949 // show_ime should still be effective even if it was set inside the IME | 958 // show_ime should still be effective even if it was set inside the IME |
| 950 // event guard. | 959 // event guard. |
| 951 if (show_ime == ShowIme::IF_NEEDED) { | 960 if (show_ime == ShowIme::IF_NEEDED) { |
| 952 ime_event_guard_->set_show_ime(true); | 961 ime_event_guard_->set_show_ime(true); |
| 953 } | 962 } |
| 954 return; | 963 return; |
| 955 } | 964 } |
| 956 | 965 |
| 957 if (!GetWebWidget()) | 966 ui::TextInputType new_type = GetTextInputType(); |
| 958 return; | 967 if (IsDateTimeInput(new_type)) |
| 968 return; // Not considered as a text input field in WebKit/Chromium. |
| 959 | 969 |
| 960 blink::WebTextInputInfo new_info = GetWebWidget()->textInputInfo(); | 970 blink::WebTextInputInfo new_info; |
| 961 | 971 if (GetWebWidget()) |
| 972 new_info = GetWebWidget()->textInputInfo(); |
| 962 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); | 973 const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); |
| 963 | 974 |
| 964 bool new_can_compose_inline = CanComposeInline(); | 975 bool new_can_compose_inline = CanComposeInline(); |
| 965 | 976 |
| 966 // Only sends text input params if they are changed or if the ime should be | 977 // Only sends text input params if they are changed or if the ime should be |
| 967 // shown. | 978 // shown. |
| 968 if (show_ime == ShowIme::IF_NEEDED || | 979 if (show_ime == ShowIme::IF_NEEDED || |
| 969 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || | 980 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || |
| 970 (text_input_mode_ != new_mode || text_input_info_ != new_info || | 981 (text_input_type_ != new_type || text_input_mode_ != new_mode || |
| 982 text_input_info_ != new_info || |
| 971 can_compose_inline_ != new_can_compose_inline) | 983 can_compose_inline_ != new_can_compose_inline) |
| 972 #if defined(OS_ANDROID) | 984 #if defined(OS_ANDROID) |
| 973 || text_field_is_dirty_ | 985 || text_field_is_dirty_ |
| 974 #endif | 986 #endif |
| 975 ) { | 987 ) { |
| 976 TextInputState params; | 988 TextInputState params; |
| 977 params.type = WebKitToUiTextInputType(new_info.type); | 989 params.type = new_type; |
| 978 params.mode = new_mode; | 990 params.mode = new_mode; |
| 979 params.flags = new_info.flags; | 991 params.flags = new_info.flags; |
| 980 params.value = new_info.value.utf8(); | 992 params.value = new_info.value.utf8(); |
| 981 params.selection_start = new_info.selectionStart; | 993 params.selection_start = new_info.selectionStart; |
| 982 params.selection_end = new_info.selectionEnd; | 994 params.selection_end = new_info.selectionEnd; |
| 983 params.composition_start = new_info.compositionStart; | 995 params.composition_start = new_info.compositionStart; |
| 984 params.composition_end = new_info.compositionEnd; | 996 params.composition_end = new_info.compositionEnd; |
| 985 params.can_compose_inline = new_can_compose_inline; | 997 params.can_compose_inline = new_can_compose_inline; |
| 986 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED); | 998 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED); |
| 987 #if defined(USE_AURA) | 999 #if defined(USE_AURA) |
| 988 params.is_non_ime_change = true; | 1000 params.is_non_ime_change = true; |
| 989 #endif | 1001 #endif |
| 990 #if defined(OS_ANDROID) | 1002 #if defined(OS_ANDROID) |
| 991 params.is_non_ime_change = | 1003 params.is_non_ime_change = |
| 992 (change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_; | 1004 (change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_; |
| 993 params.batch_edit = ime_in_batch_edit_; | 1005 params.batch_edit = ime_in_batch_edit_; |
| 994 if (params.is_non_ime_change) | 1006 if (params.is_non_ime_change) |
| 995 OnImeEventSentForAck(new_info); | 1007 OnImeEventSentForAck(new_info); |
| 996 text_field_is_dirty_ = false; | 1008 text_field_is_dirty_ = false; |
| 997 #endif | 1009 #endif |
| 998 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params)); | 1010 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params)); |
| 999 | 1011 |
| 1000 text_input_info_ = new_info; | 1012 text_input_info_ = new_info; |
| 1013 text_input_type_ = new_type; |
| 1001 text_input_mode_ = new_mode; | 1014 text_input_mode_ = new_mode; |
| 1002 can_compose_inline_ = new_can_compose_inline; | 1015 can_compose_inline_ = new_can_compose_inline; |
| 1003 text_input_flags_ = new_info.flags; | 1016 text_input_flags_ = new_info.flags; |
| 1004 } | 1017 } |
| 1005 } | 1018 } |
| 1006 | 1019 |
| 1007 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { | 1020 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { |
| 1008 if (owner_delegate_) | 1021 if (owner_delegate_) |
| 1009 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); | 1022 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); |
| 1010 | 1023 |
| (...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2024 break; | 2037 break; |
| 2025 } | 2038 } |
| 2026 web_screen_info.orientationAngle = screen_info_.orientation_angle; | 2039 web_screen_info.orientationAngle = screen_info_.orientation_angle; |
| 2027 return web_screen_info; | 2040 return web_screen_info; |
| 2028 } | 2041 } |
| 2029 | 2042 |
| 2030 void RenderWidget::resetInputMethod() { | 2043 void RenderWidget::resetInputMethod() { |
| 2031 ImeEventGuard guard(this); | 2044 ImeEventGuard guard(this); |
| 2032 // If the last text input type is not None, then we should finish any | 2045 // If the last text input type is not None, then we should finish any |
| 2033 // ongoing composition regardless of the new text input type. | 2046 // ongoing composition regardless of the new text input type. |
| 2034 if (text_input_info_.type != blink::WebTextInputTypeNone) { | 2047 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { |
| 2035 // If a composition text exists, then we need to let the browser process | 2048 // If a composition text exists, then we need to let the browser process |
| 2036 // to cancel the input method's ongoing composition session. | 2049 // to cancel the input method's ongoing composition session. |
| 2037 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) | 2050 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) |
| 2038 Send(new InputHostMsg_ImeCancelComposition(routing_id())); | 2051 Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
| 2039 } | 2052 } |
| 2040 | 2053 |
| 2041 UpdateCompositionInfo(false /* not an immediate request */); | 2054 UpdateCompositionInfo(false /* not an immediate request */); |
| 2042 } | 2055 } |
| 2043 | 2056 |
| 2044 #if defined(OS_ANDROID) | 2057 #if defined(OS_ANDROID) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 bool RenderWidget::isPointerLocked() { | 2206 bool RenderWidget::isPointerLocked() { |
| 2194 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2207 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2195 webwidget_mouse_lock_target_.get()); | 2208 webwidget_mouse_lock_target_.get()); |
| 2196 } | 2209 } |
| 2197 | 2210 |
| 2198 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2211 blink::WebWidget* RenderWidget::GetWebWidget() const { |
| 2199 return webwidget_internal_; | 2212 return webwidget_internal_; |
| 2200 } | 2213 } |
| 2201 | 2214 |
| 2202 } // namespace content | 2215 } // namespace content |
| OLD | NEW |