summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 05:19:54 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-13 05:19:54 +0000
commitb25b3ee65454e190be9c17cf3a08abf5ef44619b (patch)
treeecc712e60ad2796295104df9c9a61cbcbb5124d0 /content
parentb5a29696d7b5f3d2341fc0694e37dacee69d45b3 (diff)
downloadchromium_src-b25b3ee65454e190be9c17cf3a08abf5ef44619b.zip
chromium_src-b25b3ee65454e190be9c17cf3a08abf5ef44619b.tar.gz
chromium_src-b25b3ee65454e190be9c17cf3a08abf5ef44619b.tar.bz2
[Mac] Place IME candidate window on Pepper plugins near the caret.
BUG=104174 TEST=Manual: 1. make ppapi_example_ime 2. ./your/chrome --register-pepper-plugins=\ "/path/to/ppapi_example_ime.plugin;application/x-ppapi-example-ime" \ file:///path/to/ppapi/examples/ime/ime.html 3. Type some text in the plugin displayed at the top of the example page using Chinese or Japanese input methods. Verify the candidate window is shown below the caret. Review URL: http://codereview.chromium.org/9107003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/renderer/render_view_impl.cc7
-rw-r--r--content/renderer/render_view_impl.h3
-rw-r--r--content/renderer/text_input_client_observer.cc16
-rw-r--r--content/renderer/text_input_client_observer.h4
4 files changed, 23 insertions, 7 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 12a5ac7..1fb37fe 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4442,6 +4442,13 @@ void RenderViewImpl::PpapiPluginCaretPositionChanged() {
UpdateSelectionBounds();
}
+bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) {
+ if (!pepper_delegate_.IsPluginFocused())
+ return false;
+ *rect = pepper_delegate_.GetCaretBounds();
+ return true;
+}
+
void RenderViewImpl::PpapiPluginCancelComposition() {
Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
ui::Range range(ui::Range::InvalidRange());
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index b534393..be94611 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -257,6 +257,9 @@ class RenderViewImpl : public RenderWidget,
// Cancels current composition.
void PpapiPluginCancelComposition();
+ // Retrieves the current caret position if a PPAPI plugin has focus.
+ bool GetPpapiPluginCaretBounds(gfx::Rect* rect);
+
#if defined(OS_MACOSX) || defined(OS_WIN)
// Informs the render view that the given plugin has gained or lost focus.
void PluginFocusChanged(bool focused, int plugin_id);
diff --git a/content/renderer/text_input_client_observer.cc b/content/renderer/text_input_client_observer.cc
index 17239b7..cbb64b6 100644
--- a/content/renderer/text_input_client_observer.cc
+++ b/content/renderer/text_input_client_observer.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -17,7 +17,8 @@
#include "ui/gfx/rect.h"
TextInputClientObserver::TextInputClientObserver(RenderViewImpl* render_view)
- : content::RenderViewObserver(render_view) {
+ : content::RenderViewObserver(render_view),
+ render_view_impl_(render_view) {
}
TextInputClientObserver::~TextInputClientObserver() {
@@ -48,10 +49,13 @@ void TextInputClientObserver::OnCharacterIndexForPoint(gfx::Point point) {
}
void TextInputClientObserver::OnFirstRectForCharacterRange(ui::Range range) {
- WebKit::WebFrame* frame = webview()->focusedFrame();
- WebKit::WebRect web_rect;
- frame->firstRectForCharacterRange(range.start(), range.length(), web_rect);
- gfx::Rect rect(web_rect);
+ gfx::Rect rect;
+ if (!render_view_impl_->GetPpapiPluginCaretBounds(&rect)) {
+ WebKit::WebFrame* frame = webview()->focusedFrame();
+ WebKit::WebRect web_rect;
+ frame->firstRectForCharacterRange(range.start(), range.length(), web_rect);
+ rect = web_rect;
+ }
Send(new TextInputClientReplyMsg_GotFirstRectForRange(routing_id(), rect));
}
diff --git a/content/renderer/text_input_client_observer.h b/content/renderer/text_input_client_observer.h
index 9e5e86e..c0d6b46e 100644
--- a/content/renderer/text_input_client_observer.h
+++ b/content/renderer/text_input_client_observer.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -37,6 +37,8 @@ class TextInputClientObserver : public content::RenderViewObserver {
void OnFirstRectForCharacterRange(ui::Range range);
void OnStringForRange(ui::Range range);
+ RenderViewImpl* const render_view_impl_;
+
DISALLOW_COPY_AND_ASSIGN(TextInputClientObserver);
};