diff options
author | kinaba@google.com <kinaba@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-24 19:31:37 +0000 |
---|---|---|
committer | kinaba@google.com <kinaba@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-24 19:31:37 +0000 |
commit | 1bdccb88f91e6dc6915315c7b1c98459cc4a01dc (patch) | |
tree | a40d5edac71adfcea2e01c3ca97d36ca33452a72 | |
parent | 41e15abb07b747b5827704e3c56ef4dfe62c3e3a (diff) | |
download | chromium_src-1bdccb88f91e6dc6915315c7b1c98459cc4a01dc.zip chromium_src-1bdccb88f91e6dc6915315c7b1c98459cc4a01dc.tar.gz chromium_src-1bdccb88f91e6dc6915315c7b1c98459cc4a01dc.tar.bz2 |
Merge 106796 - Handle the change from CaretBounds to SelectionBounds for PPAPI Plugins.
BUG=101173
TEST=Manual: run ppapi_example_ime and verify the candidate window to pop up
in a correct place, or open a Flash website with text field on Chrome OS, and
verify that the candidate window is displayed in the bottom-left corner of
the Flash rect.
This CL is to reflect the refactoring http://crrev.com/105699 on IPCs also
for Pepper plugins, and make IME candidate windows to be displayed on intended
positions.
Review URL: http://codereview.chromium.org/8363015
TBR=kinaba@chromium.org
Review URL: http://codereview.chromium.org/8382011
git-svn-id: svn://svn.chromium.org/chrome/branches/912/src@106957 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.cc | 6 | ||||
-rw-r--r-- | content/renderer/pepper_plugin_delegate_impl.h | 2 | ||||
-rw-r--r-- | content/renderer/render_view_impl.cc | 20 | ||||
-rw-r--r-- | content/renderer/render_view_impl.h | 3 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 19 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 2 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/mock_plugin_delegate.h | 1 | ||||
-rw-r--r-- | webkit/plugins/ppapi/plugin_delegate.h | 3 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppapi_plugin_instance.cc | 2 |
10 files changed, 46 insertions, 15 deletions
diff --git a/content/renderer/pepper_plugin_delegate_impl.cc b/content/renderer/pepper_plugin_delegate_impl.cc index 9206bcc..5618c55 100644 --- a/content/renderer/pepper_plugin_delegate_impl.cc +++ b/content/renderer/pepper_plugin_delegate_impl.cc @@ -867,6 +867,12 @@ void PepperPluginDelegateImpl::PluginTextInputTypeChanged( render_view_->PpapiPluginTextInputTypeChanged(); } +void PepperPluginDelegateImpl::PluginCaretPositionChanged( + webkit::ppapi::PluginInstance* instance) { + if (focused_plugin_ == instance && render_view_) + render_view_->PpapiPluginCaretPositionChanged(); +} + void PepperPluginDelegateImpl::PluginRequestedCancelComposition( webkit::ppapi::PluginInstance* instance) { if (focused_plugin_ == instance && render_view_) diff --git a/content/renderer/pepper_plugin_delegate_impl.h b/content/renderer/pepper_plugin_delegate_impl.h index 84ec4b7..998fe1e 100644 --- a/content/renderer/pepper_plugin_delegate_impl.h +++ b/content/renderer/pepper_plugin_delegate_impl.h @@ -200,6 +200,8 @@ class PepperPluginDelegateImpl bool focused) OVERRIDE; virtual void PluginTextInputTypeChanged( webkit::ppapi::PluginInstance* instance) OVERRIDE; + virtual void PluginCaretPositionChanged( + webkit::ppapi::PluginInstance* instance) OVERRIDE; virtual void PluginRequestedCancelComposition( webkit::ppapi::PluginInstance* instance) OVERRIDE; virtual void PluginCrashed(webkit::ppapi::PluginInstance* instance); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index d3dfc1f..82f36de 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -4185,12 +4185,17 @@ void RenderViewImpl::OnSetFocus(bool enable) { void RenderViewImpl::PpapiPluginFocusChanged() { UpdateTextInputState(); + UpdateSelectionBounds(); } void RenderViewImpl::PpapiPluginTextInputTypeChanged() { UpdateTextInputState(); } +void RenderViewImpl::PpapiPluginCaretPositionChanged() { + UpdateSelectionBounds(); +} + void RenderViewImpl::PpapiPluginCancelComposition() { Send(new ViewHostMsg_ImeCancelComposition(routing_id())); ui::Range range(ui::Range::InvalidRange()); @@ -4285,9 +4290,18 @@ ui::TextInputType RenderViewImpl::GetTextInputType() { pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); } -gfx::Rect RenderViewImpl::GetCaretBounds() { - return pepper_delegate_.IsPluginFocused() ? - pepper_delegate_.GetCaretBounds() : RenderWidget::GetCaretBounds(); +void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { + if (pepper_delegate_.IsPluginFocused()) { + // TODO(kinaba) http://crbug.com/101101 + // Current Pepper IME API does not handle selection bounds. So we simply + // use the caret position as an empty range for now. It will be updated + // after Pepper API equips features related to surrounding text retrieval. + gfx::Rect caret = pepper_delegate_.GetCaretBounds(); + *start = caret; + *end = caret; + return; + } + RenderWidget::GetSelectionBounds(start, end); } bool RenderViewImpl::CanComposeInline() { diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index 2ae0e9d..7fc70ef 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -252,6 +252,7 @@ class RenderViewImpl : public RenderWidget, // Informs the render view that a PPAPI plugin has changed text input status. void PpapiPluginTextInputTypeChanged(); + void PpapiPluginCaretPositionChanged(); // Cancels current composition. void PpapiPluginCancelComposition(); @@ -643,7 +644,7 @@ class RenderViewImpl : public RenderWidget, virtual void OnImeConfirmComposition( const string16& text, const ui::Range& replacement_range) OVERRIDE; virtual ui::TextInputType GetTextInputType() OVERRIDE; - virtual gfx::Rect GetCaretBounds() OVERRIDE; + virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) OVERRIDE; virtual bool CanComposeInline() OVERRIDE; virtual bool WebWidgetHandlesCompositorScheduling() const OVERRIDE; diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index 960fa49..f7c7362 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -1313,22 +1313,21 @@ void RenderWidget::UpdateTextInputState() { } } -gfx::Rect RenderWidget::GetCaretBounds() { - if (!webwidget_) - return gfx::Rect(); - return webwidget_->caretOrSelectionBounds(); +void RenderWidget::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { + WebRect start_webrect; + WebRect end_webrect; + webwidget_->selectionBounds(start_webrect, end_webrect); + *start = start_webrect; + *end = end_webrect; } void RenderWidget::UpdateSelectionBounds() { if (!webwidget_) return; - WebRect start; - WebRect end; - webwidget_->selectionBounds(start, end); - - gfx::Rect start_rect = start; - gfx::Rect end_rect = end; + gfx::Rect start_rect; + gfx::Rect end_rect; + GetSelectionBounds(&start_rect, &end_rect); if (selection_start_rect_ == start_rect && selection_end_rect_ == end_rect) return; diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index 44a1106..d30b027 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -292,7 +292,7 @@ class CONTENT_EXPORT RenderWidget // Override point to obtain that the current input method state and caret // position. virtual ui::TextInputType GetTextInputType(); - virtual gfx::Rect GetCaretBounds(); + virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end); // Override point to obtain that the current input method state about // composition text. diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc index 060284c..c100c32 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.cc +++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc @@ -25,6 +25,9 @@ void MockPluginDelegate::PluginFocusChanged(PluginInstance* instance, void MockPluginDelegate::PluginTextInputTypeChanged(PluginInstance* instance) { } +void MockPluginDelegate::PluginCaretPositionChanged(PluginInstance* instance) { +} + void MockPluginDelegate::PluginRequestedCancelComposition( PluginInstance* instance) { } diff --git a/webkit/plugins/ppapi/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h index 523973b..5951ba9 100644 --- a/webkit/plugins/ppapi/mock_plugin_delegate.h +++ b/webkit/plugins/ppapi/mock_plugin_delegate.h @@ -17,6 +17,7 @@ class MockPluginDelegate : public PluginDelegate { virtual void PluginFocusChanged(PluginInstance* instance, bool focused); virtual void PluginTextInputTypeChanged(PluginInstance* instance); + virtual void PluginCaretPositionChanged(PluginInstance* instance); virtual void PluginRequestedCancelComposition(PluginInstance* instance); virtual void PluginCrashed(PluginInstance* instance); virtual void InstanceCreated(PluginInstance* instance); diff --git a/webkit/plugins/ppapi/plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h index e9c0258..01f3f95 100644 --- a/webkit/plugins/ppapi/plugin_delegate.h +++ b/webkit/plugins/ppapi/plugin_delegate.h @@ -251,6 +251,9 @@ class PluginDelegate { // Notification that the text input status of the given plugin is changed. virtual void PluginTextInputTypeChanged( webkit::ppapi::PluginInstance* instance) = 0; + // Notification that the caret position in the given plugin is changed. + virtual void PluginCaretPositionChanged( + webkit::ppapi::PluginInstance* instance) = 0; // Notification that the plugin requested to cancel the current composition. virtual void PluginRequestedCancelComposition( webkit::ppapi::PluginInstance* instance) = 0; diff --git a/webkit/plugins/ppapi/ppapi_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc index 5ec687d..14724c8 100644 --- a/webkit/plugins/ppapi/ppapi_plugin_instance.cc +++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc @@ -629,10 +629,12 @@ void PluginInstance::UpdateCaretPosition(const gfx::Rect& caret, text_input_caret_ = caret; text_input_caret_bounds_ = bounding_box; text_input_caret_set_ = true; + delegate()->PluginCaretPositionChanged(this); } void PluginInstance::SetTextInputType(ui::TextInputType type) { text_input_type_ = type; + delegate()->PluginTextInputTypeChanged(this); } bool PluginInstance::IsPluginAcceptingCompositionEvents() const { |