Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Unified Diff: ui/views/widget/widget.cc

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index a57392053e57788faee01af110c585c0e82ea404..8baea97748786da5de544578ec5bdfe48ab5fea4 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"
@@ -64,6 +64,14 @@ NativeWidget* CreateNativeWidget(NativeWidget* native_widget,
return native_widget;
}
+void NotifyCaretBoundsChanged(ui::InputMethod* input_method) {
+ if (!input_method)
+ return;
+ ui::TextInputClient* client = input_method->GetTextInputClient();
+ if (client)
+ input_method->OnCaretBoundsChanged(client);
+}
+
} // namespace
// A default implementation of WidgetDelegate, used by Widget when no
@@ -764,36 +772,25 @@ const FocusManager* Widget::GetFocusManager() const {
}
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());
+ return nullptr;
}
-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 +1112,8 @@ 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);
- }
+ NotifyCaretBoundsChanged(GetInputMethod());
+
FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged(
this,
GetWindowBoundsInScreen()));
@@ -1128,14 +1121,10 @@ 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);
- }
- }
+
+ NotifyCaretBoundsChanged(GetInputMethod());
SaveWindowPlacementIfInitialized();
FOR_EACH_OBSERVER(WidgetObserver, observers_, OnWidgetBoundsChanged(
@@ -1294,10 +1283,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 +1376,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 +1483,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 {
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « ui/views/widget/widget.h ('k') | ui/views/widget/widget_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698