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

Side by Side Diff: ui/views/ime/input_method_bridge.cc

Issue 1155013005: Refactoring the ownership of ui::InputMethod. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pls be 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/ime/input_method_bridge.h" 5 #include "ui/views/ime/input_method_bridge.h"
6 6
7 #include "ui/base/ime/input_method.h" 7 #include "ui/base/ime/input_method.h"
8 #include "ui/base/ime/input_method_observer.h" 8 #include "ui/base/ime/input_method_observer.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use 74 // this and go into |widget_|. NULL out |widget_| so we don't attempt to use
75 // it. 75 // it.
76 DetachFromWidget(); 76 DetachFromWidget();
77 77
78 // Host input method might have been destroyed at this point. 78 // Host input method might have been destroyed at this point.
79 if (host_) 79 if (host_)
80 host_->DetachTextInputClient(this); 80 host_->DetachTextInputClient(this);
81 } 81 }
82 82
83 void InputMethodBridge::OnFocus() { 83 void InputMethodBridge::OnFocus() {
84 DCHECK(host_); 84 if (!host_) // |host_| could be NULL after OnInputMethodDestroyed.
85 return;
85 86
86 // Direct the shared IME to send TextInputClient messages to |this| object. 87 // Direct the shared IME to send TextInputClient messages to |this| object.
87 if (shared_input_method_ || !host_->GetTextInputClient()) 88 if (shared_input_method_ || !host_->GetTextInputClient())
88 host_->SetFocusedTextInputClient(this); 89 host_->SetFocusedTextInputClient(this);
89 90
90 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move 91 // TODO(yusukes): We don't need to call OnTextInputTypeChanged() once we move
91 // text input type tracker code to ui::InputMethodBase. 92 // text input type tracker code to ui::InputMethodBase.
92 if (GetFocusedView()) { 93 if (GetFocusedView()) {
93 OnTextInputTypeChanged(GetFocusedView()); 94 OnTextInputTypeChanged(GetFocusedView());
94 OnCaretBoundsChanged(GetFocusedView()); 95 OnCaretBoundsChanged(GetFocusedView());
95 } 96 }
96 } 97 }
97 98
98 void InputMethodBridge::OnBlur() { 99 void InputMethodBridge::OnBlur() {
99 DCHECK(host_); 100 if (!host_) // |host_| could be NULL after OnInputMethodDestroyed.
101 return;
100 102
101 if (HasCompositionText()) { 103 if (HasCompositionText()) {
102 ConfirmCompositionText(); 104 ConfirmCompositionText();
103 host_->CancelComposition(this); 105 host_->CancelComposition(this);
104 } 106 }
105 107
106 if (host_->GetTextInputClient() == this) 108 if (host_->GetTextInputClient() == this)
107 host_->SetFocusedTextInputClient(NULL); 109 host_->SetFocusedTextInputClient(NULL);
108 } 110 }
109 111
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 OnTextInputTypeChanged(focused); 346 OnTextInputTypeChanged(focused);
345 OnCaretBoundsChanged(focused); 347 OnCaretBoundsChanged(focused);
346 } 348 }
347 349
348 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const { 350 ui::InputMethod* InputMethodBridge::GetHostInputMethod() const {
349 return host_; 351 return host_;
350 } 352 }
351 353
352 354
353 } // namespace views 355 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698