summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 22:11:23 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-20 22:11:23 +0000
commit7135a6ad137d4659f1e50f4dcab150ba21f16d01 (patch)
tree447a38896821124816d7b72ee51e37d89a9c51b0
parenta6191d84852eda1bac7fee961911f8090569f98b (diff)
downloadchromium_src-7135a6ad137d4659f1e50f4dcab150ba21f16d01.zip
chromium_src-7135a6ad137d4659f1e50f4dcab150ba21f16d01.tar.gz
chromium_src-7135a6ad137d4659f1e50f4dcab150ba21f16d01.tar.bz2
Merge 44904 - A quick fix for Issue 34970.
This issue is caused by r34322 that changes text composed by an IME. (It makes Windows reset the IME.) As a quick fix, this changes adds a new method TextField::IMEIsComposing() and call it before changing text in FindBarView::UpdateForResult(). BUG=34970 TEST=Type Ctrl+F, enable a Japanese IME, and type shift+a, return, and shift+a. Verify if the find box has two As, i.e. 'AA'. Review URL: http://codereview.chromium.org/1630014 TBR=hbono@chromium.org Review URL: http://codereview.chromium.org/2119013 git-svn-id: svn://svn.chromium.org/chrome/branches/375/src@47851 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/find_bar_view.cc5
-rw-r--r--views/controls/textfield/native_textfield_gtk.cc4
-rw-r--r--views/controls/textfield/native_textfield_gtk.h1
-rw-r--r--views/controls/textfield/native_textfield_win.cc14
-rw-r--r--views/controls/textfield/native_textfield_win.h1
-rw-r--r--views/controls/textfield/native_textfield_wrapper.h9
-rw-r--r--views/controls/textfield/textfield.cc6
-rw-r--r--views/controls/textfield/textfield.h3
8 files changed, 38 insertions, 5 deletions
diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc
index 4bf07fd..7e15345 100644
--- a/chrome/browser/views/find_bar_view.cc
+++ b/chrome/browser/views/find_bar_view.cc
@@ -179,7 +179,10 @@ void FindBarView::UpdateForResult(const FindNotificationDetails& result,
bool have_valid_range =
result.number_of_matches() != -1 && result.active_match_ordinal() != -1;
- if (find_text_->text() != find_text) {
+ // http://crbug.com/34970: some IMEs get confused if we change the text
+ // composed by them. To avoid this problem, we should check the IME status and
+ // update the text only when the IME is not composing text.
+ if (find_text_->text() != find_text && !find_text_->IsIMEComposing()) {
find_text_->SetText(find_text);
find_text_->SelectAll();
}
diff --git a/views/controls/textfield/native_textfield_gtk.cc b/views/controls/textfield/native_textfield_gtk.cc
index 1d4dd23..91f1012 100644
--- a/views/controls/textfield/native_textfield_gtk.cc
+++ b/views/controls/textfield/native_textfield_gtk.cc
@@ -212,6 +212,10 @@ gfx::NativeView NativeTextfieldGtk::GetTestingHandle() const {
return native_view();
}
+bool NativeTextfieldGtk::IsIMEComposing() const {
+ return false;
+}
+
// static
gboolean NativeTextfieldGtk::OnKeyPressEventHandler(
GtkWidget* entry,
diff --git a/views/controls/textfield/native_textfield_gtk.h b/views/controls/textfield/native_textfield_gtk.h
index 0e4a1b5..1ada4ac 100644
--- a/views/controls/textfield/native_textfield_gtk.h
+++ b/views/controls/textfield/native_textfield_gtk.h
@@ -44,6 +44,7 @@ class NativeTextfieldGtk : public NativeControlGtk,
virtual void SetFocus();
virtual View* GetView();
virtual gfx::NativeView GetTestingHandle() const;
+ virtual bool IsIMEComposing() const;
// Overridden from NativeControlGtk:
virtual void CreateNativeControl();
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 73a5987..13cf93b 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -244,6 +244,20 @@ gfx::NativeView NativeTextfieldWin::GetTestingHandle() const {
return m_hWnd;
}
+bool NativeTextfieldWin::IsIMEComposing() const {
+ // Retrieve the length of the composition string to check if an IME is
+ // composing text. (If this length is > 0 then an IME is being used to compose
+ // text.)
+ HIMC imm_context = ImmGetContext(m_hWnd);
+ if (!imm_context)
+ return false;
+
+ const int composition_size = ImmGetCompositionString(imm_context, GCS_COMPSTR,
+ NULL, 0);
+ ImmReleaseContext(m_hWnd, imm_context);
+ return composition_size > 0;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeTextfieldWin, menus::SimpleMenuModel::Delegate implementation:
diff --git a/views/controls/textfield/native_textfield_win.h b/views/controls/textfield/native_textfield_win.h
index 78339e3..496e332 100644
--- a/views/controls/textfield/native_textfield_win.h
+++ b/views/controls/textfield/native_textfield_win.h
@@ -62,6 +62,7 @@ class NativeTextfieldWin
virtual void SetFocus();
virtual View* GetView();
virtual gfx::NativeView GetTestingHandle() const;
+ virtual bool IsIMEComposing() const;
// Overridden from menus::SimpleMenuModel::Delegate:
virtual bool IsCommandIdChecked(int command_id) const;
diff --git a/views/controls/textfield/native_textfield_wrapper.h b/views/controls/textfield/native_textfield_wrapper.h
index aa21d85..90321a9 100644
--- a/views/controls/textfield/native_textfield_wrapper.h
+++ b/views/controls/textfield/native_textfield_wrapper.h
@@ -1,6 +1,6 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#ifndef VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_
#define VIEWS_CONTROLS_TEXTFIELD_NATIVE_TEXTFIELD_WRAPPER_H_
@@ -82,6 +82,9 @@ class NativeTextfieldWrapper {
// Returns a handle to the underlying native view for testing.
virtual gfx::NativeView GetTestingHandle() const = 0;
+ // Returns whether or not an IME is composing text.
+ virtual bool IsIMEComposing() const = 0;
+
// Creates an appropriate NativeTextfieldWrapper for the platform.
static NativeTextfieldWrapper* CreateWrapper(Textfield* field);
};
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index 11dceba..cf54251 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -202,6 +202,10 @@ void Textfield::SyncText() {
text_ = native_wrapper_->GetText();
}
+bool Textfield::IsIMEComposing() const {
+ return native_wrapper_ && native_wrapper_->IsIMEComposing();
+}
+
////////////////////////////////////////////////////////////////////////////////
// Textfield, View overrides:
@@ -260,7 +264,7 @@ bool Textfield::GetAccessibleRole(AccessibilityTypes::Role* role) {
bool Textfield::GetAccessibleState(AccessibilityTypes::State* state) {
DCHECK(state);
-
+
*state = 0;
if (read_only())
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index 8be768a..c0e125d 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -206,6 +206,9 @@ class Textfield : public View {
// been deleted during a window close.
void SyncText();
+ // Returns whether or not an IME is composing text.
+ bool IsIMEComposing() const;
+
#ifdef UNIT_TEST
gfx::NativeView GetTestingHandle() const {
return native_wrapper_ ? native_wrapper_->GetTestingHandle() : NULL;