Index: content/renderer/render_view.cc |
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc |
index 4cbe162e01b4196609bff7f1d1a875c50124eda8..d57492597d875125d1e47acbdcd1c89a269f277b 100644 |
--- a/content/renderer/render_view.cc |
+++ b/content/renderer/render_view.cc |
@@ -89,6 +89,7 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNetworkStateNotifier.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
@@ -350,6 +351,7 @@ RenderView::RenderView(RenderThreadBase* render_thread, |
has_unload_listener_(false), |
target_url_status_(TARGET_NONE), |
ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), |
+ is_ppapi_plugin_focused_(false), |
ALLOW_THIS_IN_INITIALIZER_LIST(accessibility_method_factory_(this)), |
ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
geolocation_dispatcher_(NULL), |
@@ -3936,6 +3938,62 @@ void RenderView::OnSetFocus(bool enable) { |
} |
} |
+void RenderView::PpapiPluginFocusChanged(bool focused) { |
+ is_ppapi_plugin_focused_ = focused; |
+ UpdateInputMethod(); |
+} |
+ |
+void RenderView::OnImeSetComposition( |
+ const string16& text, |
+ const std::vector<WebKit::WebCompositionUnderline>& underlines, |
+ int selection_start, |
+ int selection_end) { |
+ // Until PPAPI has an interface for handling IME events, we skip sending |
+ // OnImeSetComposition. Otherwise the composition is canceled when a |
+ // non-editable DOM element is focused. |
+ // |
+ // TODO(kinaba) This temporal remedy can be removed after PPAPI is extended |
+ // with an IME handling interface. |
+ if (!is_ppapi_plugin_focused_) { |
+ RenderWidget::OnImeSetComposition(text, |
+ underlines, |
+ selection_start, |
+ selection_end); |
+ } |
+} |
+ |
+void RenderView::OnImeConfirmComposition(const string16& text) { |
+ if (is_ppapi_plugin_focused_) { |
+ // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
+ // send character events. |
+ for (size_t i = 0; i < text.size(); ++i) { |
+ WebKit::WebKeyboardEvent char_event; |
+ char_event.type = WebKit::WebInputEvent::Char; |
+ char_event.timeStampSeconds = base::Time::Now().ToDoubleT(); |
+ char_event.modifiers = 0; |
+ char_event.windowsKeyCode = text[i]; |
+ char_event.nativeKeyCode = text[i]; |
+ char_event.text[0] = text[i]; |
+ char_event.unmodifiedText[0] = text[i]; |
+ if (webwidget_) |
+ webwidget_->handleInputEvent(char_event); |
+ } |
+ } else { |
+ RenderWidget::OnImeConfirmComposition(text); |
+ } |
+} |
+ |
+void RenderView::GetTextInputType(WebKit::WebTextInputType* type, |
+ WebKit::WebRect* caret_bounds) { |
+ if (is_ppapi_plugin_focused_) { |
+ // TODO(kinaba) Until PPAPI has an interface for handling IME events, we |
+ // consider all the parts of PPAPI plugins are accepting text inputs. |
+ *type = WebKit::WebTextInputTypeText; |
+ } else { |
+ RenderWidget::GetTextInputType(type, caret_bounds); |
+ } |
+} |
+ |
#if defined(OS_MACOSX) |
void RenderView::PluginFocusChanged(bool focused, int plugin_id) { |
IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |