summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
authorpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 15:09:55 +0000
committerpenghuang@chromium.org <penghuang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 15:09:55 +0000
commit35b43438ae0a69558f6fec5d48be3d4a59c4ea65 (patch)
tree142fec0f41d598a4c18c317ca3368400a65207cf /views/widget
parent3366781081c7264144fc9d3e79335ec6462f89b8 (diff)
downloadchromium_src-35b43438ae0a69558f6fec5d48be3d4a59c4ea65.zip
chromium_src-35b43438ae0a69558f6fec5d48be3d4a59c4ea65.tar.gz
chromium_src-35b43438ae0a69558f6fec5d48be3d4a59c4ea65.tar.bz2
Create the InputMethod when it is first requested by a child view.
Many widgets(popup menu) do not contain any views which need input method and creating an input method instance may be high cost operation. In those cases we do not create input method util it is fist requested by a child view. BUG=None TEST=Manually Review URL: http://codereview.chromium.org/7170018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89336 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/native_widget_gtk.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 74795e9..ea7dc50 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -682,22 +682,6 @@ void NativeWidgetGtk::InitNativeWidget(const Widget::InitParams& params) {
CreateGtkWidget(modified_params);
delegate_->OnNativeWidgetCreated();
- // Creates input method for toplevel widget after calling
- // delegate_->OnNativeWidgetCreated(), to make sure that focus manager is
- // already created at this point.
- // TODO(suzhe): Always enable input method when we start to use
- // RenderWidgetHostViewViews in normal ChromeOS.
- if (!child_ && NativeTextfieldViews::IsTextfieldViewsEnabled()) {
-#if defined(HAVE_IBUS)
- input_method_.reset(InputMethodIBus::IsInputMethodIBusEnabled() ?
- static_cast<InputMethod*>(new InputMethodIBus(this)) :
- static_cast<InputMethod*>(new InputMethodGtk(this)));
-#else
- input_method_.reset(new InputMethodGtk(this));
-#endif
- input_method_->Init(GetWidget());
- }
-
if (opacity_ != 255)
SetOpacity(opacity_);
@@ -906,6 +890,21 @@ bool NativeWidgetGtk::IsMouseButtonDown() const {
}
InputMethod* NativeWidgetGtk::GetInputMethodNative() {
+ if (!input_method_.get()) {
+ // Create input method when it is requested by a child view.
+ // TODO(suzhe): Always enable input method when we start to use
+ // RenderWidgetHostViewViews in normal ChromeOS.
+ if (!child_ && NativeTextfieldViews::IsTextfieldViewsEnabled()) {
+#if defined(HAVE_IBUS)
+ input_method_.reset(InputMethodIBus::IsInputMethodIBusEnabled() ?
+ static_cast<InputMethod*>(new InputMethodIBus(this)) :
+ static_cast<InputMethod*>(new InputMethodGtk(this)));
+#else
+ input_method_.reset(new InputMethodGtk(this));
+#endif
+ input_method_->Init(GetWidget());
+ }
+ }
return input_method_.get();
}