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

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: reverted changes for MockInputMethod. 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
Index: ui/views/widget/widget.cc
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 0b4e2479bc6ada001a5a72752de48deefb4746e9..d26af464ac28a77f11bdefc4ad07d20b3d344127 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"
@@ -769,31 +769,22 @@ ui::TextInputClient* Widget::GetFocusedTextInputClient() {
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,
@@ -1128,12 +1119,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()));
@@ -1141,13 +1133,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();
@@ -1307,10 +1299,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;
@@ -1404,8 +1392,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() {
@@ -1513,19 +1499,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 {
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698