Index: ui/views/controls/textfield/native_textfield_views.cc |
diff --git a/ui/views/controls/textfield/native_textfield_views.cc b/ui/views/controls/textfield/native_textfield_views.cc |
index 0e807556ef17f3f3ed9fc71fa049f1fdfb8492cf..80acc84e7ce0d6ada214246d6e4826c2777261e0 100644 |
--- a/ui/views/controls/textfield/native_textfield_views.cc |
+++ b/ui/views/controls/textfield/native_textfield_views.cc |
@@ -967,7 +967,18 @@ void NativeTextfieldViews::InsertChar(char16 ch, int flags) { |
} |
gfx::NativeWindow NativeTextfieldViews::GetAttachedWindow() const { |
- return GetWidget()->GetNativeWindow(); |
+ // Imagine the following hierarchy. |
+ // [NativeWidget A] - FocusManager |
+ // [View] |
+ // [NativeWidget B] |
+ // [View] |
+ // [View X] |
+ // An important thing is that [NativeWidget A] owns Win32 input focus even |
+ // when [View X] is logically focused by FocusManager. As a result, an Win32 |
+ // IME may want to interact with the native view of [NativeWidget A] rather |
+ // than that of [NativeWidget B]. This is why we need to call |
+ // GetTopLevelWidget() here. |
+ return GetWidget()->GetTopLevelWidget()->GetNativeView(); |
} |
ui::TextInputType NativeTextfieldViews::GetTextInputType() const { |