diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 05:50:13 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-19 05:50:13 +0000 |
commit | f38bc36ec590b9069b79c24e3d4b7462609cbb99 (patch) | |
tree | bd15e5bbe7a54d0c5526ba4b851699ff9025adf0 /views | |
parent | eb3895186d79897fc17310cae771ce2d8df32066 (diff) | |
download | chromium_src-f38bc36ec590b9069b79c24e3d4b7462609cbb99.zip chromium_src-f38bc36ec590b9069b79c24e3d4b7462609cbb99.tar.gz chromium_src-f38bc36ec590b9069b79c24e3d4b7462609cbb99.tar.bz2 |
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
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.cc | 4 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_gtk.h | 1 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_win.cc | 14 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_win.h | 1 | ||||
-rw-r--r-- | views/controls/textfield/native_textfield_wrapper.h | 9 | ||||
-rw-r--r-- | views/controls/textfield/textfield.cc | 6 | ||||
-rw-r--r-- | views/controls/textfield/textfield.h | 3 |
7 files changed, 34 insertions, 4 deletions
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; |