| Index: ui/views/widget/widget.cc
|
| diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
|
| index a57392053e57788faee01af110c585c0e82ea404..f851c49c248368d9bd6b28d07615a1338d079d4d 100644
|
| --- a/ui/views/widget/widget.cc
|
| +++ b/ui/views/widget/widget.cc
|
| @@ -11,6 +11,7 @@
|
| #include "ui/base/cursor/cursor.h"
|
| #include "ui/base/default_theme_provider.h"
|
| #include "ui/base/hit_test.h"
|
| +#include "ui/base/ime/input_method.h"
|
| #include "ui/base/l10n/l10n_font_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/compositor/compositor.h"
|
| @@ -24,7 +25,6 @@
|
| #include "ui/views/focus/focus_manager_factory.h"
|
| #include "ui/views/focus/view_storage.h"
|
| #include "ui/views/focus/widget_focus_manager.h"
|
| -#include "ui/views/ime/input_method.h"
|
| #include "ui/views/views_delegate.h"
|
| #include "ui/views/widget/native_widget_private.h"
|
| #include "ui/views/widget/root_view.h"
|
| @@ -763,37 +763,22 @@ const FocusManager* Widget::GetFocusManager() const {
|
| return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL;
|
| }
|
|
|
| -ui::TextInputClient* Widget::GetFocusedTextInputClient() {
|
| - FocusManager* focus_manager = GetFocusManager();
|
| - View* view = focus_manager ? focus_manager->GetFocusedView() : nullptr;
|
| - return view ? view->GetTextInputClient() : nullptr;
|
| -}
|
| -
|
| -InputMethod* Widget::GetInputMethod() {
|
| - return const_cast<InputMethod*>(
|
| - const_cast<const Widget*>(this)->GetInputMethod());
|
| -}
|
| -
|
| -const InputMethod* Widget::GetInputMethod() const {
|
| +ui::InputMethod* Widget::GetInputMethod() {
|
| if (is_top_level()) {
|
| - if (!input_method_.get())
|
| - input_method_ = const_cast<Widget*>(this)->CreateInputMethod().Pass();
|
| - return input_method_.get();
|
| + // Only creates the shared the input method instance on top level widget.
|
| + return native_widget_private()->GetInputMethod();
|
| } else {
|
| - const Widget* toplevel = GetTopLevelWidget();
|
| + Widget* toplevel = GetTopLevelWidget();
|
| // If GetTopLevelWidget() returns itself which is not toplevel,
|
| // the widget is detached from toplevel widget.
|
| // TODO(oshima): Fix GetTopLevelWidget() to return NULL
|
| // if there is no toplevel. We probably need to add GetTopMostWidget()
|
| // to replace some use cases.
|
| - return (toplevel && toplevel != this) ? toplevel->GetInputMethod() : NULL;
|
| + return (toplevel && toplevel != this) ? toplevel->GetInputMethod()
|
| + : nullptr;
|
| }
|
| }
|
|
|
| -ui::InputMethod* Widget::GetHostInputMethod() {
|
| - return native_widget_private()->GetHostInputMethod();
|
| -}
|
| -
|
| void Widget::RunShellDrag(View* view,
|
| const ui::OSExchangeData& data,
|
| const gfx::Point& location,
|
| @@ -1115,12 +1100,13 @@ gfx::Size Widget::GetMaximumSize() const {
|
|
|
| void Widget::OnNativeWidgetMove() {
|
| widget_delegate_->OnWidgetMove();
|
| - View* root = GetRootView();
|
| - if (root && root->GetFocusManager()) {
|
| - View* focused_view = root->GetFocusManager()->GetFocusedView();
|
| - if (focused_view && focused_view->GetInputMethod())
|
| - focused_view->GetInputMethod()->OnCaretBoundsChanged(focused_view);
|
| + ui::InputMethod* input_method = GetInputMethod();
|
| + if (input_method) {
|
| + ui::TextInputClient* client = input_method->GetTextInputClient();
|
| + if (client)
|
| + input_method->OnCaretBoundsChanged(client);
|
| }
|
| +
|
| FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged(
|
| this,
|
| GetWindowBoundsInScreen()));
|
| @@ -1128,13 +1114,13 @@ void Widget::OnNativeWidgetMove() {
|
|
|
| void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) {
|
| View* root = GetRootView();
|
| - if (root) {
|
| + if (root)
|
| root->SetSize(new_size);
|
| - if (root->GetFocusManager()) {
|
| - View* focused_view = GetRootView()->GetFocusManager()->GetFocusedView();
|
| - if (focused_view && focused_view->GetInputMethod())
|
| - focused_view->GetInputMethod()->OnCaretBoundsChanged(focused_view);
|
| - }
|
| + ui::InputMethod* input_method = GetInputMethod();
|
| + if (input_method) {
|
| + ui::TextInputClient* client = input_method->GetTextInputClient();
|
| + if (client)
|
| + input_method->OnCaretBoundsChanged(client);
|
| }
|
| SaveWindowPlacementIfInitialized();
|
|
|
| @@ -1294,10 +1280,6 @@ bool Widget::ExecuteCommand(int command_id) {
|
| return widget_delegate_->ExecuteWindowsCommand(command_id);
|
| }
|
|
|
| -InputMethod* Widget::GetInputMethodDirect() {
|
| - return input_method_.get();
|
| -}
|
| -
|
| const std::vector<ui::Layer*>& Widget::GetRootLayers() {
|
| if (root_layers_dirty_) {
|
| root_layers_dirty_ = false;
|
| @@ -1391,8 +1373,6 @@ internal::RootView* Widget::CreateRootView() {
|
| void Widget::DestroyRootView() {
|
| non_client_view_ = NULL;
|
| root_view_.reset();
|
| - // Input method has to be destroyed before focus manager.
|
| - input_method_.reset();
|
| }
|
|
|
| void Widget::OnDragWillStart() {
|
| @@ -1500,19 +1480,6 @@ bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds,
|
| return false;
|
| }
|
|
|
| -scoped_ptr<InputMethod> Widget::CreateInputMethod() {
|
| - scoped_ptr<InputMethod> input_method(native_widget_->CreateInputMethod());
|
| - if (input_method.get())
|
| - input_method->Init(this);
|
| - return input_method.Pass();
|
| -}
|
| -
|
| -void Widget::ReplaceInputMethod(InputMethod* input_method) {
|
| - input_method_.reset(input_method);
|
| - input_method->SetDelegate(native_widget_->GetInputMethodDelegate());
|
| - input_method->Init(this);
|
| -}
|
| -
|
| namespace internal {
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
|
|