| Index: content/renderer/render_widget.cc
|
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
|
| index 7797b31cf3041a4f58b09656ab2a484985418220..7a9920204a6ac5d184a089a19347b6d04a788b65 100644
|
| --- a/content/renderer/render_widget.cc
|
| +++ b/content/renderer/render_widget.cc
|
| @@ -257,7 +257,8 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
|
| frame_swap_message_queue_(new FrameSwapMessageQueue()),
|
| resizing_mode_selector_(new ResizingModeSelector()),
|
| has_host_context_menu_location_(false),
|
| - has_focus_(false) {
|
| + has_focus_(false),
|
| + focused_pepper_plugin_(nullptr) {
|
| if (!swapped_out)
|
| RenderProcess::current()->AddRefProcess();
|
| DCHECK(RenderThread::Get());
|
| @@ -1337,6 +1338,18 @@ void RenderWidget::OnImeSetComposition(
|
| const std::vector<WebCompositionUnderline>& underlines,
|
| const gfx::Range& replacement_range,
|
| int selection_start, int selection_end) {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_) {
|
| + focused_pepper_plugin_->render_frame()->OnImeSetComposition(
|
| + text, underlines, selection_start, selection_end);
|
| + return;
|
| + }
|
| +#endif
|
| + if (replacement_range.IsValid()) {
|
| + webwidget_->applyReplacementRange(replacement_range.start(),
|
| + replacement_range.length());
|
| + }
|
| +
|
| if (!ShouldHandleImeEvent())
|
| return;
|
| ImeEventGuard guard(this);
|
| @@ -1354,6 +1367,18 @@ void RenderWidget::OnImeSetComposition(
|
| void RenderWidget::OnImeConfirmComposition(const base::string16& text,
|
| const gfx::Range& replacement_range,
|
| bool keep_selection) {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_) {
|
| + focused_pepper_plugin_->render_frame()->OnImeConfirmComposition(
|
| + text, replacement_range, keep_selection);
|
| + return;
|
| + }
|
| +#endif
|
| + if (replacement_range.IsValid()) {
|
| + webwidget_->applyReplacementRange(replacement_range.start(),
|
| + replacement_range.length());
|
| + }
|
| +
|
| if (!ShouldHandleImeEvent())
|
| return;
|
| ImeEventGuard guard(this);
|
| @@ -1441,6 +1466,10 @@ void RenderWidget::showImeIfNeeded() {
|
| }
|
|
|
| ui::TextInputType RenderWidget::GetTextInputType() {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_)
|
| + return focused_pepper_plugin_->text_input_type();
|
| +#endif
|
| if (webwidget_)
|
| return WebKitToUiTextInputType(webwidget_->textInputType());
|
| return ui::TEXT_INPUT_TYPE_NONE;
|
| @@ -1653,6 +1682,19 @@ void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) {
|
| }
|
|
|
| void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_) {
|
| + // 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.
|
| + blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds());
|
| + convertViewportToWindow(&caret);
|
| + *focus = caret;
|
| + *anchor = caret;
|
| + return;
|
| + }
|
| +#endif
|
| WebRect focus_webrect;
|
| WebRect anchor_webrect;
|
| webwidget_->selectionBounds(focus_webrect, anchor_webrect);
|
| @@ -1768,9 +1810,29 @@ void RenderWidget::GetCompositionCharacterBounds(
|
| std::vector<gfx::Rect>* bounds) {
|
| DCHECK(bounds);
|
| bounds->clear();
|
| +
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_)
|
| + return;
|
| +#endif
|
| +
|
| + if (!webwidget_)
|
| + return;
|
| + blink::WebVector<blink::WebRect> bounds_from_blink;
|
| + if (!webwidget_->getCompositionCharacterBounds(bounds_from_blink))
|
| + return;
|
| +
|
| + for (size_t i = 0; i < bounds_from_blink.size(); ++i) {
|
| + convertViewportToWindow(&bounds_from_blink[i]);
|
| + bounds->push_back(bounds_from_blink[i]);
|
| + }
|
| }
|
|
|
| void RenderWidget::GetCompositionRange(gfx::Range* range) {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_)
|
| + return;
|
| +#endif
|
| size_t location, length;
|
| if (webwidget_->compositionRange(&location, &length)) {
|
| range->set_start(location);
|
| @@ -1798,6 +1860,10 @@ bool RenderWidget::ShouldUpdateCompositionInfo(
|
| }
|
|
|
| bool RenderWidget::CanComposeInline() {
|
| +#if defined(ENABLE_PLUGINS)
|
| + if (focused_pepper_plugin_)
|
| + return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents();
|
| +#endif
|
| return true;
|
| }
|
|
|
|
|