diff options
author | Shu Chen <shuchen@google.com> | 2014-10-21 01:18:45 +0800 |
---|---|---|
committer | Shu Chen <shuchen@google.com> | 2014-10-20 17:20:56 +0000 |
commit | 274aa5b7f0f4e3095a98d64b9ee2e8ed78621c38 (patch) | |
tree | 7bfb0e2a075a006a847dc8fe85a5f9f5c4a17a87 /content | |
parent | eab0388f8dc375b88827814915abfd008481bc83 (diff) | |
download | chromium_src-274aa5b7f0f4e3095a98d64b9ee2e8ed78621c38.zip chromium_src-274aa5b7f0f4e3095a98d64b9ee2e8ed78621c38.tar.gz chromium_src-274aa5b7f0f4e3095a98d64b9ee2e8ed78621c38.tar.bz2 |
Revert "Merge ViewHostMsg_TextInputTypeChanged and ViewHostMsg_TextInputStateChanged into one."
This reverts commit 2dd467c5edc6a802877f9a582a4278b5c5332dbd.
https://codereview.chromium.org/326403002/
Conflicts:
content/browser/browser_plugin/browser_plugin_guest.cc
content/browser/browser_plugin/browser_plugin_guest.h
content/browser/frame_host/render_widget_host_view_child_frame.cc
content/browser/frame_host/render_widget_host_view_child_frame.h
content/browser/frame_host/render_widget_host_view_guest.h
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
content/browser/renderer_host/render_widget_host_view_android.h
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/renderer_host/render_widget_host_view_base.h
content/browser/renderer_host/render_widget_host_view_mac.h
content/common/view_messages.h
content/renderer/render_frame_impl.cc
content/renderer/render_widget.cc
content/test/test_render_view_host.h
BUG=417152
TEST=None
Review URL: https://codereview.chromium.org/634313007
Cr-Commit-Position: refs/heads/master@{#299646}
(cherry picked from commit 3517bb6c601efad861dddcf01a16e2c68bf927c7)
Conflicts:
content/browser/frame_host/render_widget_host_view_child_frame.h
content/browser/frame_host/render_widget_host_view_guest.h
content/browser/renderer_host/render_widget_host_view_android.h
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/renderer_host/render_widget_host_view_mac.h
content/test/test_render_view_host.h
Review URL: https://codereview.chromium.org/663803003
Cr-Commit-Position: refs/branch-heads/2171@{#189}
Cr-Branched-From: 267aeeb8d85c8503a7fd12bd14654b8ea78d3974-refs/heads/master@{#297060}
Diffstat (limited to 'content')
23 files changed, 205 insertions, 115 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index f2a0f74..27905e8 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -119,11 +119,8 @@ void BrowserPluginGuest::SetFocus(RenderWidgetHost* rwh, bool focused) { RenderWidgetHostViewBase* rwhv = static_cast<RenderWidgetHostViewBase*>( rwh->GetView()); if (rwhv) { - ViewHostMsg_TextInputState_Params params; - params.type = last_text_input_type_; - params.mode = last_input_mode_; - params.can_compose_inline = last_can_compose_inline_; - rwhv->TextInputStateChanged(params); + rwhv->TextInputTypeChanged(last_text_input_type_, last_input_mode_, + last_can_compose_inline_); } } @@ -482,8 +479,8 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) - IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, - OnTextInputStateChanged) + IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, + OnTextInputTypeChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -784,15 +781,17 @@ void BrowserPluginGuest::OnTakeFocus(bool reverse) { new BrowserPluginMsg_AdvanceFocus(browser_plugin_instance_id(), reverse)); } -void BrowserPluginGuest::OnTextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { +void BrowserPluginGuest::OnTextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { // Save the state of text input so we can restore it on focus. - last_text_input_type_ = params.type; - last_input_mode_ = params.mode; - last_can_compose_inline_ = params.can_compose_inline; + last_text_input_type_ = type; + last_input_mode_ = input_mode; + last_can_compose_inline_ = can_compose_inline; static_cast<RenderWidgetHostViewBase*>( - web_contents()->GetRenderWidgetHostView())->TextInputStateChanged(params); + web_contents()->GetRenderWidgetHostView())->TextInputTypeChanged( + type, input_mode, can_compose_inline); } void BrowserPluginGuest::OnImeCancelComposition() { diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index cecca6d..05e4d14 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h @@ -45,7 +45,6 @@ struct FrameHostMsg_ReclaimCompositorResources_Params; #if defined(OS_MACOSX) struct FrameHostMsg_ShowPopup_Params; #endif -struct ViewHostMsg_TextInputState_Params; namespace blink { class WebInputEvent; @@ -285,9 +284,9 @@ class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver { void OnUnlockMouseAck(int instance_id); void OnUpdateGeometry(int instance_id, const gfx::Rect& view_rect); - void OnTextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params); - + void OnTextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline); void OnImeSetComposition( int instance_id, const std::string& text, diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.cc b/content/browser/frame_host/render_widget_host_view_child_frame.cc index 99e58e8..93d5cab 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.cc +++ b/content/browser/frame_host/render_widget_host_view_child_frame.cc @@ -150,8 +150,11 @@ void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) { NOTREACHED(); } -void RenderWidgetHostViewChildFrame::TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { +void RenderWidgetHostViewChildFrame::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { + NOTREACHED(); } void RenderWidgetHostViewChildFrame::RenderProcessGone( diff --git a/content/browser/frame_host/render_widget_host_view_child_frame.h b/content/browser/frame_host/render_widget_host_view_child_frame.h index 141a10c..33a7d18 100644 --- a/content/browser/frame_host/render_widget_host_view_child_frame.h +++ b/content/browser/frame_host/render_widget_host_view_child_frame.h @@ -11,8 +11,6 @@ #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" -struct ViewHostMsg_TextInputState_Params; - namespace content { class CrossProcessFrameConnector; class RenderWidgetHost; @@ -68,8 +66,9 @@ class CONTENT_EXPORT RenderWidgetHostViewChildFrame virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; #if defined(OS_MACOSX) || defined(USE_AURA) virtual void ImeCompositionRangeChanged( diff --git a/content/browser/frame_host/render_widget_host_view_guest.cc b/content/browser/frame_host/render_widget_host_view_guest.cc index bea8989..b4d6acf 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.cc +++ b/content/browser/frame_host/render_widget_host_view_guest.cc @@ -291,8 +291,10 @@ void RenderWidgetHostViewGuest::SetIsLoading(bool is_loading) { platform_view_->SetIsLoading(is_loading); } -void RenderWidgetHostViewGuest::TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { +void RenderWidgetHostViewGuest::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { if (!guest_) return; @@ -300,7 +302,7 @@ void RenderWidgetHostViewGuest::TextInputStateChanged( if (!rwhv) return; // Forward the information to embedding RWHV. - rwhv->TextInputStateChanged(params); + rwhv->TextInputTypeChanged(type, input_mode, can_compose_inline); } void RenderWidgetHostViewGuest::ImeCancelComposition() { diff --git a/content/browser/frame_host/render_widget_host_view_guest.h b/content/browser/frame_host/render_widget_host_view_guest.h index c807f9e..0da200c 100644 --- a/content/browser/frame_host/render_widget_host_view_guest.h +++ b/content/browser/frame_host/render_widget_host_view_guest.h @@ -18,8 +18,6 @@ #include "ui/gfx/rect.h" #include "ui/gfx/vector2d_f.h" -struct ViewHostMsg_TextInputState_Params; - namespace content { class BrowserPluginGuest; class RenderWidgetHost; @@ -75,8 +73,9 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest const std::vector<WebPluginGeometry>& moves) OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; #if defined(OS_MACOSX) || defined(USE_AURA) virtual void ImeCompositionRangeChanged( diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index f9fb437cd..a77279a 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -455,8 +455,8 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnFocus) IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnBlur) IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) - IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, - OnTextInputStateChanged) + IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputTypeChanged, + OnTextInputTypeChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, @@ -1669,10 +1669,12 @@ void RenderWidgetHostImpl::SetTouchEventEmulationEnabled(bool enabled) { } } -void RenderWidgetHostImpl::OnTextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { +void RenderWidgetHostImpl::OnTextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { if (view_) - view_->TextInputStateChanged(params); + view_->TextInputTypeChanged(type, input_mode, can_compose_inline); } #if defined(OS_MACOSX) || defined(USE_AURA) diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h index 8c295b0..80cbfb3 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -606,8 +606,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl virtual void OnFocus(); virtual void OnBlur(); void OnSetCursor(const WebCursor& cursor); - void OnTextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params); + void OnTextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline); #if defined(OS_MACOSX) || defined(USE_AURA) void OnImeCompositionRangeChanged( diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 986df1c..318ab14 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -310,6 +310,8 @@ bool RenderWidgetHostViewAndroid::OnMessageReceived( OnDidChangeBodyBackgroundColor) IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrame, OnSetNeedsBeginFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, + OnTextInputStateChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_SmartClipDataExtracted, OnSmartClipDataExtracted) IPC_MESSAGE_UNHANDLED(handled = false) @@ -620,11 +622,18 @@ void RenderWidgetHostViewAndroid::SetIsLoading(bool is_loading) { // is TabContentsDelegate. } +void RenderWidgetHostViewAndroid::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { + // Unused on Android, which uses OnTextInputChanged instead. +} + long RenderWidgetHostViewAndroid::GetNativeImeAdapter() { return reinterpret_cast<intptr_t>(&ime_adapter_android_); } -void RenderWidgetHostViewAndroid::TextInputStateChanged( +void RenderWidgetHostViewAndroid::OnTextInputStateChanged( const ViewHostMsg_TextInputState_Params& params) { if (selection_controller_) { // This call is semi-redundant with that in |OnFocusedNodeChanged|. The diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index b1750fd..5393856 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -128,8 +128,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid virtual float GetTopControlsLayoutHeight() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void FocusedNodeChanged(bool is_editable_node) OVERRIDE; virtual void RenderProcessGone(base::TerminationStatus status, @@ -228,6 +229,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid void SendMouseWheelEvent(const blink::WebMouseWheelEvent& event); void SendGestureEvent(const blink::WebGestureEvent& event); + void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params); void OnDidChangeBodyBackgroundColor(SkColor color); void OnStartContentIntent(const GURL& content_url); void OnSetNeedsBeginFrame(bool enabled); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index a1b5000..3e2466b 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -471,6 +471,20 @@ RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host) //////////////////////////////////////////////////////////////////////////////// // RenderWidgetHostViewAura, RenderWidgetHostView implementation: +bool RenderWidgetHostViewAura::OnMessageReceived( + const IPC::Message& message) { + bool handled = true; + IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) + // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC + // messages for TextInput<State|Type>Changed. Corresponding code in + // RenderWidgetHostViewAndroid should also be moved at the same time. + IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, + OnTextInputStateChanged) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + void RenderWidgetHostViewAura::InitAsChild( gfx::NativeView parent_view) { window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); @@ -834,19 +848,25 @@ void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { UpdateCursorIfOverSelf(); } -void RenderWidgetHostViewAura::TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { - if (text_input_type_ != params.type || - text_input_mode_ != params.mode || - can_compose_inline_ != params.can_compose_inline) { - text_input_type_ = params.type; - text_input_mode_ = params.mode; - can_compose_inline_ = params.can_compose_inline; +void RenderWidgetHostViewAura::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { + if (text_input_type_ != type || + text_input_mode_ != input_mode || + can_compose_inline_ != can_compose_inline) { + text_input_type_ = type; + text_input_mode_ = input_mode; + can_compose_inline_ = can_compose_inline; if (GetInputMethod()) GetInputMethod()->OnTextInputTypeChanged(this); if (touch_editing_client_) touch_editing_client_->OnTextInputTypeChanged(text_input_type_); } +} + +void RenderWidgetHostViewAura::OnTextInputStateChanged( + const ViewHostMsg_TextInputState_Params& params) { if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { if (GetInputMethod()) GetInputMethod()->ShowImeIfNeeded(); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index cfc928e..c1421d6 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -35,8 +35,6 @@ #include "ui/wm/public/activation_change_observer.h" #include "ui/wm/public/activation_delegate.h" -struct ViewHostMsg_TextInputState_Params; - namespace aura { class WindowTracker; namespace client { @@ -167,8 +165,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void ImeCompositionRangeChanged( const gfx::Range& range, @@ -326,6 +325,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura virtual void OnHostMoved(const aura::WindowTreeHost* host, const gfx::Point& new_origin) OVERRIDE; + void OnTextInputStateChanged(const ViewHostMsg_TextInputState_Params& params); + #if defined(OS_WIN) // Sets the cutout rects from constrained windows. These are rectangles that // windowed NPAPI plugins shouldn't paint in. Overwrites any previous cutout diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h index fcb9e9b..fad87cb 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -39,7 +39,6 @@ struct AccessibilityHostMsg_EventParams; struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; struct ViewHostMsg_SelectionBounds_Params; -struct ViewHostMsg_TextInputState_Params; namespace media { class VideoFrame; @@ -223,8 +222,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, virtual void SetIsLoading(bool is_loading) = 0; // Updates the type of the input method attached to the view. - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) = 0; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode mode, + bool can_compose_inline) = 0; // Cancel the ongoing composition of the input method attached to the view. virtual void ImeCancelComposition() = 0; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index fa84570..584b0df 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -33,8 +33,6 @@ #include "ui/base/cocoa/remote_layer_api.h" #include "ui/gfx/display_observer.h" -struct ViewHostMsg_TextInputState_Params; - namespace content { class BrowserCompositorviewMac; class RenderWidgetHostViewMac; @@ -265,8 +263,9 @@ class CONTENT_EXPORT RenderWidgetHostViewMac virtual void Blur() OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE; + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void ImeCompositionRangeChanged( const gfx::Range& range, diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 0d4d03c..9066e2f 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -940,12 +940,14 @@ void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { // like Chrome does on Windows, call |UpdateCursor()| here. } -void RenderWidgetHostViewMac::TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) { - if (text_input_type_ != params.type || - can_compose_inline_ != params.can_compose_inline) { - text_input_type_ = params.type; - can_compose_inline_ = params.can_compose_inline; +void RenderWidgetHostViewMac::TextInputTypeChanged( + ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) { + if (text_input_type_ != type + || can_compose_inline_ != can_compose_inline) { + text_input_type_ = type; + can_compose_inline_ = can_compose_inline; if (HasFocus()) { SetTextInputActive(true); diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 4605b46..66aa5af 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -347,9 +347,6 @@ IPC_STRUCT_BEGIN(ViewHostMsg_TextInputState_Params) // The type of input field IPC_STRUCT_MEMBER(ui::TextInputType, type) - // The mode of input field - IPC_STRUCT_MEMBER(ui::TextInputMode, mode) - // The flags of the input field (autocorrect, autocomplete, etc.) IPC_STRUCT_MEMBER(int, flags) @@ -1366,6 +1363,11 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_TakeFocus, IPC_MESSAGE_ROUTED1(ViewHostMsg_OpenDateTimeDialog, ViewHostMsg_DateTimeDialogValue_Params /* value */) +IPC_MESSAGE_ROUTED3(ViewHostMsg_TextInputTypeChanged, + ui::TextInputType /* TextInputType of the focused node */, + ui::TextInputMode /* TextInputMode of the focused node */, + bool /* can_compose_inline in the focused node */) + // Required for updating text input state. IPC_MESSAGE_ROUTED1(ViewHostMsg_TextInputStateChanged, ViewHostMsg_TextInputState_Params /* input state params */) diff --git a/content/renderer/npapi/webplugin_delegate_proxy.cc b/content/renderer/npapi/webplugin_delegate_proxy.cc index 0262e39..d04429b 100644 --- a/content/renderer/npapi/webplugin_delegate_proxy.cc +++ b/content/renderer/npapi/webplugin_delegate_proxy.cc @@ -923,13 +923,11 @@ void WebPluginDelegateProxy::OnNotifyIMEStatus(int input_type, if (!render_view_) return; - ViewHostMsg_TextInputState_Params p; - p.type = static_cast<ui::TextInputType>(input_type); - p.mode = ui::TEXT_INPUT_MODE_DEFAULT; - p.can_compose_inline = true; - - render_view_->Send(new ViewHostMsg_TextInputStateChanged( - render_view_->routing_id(), p)); + render_view_->Send(new ViewHostMsg_TextInputTypeChanged( + render_view_->routing_id(), + static_cast<ui::TextInputType>(input_type), + ui::TEXT_INPUT_MODE_DEFAULT, + true)); ViewHostMsg_SelectionBounds_Params bounds_params; bounds_params.anchor_rect = bounds_params.focus_rect = caret_rect; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 80f5113..674ae7d 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -549,8 +549,7 @@ void RenderFrameImpl::PepperTextInputTypeChanged( if (instance != render_view_->focused_pepper_plugin()) return; - GetRenderWidget()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); + GetRenderWidget()->UpdateTextInputType(); if (renderer_accessibility()) renderer_accessibility()->FocusedNodeChanged(WebNode()); } @@ -2471,14 +2470,17 @@ void RenderFrameImpl::didChangeSelection(bool is_empty_selection) { if (is_empty_selection) selection_text_.clear(); - // UpdateTextInputState should be called before SyncSelectionIfRequired. - // UpdateTextInputState may send TextInputStateChanged to notify the focus + // UpdateTextInputType should be called before SyncSelectionIfRequired. + // UpdateTextInputType may send TextInputTypeChanged to notify the focus // was changed, and SyncSelectionIfRequired may send SelectionChanged // to notify the selection was changed. Focus change should be notified // before selection change. - GetRenderWidget()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); + GetRenderWidget()->UpdateTextInputType(); SyncSelectionIfRequired(); +#if defined(OS_ANDROID) + GetRenderWidget()->UpdateTextInputState(RenderWidget::NO_SHOW_IME, + RenderWidget::FROM_NON_IME); +#endif } blink::WebColorChooser* RenderFrameImpl::createColorChooser( diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index 5752e37..e0441fa 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -963,16 +963,17 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) { // Update the IME status and verify if our IME backend sends an IPC message // to activate IMEs. - view()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); + view()->UpdateTextInputType(); const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); EXPECT_TRUE(msg != NULL); - EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); - ViewHostMsg_TextInputStateChanged::Param params; - ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); - ViewHostMsg_TextInputState_Params p = params.a; - EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, p.type); - EXPECT_EQ(true, p.can_compose_inline); + EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); + ViewHostMsg_TextInputTypeChanged::Param params; + ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); + ui::TextInputType type = params.a; + ui::TextInputMode input_mode = params.b; + bool can_compose_inline = params.c; + EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); + EXPECT_EQ(true, can_compose_inline); // Move the input focus to the second <input> element, where we should // de-activate IMEs. @@ -982,34 +983,36 @@ TEST_F(RenderViewImplTest, OnImeTypeChanged) { // Update the IME status and verify if our IME backend sends an IPC message // to de-activate IMEs. - view()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); + view()->UpdateTextInputType(); msg = render_thread_->sink().GetMessageAt(0); EXPECT_TRUE(msg != NULL); - EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); - ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); - EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, params.a.type); - - for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kInputModeTestCases); j++) { - const InputModeTestCase* test_case = &kInputModeTestCases[j]; + EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); + ViewHostMsg_TextInputTypeChanged::Read(msg, & params); + type = params.a; + input_mode = params.b; + EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInputModeTestCases); i++) { + const InputModeTestCase* test_case = &kInputModeTestCases[i]; std::string javascript = base::StringPrintf("document.getElementById('%s').focus();", test_case->input_id); // Move the input focus to the target <input> element, where we should // activate IMEs. - ExecuteJavaScript(javascript.c_str()); + ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); ProcessPendingMessages(); render_thread_->sink().ClearMessages(); // Update the IME status and verify if our IME backend sends an IPC // message to activate IMEs. - view()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); - msg = render_thread_->sink().GetMessageAt(0); + view()->UpdateTextInputType(); + const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); EXPECT_TRUE(msg != NULL); - EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); - ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); - EXPECT_EQ(test_case->expected_mode, params.a.mode); + EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); + ViewHostMsg_TextInputTypeChanged::Read(msg, & params); + type = params.a; + input_mode = params.b; + EXPECT_EQ(test_case->expected_mode, input_mode); } } } @@ -1138,8 +1141,7 @@ TEST_F(RenderViewImplTest, ImeComposition) { // Update the status of our IME back-end. // TODO(hbono): we should verify messages to be sent from the back-end. - view()->UpdateTextInputState( - RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); + view()->UpdateTextInputType(); ProcessPendingMessages(); render_thread_->sink().ClearMessages(); @@ -2136,7 +2138,7 @@ TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); - if (type == ViewHostMsg_TextInputStateChanged::ID) { + if (type == ViewHostMsg_TextInputTypeChanged::ID) { is_input_type_called = true; last_input_type = i; } else if (type == ViewHostMsg_SelectionChanged::ID) { diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index a214947..3a1eb45 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -1214,7 +1214,7 @@ void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, else if (focused_pepper_plugin_ == instance) focused_pepper_plugin_ = NULL; - UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); + UpdateTextInputType(); UpdateSelectionBounds(); } diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 1034e08..43bac58 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -1237,7 +1237,10 @@ void RenderWidget::willBeginCompositorFrame() { // The following two can result in further layout and possibly // enable GPU acceleration so they need to be called before any painting // is done. + UpdateTextInputType(); +#if defined(OS_ANDROID) UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); +#endif UpdateSelectionBounds(); } @@ -1747,6 +1750,43 @@ void RenderWidget::FinishHandlingImeEvent() { #endif } +void RenderWidget::UpdateTextInputType() { + // On Windows, not only an IME but also an on-screen keyboard relies on the + // latest TextInputType to optimize its layout and functionality. Thus + // |input_method_is_active_| is no longer an appropriate condition to suppress + // TextInputTypeChanged IPC on Windows. + // TODO(yukawa, yoichio): Consider to stop checking |input_method_is_active_| + // on other platforms as well as Windows if the overhead is acceptable. +#if !defined(OS_WIN) + if (!input_method_is_active_) + return; +#endif + + ui::TextInputType new_type = GetTextInputType(); + if (IsDateTimeInput(new_type)) + return; // Not considered as a text input field in WebKit/Chromium. + + bool new_can_compose_inline = CanComposeInline(); + + blink::WebTextInputInfo new_info; + if (webwidget_) + new_info = webwidget_->textInputInfo(); + const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); + + if (text_input_type_ != new_type + || can_compose_inline_ != new_can_compose_inline + || text_input_mode_ != new_mode) { + Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), + new_type, + new_mode, + new_can_compose_inline)); + text_input_type_ = new_type; + can_compose_inline_ = new_can_compose_inline; + text_input_mode_ = new_mode; + } +} + +#if defined(OS_ANDROID) || defined(USE_AURA) void RenderWidget::UpdateTextInputState(ShowIme show_ime, ChangeSource change_source) { if (handling_ime_event_) @@ -1760,7 +1800,6 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime, blink::WebTextInputInfo new_info; if (webwidget_) new_info = webwidget_->textInputInfo(); - const ui::TextInputMode new_mode = ConvertInputMode(new_info.inputMode); bool new_can_compose_inline = CanComposeInline(); @@ -1768,7 +1807,6 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime, // shown. if (show_ime == SHOW_IME_IF_NEEDED || (text_input_type_ != new_type || - text_input_mode_ != new_mode || text_input_info_ != new_info || can_compose_inline_ != new_can_compose_inline) #if defined(OS_ANDROID) @@ -1778,7 +1816,6 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime, ViewHostMsg_TextInputState_Params p; p.type = new_type; p.flags = new_info.flags; - p.mode = new_mode; p.value = new_info.value.utf8(); p.selection_start = new_info.selectionStart; p.selection_end = new_info.selectionEnd; @@ -1796,14 +1833,20 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime, IncrementOutstandingImeEventAcks(); text_field_is_dirty_ = false; #endif +#if defined(USE_AURA) + Send(new ViewHostMsg_TextInputTypeChanged(routing_id(), + new_type, + text_input_mode_, + new_can_compose_inline)); +#endif Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); text_input_info_ = new_info; text_input_type_ = new_type; - text_input_mode_ = new_mode; can_compose_inline_ = new_can_compose_inline; } } +#endif void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { WebRect focus_webrect; diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index cdb166a..824b245 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -261,6 +261,10 @@ class CONTENT_EXPORT RenderWidget void OnSwapBuffersComplete(); void OnSwapBuffersAborted(); + // Checks if the text input state and compose inline mode have been changed. + // If they are changed, the new value will be sent to the browser process. + void UpdateTextInputType(); + // Checks if the selection bounds have been changed. If they are changed, // the new value will be sent to the browser process. void UpdateSelectionBounds(); @@ -269,6 +273,7 @@ class CONTENT_EXPORT RenderWidget void OnShowHostContextMenu(ContextMenuParams* params); +#if defined(OS_ANDROID) || defined(USE_AURA) enum ShowIme { SHOW_IME_IF_NEEDED, NO_SHOW_IME, @@ -286,6 +291,7 @@ class CONTENT_EXPORT RenderWidget // IME events. This is when the text change did not originate from the IME in // the browser side, such as changes by JavaScript or autofill. void UpdateTextInputState(ShowIme show_ime, ChangeSource change_source); +#endif #if defined(OS_MACOSX) || defined(USE_AURA) // Checks if the composition range or composition character bounds have been diff --git a/content/test/test_render_view_host.h b/content/test/test_render_view_host.h index 03642dd..9c18d27 100644 --- a/content/test/test_render_view_host.h +++ b/content/test/test_render_view_host.h @@ -27,7 +27,6 @@ // To use, derive your test base class from RenderViewHostImplTestHarness. struct FrameHostMsg_DidCommitProvisionalLoad_Params; -struct ViewHostMsg_TextInputState_Params; namespace gfx { class Rect; @@ -99,8 +98,9 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { virtual void Blur() OVERRIDE {} virtual void SetIsLoading(bool is_loading) OVERRIDE {} virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE {} - virtual void TextInputStateChanged( - const ViewHostMsg_TextInputState_Params& params) OVERRIDE {} + virtual void TextInputTypeChanged(ui::TextInputType type, + ui::TextInputMode input_mode, + bool can_compose_inline) OVERRIDE {} virtual void ImeCancelComposition() OVERRIDE {} #if defined(OS_MACOSX) || defined(USE_AURA) virtual void ImeCompositionRangeChanged( |