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

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

Issue 2442323004: Revert "Simplify handling of text input types in RenderWidget." (Closed)
Patch Set: Rebased. Created 4 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') | third_party/WebKit/public/web/WebTextInputType.h » ('j') | 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 <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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { 144 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override {
145 // The WebWidget handles mouse lock in Blink's handleInputEvent(). 145 // The WebWidget handles mouse lock in Blink's handleInputEvent().
146 return false; 146 return false;
147 } 147 }
148 148
149 private: 149 private:
150 blink::WebWidget* webwidget_; 150 blink::WebWidget* webwidget_;
151 }; 151 };
152 152
153 bool IsDateTimeInput(ui::TextInputType type) {
154 return type == ui::TEXT_INPUT_TYPE_DATE ||
155 type == ui::TEXT_INPUT_TYPE_DATE_TIME ||
156 type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL ||
157 type == ui::TEXT_INPUT_TYPE_MONTH ||
158 type == ui::TEXT_INPUT_TYPE_TIME || type == ui::TEXT_INPUT_TYPE_WEEK;
159 }
160
153 content::RenderWidgetInputHandlerDelegate* GetRenderWidgetInputHandlerDelegate( 161 content::RenderWidgetInputHandlerDelegate* GetRenderWidgetInputHandlerDelegate(
154 content::RenderWidget* widget) { 162 content::RenderWidget* widget) {
155 #if defined(USE_AURA) 163 #if defined(USE_AURA)
156 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess(); 164 const base::CommandLine& cmdline = *base::CommandLine::ForCurrentProcess();
157 if (content::ServiceManagerConnection::GetForProcess() && 165 if (content::ServiceManagerConnection::GetForProcess() &&
158 cmdline.HasSwitch(switches::kUseMusInRenderer)) { 166 cmdline.HasSwitch(switches::kUseMusInRenderer)) {
159 return content::RenderWidgetMusConnection::GetOrCreate( 167 return content::RenderWidgetMusConnection::GetOrCreate(
160 widget->routing_id()); 168 widget->routing_id());
161 } 169 }
162 #endif 170 #endif
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 is_hidden_(hidden), 218 is_hidden_(hidden),
211 compositor_never_visible_(never_visible), 219 compositor_never_visible_(never_visible),
212 is_fullscreen_granted_(false), 220 is_fullscreen_granted_(false),
213 display_mode_(blink::WebDisplayModeUndefined), 221 display_mode_(blink::WebDisplayModeUndefined),
214 ime_event_guard_(nullptr), 222 ime_event_guard_(nullptr),
215 ime_in_batch_edit_(false), 223 ime_in_batch_edit_(false),
216 closing_(false), 224 closing_(false),
217 host_closing_(false), 225 host_closing_(false),
218 is_swapped_out_(swapped_out), 226 is_swapped_out_(swapped_out),
219 for_oopif_(false), 227 for_oopif_(false),
228 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
220 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 229 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
221 text_input_flags_(0), 230 text_input_flags_(0),
222 can_compose_inline_(true), 231 can_compose_inline_(true),
223 composition_range_(gfx::Range::InvalidRange()), 232 composition_range_(gfx::Range::InvalidRange()),
224 popup_type_(popup_type), 233 popup_type_(popup_type),
225 pending_window_rect_count_(0), 234 pending_window_rect_count_(0),
226 screen_info_(screen_info), 235 screen_info_(screen_info),
227 device_scale_factor_(screen_info_.device_scale_factor), 236 device_scale_factor_(screen_info_.device_scale_factor),
228 #if defined(OS_ANDROID) 237 #if defined(OS_ANDROID)
229 text_field_is_dirty_(false), 238 text_field_is_dirty_(false),
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); 901 TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState");
893 if (ime_event_guard_) { 902 if (ime_event_guard_) {
894 // show_ime should still be effective even if it was set inside the IME 903 // show_ime should still be effective even if it was set inside the IME
895 // event guard. 904 // event guard.
896 if (show_ime == ShowIme::IF_NEEDED) { 905 if (show_ime == ShowIme::IF_NEEDED) {
897 ime_event_guard_->set_show_ime(true); 906 ime_event_guard_->set_show_ime(true);
898 } 907 }
899 return; 908 return;
900 } 909 }
901 910
902 if (!GetWebWidget()) 911 ui::TextInputType new_type = GetTextInputType();
903 return; 912 if (IsDateTimeInput(new_type))
913 return; // Not considered as a text input field in WebKit/Chromium.
904 914
905 blink::WebTextInputInfo new_info = GetWebWidget()->textInputInfo(); 915 blink::WebTextInputInfo new_info;
906 916 if (GetWebWidget())
917 new_info = GetWebWidget()->textInputInfo();
907 const ui::TextInputMode new_mode = 918 const ui::TextInputMode new_mode =
908 ConvertWebTextInputMode(new_info.inputMode); 919 ConvertWebTextInputMode(new_info.inputMode);
909 920
910 bool new_can_compose_inline = CanComposeInline(); 921 bool new_can_compose_inline = CanComposeInline();
911 922
912 // Only sends text input params if they are changed or if the ime should be 923 // Only sends text input params if they are changed or if the ime should be
913 // shown. 924 // shown.
914 if (show_ime == ShowIme::IF_NEEDED || 925 if (show_ime == ShowIme::IF_NEEDED ||
915 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) || 926 (IsUsingImeThread() && change_source == ChangeSource::FROM_IME) ||
916 (text_input_mode_ != new_mode || text_input_info_ != new_info || 927 (text_input_type_ != new_type || text_input_mode_ != new_mode ||
928 text_input_info_ != new_info ||
917 can_compose_inline_ != new_can_compose_inline) 929 can_compose_inline_ != new_can_compose_inline)
918 #if defined(OS_ANDROID) 930 #if defined(OS_ANDROID)
919 || text_field_is_dirty_ 931 || text_field_is_dirty_
920 #endif 932 #endif
921 ) { 933 ) {
922 TextInputState params; 934 TextInputState params;
923 params.type = ConvertWebTextInputType(new_info.type); 935 params.type = new_type;
924 params.mode = new_mode; 936 params.mode = new_mode;
925 params.flags = new_info.flags; 937 params.flags = new_info.flags;
926 params.value = new_info.value.utf8(); 938 params.value = new_info.value.utf8();
927 params.selection_start = new_info.selectionStart; 939 params.selection_start = new_info.selectionStart;
928 params.selection_end = new_info.selectionEnd; 940 params.selection_end = new_info.selectionEnd;
929 params.composition_start = new_info.compositionStart; 941 params.composition_start = new_info.compositionStart;
930 params.composition_end = new_info.compositionEnd; 942 params.composition_end = new_info.compositionEnd;
931 params.can_compose_inline = new_can_compose_inline; 943 params.can_compose_inline = new_can_compose_inline;
932 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED); 944 params.show_ime_if_needed = (show_ime == ShowIme::IF_NEEDED);
933 #if defined(USE_AURA) 945 #if defined(USE_AURA)
934 params.is_non_ime_change = true; 946 params.is_non_ime_change = true;
935 #endif 947 #endif
936 #if defined(OS_ANDROID) 948 #if defined(OS_ANDROID)
937 params.is_non_ime_change = 949 params.is_non_ime_change =
938 (change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_; 950 (change_source == ChangeSource::FROM_NON_IME) || text_field_is_dirty_;
939 params.batch_edit = ime_in_batch_edit_; 951 params.batch_edit = ime_in_batch_edit_;
940 if (params.is_non_ime_change) 952 if (params.is_non_ime_change)
941 OnImeEventSentForAck(new_info); 953 OnImeEventSentForAck(new_info);
942 text_field_is_dirty_ = false; 954 text_field_is_dirty_ = false;
943 #endif 955 #endif
944 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params)); 956 Send(new ViewHostMsg_TextInputStateChanged(routing_id(), params));
945 957
946 text_input_info_ = new_info; 958 text_input_info_ = new_info;
959 text_input_type_ = new_type;
947 text_input_mode_ = new_mode; 960 text_input_mode_ = new_mode;
948 can_compose_inline_ = new_can_compose_inline; 961 can_compose_inline_ = new_can_compose_inline;
949 text_input_flags_ = new_info.flags; 962 text_input_flags_ = new_info.flags;
950 } 963 }
951 } 964 }
952 965
953 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { 966 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) {
954 if (owner_delegate_) 967 if (owner_delegate_)
955 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); 968 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event);
956 969
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 break; 1945 break;
1933 } 1946 }
1934 web_screen_info.orientationAngle = screen_info_.orientation_angle; 1947 web_screen_info.orientationAngle = screen_info_.orientation_angle;
1935 return web_screen_info; 1948 return web_screen_info;
1936 } 1949 }
1937 1950
1938 void RenderWidget::resetInputMethod() { 1951 void RenderWidget::resetInputMethod() {
1939 ImeEventGuard guard(this); 1952 ImeEventGuard guard(this);
1940 // If the last text input type is not None, then we should finish any 1953 // If the last text input type is not None, then we should finish any
1941 // ongoing composition regardless of the new text input type. 1954 // ongoing composition regardless of the new text input type.
1942 if (text_input_info_.type != blink::WebTextInputTypeNone) { 1955 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
1943 // If a composition text exists, then we need to let the browser process 1956 // If a composition text exists, then we need to let the browser process
1944 // to cancel the input method's ongoing composition session. 1957 // to cancel the input method's ongoing composition session.
1945 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection)) 1958 if (GetWebWidget()->finishComposingText(WebWidget::DoNotKeepSelection))
1946 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1959 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1947 } 1960 }
1948 1961
1949 UpdateCompositionInfo(false /* not an immediate request */); 1962 UpdateCompositionInfo(false /* not an immediate request */);
1950 } 1963 }
1951 1964
1952 #if defined(OS_ANDROID) 1965 #if defined(OS_ANDROID)
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 bool RenderWidget::isPointerLocked() { 2098 bool RenderWidget::isPointerLocked() {
2086 return mouse_lock_dispatcher_->IsMouseLockedTo( 2099 return mouse_lock_dispatcher_->IsMouseLockedTo(
2087 webwidget_mouse_lock_target_.get()); 2100 webwidget_mouse_lock_target_.get());
2088 } 2101 }
2089 2102
2090 blink::WebWidget* RenderWidget::GetWebWidget() const { 2103 blink::WebWidget* RenderWidget::GetWebWidget() const {
2091 return webwidget_internal_; 2104 return webwidget_internal_;
2092 } 2105 }
2093 2106
2094 } // namespace content 2107 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | third_party/WebKit/public/web/WebTextInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698