Chromium Code Reviews| Index: components/arc/ime/arc_ime_service.cc |
| diff --git a/components/arc/ime/arc_ime_service.cc b/components/arc/ime/arc_ime_service.cc |
| index 9259f31aad29e083415249ddb1dc897270a5f615..fa73fc9b88179e37ce5ac72e1ceb3412575efe77 100644 |
| --- a/components/arc/ime/arc_ime_service.cc |
| +++ b/components/arc/ime/arc_ime_service.cc |
| @@ -18,6 +18,7 @@ |
| #include "ui/events/base_event_utils.h" |
| #include "ui/events/event.h" |
| #include "ui/events/keycodes/keyboard_codes.h" |
| +#include "ui/gfx/range/range.h" |
| namespace arc { |
| @@ -231,6 +232,18 @@ void ArcImeService::ShowImeIfNeeded() { |
| } |
| } |
| +void ArcImeService::OnCursorRectChangedWithSurroundingText( |
| + const gfx::Rect& rect, |
| + const gfx::Range& text_range, |
| + const base::string16& text_in_range, |
| + const gfx::Range& selection_range) { |
| + text_range_ = text_range; |
| + text_in_range_ = text_in_range; |
| + selection_range_ = selection_range; |
| + OnCursorRectChanged(rect); |
| + InvalidateSurroundingTextAndSelectionRange(); |
|
kinaba
2017/05/15 01:35:09
I guess you meant to Invalidate() in other place(s
yhanada
2017/05/15 07:42:58
Done.
|
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // Overridden from keyboard::KeyboardControllerObserver |
| void ArcImeService::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { |
| @@ -337,6 +350,32 @@ gfx::Rect ArcImeService::GetCaretBounds() const { |
| return converted; |
| } |
| +bool ArcImeService::GetTextRange(gfx::Range* range) const { |
| + if (!text_range_.IsValid()) |
| + return false; |
| + *range = text_range_; |
| + return true; |
| +} |
| + |
| +bool ArcImeService::GetSelectionRange(gfx::Range* range) const { |
| + if (!selection_range_.IsValid()) |
| + return false; |
| + *range = selection_range_; |
| + return true; |
| +} |
| + |
| +bool ArcImeService::GetTextFromRange(const gfx::Range& range, |
| + base::string16* text) const { |
| + // It's supposed that this methdo is called only from |
|
kinaba
2017/05/15 01:35:09
methdo => method
yhanada
2017/05/15 07:42:58
Done.
|
| + // InputMethod::OnCaretBoundsChanged(). In that method, the range obtained |
| + // from GetTextRange() is used as the argument of this method. To prevent an |
| + // unexpected usage, the check, |range != text_range_|, is added. |
| + if (!text_range_.IsValid() || range != text_range_) |
| + return false; |
| + *text = text_in_range_; |
| + return true; |
| +} |
| + |
| ui::TextInputMode ArcImeService::GetTextInputMode() const { |
| return ui::TEXT_INPUT_MODE_DEFAULT; |
| } |
| @@ -366,18 +405,10 @@ bool ArcImeService::HasCompositionText() const { |
| return has_composition_text_; |
| } |
| -bool ArcImeService::GetTextRange(gfx::Range* range) const { |
| - return false; |
| -} |
| - |
| bool ArcImeService::GetCompositionTextRange(gfx::Range* range) const { |
| return false; |
| } |
| -bool ArcImeService::GetSelectionRange(gfx::Range* range) const { |
| - return false; |
| -} |
| - |
| bool ArcImeService::SetSelectionRange(const gfx::Range& range) { |
| return false; |
| } |
| @@ -386,11 +417,6 @@ bool ArcImeService::DeleteRange(const gfx::Range& range) { |
| return false; |
| } |
| -bool ArcImeService::GetTextFromRange( |
| - const gfx::Range& range, base::string16* text) const { |
| - return false; |
| -} |
| - |
| bool ArcImeService::ChangeTextDirectionAndLayoutAlignment( |
| base::i18n::TextDirection direction) { |
| return false; |
| @@ -401,4 +427,10 @@ bool ArcImeService::IsTextEditCommandEnabled( |
| return false; |
| } |
| +void ArcImeService::InvalidateSurroundingTextAndSelectionRange() { |
| + text_range_ = gfx::Range::InvalidRange(); |
| + text_in_range_ = base::ASCIIToUTF16(""); |
|
kinaba
2017/05/15 01:35:09
base::string16()
yhanada
2017/05/15 07:42:58
Done.
|
| + selection_range_ = gfx::Range::InvalidRange(); |
| +} |
| + |
| } // namespace arc |