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

Unified Diff: ui/base/ime/input_method_ibus.cc

Issue 48393003: Add InputMethodObserver support into InputMethodBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix -Werror=sign-compare Created 7 years, 2 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/base/ime/input_method_ibus.h ('k') | ui/base/ime/input_method_imm32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/ime/input_method_ibus.cc
diff --git a/ui/base/ime/input_method_ibus.cc b/ui/base/ime/input_method_ibus.cc
index d7124633ae77df8c4f7b9243e2f235cfb0babdca..c0bfed1cf3dce1cc03e713011a44f78341b1dc60 100644
--- a/ui/base/ime/input_method_ibus.cc
+++ b/ui/base/ime/input_method_ibus.cc
@@ -234,61 +234,8 @@ void InputMethodIBus::OnTextInputTypeChanged(const TextInputClient* client) {
}
void InputMethodIBus::OnCaretBoundsChanged(const TextInputClient* client) {
- if (!context_focused_ || !IsTextInputClientFocused(client))
- return;
-
- // The current text input type should not be NONE if |context_| is focused.
- DCHECK(!IsTextInputTypeNone());
- const gfx::Rect rect = GetTextInputClient()->GetCaretBounds();
-
- gfx::Rect composition_head;
- if (!GetTextInputClient()->GetCompositionCharacterBounds(0,
- &composition_head)) {
- composition_head = rect;
- }
-
- chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window =
- chromeos::IBusBridge::Get()->GetCandidateWindowHandler();
- if (!candidate_window)
- return;
- candidate_window->SetCursorLocation(
- GfxRectToIBusRect(rect),
- GfxRectToIBusRect(composition_head));
-
- gfx::Range text_range;
- gfx::Range selection_range;
- string16 surrounding_text;
- if (!GetTextInputClient()->GetTextRange(&text_range) ||
- !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) ||
- !GetTextInputClient()->GetSelectionRange(&selection_range)) {
- previous_surrounding_text_.clear();
- previous_selection_range_ = gfx::Range::InvalidRange();
- return;
- }
-
- if (previous_selection_range_ == selection_range &&
- previous_surrounding_text_ == surrounding_text)
- return;
-
- previous_selection_range_ = selection_range;
- previous_surrounding_text_ = surrounding_text;
-
- if (!selection_range.IsValid()) {
- // TODO(nona): Ideally selection_range should not be invalid.
- // TODO(nona): If javascript changes the focus on page loading, even (0,0)
- // can not be obtained. Need investigation.
- return;
- }
-
- // Here SetSurroundingText accepts relative position of |surrounding_text|, so
- // we have to convert |selection_range| from node coordinates to
- // |surrounding_text| coordinates.
- if (!GetEngine())
- return;
- GetEngine()->SetSurroundingText(
- UTF16ToUTF8(surrounding_text),
- selection_range.start() - text_range.start(),
- selection_range.end() - text_range.start());
+ OnCaretBoundsChangedInternal(client);
+ InputMethodBase::OnCaretBoundsChanged(client);
}
void InputMethodIBus::CancelComposition(const TextInputClient* client) {
@@ -296,10 +243,6 @@ void InputMethodIBus::CancelComposition(const TextInputClient* client) {
ResetContext();
}
-void InputMethodIBus::OnInputLocaleChanged() {
- // Not supported.
-}
-
std::string InputMethodIBus::GetInputLocale() {
// Not supported.
return "";
@@ -806,4 +749,63 @@ void InputMethodIBus::ExtractCompositionText(
}
}
+void InputMethodIBus::OnCaretBoundsChangedInternal(
+ const TextInputClient* client) {
+ if (!context_focused_ || !IsTextInputClientFocused(client))
+ return;
+
+ // The current text input type should not be NONE if |context_| is focused.
+ DCHECK(!IsTextInputTypeNone());
+ const gfx::Rect rect = GetTextInputClient()->GetCaretBounds();
+
+ gfx::Rect composition_head;
+ if (!GetTextInputClient()->GetCompositionCharacterBounds(0,
+ &composition_head)) {
+ composition_head = rect;
+ }
+
+ chromeos::IBusPanelCandidateWindowHandlerInterface* candidate_window =
+ chromeos::IBusBridge::Get()->GetCandidateWindowHandler();
+ if (!candidate_window)
+ return;
+ candidate_window->SetCursorLocation(
+ GfxRectToIBusRect(rect),
+ GfxRectToIBusRect(composition_head));
+
+ gfx::Range text_range;
+ gfx::Range selection_range;
+ string16 surrounding_text;
+ if (!GetTextInputClient()->GetTextRange(&text_range) ||
+ !GetTextInputClient()->GetTextFromRange(text_range, &surrounding_text) ||
+ !GetTextInputClient()->GetSelectionRange(&selection_range)) {
+ previous_surrounding_text_.clear();
+ previous_selection_range_ = gfx::Range::InvalidRange();
+ return;
+ }
+
+ if (previous_selection_range_ == selection_range &&
+ previous_surrounding_text_ == surrounding_text)
+ return;
+
+ previous_selection_range_ = selection_range;
+ previous_surrounding_text_ = surrounding_text;
+
+ if (!selection_range.IsValid()) {
+ // TODO(nona): Ideally selection_range should not be invalid.
+ // TODO(nona): If javascript changes the focus on page loading, even (0,0)
+ // can not be obtained. Need investigation.
+ return;
+ }
+
+ // Here SetSurroundingText accepts relative position of |surrounding_text|, so
+ // we have to convert |selection_range| from node coordinates to
+ // |surrounding_text| coordinates.
+ if (!GetEngine())
+ return;
+ GetEngine()->SetSurroundingText(
+ UTF16ToUTF8(surrounding_text),
+ selection_range.start() - text_range.start(),
+ selection_range.end() - text_range.start());
+}
+
} // namespace ui
« no previous file with comments | « ui/base/ime/input_method_ibus.h ('k') | ui/base/ime/input_method_imm32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698