summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_widget.cc
diff options
context:
space:
mode:
authorhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 07:40:53 +0000
committerhbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 07:40:53 +0000
commit34f6bc1937fe617875e8f5e95485904569cca582 (patch)
tree94f201b6bb78ff601a8a97783f4ac0134423af48 /chrome/renderer/render_widget.cc
parent576d8bff4e6778c6de60b8a7269a78c5e8bf602a (diff)
downloadchromium_src-34f6bc1937fe617875e8f5e95485904569cca582.zip
chromium_src-34f6bc1937fe617875e8f5e95485904569cca582.tar.gz
chromium_src-34f6bc1937fe617875e8f5e95485904569cca582.tar.bz2
Changes parameters used by IME code to fix several issues caused by Japanese IMEs.
Recent Japanese IMEs (ATOK2008 and MSIME 2007) display a suggestion window (a window which contains suggestions) above a composition string. To fix this issue, we do not only send the lower-left corner of a composition string but also send its upper-left corner and its upper-right corner. So, this change changes IPC parameters used by IME from a tuple of integers to gfx::Rect. Also, this change fixes cursor positions for Japanese IMEs. BUG=2770 "IME: Candidate window of Japanese IME follows the end of composition" BUG=2771 "ATOK 2008 IME pop-ups are displayed below the main Chrome window." BUG=2775 "IME: Caret is always displayed at the last of IME composition." Review URL: http://codereview.chromium.org/7385 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_widget.cc')
-rw-r--r--chrome/renderer/render_widget.cc42
1 files changed, 23 insertions, 19 deletions
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index c8d3070..ab1a270 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -667,11 +667,9 @@ void RenderWidget::OnImeSetComposition(int string_type,
int target_start, int target_end,
const std::wstring& ime_string) {
if (webwidget_) {
- int string_length = static_cast<int>(ime_string.length());
- const wchar_t* string_data = ime_string.data();
webwidget_->ImeSetComposition(string_type, cursor_position,
target_start, target_end,
- string_length, string_data);
+ ime_string);
}
}
@@ -693,17 +691,20 @@ void RenderWidget::UpdateIME() {
if (!ime_is_active_) {
return;
}
- // Retrieve the caret position from the focused widget.
- bool enable_ime;
- int x, y;
- const void *id;
- if (!webwidget_ || !webwidget_->ImeUpdateStatus(&enable_ime, &id, &x, &y)) {
+ // Retrieve the caret position from the focused widget and verify we should
+ // enabled IMEs attached to the browser process.
+ bool enable_ime = false;
+ const void* node = NULL;
+ gfx::Rect caret_rect;
+ if (!webwidget_ ||
+ !webwidget_->ImeUpdateStatus(&enable_ime, &node, &caret_rect)) {
// There are not any editable widgets attached to this process.
// We should disable the IME to prevent it from sending CJK strings to
// non-editable widgets.
ime_control_updated_ = true;
ime_control_new_state_ = false;
}
+ ime_control_new_state_ = enable_ime;
if (ime_control_updated_) {
// The input focus has been changed.
// Compare the current state with the updated state and choose actions.
@@ -711,20 +712,22 @@ void RenderWidget::UpdateIME() {
if (ime_control_new_state_) {
// Case 1: a text input -> another text input
// Complete the current composition and notify the caret position.
- enum ViewHostMsg_ImeControl control = IME_COMPLETE_COMPOSITION;
- Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), control, x, y));
+ Send(new ViewHostMsg_ImeUpdateStatus(routing_id(),
+ IME_COMPLETE_COMPOSITION,
+ caret_rect));
} else {
// Case 2: a text input -> a password input (or a static control)
// Complete the current composition and disable the IME.
- enum ViewHostMsg_ImeControl control = IME_DISABLE;
- Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), control, x, y));
+ Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), IME_DISABLE,
+ caret_rect));
}
} else {
if (ime_control_new_state_) {
// Case 3: a password input (or a static control) -> a text input
// Enable the IME and notify the caret position.
- enum ViewHostMsg_ImeControl control = IME_COMPLETE_COMPOSITION;
- Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), control, x, y));
+ Send(new ViewHostMsg_ImeUpdateStatus(routing_id(),
+ IME_COMPLETE_COMPOSITION,
+ caret_rect));
} else {
// Case 4: a password input (or a static contol) -> another password
// input (or another static control).
@@ -735,17 +738,18 @@ void RenderWidget::UpdateIME() {
// The input focus is not changed.
// Notify the caret position to a browser process only if it is changed.
if (ime_control_enable_ime_) {
- if (x != ime_control_x_ || y != ime_control_y_) {
- enum ViewHostMsg_ImeControl control = IME_MOVE_WINDOWS;
- Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), control, x, y));
+ if (caret_rect.x() != ime_control_x_ ||
+ caret_rect.y() != ime_control_y_) {
+ Send(new ViewHostMsg_ImeUpdateStatus(routing_id(), IME_MOVE_WINDOWS,
+ caret_rect));
}
}
}
// Save the updated IME status to prevent from sending the same IPC messages.
ime_control_updated_ = false;
ime_control_enable_ime_ = ime_control_new_state_;
- ime_control_x_ = x;
- ime_control_y_ = y;
+ ime_control_x_ = caret_rect.x();
+ ime_control_y_ = caret_rect.y();
}
void RenderWidget::DidMove(WebWidget* webwidget,