summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjennyz <jennyz@chromium.org>2014-10-23 14:52:41 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-23 21:53:01 +0000
commit91b6ed0c33013c73e91b5c8c8be57f340a76f7a6 (patch)
tree0537f8efcb4e0b9dffb87fa6ffe25f75fb4eb4ae /ui
parent0dd094342a90d81ce1e25f2db110bfe51c76d478 (diff)
downloadchromium_src-91b6ed0c33013c73e91b5c8c8be57f340a76f7a6.zip
chromium_src-91b6ed0c33013c73e91b5c8c8be57f340a76f7a6.tar.gz
chromium_src-91b6ed0c33013c73e91b5c8c8be57f340a76f7a6.tar.bz2
Magnifier needs to follow the focus and caret change of the textfield.
BUG=426232 Review URL: https://codereview.chromium.org/665903003 Cr-Commit-Position: refs/heads/master@{#300955}
Diffstat (limited to 'ui')
-rw-r--r--ui/base/ime/input_method_base.cc6
-rw-r--r--ui/base/ime/input_method_base.h4
-rw-r--r--ui/base/ime/input_method_chromeos.cc19
-rw-r--r--ui/base/ime/input_method_chromeos.h6
4 files changed, 28 insertions, 7 deletions
diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc
index 53a16d1..0dca378 100644
--- a/ui/base/ime/input_method_base.cc
+++ b/ui/base/ime/input_method_base.cc
@@ -131,6 +131,12 @@ void InputMethodBase::NotifyTextInputStateChanged(
OnTextInputStateChanged(client));
}
+void InputMethodBase::NotifyTextInputCaretBoundsChanged(
+ const TextInputClient* client) {
+ FOR_EACH_OBSERVER(
+ InputMethodObserver, observer_list_, OnCaretBoundsChanged(client));
+}
+
void InputMethodBase::SetFocusedTextInputClientInternal(
TextInputClient* client) {
if (switches::IsTextInputFocusManagerEnabled())
diff --git a/ui/base/ime/input_method_base.h b/ui/base/ime/input_method_base.h
index e388948..4d732cd 100644
--- a/ui/base/ime/input_method_base.h
+++ b/ui/base/ime/input_method_base.h
@@ -82,6 +82,10 @@ class UI_BASE_EXPORT InputMethodBase
// Convenience method to notify all observers of TextInputClient changes.
void NotifyTextInputStateChanged(const TextInputClient* client);
+ // Convenience method to notify all observers of CaretBounds changes on
+ // |client| which is the text input client with focus.
+ void NotifyTextInputCaretBoundsChanged(const TextInputClient* client);
+
// Interface for for signalling candidate window events.
// See also *Callback functions below. To avoid reentrancy issue that
// TextInputClient manipulates IME state during even handling, these methods
diff --git a/ui/base/ime/input_method_chromeos.cc b/ui/base/ime/input_method_chromeos.cc
index d2ca6f0..37a9c3c 100644
--- a/ui/base/ime/input_method_chromeos.cc
+++ b/ui/base/ime/input_method_chromeos.cc
@@ -123,7 +123,7 @@ bool InputMethodChromeOS::DispatchKeyEvent(const ui::KeyEvent& event) {
// normal input field (not a password field).
// Note: We need to send the key event to ibus even if the |context_| is not
// enabled, so that ibus can have a chance to enable the |context_|.
- if (!IsInputFieldFocused() || !GetEngine()) {
+ if (!IsNonPasswordInputFieldFocused() || !GetEngine()) {
if (event.type() == ET_KEY_PRESSED) {
if (ExecuteCharacterComposer(event)) {
// Treating as PostIME event if character composer handles key event and
@@ -178,6 +178,11 @@ void InputMethodChromeOS::OnCaretBoundsChanged(const TextInputClient* client) {
if (!IsInputFieldFocused() || !IsTextInputClientFocused(client))
return;
+ NotifyTextInputCaretBoundsChanged(client);
+
+ if (!IsNonPasswordInputFieldFocused())
+ return;
+
// The current text input type should not be NONE if |context_| is focused.
DCHECK(!IsTextInputTypeNone());
const gfx::Rect rect = GetTextInputClient()->GetCaretBounds();
@@ -230,7 +235,7 @@ void InputMethodChromeOS::OnCaretBoundsChanged(const TextInputClient* client) {
}
void InputMethodChromeOS::CancelComposition(const TextInputClient* client) {
- if (IsInputFieldFocused() && IsTextInputClientFocused(client))
+ if (IsNonPasswordInputFieldFocused() && IsTextInputClientFocused(client))
ResetContext();
}
@@ -285,7 +290,7 @@ void InputMethodChromeOS::ConfirmCompositionText() {
}
void InputMethodChromeOS::ResetContext() {
- if (!IsInputFieldFocused() || !GetTextInputClient())
+ if (!IsNonPasswordInputFieldFocused() || !GetTextInputClient())
return;
DCHECK(system_toplevel_window_focused());
@@ -319,7 +324,7 @@ void InputMethodChromeOS::UpdateContextFocusState() {
chromeos::IMECandidateWindowHandlerInterface* candidate_window =
chromeos::IMEBridge::Get()->GetCandidateWindowHandler();
if (candidate_window)
- candidate_window->FocusStateChanged(IsInputFieldFocused());
+ candidate_window->FocusStateChanged(IsNonPasswordInputFieldFocused());
chromeos::IMEBridge::Get()->SetCurrentTextInputType(GetTextInputType());
@@ -654,9 +659,13 @@ void InputMethodChromeOS::ExtractCompositionText(
}
}
-bool InputMethodChromeOS::IsInputFieldFocused() {
+bool InputMethodChromeOS::IsNonPasswordInputFieldFocused() {
TextInputType type = GetTextInputType();
return (type != TEXT_INPUT_TYPE_NONE) && (type != TEXT_INPUT_TYPE_PASSWORD);
}
+bool InputMethodChromeOS::IsInputFieldFocused() {
+ return GetTextInputType() != TEXT_INPUT_TYPE_NONE;
+}
+
} // namespace ui
diff --git a/ui/base/ime/input_method_chromeos.h b/ui/base/ime/input_method_chromeos.h
index a09cd3d..1022b04 100644
--- a/ui/base/ime/input_method_chromeos.h
+++ b/ui/base/ime/input_method_chromeos.h
@@ -112,8 +112,10 @@ class UI_BASE_EXPORT InputMethodChromeOS
// Callback function for IMEEngineHandlerInterface::ProcessKeyEvent.
void ProcessKeyEventDone(uint32 id, ui::KeyEvent* event, bool is_handled);
- // Returns whether an input field is focused. Note that password field is not
- // considered as an input field.
+ // Returns whether an non-password input field is focused.
+ bool IsNonPasswordInputFieldFocused();
+
+ // Returns true if an text input field is focused.
bool IsInputFieldFocused();
// All pending key events. Note: we do not own these object, we just save