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

Unified Diff: chrome/renderer/render_widget.cc

Issue 6289009: [Mac] Implement the system dictionary popup by implementing NSTextInput methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Work on IME Created 9 years, 10 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: chrome/renderer/render_widget.cc
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index b9147867edcb21016085fec2d77c442e81e14dd5..180afa24cd699ad42e71ad8282b8514ffc30b496 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -14,6 +14,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
+#include "chrome/common/text_input_client_messages.h"
#include "chrome/renderer/render_process.h"
#include "chrome/renderer/render_thread.h"
#include "chrome/renderer/renderer_webkitclient_impl.h"
@@ -23,6 +24,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
@@ -48,6 +50,7 @@ using WebKit::WebNavigationPolicy;
using WebKit::WebPopupMenu;
using WebKit::WebPopupMenuInfo;
using WebKit::WebPopupType;
+using WebKit::WebRange;
using WebKit::WebRect;
using WebKit::WebScreenInfo;
using WebKit::WebSize;
@@ -862,19 +865,37 @@ void RenderWidget::OnImeSetComposition(
int selection_start, int selection_end) {
if (!webwidget_)
return;
- if (!webwidget_->setComposition(
+ if (webwidget_->setComposition(
text, WebVector<WebCompositionUnderline>(underlines),
selection_start, selection_end)) {
+ // Setting the IME composition was successful. Send the new composition
+ // range to the browser.
+ WebRange range = webwidget_->compositionRange();
+ if (range.isNull()) {
+ // The IME was cancelled via the Esc key, so just send back the caret.
+ range = webwidget_->caretOrSelectionRange();
+ }
+ Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(),
+ range.startOffset(), range.endOffset()));
+ } else {
// If we failed to set the composition text, then we need to let the browser
// process to cancel the input method's ongoing composition session, to make
// sure we are in a consistent state.
Send(new ViewHostMsg_ImeCancelComposition(routing_id()));
+ // Send an updated IME range with just the caret range.
+ WebRange range = webwidget_->caretOrSelectionRange();
+ Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(),
+ range.startOffset(), range.endOffset()));
James Su 2011/02/17 02:03:00 We need this code in RenderWidget::resetInputMetho
Robert Sesek 2011/02/17 20:05:04 Done.
}
}
void RenderWidget::OnImeConfirmComposition(const string16& text) {
if (webwidget_)
webwidget_->confirmComposition(text);
+ // Send an updated IME range with just the caret range.
+ WebRange range = webwidget_->caretOrSelectionRange();
+ Send(new TextInputClientViewHostMsg_ImeCompositionRangeChanged(routing_id(),
+ range.startOffset(), range.endOffset()));
}
// This message causes the renderer to render an image of the

Powered by Google App Engine
This is Rietveld 408576698