diff options
20 files changed, 130 insertions, 61 deletions
diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc index fc46a98..4df6eb8 100644 --- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc +++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc @@ -225,8 +225,10 @@ void GtkIMContextWrapper::ProcessKeyEvent(GdkEventKey* event) { last_key_filtered_no_result_ = (filtered && !has_result); } -void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, - const gfx::Rect& caret_rect) { +void GtkIMContextWrapper::UpdateInputMethodState( + ui::TextInputType type, + bool can_compose_inline, + const gfx::Rect& caret_rect) { suppress_next_commit_ = false; // The renderer has updated its IME status. @@ -236,7 +238,7 @@ void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, DCHECK(!is_in_key_event_handler_); - bool is_enabled = (type == WebKit::WebTextInputTypeText); + bool is_enabled = (type == ui::TEXT_INPUT_TYPE_TEXT); if (is_enabled_ != is_enabled) { is_enabled_ = is_enabled; if (is_enabled) @@ -246,6 +248,10 @@ void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, } if (is_enabled) { + // If the focused element supports inline rendering of composition text, + // we receive and send related events to it. Otherwise, the events related + // to the updates of composition text are directed to the candidate window. + gtk_im_context_set_use_preedit(context_, can_compose_inline); // Updates the position of the IME candidate window. // The position sent from the renderer is a relative one, so we need to // attach the GtkIMContext object to this window before changing the diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.h b/chrome/browser/renderer_host/gtk_im_context_wrapper.h index f41b7c1..5cafa95 100644 --- a/chrome/browser/renderer_host/gtk_im_context_wrapper.h +++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,8 +14,8 @@ #include "base/gtest_prod_util.h" #include "base/string16.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" #include "ui/base/ime/composition_text.h" +#include "ui/base/ime/text_input_type.h" namespace gfx { class Rect; @@ -48,7 +48,8 @@ class GtkIMContextWrapper { // Processes a gdk key event received by |host_view|. void ProcessKeyEvent(GdkEventKey* event); - void UpdateInputMethodState(WebKit::WebTextInputType type, + void UpdateInputMethodState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect); void OnFocusIn(); void OnFocusOut(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index 2970a7f..2295ea3 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -726,9 +726,10 @@ void RenderWidgetHostViewGtk::SetIsLoading(bool is_loading) { } void RenderWidgetHostViewGtk::ImeUpdateTextInputState( - WebKit::WebTextInputType type, + ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) { - im_context_->UpdateInputMethodState(type, caret_rect); + im_context_->UpdateInputMethodState(type, can_compose_inline, caret_rect); } void RenderWidgetHostViewGtk::ImeCancelComposition() { diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index 6ea6fc7..b26fc52 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -73,7 +73,8 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, + virtual void ImeUpdateTextInputState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void DidUpdateBackingStore( diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index 6658396b..923e401 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -192,7 +192,8 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType state, + virtual void ImeUpdateTextInputState(ui::TextInputType state, + bool can_compose_inline, const gfx::Rect& caret_rect) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void ImeCompositionRangeChanged(const ui::Range& range) OVERRIDE; @@ -331,7 +332,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { base::TimeTicks tab_switch_paint_time_; // Current text input type. - WebKit::WebTextInputType text_input_type_; + ui::TextInputType text_input_type_; typedef std::map<gfx::PluginWindowHandle, AcceleratedPluginView*> PluginViewMap; diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index 498a8e3..83aec9e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -233,7 +233,7 @@ RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) : render_widget_host_(widget), about_to_validate_and_paint_(false), call_set_needs_display_in_rect_pending_(false), - text_input_type_(WebKit::WebTextInputTypeNone), + text_input_type_(ui::TEXT_INPUT_TYPE_NONE), spellcheck_enabled_(false), spellcheck_checked_(false), is_loading_(false), @@ -498,8 +498,13 @@ void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { } void RenderWidgetHostViewMac::ImeUpdateTextInputState( - WebKit::WebTextInputType type, + ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) { + // TODO(kinaba): currently, can_compose_inline is ignored and always treated + // as true. We need to support "can_compose_inline=false" for PPAPI plugins + // that may want to avoid drawing composition-text by themselves and pass + // the responsibility to the browser. if (text_input_type_ != type) { text_input_type_ = type; if (HasFocus()) { @@ -1037,12 +1042,12 @@ void RenderWidgetHostViewMac::OnAccessibilityNotifications( void RenderWidgetHostViewMac::SetTextInputActive(bool active) { if (active) { - if (text_input_type_ == WebKit::WebTextInputTypePassword) + if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) EnablePasswordInput(); else DisablePasswordInput(); } else { - if (text_input_type_ == WebKit::WebTextInputTypePassword) + if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) DisablePasswordInput(); } } @@ -2246,8 +2251,8 @@ extern NSString *NSTextInputReplacementRangeAttributeName; return [[ComplexTextInputPanel sharedComplexTextInputPanel] inputContext]; switch(renderWidgetHostView_->text_input_type_) { - case WebKit::WebTextInputTypeNone: - case WebKit::WebTextInputTypePassword: + case ui::TEXT_INPUT_TYPE_NONE: + case ui::TEXT_INPUT_TYPE_PASSWORD: return nil; default: return [super inputContext]; @@ -2538,7 +2543,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName; BOOL returnTypeIsString = [returnType isEqual:NSStringPboardType]; BOOL hasText = !renderWidgetHostView_->selected_text().empty(); BOOL takesText = - renderWidgetHostView_->text_input_type_ != WebKit::WebTextInputTypeNone; + renderWidgetHostView_->text_input_type_ != ui::TEXT_INPUT_TYPE_NONE; if (sendTypeIsString && hasText && !returnType) { requestor = self; diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.cc b/chrome/browser/renderer_host/render_widget_host_view_views.cc index 5271c69..5e3adb6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_views.cc @@ -296,12 +296,16 @@ void RenderWidgetHostViewViews::SetIsLoading(bool is_loading) { } void RenderWidgetHostViewViews::ImeUpdateTextInputState( - WebKit::WebTextInputType type, + ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) { + // TODO(kinaba): currently, can_compose_inline is ignored and always treated + // as true. We need to support "can_compose_inline=false" for PPAPI plugins + // that may want to avoid drawing composition-text by themselves and pass + // the responsibility to the browser. DCHECK(GetInputMethod()); - ui::TextInputType new_type = static_cast<ui::TextInputType>(type); - if (text_input_type_ != new_type) { - text_input_type_ = new_type; + if (text_input_type_ != type) { + text_input_type_ = type; GetInputMethod()->OnTextInputTypeChanged(this); } if (caret_bounds_ != caret_rect) { diff --git a/chrome/browser/renderer_host/render_widget_host_view_views.h b/chrome/browser/renderer_host/render_widget_host_view_views.h index 1811d6d..78957ec 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_views.h +++ b/chrome/browser/renderer_host/render_widget_host_view_views.h @@ -63,7 +63,8 @@ class RenderWidgetHostViewViews : public RenderWidgetHostView, virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, + virtual void ImeUpdateTextInputState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void DidUpdateBackingStore( diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index 03e2b9e..1ff06f4 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -237,7 +237,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) parent_hwnd_(NULL), is_loading_(false), overlay_color_(0), - text_input_type_(WebKit::WebTextInputTypeNone) { + text_input_type_(ui::TEXT_INPUT_TYPE_NONE) { render_widget_host_->set_view(this); registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, @@ -578,18 +578,23 @@ void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) { } void RenderWidgetHostViewWin::ImeUpdateTextInputState( - WebKit::WebTextInputType type, + ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) { + // TODO(kinaba): currently, can_compose_inline is ignored and always treated + // as true. We need to support "can_compose_inline=false" for PPAPI plugins + // that may want to avoid drawing composition-text by themselves and pass + // the responsibility to the browser. if (text_input_type_ != type) { text_input_type_ = type; - if (type == WebKit::WebTextInputTypeText) + if (type == ui::TEXT_INPUT_TYPE_TEXT) ime_input_.EnableIME(m_hWnd); else ime_input_.DisableIME(m_hWnd); } // Only update caret position if the input method is enabled. - if (type == WebKit::WebTextInputTypeText) + if (type == ui::TEXT_INPUT_TYPE_TEXT) ime_input_.UpdateCaretRect(m_hWnd, caret_rect); } diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index 42b76d7..b72d853 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -148,7 +148,8 @@ class RenderWidgetHostViewWin virtual gfx::Rect GetViewBounds() const OVERRIDE; virtual void UpdateCursor(const WebCursor& cursor) OVERRIDE; virtual void SetIsLoading(bool is_loading) OVERRIDE; - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, + virtual void ImeUpdateTextInputState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) OVERRIDE; virtual void ImeCancelComposition() OVERRIDE; virtual void DidUpdateBackingStore( @@ -362,7 +363,7 @@ class RenderWidgetHostViewWin // Stores the current text input type received by ImeUpdateTextInputState() // method. - WebKit::WebTextInputType text_input_type_; + ui::TextInputType text_input_type_; ScopedVector<ui::ViewProp> props_; diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index f916ba1..1f98484 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -1048,10 +1048,11 @@ void RenderWidgetHost::OnMsgSetCursor(const WebCursor& cursor) { } void RenderWidgetHost::OnMsgImeUpdateTextInputState( - WebKit::WebTextInputType type, + ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) { if (view_) - view_->ImeUpdateTextInputState(type, caret_rect); + view_->ImeUpdateTextInputState(type, can_compose_inline, caret_rect); } void RenderWidgetHost::OnMsgImeCompositionRangeChanged(const ui::Range& range) { diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 70e67f24..80f1bc4b 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -20,7 +20,7 @@ #include "ipc/ipc_channel.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" +#include "ui/base/ime/text_input_type.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -453,7 +453,8 @@ class RenderWidgetHost : public IPC::Channel::Listener, virtual void OnMsgBlur(); void OnMsgSetCursor(const WebCursor& cursor); - void OnMsgImeUpdateTextInputState(WebKit::WebTextInputType type, + void OnMsgImeUpdateTextInputState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect); void OnMsgImeCompositionRangeChanged(const ui::Range& range); void OnMsgImeCancelComposition(); diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index f443d1c..9f6191a 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -17,7 +17,7 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkColor.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" +#include "ui/base/ime/text_input_type.h" #include "ui/base/range/range.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" @@ -134,7 +134,8 @@ class RenderWidgetHostView { virtual void SetIsLoading(bool is_loading) = 0; // Updates the state of the input method attached to the view. - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType type, + virtual void ImeUpdateTextInputState(ui::TextInputType type, + bool can_compose_inline, const gfx::Rect& caret_rect) = 0; // Cancel the ongoing composition of the input method attached to the view. diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 4bcde5c..dddd005 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -78,7 +78,8 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void SetIsLoading(bool is_loading) {} virtual void UpdateCursor(const WebCursor& cursor) {} virtual void UpdateCursorIfOverSelf() {} - virtual void ImeUpdateTextInputState(WebKit::WebTextInputType state, + virtual void ImeUpdateTextInputState(ui::TextInputType state, + bool can_compose_inline, const gfx::Rect& caret_rect) {} virtual void ImeCancelComposition() {} virtual void DidUpdateBackingStore( diff --git a/content/common/view_messages.h b/content/common/view_messages.h index 6582c89..57d7bd2 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -24,7 +24,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" +#include "ui/base/ime/text_input_type.h" #include "ui/base/range/range.h" #include "ui/gfx/rect.h" #include "webkit/glue/context_menu.h" @@ -164,7 +164,7 @@ IPC_ENUM_TRAITS(ViewMsg_StopFinding_Params::Action) IPC_ENUM_TRAITS(WebKit::WebContextMenuData::MediaType) IPC_ENUM_TRAITS(WebKit::WebMediaPlayerAction::Type) IPC_ENUM_TRAITS(WebKit::WebPopupType) -IPC_ENUM_TRAITS(WebKit::WebTextInputType) +IPC_ENUM_TRAITS(ui::TextInputType) IPC_ENUM_TRAITS(WebMenuItem::Type) IPC_ENUM_TRAITS(WindowContainerType) IPC_ENUM_TRAITS(webkit_glue::WebAccessibility::Role) @@ -1696,8 +1696,9 @@ IPC_SYNC_MESSAGE_ROUTED1_1(ViewHostMsg_GetRootWindowRect, gfx::Rect /* Out: Window location */) // Required for updating text input state. -IPC_MESSAGE_ROUTED2(ViewHostMsg_ImeUpdateTextInputState, - WebKit::WebTextInputType, /* text_input_type */ +IPC_MESSAGE_ROUTED3(ViewHostMsg_ImeUpdateTextInputState, + ui::TextInputType, /* text_input_type */ + bool, /* can_compose_inline */ gfx::Rect /* caret_rect */) diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc index fc83a1d..f164c06 100644 --- a/content/renderer/render_view.cc +++ b/content/renderer/render_view.cc @@ -3980,14 +3980,24 @@ void RenderView::OnImeConfirmComposition(const string16& text) { } } -WebKit::WebTextInputType RenderView::GetTextInputType() { +ui::TextInputType RenderView::GetTextInputType() { if (pepper_delegate_.IsPluginFocused()) { // TODO(kinaba) Until PPAPI has an interface for handling IME events, we // consider all the parts of PPAPI plugins are accepting text inputs. - return WebKit::WebTextInputTypeText; - } else { - return RenderWidget::GetTextInputType(); + return ui::TEXT_INPUT_TYPE_TEXT; } + return RenderWidget::GetTextInputType(); +} + +bool RenderView::CanComposeInline() { + if (pepper_delegate_.IsPluginFocused()) { + // TODO(kinaba) Until PPAPI has an interface for handling IME events, there + // is no way for the browser to know whether the plugin is capable of + // drawing composition text. We assume plugins are incapable and let the + // browser handle composition display for now. + return false; + } + return true; } #if defined(OS_MACOSX) diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h index a5cee65..8d3d9c6 100644 --- a/content/renderer/render_view.h +++ b/content/renderer/render_view.h @@ -617,7 +617,8 @@ class RenderView : public RenderWidget, int selection_start, int selection_end) OVERRIDE; virtual void OnImeConfirmComposition(const string16& text) OVERRIDE; - virtual WebKit::WebTextInputType GetTextInputType() OVERRIDE; + virtual ui::TextInputType GetTextInputType() OVERRIDE; + virtual bool CanComposeInline() OVERRIDE; private: // For unit tests. diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc index d06251e..6e0d5b0 100644 --- a/content/renderer/render_view_browsertest.cc +++ b/content/renderer/render_view_browsertest.cc @@ -169,8 +169,9 @@ TEST_F(RenderViewTest, OnImeStateChanged) { EXPECT_EQ(ViewHostMsg_ImeUpdateTextInputState::ID, msg->type()); ViewHostMsg_ImeUpdateTextInputState::Param params; ViewHostMsg_ImeUpdateTextInputState::Read(msg, ¶ms); - EXPECT_EQ(params.a, WebKit::WebTextInputTypeText); - EXPECT_TRUE(params.b.x() > 0 && params.b.y() > 0); + EXPECT_EQ(params.a, ui::TEXT_INPUT_TYPE_TEXT); + EXPECT_EQ(params.b, true); + EXPECT_TRUE(params.c.x() > 0 && params.c.y() > 0); // Move the input focus to the second <input> element, where we should // de-activate IMEs. @@ -185,7 +186,7 @@ TEST_F(RenderViewTest, OnImeStateChanged) { EXPECT_TRUE(msg != NULL); EXPECT_EQ(ViewHostMsg_ImeUpdateTextInputState::ID, msg->type()); ViewHostMsg_ImeUpdateTextInputState::Read(msg, ¶ms); - EXPECT_EQ(params.a, WebKit::WebTextInputTypePassword); + EXPECT_EQ(params.a, ui::TEXT_INPUT_TYPE_PASSWORD); } } diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index c2d36f2..c2102dc 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -58,7 +58,6 @@ using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSize; using WebKit::WebTextDirection; -using WebKit::WebTextInputType; using WebKit::WebVector; using WebKit::WebWidget; @@ -83,7 +82,8 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread, closing_(false), is_swapped_out_(false), input_method_is_active_(false), - text_input_type_(WebKit::WebTextInputTypeNone), + text_input_type_(ui::TEXT_INPUT_TYPE_NONE), + can_compose_inline_(true), popup_type_(popup_type), pending_window_rect_count_(0), suppress_next_char_events_(false), @@ -1283,7 +1283,8 @@ void RenderWidget::UpdateInputMethod() { if (!input_method_is_active_) return; - WebTextInputType new_type = GetTextInputType(); + ui::TextInputType new_type = GetTextInputType(); + bool new_can_compose_inline = CanComposeInline(); WebRect new_caret_bounds; if (webwidget_) @@ -1291,18 +1292,36 @@ void RenderWidget::UpdateInputMethod() { // Only sends text input type and caret bounds to the browser process if they // are changed. - if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds) { + if (text_input_type_ != new_type || caret_bounds_ != new_caret_bounds || + can_compose_inline_ != new_can_compose_inline) { text_input_type_ = new_type; + can_compose_inline_ = new_can_compose_inline; caret_bounds_ = new_caret_bounds; Send(new ViewHostMsg_ImeUpdateTextInputState( - routing_id(), new_type, new_caret_bounds)); + routing_id(), new_type, new_can_compose_inline, new_caret_bounds)); } } -WebKit::WebTextInputType RenderWidget::GetTextInputType() { - if (webwidget_) - return webwidget_->textInputType(); - return WebKit::WebTextInputTypeNone; +COMPILE_ASSERT(int(WebKit::WebTextInputTypeNone) == \ + int(ui::TEXT_INPUT_TYPE_NONE), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextInputTypeText) == \ + int(ui::TEXT_INPUT_TYPE_TEXT), mismatching_enums); +COMPILE_ASSERT(int(WebKit::WebTextInputTypePassword) == \ + int(ui::TEXT_INPUT_TYPE_PASSWORD), mismatching_enums); + +ui::TextInputType RenderWidget::GetTextInputType() { + if (webwidget_) { + int type = webwidget_->textInputType(); + // Check the type is in the range representable by ui::TextInputType. + DCHECK(type <= ui::TEXT_INPUT_TYPE_PASSWORD) << + "WebKit::WebTextInputType and ui::TextInputType not synchronized"; + return static_cast<ui::TextInputType>(type); + } + return ui::TEXT_INPUT_TYPE_NONE; +} + +bool RenderWidget::CanComposeInline() { + return true; } WebScreenInfo RenderWidget::screenInfo() { @@ -1317,7 +1336,7 @@ void RenderWidget::resetInputMethod() { // If the last text input type is not None, then we should finish any // ongoing composition regardless of the new text input type. - if (text_input_type_ != WebKit::WebTextInputTypeNone) { + if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { // If a composition text exists, then we need to let the browser process // to cancel the input method's ongoing composition session. if (webwidget_->confirmComposition()) diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index d48c336..fde8220 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -18,9 +18,9 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupType.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextDirection.h" -#include "third_party/WebKit/Source/WebKit/chromium/public/WebTextInputType.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebWidgetClient.h" #include "third_party/skia/include/core/SkBitmap.h" +#include "ui/base/ime/text_input_type.h" #include "ui/gfx/native_widget_types.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -278,7 +278,11 @@ class RenderWidget : public IPC::Channel::Listener, // Override point to obtain that the current input method state and caret // position. - virtual WebKit::WebTextInputType GetTextInputType(); + virtual ui::TextInputType GetTextInputType(); + + // Override point to obtain that the current input method state about + // composition text. + virtual bool CanComposeInline(); // Tells the renderer it does not have focus. Used to prevent us from getting // the focus on our own when the browser did not focus us. @@ -397,7 +401,10 @@ class RenderWidget : public IPC::Channel::Listener, bool input_method_is_active_; // Stores the current text input type of |webwidget_|. - WebKit::WebTextInputType text_input_type_; + ui::TextInputType text_input_type_; + + // Stores the current type of composition text rendering of |webwidget_|. + bool can_compose_inline_; // Stores the current caret bounds of input focus. WebKit::WebRect caret_bounds_; |