Chromium Code Reviews| Index: chrome/browser/renderer_host/gtk_im_context_wrapper.cc |
| diff --git a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc |
| index fc46a9861fb2dac3feec2e416bb67b7ace7bee9f..f6741bce8c41b5c107ab5093d0ba22677df64549 100644 |
| --- a/chrome/browser/renderer_host/gtk_im_context_wrapper.cc |
| +++ b/chrome/browser/renderer_host/gtk_im_context_wrapper.cc |
| @@ -61,6 +61,7 @@ GtkIMContextWrapper::GtkIMContextWrapper(RenderWidgetHostViewGtk* host_view) |
| context_(gtk_im_multicontext_new()), |
| context_simple_(gtk_im_context_simple_new()), |
| is_focused_(false), |
| + is_ppapi_plugin_focused_(false), |
| is_composing_text_(false), |
| is_enabled_(false), |
| is_in_key_event_handler_(false), |
| @@ -227,6 +228,9 @@ void GtkIMContextWrapper::ProcessKeyEvent(GdkEventKey* event) { |
| void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, |
| const gfx::Rect& caret_rect) { |
| + text_input_type_ = type; |
| + caret_rect_ = caret_rect; |
| + |
| suppress_next_commit_ = false; |
| // The renderer has updated its IME status. |
| @@ -236,7 +240,9 @@ void GtkIMContextWrapper::UpdateInputMethodState(WebKit::WebTextInputType type, |
| DCHECK(!is_in_key_event_handler_); |
| - bool is_enabled = (type == WebKit::WebTextInputTypeText); |
| + // If the focus is on a editable text, or on a PPAPI plugin, turn IME on. |
| + bool is_enabled = (type == WebKit::WebTextInputTypeText) |
| + || is_ppapi_plugin_focused_; |
|
kochi
2011/05/25 06:19:44
Put || in the end of the previous line, rather tha
kinaba
2011/05/25 22:23:53
The whole change here is removed from the patch se
|
| if (is_enabled_ != is_enabled) { |
| is_enabled_ = is_enabled; |
| if (is_enabled) |
| @@ -309,6 +315,14 @@ void GtkIMContextWrapper::OnFocusOut() { |
| host_view_->GetRenderWidgetHost()->SetInputMethodActive(false); |
| } |
| +void GtkIMContextWrapper::OnPpapiPluginFocusChanged(bool focused) { |
| + if (focused != is_ppapi_plugin_focused_) { |
| + is_ppapi_plugin_focused_ = focused; |
| + UpdateInputMethodState(text_input_type_, caret_rect_); |
| + } |
| +} |
| + |
| + |
| #if !defined(TOOLKIT_VIEWS) |
| // Not defined for views because the views context menu doesn't |
| // implement input methods yet. |
| @@ -457,12 +471,17 @@ void GtkIMContextWrapper::ProcessInputMethodResult(const GdkEventKey* event, |
| is_composing_text_ = true; |
| // TODO(suzhe): convert both renderer_host and renderer to use |
| // ui::CompositionText. |
| - const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| - reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
| - composition_.underlines); |
| - host->ImeSetComposition(composition_.text, underlines, |
| - composition_.selection.start(), |
| - composition_.selection.end()); |
| + |
| + // For now, if a PPAPI plugin is focused, we don't send ImeSetCompostion. |
|
kochi
2011/05/25 06:19:44
"For now" sounds ambiguous for any future referenc
kinaba
2011/05/25 22:23:53
Done (the code is moved to content/renderer/render
|
| + if (!is_ppapi_plugin_focused_) { |
| + const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| + reinterpret_cast< |
| + const std::vector<WebKit::WebCompositionUnderline>&>( |
| + composition_.underlines); |
| + host->ImeSetComposition(composition_.text, underlines, |
| + composition_.selection.start(), |
| + composition_.selection.end()); |
| + } |
| } else if (!committed) { |
| host->ImeCancelComposition(); |
| } |
| @@ -502,7 +521,19 @@ void GtkIMContextWrapper::HandleCommit(const string16& text) { |
| if (!is_in_key_event_handler_ && host_view_->GetRenderWidgetHost()) { |
| // Workaround http://crbug.com/45478 by sending fake key down/up events. |
| SendFakeCompositionKeyEvent(WebKit::WebInputEvent::RawKeyDown); |
| - host_view_->GetRenderWidgetHost()->ImeConfirmComposition(text); |
| + if (is_ppapi_plugin_focused_) { |
| + // For now, if a PPAPI plugin is focused, we directly emit character |
| + // events, instead of sending renderer an IME event. |
|
kochi
2011/05/25 06:19:44
For now -> TODO().
E.g. TODO(kinaba): Until PPAPI
kinaba
2011/05/25 22:23:53
Done (the code is moved to content/renderer/render
|
| + for (size_t i = 0; i<commit_text_.size(); ++i) { |
|
kochi
2011/05/25 06:19:44
Style nit: spaces around "<".
kinaba
2011/05/25 22:23:53
Done (the code is moved to content/renderer/render
|
| + NativeWebKeyboardEvent char_event(commit_text_[i], |
| + 0, |
| + base::Time::Now().ToDoubleT()); |
| + char_event.skip_in_browser = true; |
| + host_view_->ForwardKeyboardEvent(char_event); |
| + } |
| + } else { |
| + host_view_->GetRenderWidgetHost()->ImeConfirmComposition(text); |
| + } |
| SendFakeCompositionKeyEvent(WebKit::WebInputEvent::KeyUp); |
| } |
| } |
| @@ -545,14 +576,17 @@ void GtkIMContextWrapper::HandlePreeditChanged(const gchar* text, |
| host_view_->GetRenderWidgetHost()) { |
| // Workaround http://crbug.com/45478 by sending fake key down/up events. |
| SendFakeCompositionKeyEvent(WebKit::WebInputEvent::RawKeyDown); |
| - // TODO(suzhe): convert both renderer_host and renderer to use |
| - // ui::CompositionText. |
| - const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| - reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
| - composition_.underlines); |
| - host_view_->GetRenderWidgetHost()->ImeSetComposition( |
| - composition_.text, underlines, composition_.selection.start(), |
| - composition_.selection.end()); |
| + // For now, if a PPAPI plugin is focused, we don't send ImeSetComposition. |
|
kochi
2011/05/25 06:19:44
Ditto.
kinaba
2011/05/25 22:23:53
Done (content/renderer/render_view.cc:3951).
|
| + if (!is_ppapi_plugin_focused_) { |
| + // TODO(suzhe): convert both renderer_host and renderer to use |
| + // ui::CompositionText. |
| + const std::vector<WebKit::WebCompositionUnderline>& underlines = |
| + reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( |
| + composition_.underlines); |
| + host_view_->GetRenderWidgetHost()->ImeSetComposition( |
| + composition_.text, underlines, composition_.selection.start(), |
| + composition_.selection.end()); |
| + } |
| SendFakeCompositionKeyEvent(WebKit::WebInputEvent::KeyUp); |
| } |
| } |