Chromium Code Reviews| Index: content/renderer/render_widget.cc |
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
| index 5dad6a896032f95a839de84eb189e9b71a8437f7..25b3fb16517f488c0c9e00b506de9085bd415cda 100644 |
| --- a/content/renderer/render_widget.cc |
| +++ b/content/renderer/render_widget.cc |
| @@ -246,7 +246,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()); |
| @@ -1484,6 +1485,18 @@ void RenderWidget::OnImeSetComposition( |
| const std::vector<WebCompositionUnderline>& underlines, |
| const gfx::Range& replacement_range, |
| int selection_start, int selection_end) { |
| + FOR_EACH_OBSERVER( |
| + RenderFrameImpl, render_frames_, |
| + OnImeSetComposition(this, text, underlines, replacement_range, |
|
EhsanK
2016/06/03 02:38:54
This and the one below for OnImeConfirmComposition
kenrb
2016/06/07 20:18:13
This is a bit tricky. The code is a bit tortured a
EhsanK
2016/06/09 03:24:26
Done.
|
| + selection_start, selection_end)); |
| +} |
| + |
| +void RenderWidget::HandleImeSetComposition( |
| + const base::string16& text, |
| + const std::vector<WebCompositionUnderline>& underlines, |
| + const gfx::Range& replacement_range, |
| + int selection_start, |
| + int selection_end) { |
| if (!ShouldHandleImeEvent()) |
| return; |
| ImeEventGuard guard(this); |
| @@ -1501,6 +1514,15 @@ void RenderWidget::OnImeSetComposition( |
| void RenderWidget::OnImeConfirmComposition(const base::string16& text, |
| const gfx::Range& replacement_range, |
| bool keep_selection) { |
| + FOR_EACH_OBSERVER( |
| + RenderFrameImpl, render_frames_, |
| + OnImeConfirmComposition(this, text, replacement_range, keep_selection)); |
| +} |
| + |
| +void RenderWidget::HandleImeConfirmComposition( |
| + const base::string16& text, |
| + const gfx::Range& replacement_range, |
| + bool keep_selection) { |
| if (!ShouldHandleImeEvent()) |
| return; |
| ImeEventGuard guard(this); |
| @@ -1588,6 +1610,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; |
| @@ -1800,6 +1826,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); |
| @@ -1894,9 +1933,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); |
| @@ -1924,6 +1983,10 @@ bool RenderWidget::ShouldUpdateCompositionInfo( |
| } |
| bool RenderWidget::CanComposeInline() { |
| +#if defined(ENABLE_PLUGINS) |
| + if (focused_pepper_plugin_) |
| + return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); |
| +#endif |
| return true; |
| } |