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 |