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

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: test green. 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 a57392053e57788faee01af110c585c0e82ea404..6de5de6440d00cd66d33eceffb7ee5e8c7f81eb0 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"
@@ -764,36 +764,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 +1104,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 +1118,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();
sky 2015/06/30 16:32:31 This is the same as 1107-1112. How about a functio
Shu Chen 2015/07/01 02:38:57 Done.
+ if (input_method) {
+ ui::TextInputClient* client = input_method->GetTextInputClient();
+ if (client)
+ input_method->OnCaretBoundsChanged(client);
}
SaveWindowPlacementIfInitialized();
@@ -1294,10 +1284,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 +1377,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 +1484,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