summaryrefslogtreecommitdiffstats
path: root/content/renderer/render_view_impl.cc
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 11:38:32 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-12 11:38:32 +0000
commit73bf95813e1c23c5fb2eaadc7e88ce248084b083 (patch)
treee1d5ba6ff5d4647b5de4d908394026bbeb5fa0d4 /content/renderer/render_view_impl.cc
parent137bc957b93eae5f02969880b89c15e48d02fd86 (diff)
downloadchromium_src-73bf95813e1c23c5fb2eaadc7e88ce248084b083.zip
chromium_src-73bf95813e1c23c5fb2eaadc7e88ce248084b083.tar.gz
chromium_src-73bf95813e1c23c5fb2eaadc7e88ce248084b083.tar.bz2
Implement Pepper IME API.
BUG=59425 TEST=Build chrome and ppapi_example_ime, Confirm "out/Release/chrome --register-pepper-plugins='out/Release/lib/libppapi_example_ime.so;application/x-ppapi-example' ppapi/examples/ime/ime.html" works. This CL is the last part for adding the basic IME support for PPAPI, preceded by the previous two changes codereview.chromium.org/7882004 (API declarations) and codereview.chromium.org/7978019 (thunk and proxy implementation). This CL comes with the actual Chrome-side implementation of the API with an example to show how to use IME in PPAPI. Keep in mind the current implementation still not reached the point of "the complete" set of IME APIs yet. - Advanced features in design doc (like surrounding text retrieval) is not available. - DOM and PPAPI composition events are not converted each other. Rather, it aims to provide basic set of functions just needed to implement inline composition in plugins. Review URL: http://codereview.chromium.org/8073021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/render_view_impl.cc')
-rw-r--r--content/renderer/render_view_impl.cc69
1 files changed, 28 insertions, 41 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 9777dbd..fc2d729b 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4156,6 +4156,16 @@ void RenderViewImpl::PpapiPluginFocusChanged() {
UpdateInputMethod();
}
+void RenderViewImpl::PpapiPluginTextInputTypeChanged() {
+ UpdateInputMethod();
+}
+
+void RenderViewImpl::PpapiPluginCancelComposition() {
+ Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
+ ui::Range range(ui::Range::InvalidRange());
+ Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range));
+}
+
void RenderViewImpl::RequestRemoteAccessClientFirewallTraversal() {
Send(new ViewHostMsg_RequestRemoteAccessClientFirewallTraversal(routing_id_));
}
@@ -4165,13 +4175,13 @@ void RenderViewImpl::OnImeSetComposition(
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 (!pepper_delegate_.IsPluginFocused()) {
+ if (pepper_delegate_.IsPluginFocused()) {
+ // When a PPAPI plugin has focus, we bypass WebKit.
+ pepper_delegate_.OnImeSetComposition(text,
+ underlines,
+ selection_start,
+ selection_end);
+ } else {
#if defined(OS_WIN)
// When a plug-in has focus, we create platform-specific IME data used by
// our IME emulator and send it directly to the focused plug-in, i.e. we
@@ -4208,20 +4218,8 @@ void RenderViewImpl::OnImeSetComposition(
void RenderViewImpl::OnImeConfirmComposition(
const string16& text, const ui::Range& replacement_range) {
if (pepper_delegate_.IsPluginFocused()) {
- // 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);
- }
+ // When a PPAPI plugin has focus, we bypass WebKit.
+ pepper_delegate_.OnImeConfirmComposition(text);
} else {
#if defined(OS_WIN)
// Same as OnImeSetComposition(), we send the text from IMEs directly to
@@ -4242,29 +4240,18 @@ void RenderViewImpl::OnImeConfirmComposition(
}
ui::TextInputType RenderViewImpl::GetTextInputType() {
- if (pepper_delegate_.IsPluginFocused()) {
-#if !defined(TOUCH_UI)
- // TODO(kinaba) Until PPAPI has an interface for handling IME events, we
- // consider all the parts of PPAPI plugins are accepting text inputs.
- return ui::TEXT_INPUT_TYPE_TEXT;
-#else
- // Disable keyboard input in flash for touch ui until PPAPI can support IME
- // events.
- return ui::TEXT_INPUT_TYPE_NONE;
-#endif
- }
- return RenderWidget::GetTextInputType();
+ return pepper_delegate_.IsPluginFocused() ?
+ pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType();
+}
+
+gfx::Rect RenderViewImpl::GetCaretBounds() {
+ return pepper_delegate_.IsPluginFocused() ?
+ pepper_delegate_.GetCaretBounds() : RenderWidget::GetCaretBounds();
}
bool RenderViewImpl::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;
+ return pepper_delegate_.IsPluginFocused() ?
+ pepper_delegate_.CanComposeInline() : true;
}
#if defined(OS_WIN)