Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2801)

Unified Diff: content/renderer/render_widget.cc

Issue 2650113004: [WIP] Add support for Android SuggestionSpans when editing text (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 9ceb7970c31e94dd094ee3417c2452f0205ae751..c6ce1bd3ebfc238a245198621c95dca3bdc65573 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -587,6 +587,12 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(InputMsg_ImeCommitText, OnImeCommitText)
IPC_MESSAGE_HANDLER(InputMsg_ImeFinishComposingText,
OnImeFinishComposingText)
+ IPC_MESSAGE_HANDLER(InputMsg_ImeApplySuggestionReplacement,
+ OnImeApplySuggestionReplacement)
+ IPC_MESSAGE_HANDLER(InputMsg_ImeDeleteSuggestionHighlight,
+ OnImeDeleteSuggestionHighlight)
+ IPC_MESSAGE_HANDLER(InputMsg_ImeCloseSuggestionMenu,
+ OnImeCloseSuggestionMenu)
IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent,
OnSetEditCommandsForNextKeyEvent)
@@ -1075,6 +1081,25 @@ void RenderWidget::UpdateTextInputStateInternal(bool show_virtual_keyboard,
}
}
+void RenderWidget::HandlePotentialTextSuggestionTap() {
+ blink::WebInputMethodController* controller = GetInputMethodController();
+ if (!controller)
+ return;
+
+ WebVector<blink::WebTextSuggestionInfo> suggestion_infos =
+ controller->getTextSuggestionInfosUnderCaret();
+
+ if (suggestion_infos.size() == 0)
+ return;
+
+ // The composition is now on the suggestion range highlight
+ UpdateCompositionInfo(false /* not an immediate request */);
+
+ Send(new InputHostMsg_ShowTextSuggestionMenu(
+ routing_id(), std::vector<blink::WebTextSuggestionInfo>(
+ suggestion_infos.begin(), suggestion_infos.end())));
+}
+
bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) {
possible_drag_event_info_.event_source =
ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH;
@@ -1613,6 +1638,25 @@ void RenderWidget::OnImeFinishComposingText(bool keep_selection) {
UpdateCompositionInfo(false /* not an immediate request */);
}
+void RenderWidget::OnImeApplySuggestionReplacement(int document_marker_id,
+ int suggestion_index) {
+ if (auto* controller = GetInputMethodController()) {
+ controller->applySuggestionReplacement(document_marker_id,
+ suggestion_index);
+ }
+}
+
+void RenderWidget::OnImeDeleteSuggestionHighlight() {
+ if (auto* controller = GetInputMethodController()) {
+ controller->deleteSuggestionHighlight();
+ }
+}
+
+void RenderWidget::OnImeCloseSuggestionMenu() {
+ if (auto* controller = GetInputMethodController())
+ controller->closeSuggestionMenu();
+}
+
void RenderWidget::OnDeviceScaleFactorChanged() {
if (!compositor_)
return;

Powered by Google App Engine
This is Rietveld 408576698