summaryrefslogtreecommitdiff
path: root/chromium/ui/base/ime
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/ui/base/ime
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
downloadqtwebengine-chromium-33fc33aa94d4add0878ec30dc818e34e1dd3cc2a.tar.gz
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/base/ime')
-rw-r--r--chromium/ui/base/ime/DIR_METADATA5
-rw-r--r--chromium/ui/base/ime/ash/COMMON_METADATA5
-rw-r--r--chromium/ui/base/ime/ash/DIR_METADATA1
-rw-r--r--chromium/ui/base/ime/ash/ime_assistive_window_handler_interface.h2
-rw-r--r--chromium/ui/base/ime/ash/ime_candidate_window_handler_interface.h8
-rw-r--r--chromium/ui/base/ime/ash/ime_input_context_handler_interface.h3
-rw-r--r--chromium/ui/base/ime/ash/input_method_ash.cc20
-rw-r--r--chromium/ui/base/ime/ash/input_method_ash.h3
-rw-r--r--chromium/ui/base/ime/ash/input_method_ash_unittest.cc22
-rw-r--r--chromium/ui/base/ime/ash/input_method_manager.h22
-rw-r--r--chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.cc10
-rw-r--r--chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.h4
-rw-r--r--chromium/ui/base/ime/ash/mock_ime_input_context_handler.cc6
-rw-r--r--chromium/ui/base/ime/ash/mock_ime_input_context_handler.h5
-rw-r--r--chromium/ui/base/ime/ash/mock_input_method_manager.cc10
-rw-r--r--chromium/ui/base/ime/ash/mock_input_method_manager.h6
-rw-r--r--chromium/ui/base/ime/dummy_text_input_client.cc17
-rw-r--r--chromium/ui/base/ime/dummy_text_input_client.h6
-rw-r--r--chromium/ui/base/ime/fake_text_input_client.cc2
-rw-r--r--chromium/ui/base/ime/fake_text_input_client.h2
-rw-r--r--chromium/ui/base/ime/grammar_fragment.cc8
-rw-r--r--chromium/ui/base/ime/grammar_fragment.h7
-rw-r--r--chromium/ui/base/ime/linux/fake_input_method_context.cc13
-rw-r--r--chromium/ui/base/ime/linux/fake_input_method_context.h10
-rw-r--r--chromium/ui/base/ime/linux/input_method_auralinux.cc76
-rw-r--r--chromium/ui/base/ime/linux/input_method_auralinux.h3
-rw-r--r--chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc78
-rw-r--r--chromium/ui/base/ime/linux/linux_input_method_context.h17
-rw-r--r--chromium/ui/base/ime/text_input_client.cc6
-rw-r--r--chromium/ui/base/ime/text_input_client.h11
-rw-r--r--chromium/ui/base/ime/utf_offset_unittest.cc86
-rw-r--r--chromium/ui/base/ime/win/tsf_text_store.cc17
-rw-r--r--chromium/ui/base/ime/win/tsf_text_store_unittest.cc8
33 files changed, 275 insertions, 224 deletions
diff --git a/chromium/ui/base/ime/DIR_METADATA b/chromium/ui/base/ime/DIR_METADATA
index d50dc8612ab..e0756fd7257 100644
--- a/chromium/ui/base/ime/DIR_METADATA
+++ b/chromium/ui/base/ime/DIR_METADATA
@@ -7,6 +7,7 @@
# https://source.chromium.org/chromium/infra/infra/+/main:go/src/infra/tools/dirmd/proto/dir_metadata.proto
monorail {
- component: "OS>Inputs" # for Chrome/Chromium OS only.
- # For OSes other than Chrome/Chromium OS, please use "UI>Input>Text>IME".
+ # For non-Chrome/Chromium OS:
+ component: "UI>Input>Text>IME"
+ # For Chrome/Chromium OS, please see //ui/base/ime/ash/COMMON_METADATA.
}
diff --git a/chromium/ui/base/ime/ash/COMMON_METADATA b/chromium/ui/base/ime/ash/COMMON_METADATA
new file mode 100644
index 00000000000..134df975d4b
--- /dev/null
+++ b/chromium/ui/base/ime/ash/COMMON_METADATA
@@ -0,0 +1,5 @@
+buganizer {
+ component_id: 95887
+}
+os: CHROME_OS
+team_email: "essential-inputs-team@google.com"
diff --git a/chromium/ui/base/ime/ash/DIR_METADATA b/chromium/ui/base/ime/ash/DIR_METADATA
new file mode 100644
index 00000000000..caac77fdc9d
--- /dev/null
+++ b/chromium/ui/base/ime/ash/DIR_METADATA
@@ -0,0 +1 @@
+mixins: "//ui/base/ime/ash/COMMON_METADATA"
diff --git a/chromium/ui/base/ime/ash/ime_assistive_window_handler_interface.h b/chromium/ui/base/ime/ash/ime_assistive_window_handler_interface.h
index 6d4c4659527..c36e9606917 100644
--- a/chromium/ui/base/ime/ash/ime_assistive_window_handler_interface.h
+++ b/chromium/ui/base/ime/ash/ime_assistive_window_handler_interface.h
@@ -30,8 +30,6 @@ struct Bounds {
gfx::Rect caret;
// Position of the autocorrect span, empty if not present.
gfx::Rect autocorrect;
- // Position of the current composition text in screen
- gfx::Rect composition_text;
};
// A interface to handle the assistive windows related method call.
diff --git a/chromium/ui/base/ime/ash/ime_candidate_window_handler_interface.h b/chromium/ui/base/ime/ash/ime_candidate_window_handler_interface.h
index d3ca53b91eb..f3e24207201 100644
--- a/chromium/ui/base/ime/ash/ime_candidate_window_handler_interface.h
+++ b/chromium/ui/base/ime/ash/ime_candidate_window_handler_interface.h
@@ -26,9 +26,13 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMECandidateWindowHandlerInterface {
public:
virtual ~IMECandidateWindowHandlerInterface() = default;
+ virtual void HideLookupTable() = 0;
+
// Called when the IME updates the lookup table.
- virtual void UpdateLookupTable(const ui::CandidateWindow& candidate_window,
- bool visible) = 0;
+ // This will also show the lookup table if it is not already
+ // showing.
+ virtual void UpdateLookupTable(
+ const ui::CandidateWindow& candidate_window) = 0;
// Called when the IME updates the preedit text. The |text| is given in
// UTF-16 encoding.
diff --git a/chromium/ui/base/ime/ash/ime_input_context_handler_interface.h b/chromium/ui/base/ime/ash/ime_input_context_handler_interface.h
index 7e69ef738ee..ba8015ff975 100644
--- a/chromium/ui/base/ime/ash/ime_input_context_handler_interface.h
+++ b/chromium/ui/base/ime/ash/ime_input_context_handler_interface.h
@@ -48,8 +48,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMEInputContextHandlerInterface {
virtual gfx::Rect GetTextFieldBounds() = 0;
// Sets the autocorrect range to be `range`.
virtual bool SetAutocorrectRange(const gfx::Range& range) = 0;
- virtual absl::optional<GrammarFragment> GetGrammarFragment(
- const gfx::Range& range) = 0;
+ virtual absl::optional<GrammarFragment> GetGrammarFragmentAtCursor() = 0;
virtual bool ClearGrammarFragments(const gfx::Range& range) = 0;
virtual bool AddGrammarFragments(
const std::vector<GrammarFragment>& fragements) = 0;
diff --git a/chromium/ui/base/ime/ash/input_method_ash.cc b/chromium/ui/base/ime/ash/input_method_ash.cc
index ed669c21a27..9da2fc2e358 100644
--- a/chromium/ui/base/ime/ash/input_method_ash.cc
+++ b/chromium/ui/base/ime/ash/input_method_ash.cc
@@ -244,7 +244,6 @@ void InputMethodAsh::OnCaretBoundsChanged(const TextInputClient* client) {
ash::Bounds bounds;
bounds.caret = caret_rect;
bounds.autocorrect = client->GetAutocorrectCharacterBounds();
- client->GetCompositionCharacterBounds(0, &bounds.composition_text);
assistive_window->SetBounds(bounds);
}
@@ -454,11 +453,10 @@ bool InputMethodAsh::SetAutocorrectRange(const gfx::Range& range) {
}
}
-absl::optional<GrammarFragment> InputMethodAsh::GetGrammarFragment(
- const gfx::Range& range) {
+absl::optional<GrammarFragment> InputMethodAsh::GetGrammarFragmentAtCursor() {
if (IsTextInputTypeNone())
return absl::nullopt;
- return GetTextInputClient()->GetGrammarFragment(range);
+ return GetTextInputClient()->GetGrammarFragmentAtCursor();
}
bool InputMethodAsh::ClearGrammarFragments(const gfx::Range& range) {
@@ -646,16 +644,9 @@ void InputMethodAsh::MaybeProcessPendingInputMethodResult(ui::KeyEvent* event,
DCHECK(client);
if (pending_commit_) {
- if (handled && NeedInsertChar()) {
- for (const auto& ch : pending_commit_->text) {
- KeyEvent ch_event(ET_KEY_PRESSED, VKEY_UNKNOWN, EF_NONE);
- ch_event.set_character(ch);
- client->InsertChar(ch_event);
- }
- } else if (pending_commit_->text.empty()) {
+ if (pending_commit_->text.empty()) {
client->InsertText(
u"", TextInputClient::InsertTextCursorBehavior::kMoveCursorAfterText);
- composing_text_ = false;
} else {
// Split the commit into two separate commits, one for the substring
// before the cursor and one for the substring after.
@@ -673,8 +664,8 @@ void InputMethodAsh::MaybeProcessPendingInputMethodResult(ui::KeyEvent* event,
after_cursor,
TextInputClient::InsertTextCursorBehavior::kMoveCursorBeforeText);
}
- composing_text_ = false;
}
+ composing_text_ = false;
typing_session_manager_.CommitCharacters(pending_commit_->text.length());
}
@@ -848,7 +839,8 @@ SurroundingTextInfo InputMethodAsh::GetSurroundingTextInfo() {
gfx::Range text_range;
SurroundingTextInfo info;
TextInputClient* client = GetTextInputClient();
- if (!client->GetTextRange(&text_range) ||
+ if (!client ||
+ !client->GetTextRange(&text_range) ||
!client->GetTextFromRange(text_range, &info.surrounding_text) ||
!client->GetEditableSelectionRange(&info.selection_range)) {
return SurroundingTextInfo();
diff --git a/chromium/ui/base/ime/ash/input_method_ash.h b/chromium/ui/base/ime/ash/input_method_ash.h
index 7b472f6d00a..c6c0f3987b1 100644
--- a/chromium/ui/base/ime/ash/input_method_ash.h
+++ b/chromium/ui/base/ime/ash/input_method_ash.h
@@ -67,8 +67,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodAsh
gfx::Rect GetAutocorrectCharacterBounds() override;
gfx::Rect GetTextFieldBounds() override;
bool SetAutocorrectRange(const gfx::Range& range) override;
- absl::optional<GrammarFragment> GetGrammarFragment(
- const gfx::Range& range) override;
+ absl::optional<GrammarFragment> GetGrammarFragmentAtCursor() override;
bool ClearGrammarFragments(const gfx::Range& range) override;
bool AddGrammarFragments(
const std::vector<GrammarFragment>& fragments) override;
diff --git a/chromium/ui/base/ime/ash/input_method_ash_unittest.cc b/chromium/ui/base/ime/ash/input_method_ash_unittest.cc
index e943f986f6e..e97d82cdf4f 100644
--- a/chromium/ui/base/ime/ash/input_method_ash_unittest.cc
+++ b/chromium/ui/base/ime/ash/input_method_ash_unittest.cc
@@ -86,6 +86,10 @@ class TestableInputMethodAsh : public InputMethodAsh {
text_committed_ = text;
}
+ void SetEditableSelectionRange(gfx::Range range) {
+ GetTextInputClient()->SetEditableSelectionRange(range);
+ }
+
void ResetCallCount() { process_key_event_post_ime_call_count_ = 0; }
const ProcessKeyEventPostIMEArgs& process_key_event_post_ime_args() const {
@@ -1005,7 +1009,7 @@ TEST_F(InputMethodAshKeyEventTest, KeyEventDelayResponseTest) {
u"A",
TextInputClient::InsertTextCursorBehavior::kMoveCursorAfterText);
- EXPECT_EQ(0, inserted_char_);
+ EXPECT_EQ(u"", inserted_text_);
// Do callback.
std::move(mock_ime_engine_handler_->last_passed_callback()).Run(true);
@@ -1018,7 +1022,7 @@ TEST_F(InputMethodAshKeyEventTest, KeyEventDelayResponseTest) {
EXPECT_EQ(kFlags, stored_event.flags());
EXPECT_TRUE(ime_->process_key_event_post_ime_args().handled);
- EXPECT_EQ(L'A', inserted_char_);
+ EXPECT_EQ(u"A", inserted_text_);
}
TEST_F(InputMethodAshKeyEventTest, MultiKeyEventDelayResponseTest) {
@@ -1185,7 +1189,7 @@ TEST_F(InputMethodAshKeyEventTest, SetAutocorrectRangeRunsAfterCommitText) {
std::move(mock_ime_engine_handler_->last_passed_callback())
.Run(/*handled=*/true);
- EXPECT_EQ(L'a', inserted_char_);
+ EXPECT_EQ(u"a", inserted_text_);
EXPECT_EQ(gfx::Range(0, 1), GetAutocorrectRange());
}
@@ -1325,11 +1329,15 @@ TEST_F(InputMethodAshTest, GetsGrammarFragments) {
GrammarFragment fragment(gfx::Range(0, 5), "fake");
ime_->AddGrammarFragments({fragment});
- EXPECT_EQ(ime_->GetGrammarFragment(gfx::Range(3, 3)), fragment);
- EXPECT_EQ(ime_->GetGrammarFragment(gfx::Range(2, 4)), fragment);
+ ime_->SetEditableSelectionRange(gfx::Range(3, 3));
+ EXPECT_EQ(ime_->GetGrammarFragmentAtCursor(), fragment);
+ ime_->SetEditableSelectionRange(gfx::Range(2, 4));
+ EXPECT_EQ(ime_->GetGrammarFragmentAtCursor(), fragment);
- EXPECT_EQ(ime_->GetGrammarFragment(gfx::Range(7, 7)), absl::nullopt);
- EXPECT_EQ(ime_->GetGrammarFragment(gfx::Range(4, 7)), absl::nullopt);
+ ime_->SetEditableSelectionRange(gfx::Range(7, 7));
+ EXPECT_EQ(ime_->GetGrammarFragmentAtCursor(), absl::nullopt);
+ ime_->SetEditableSelectionRange(gfx::Range(4, 7));
+ EXPECT_EQ(ime_->GetGrammarFragmentAtCursor(), absl::nullopt);
}
} // namespace ui
diff --git a/chromium/ui/base/ime/ash/input_method_manager.h b/chromium/ui/base/ime/ash/input_method_manager.h
index f39b76193d7..66623e0267b 100644
--- a/chromium/ui/base/ime/ash/input_method_manager.h
+++ b/chromium/ui/base/ime/ash/input_method_manager.h
@@ -174,7 +174,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodManager {
const std::vector<std::string>& initial_layouts) = 0;
// Filters current state layouts and leaves only suitable for lock screen.
- virtual void EnableLockScreenLayouts() = 0;
+ virtual void DisableNonLockScreenLayouts() = 0;
// Returns a list of descriptors for all Input Method Extensions.
virtual void GetInputMethodExtensions(InputMethodDescriptors* result) = 0;
@@ -233,26 +233,28 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodManager {
// Gets the descriptor of the input method which is currently selected.
virtual InputMethodDescriptor GetCurrentInputMethod() const = 0;
- // Updates the list of enabled input method IDs, and then starts or stops
- // the system input method framework as needed.
+ // Updates the list of enabled input method IDs (checking that they are
+ // valid and allowed by policy), and then starts or stops the system input
+ // method framework as needed.
virtual bool ReplaceEnabledInputMethods(
const std::vector<std::string>& new_enabled_input_method_ids) = 0;
- // Sets the currently allowed input methods (e.g. due to policy). Invalid
+ // Sets the currently allowed input methods due to policy. Invalid
// input method ids are ignored. Passing an empty vector means that all
- // input methods are allowed, which is the default. When
- // |enable_allowed_input_menthods| is true, the allowed input methods are
- // also automatically enabled.
+ // input methods are allowed, which is the default.
virtual bool SetAllowedInputMethods(
- const std::vector<std::string>& allowed_input_method_ids,
- bool enable_allowed_input_methods) = 0;
+ const std::vector<std::string>& allowed_input_method_ids) = 0;
// Returns IDs of currently allowed input methods, as set by
- // SetAllowedInputMethodIds. An empty vector means that all input methods
+ // `SetAllowedInputMethods()`. An empty vector means that all input methods
// are allowed.
virtual const std::vector<std::string>& GetAllowedInputMethodIds()
const = 0;
+ // Returns the first hardware input method that is allowed or the first
+ // allowed input method, if no hardware input method is allowed.
+ virtual std::string GetAllowedFallBackKeyboardLayout() const = 0;
+
// Methods related to custom input view of the input method.
// Enables custom input view of the current (active) input method.
virtual void EnableInputView() = 0;
diff --git a/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.cc b/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.cc
index 3f63ec8136c..2396d1e1056 100644
--- a/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.cc
+++ b/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.cc
@@ -13,12 +13,16 @@ MockIMECandidateWindowHandler::MockIMECandidateWindowHandler()
MockIMECandidateWindowHandler::~MockIMECandidateWindowHandler() = default;
+void MockIMECandidateWindowHandler::HideLookupTable() {
+ ++update_lookup_table_call_count_;
+ last_update_lookup_table_arg_.is_visible = false;
+}
+
void MockIMECandidateWindowHandler::UpdateLookupTable(
- const ui::CandidateWindow& table,
- bool visible) {
+ const ui::CandidateWindow& table) {
++update_lookup_table_call_count_;
last_update_lookup_table_arg_.lookup_table.CopyFrom(table);
- last_update_lookup_table_arg_.is_visible = visible;
+ last_update_lookup_table_arg_.is_visible = true;
}
void MockIMECandidateWindowHandler::UpdatePreeditText(
diff --git a/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.h b/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.h
index 910855898ad..9e60228275e 100644
--- a/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.h
+++ b/chromium/ui/base/ime/ash/mock_ime_candidate_window_handler.h
@@ -31,8 +31,8 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockIMECandidateWindowHandler
~MockIMECandidateWindowHandler() override;
// IMECandidateWindowHandlerInterface override.
- void UpdateLookupTable(const ui::CandidateWindow& candidate_window,
- bool visible) override;
+ void HideLookupTable() override;
+ void UpdateLookupTable(const ui::CandidateWindow& candidate_window) override;
void UpdatePreeditText(const std::u16string& text,
uint32_t cursor_pos,
bool visible) override;
diff --git a/chromium/ui/base/ime/ash/mock_ime_input_context_handler.cc b/chromium/ui/base/ime/ash/mock_ime_input_context_handler.cc
index d7581a9e6ff..a7fe55850f1 100644
--- a/chromium/ui/base/ime/ash/mock_ime_input_context_handler.cc
+++ b/chromium/ui/base/ime/ash/mock_ime_input_context_handler.cc
@@ -73,10 +73,10 @@ bool MockIMEInputContextHandler::SetAutocorrectRange(const gfx::Range& range) {
return true;
}
-absl::optional<GrammarFragment> MockIMEInputContextHandler::GetGrammarFragment(
- const gfx::Range& range) {
+absl::optional<GrammarFragment>
+MockIMEInputContextHandler::GetGrammarFragmentAtCursor() {
for (const auto& fragment : grammar_fragments_) {
- if (fragment.range.Contains(range)) {
+ if (fragment.range.Contains(cursor_range_)) {
return fragment;
}
}
diff --git a/chromium/ui/base/ime/ash/mock_ime_input_context_handler.h b/chromium/ui/base/ime/ash/mock_ime_input_context_handler.h
index 45c3b4a8733..c17e68b5bfd 100644
--- a/chromium/ui/base/ime/ash/mock_ime_input_context_handler.h
+++ b/chromium/ui/base/ime/ash/mock_ime_input_context_handler.h
@@ -55,8 +55,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockIMEInputContextHandler
gfx::Rect GetTextFieldBounds() override;
bool SetAutocorrectRange(const gfx::Range& range) override;
bool ClearGrammarFragments(const gfx::Range& range) override;
- absl::optional<GrammarFragment> GetGrammarFragment(
- const gfx::Range& range) override;
+ absl::optional<GrammarFragment> GetGrammarFragmentAtCursor() override;
bool AddGrammarFragments(
const std::vector<GrammarFragment>& fragments) override;
bool SetSelectionRange(uint32_t start, uint32_t end) override;
@@ -73,6 +72,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockIMEInputContextHandler
return grammar_fragments_;
}
+ void set_cursor_range(gfx::Range range) { cursor_range_ = range; }
int commit_text_call_count() const { return commit_text_call_count_; }
int set_selection_range_call_count() const {
return set_selection_range_call_count_;
@@ -115,6 +115,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockIMEInputContextHandler
DeleteSurroundingTextArg last_delete_surrounding_text_arg_;
gfx::Range autocorrect_range_;
std::vector<GrammarFragment> grammar_fragments_;
+ gfx::Range cursor_range_;
};
} // namespace ui
diff --git a/chromium/ui/base/ime/ash/mock_input_method_manager.cc b/chromium/ui/base/ime/ash/mock_input_method_manager.cc
index 4976cb29efe..c0050a9e5cb 100644
--- a/chromium/ui/base/ime/ash/mock_input_method_manager.cc
+++ b/chromium/ui/base/ime/ash/mock_input_method_manager.cc
@@ -43,7 +43,7 @@ void MockInputMethodManager::State::EnableLoginLayouts(
const std::string& language_code,
const std::vector<std::string>& initial_layout) {}
-void MockInputMethodManager::State::EnableLockScreenLayouts() {}
+void MockInputMethodManager::State::DisableNonLockScreenLayouts() {}
void MockInputMethodManager::State::GetInputMethodExtensions(
InputMethodDescriptors* result) {}
@@ -98,8 +98,7 @@ bool MockInputMethodManager::State::ReplaceEnabledInputMethods(
}
bool MockInputMethodManager::State::SetAllowedInputMethods(
- const std::vector<std::string>& new_allowed_input_method_ids,
- bool enable_allowed_input_methods) {
+ const std::vector<std::string>& new_allowed_input_method_ids) {
allowed_input_method_ids_ = new_allowed_input_method_ids;
return true;
}
@@ -109,6 +108,11 @@ MockInputMethodManager::State::GetAllowedInputMethodIds() const {
return allowed_input_method_ids_;
}
+std::string MockInputMethodManager::State::GetAllowedFallBackKeyboardLayout()
+ const {
+ return "input_method_id";
+}
+
void MockInputMethodManager::State::EnableInputView() {}
void MockInputMethodManager::State::DisableInputView() {}
diff --git a/chromium/ui/base/ime/ash/mock_input_method_manager.h b/chromium/ui/base/ime/ash/mock_input_method_manager.h
index 7adde602911..fd46651c3d3 100644
--- a/chromium/ui/base/ime/ash/mock_input_method_manager.h
+++ b/chromium/ui/base/ime/ash/mock_input_method_manager.h
@@ -44,7 +44,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockInputMethodManager
void EnableLoginLayouts(
const std::string& language_code,
const std::vector<std::string>& initial_layouts) override;
- void EnableLockScreenLayouts() override;
+ void DisableNonLockScreenLayouts() override;
void GetInputMethodExtensions(InputMethodDescriptors* result) override;
std::unique_ptr<InputMethodDescriptors>
GetEnabledInputMethodsSortedByLocalizedDisplayNames() const override;
@@ -64,9 +64,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockInputMethodManager
bool ReplaceEnabledInputMethods(
const std::vector<std::string>& new_enabled_input_method_ids) override;
bool SetAllowedInputMethods(
- const std::vector<std::string>& new_allowed_input_method_ids,
- bool enable_allowed_input_methods) override;
+ const std::vector<std::string>& new_allowed_input_method_ids) override;
const std::vector<std::string>& GetAllowedInputMethodIds() const override;
+ std::string GetAllowedFallBackKeyboardLayout() const override;
void EnableInputView() override;
void DisableInputView() override;
const GURL& GetInputViewUrl() const override;
diff --git a/chromium/ui/base/ime/dummy_text_input_client.cc b/chromium/ui/base/ime/dummy_text_input_client.cc
index f6be8afc254..063ab67bd46 100644
--- a/chromium/ui/base/ime/dummy_text_input_client.cc
+++ b/chromium/ui/base/ime/dummy_text_input_client.cc
@@ -104,12 +104,17 @@ bool DummyTextInputClient::GetCompositionTextRange(gfx::Range* range) const {
}
bool DummyTextInputClient::GetEditableSelectionRange(gfx::Range* range) const {
- return false;
+ if (!cursor_range_.IsValid())
+ return false;
+ range->set_start(cursor_range_.start());
+ range->set_end(cursor_range_.end());
+ return true;
}
bool DummyTextInputClient::SetEditableSelectionRange(const gfx::Range& range) {
selection_history_.push_back(range);
- return false;
+ cursor_range_ = range;
+ return true;
}
bool DummyTextInputClient::DeleteRange(const gfx::Range& range) {
@@ -159,7 +164,7 @@ bool DummyTextInputClient::SetCompositionFromExistingText(
}
#endif
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
gfx::Range DummyTextInputClient::GetAutocorrectRange() const {
return autocorrect_range_;
}
@@ -173,10 +178,10 @@ bool DummyTextInputClient::SetAutocorrectRange(
return true;
}
-absl::optional<GrammarFragment> DummyTextInputClient::GetGrammarFragment(
- const gfx::Range& range) {
+absl::optional<GrammarFragment>
+DummyTextInputClient::GetGrammarFragmentAtCursor() const {
for (const auto& fragment : grammar_fragments_) {
- if (fragment.range.Contains(range)) {
+ if (fragment.range.Contains(cursor_range_)) {
return fragment;
}
}
diff --git a/chromium/ui/base/ime/dummy_text_input_client.h b/chromium/ui/base/ime/dummy_text_input_client.h
index 75ad8603d7e..0b30b29236b 100644
--- a/chromium/ui/base/ime/dummy_text_input_client.h
+++ b/chromium/ui/base/ime/dummy_text_input_client.h
@@ -69,12 +69,11 @@ class DummyTextInputClient : public TextInputClient {
const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) override;
#endif
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
gfx::Range GetAutocorrectRange() const override;
gfx::Rect GetAutocorrectCharacterBounds() const override;
bool SetAutocorrectRange(const gfx::Range& range) override;
- absl::optional<GrammarFragment> GetGrammarFragment(
- const gfx::Range& range) override;
+ absl::optional<GrammarFragment> GetGrammarFragmentAtCursor() const override;
bool ClearGrammarFragments(const gfx::Range& range) override;
bool AddGrammarFragments(
const std::vector<GrammarFragment>& fragments) override;
@@ -119,6 +118,7 @@ class DummyTextInputClient : public TextInputClient {
std::vector<gfx::Range> selection_history_;
gfx::Range autocorrect_range_;
std::vector<GrammarFragment> grammar_fragments_;
+ gfx::Range cursor_range_ = gfx::Range::InvalidRange();
};
} // namespace ui
diff --git a/chromium/ui/base/ime/fake_text_input_client.cc b/chromium/ui/base/ime/fake_text_input_client.cc
index 69095ce118f..7b3c2253f35 100644
--- a/chromium/ui/base/ime/fake_text_input_client.cc
+++ b/chromium/ui/base/ime/fake_text_input_client.cc
@@ -174,7 +174,7 @@ bool FakeTextInputClient::SetCompositionFromExistingText(
}
#endif
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
gfx::Range FakeTextInputClient::GetAutocorrectRange() const {
return autocorrect_range_;
}
diff --git a/chromium/ui/base/ime/fake_text_input_client.h b/chromium/ui/base/ime/fake_text_input_client.h
index 8a570158f79..5a7feaeeb18 100644
--- a/chromium/ui/base/ime/fake_text_input_client.h
+++ b/chromium/ui/base/ime/fake_text_input_client.h
@@ -74,7 +74,7 @@ class FakeTextInputClient : public TextInputClient {
const gfx::Range& range,
const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) override;
#endif
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
gfx::Range GetAutocorrectRange() const override;
gfx::Rect GetAutocorrectCharacterBounds() const override;
bool SetAutocorrectRange(const gfx::Range& range) override;
diff --git a/chromium/ui/base/ime/grammar_fragment.cc b/chromium/ui/base/ime/grammar_fragment.cc
index cb1a3404c13..36a005e1390 100644
--- a/chromium/ui/base/ime/grammar_fragment.cc
+++ b/chromium/ui/base/ime/grammar_fragment.cc
@@ -7,17 +7,15 @@
namespace ui {
GrammarFragment::GrammarFragment(const gfx::Range& range,
- const std::string& suggestion,
- const std::string& original_text)
- : range(range), suggestion(suggestion), original_text(original_text) {}
+ const std::string& suggestion)
+ : range(range), suggestion(suggestion) {}
GrammarFragment::GrammarFragment(const GrammarFragment& other) = default;
GrammarFragment::~GrammarFragment() = default;
bool GrammarFragment::operator==(const GrammarFragment& other) const {
- return range == other.range && suggestion == other.suggestion &&
- original_text == other.original_text;
+ return range == other.range && suggestion == other.suggestion;
}
bool GrammarFragment::operator!=(const GrammarFragment& other) const {
diff --git a/chromium/ui/base/ime/grammar_fragment.h b/chromium/ui/base/ime/grammar_fragment.h
index 6f0535aefee..b97cadc162d 100644
--- a/chromium/ui/base/ime/grammar_fragment.h
+++ b/chromium/ui/base/ime/grammar_fragment.h
@@ -14,9 +14,7 @@ namespace ui {
// A struct represents a fragment of grammar edit suggestion.
struct COMPONENT_EXPORT(UI_BASE_IME_TYPES) GrammarFragment {
- GrammarFragment(const gfx::Range& range,
- const std::string& suggestion,
- const std::string& original_text = std::string());
+ GrammarFragment(const gfx::Range& range, const std::string& suggestion);
GrammarFragment(const GrammarFragment& other);
~GrammarFragment();
@@ -29,9 +27,6 @@ struct COMPONENT_EXPORT(UI_BASE_IME_TYPES) GrammarFragment {
// The replacement text suggested by the grammar model.
std::string suggestion;
-
- // The original text to be replaced.
- std::string original_text;
};
} // namespace ui
diff --git a/chromium/ui/base/ime/linux/fake_input_method_context.cc b/chromium/ui/base/ime/linux/fake_input_method_context.cc
index c21162347a8..79c95d4d844 100644
--- a/chromium/ui/base/ime/linux/fake_input_method_context.cc
+++ b/chromium/ui/base/ime/linux/fake_input_method_context.cc
@@ -22,11 +22,9 @@ bool FakeInputMethodContext::IsPeekKeyEvent(const ui::KeyEvent& key_event) {
void FakeInputMethodContext::Reset() {
}
-void FakeInputMethodContext::Focus() {
-}
-
-void FakeInputMethodContext::Blur() {
-}
+void FakeInputMethodContext::UpdateFocus(bool has_client,
+ TextInputType old_type,
+ TextInputType new_type) {}
void FakeInputMethodContext::SetCursorLocation(const gfx::Rect& rect) {
}
@@ -35,8 +33,9 @@ void FakeInputMethodContext::SetSurroundingText(
const std::u16string& text,
const gfx::Range& selection_range) {}
-void FakeInputMethodContext::SetContentType(TextInputType input_type,
- int input_flags,
+void FakeInputMethodContext::SetContentType(TextInputType type,
+ TextInputMode mode,
+ uint32_t flags,
bool should_do_learning) {}
VirtualKeyboardController*
diff --git a/chromium/ui/base/ime/linux/fake_input_method_context.h b/chromium/ui/base/ime/linux/fake_input_method_context.h
index f95f0ad8276..7e5746ee715 100644
--- a/chromium/ui/base/ime/linux/fake_input_method_context.h
+++ b/chromium/ui/base/ime/linux/fake_input_method_context.h
@@ -23,13 +23,15 @@ class COMPONENT_EXPORT(UI_BASE_IME_LINUX) FakeInputMethodContext
bool DispatchKeyEvent(const ui::KeyEvent& key_event) override;
bool IsPeekKeyEvent(const ui::KeyEvent& key_event) override;
void Reset() override;
- void Focus() override;
- void Blur() override;
+ void UpdateFocus(bool has_client,
+ TextInputType old_type,
+ TextInputType new_type) override;
void SetCursorLocation(const gfx::Rect& rect) override;
void SetSurroundingText(const std::u16string& text,
const gfx::Range& selection_range) override;
- void SetContentType(TextInputType input_type,
- int input_flags,
+ void SetContentType(TextInputType type,
+ TextInputMode mode,
+ uint32_t flags,
bool should_do_learning) override;
VirtualKeyboardController* GetVirtualKeyboardController() override;
};
diff --git a/chromium/ui/base/ime/linux/input_method_auralinux.cc b/chromium/ui/base/ime/linux/input_method_auralinux.cc
index 46f8f37a1aa..7293030a71c 100644
--- a/chromium/ui/base/ime/linux/input_method_auralinux.cc
+++ b/chromium/ui/base/ime/linux/input_method_auralinux.cc
@@ -146,6 +146,7 @@ ui::EventDispatchDetails InputMethodAuraLinux::DispatchKeyEvent(
{
suppress_non_key_input_until_ = base::TimeTicks::UnixEpoch();
composition_changed_ = false;
+ last_commit_result_.reset();
result_text_.clear();
base::AutoReset<bool> flipper(&is_sync_mode_, true);
filtered = context->DispatchKeyEvent(*event);
@@ -343,35 +344,29 @@ bool InputMethodAuraLinux::MaybeUpdateComposition(bool text_committed) {
}
void InputMethodAuraLinux::UpdateContextFocusState() {
- bool old_text_input_type = text_input_type_;
+ auto old_text_input_type = text_input_type_;
text_input_type_ = GetTextInputType();
- // We only focus in |context_| when the focus is in a textfield.
- if (old_text_input_type != TEXT_INPUT_TYPE_NONE &&
- text_input_type_ == TEXT_INPUT_TYPE_NONE) {
- context_->Blur();
- } else if (old_text_input_type == TEXT_INPUT_TYPE_NONE &&
- text_input_type_ != TEXT_INPUT_TYPE_NONE) {
- context_->Focus();
- }
-
- // |context_simple_| can be used in any textfield, including password box, and
- // even if the focused text input client's text input type is
- // ui::TEXT_INPUT_TYPE_NONE.
auto* client = GetTextInputClient();
- if (client)
- context_simple_->Focus();
- else
- context_simple_->Blur();
+ bool has_client = client != nullptr;
+ context_->UpdateFocus(has_client, old_text_input_type, text_input_type_);
+ context_simple_->UpdateFocus(has_client, old_text_input_type,
+ text_input_type_);
LinuxInputMethodContext* context =
text_input_type_ != TEXT_INPUT_TYPE_NONE &&
text_input_type_ != TEXT_INPUT_TYPE_PASSWORD
? context_.get()
: context_simple_.get();
- int flags = client ? client->GetTextInputFlags() : TEXT_INPUT_FLAG_NONE;
- context->SetContentType(text_input_type_, flags,
- client && client->ShouldDoLearning());
+ TextInputMode mode = TEXT_INPUT_MODE_DEFAULT;
+ int flags = TEXT_INPUT_FLAG_NONE;
+ bool should_do_learning = false;
+ if (client) {
+ mode = client->GetTextInputMode();
+ flags = client->GetTextInputFlags();
+ should_do_learning = client->ShouldDoLearning();
+ }
+ context->SetContentType(text_input_type_, mode, flags, should_do_learning);
}
void InputMethodAuraLinux::OnTextInputTypeChanged(TextInputClient* client) {
@@ -456,16 +451,18 @@ void InputMethodAuraLinux::OnCommit(const std::u16string& text) {
// the focused text input client does not support text input.
if (!is_sync_mode_ && !IsTextInputTypeNone()) {
ui::KeyEvent event =
- ime_filtered_key_event_.has_value()
- ? std::move(*ime_filtered_key_event_)
- : ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, 0);
- ime_filtered_key_event_.reset();
- ui::EventDispatchDetails details = DispatchImeFilteredKeyPressEvent(&event);
- if (details.target_destroyed || details.dispatcher_destroyed ||
- event.stopped_propagation()) {
- return;
+ ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, 0);
+ if (ime_filtered_key_event_.has_value()) {
+ event = std::move(*ime_filtered_key_event_);
+ ime_filtered_key_event_.reset();
+ ui::EventDispatchDetails details =
+ DispatchImeFilteredKeyPressEvent(&event);
+ if (details.target_destroyed || details.dispatcher_destroyed ||
+ event.stopped_propagation()) {
+ return;
+ }
}
- MaybeCommitResult(/*filtered=*/true, event);
+ last_commit_result_ = MaybeCommitResult(/*filtered=*/true, event);
composition_ = CompositionText();
}
}
@@ -531,17 +528,18 @@ void InputMethodAuraLinux::OnPreeditUpdate(
if (!force_update_client)
return;
- ui::KeyEvent event =
- ime_filtered_key_event_.has_value()
- ? std::move(*ime_filtered_key_event_)
- : ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_PROCESSKEY, 0);
- ime_filtered_key_event_.reset();
- ui::EventDispatchDetails details = DispatchImeFilteredKeyPressEvent(&event);
- if (details.target_destroyed || details.dispatcher_destroyed ||
- event.stopped_propagation()) {
- return;
+
+ if (ime_filtered_key_event_.has_value()) {
+ ui::KeyEvent event = std::move(*ime_filtered_key_event_);
+ ime_filtered_key_event_.reset();
+ ui::EventDispatchDetails details = DispatchImeFilteredKeyPressEvent(&event);
+ if (details.target_destroyed || details.dispatcher_destroyed ||
+ event.stopped_propagation()) {
+ return;
+ }
}
- MaybeUpdateComposition(/*text_committed=*/false);
+ MaybeUpdateComposition(last_commit_result_ == CommitResult::kSuccess);
+ last_commit_result_.reset();
}
bool InputMethodAuraLinux::HasInputMethodResult() {
diff --git a/chromium/ui/base/ime/linux/input_method_auralinux.h b/chromium/ui/base/ime/linux/input_method_auralinux.h
index ca27b0f662c..133cc14f696 100644
--- a/chromium/ui/base/ime/linux/input_method_auralinux.h
+++ b/chromium/ui/base/ime/linux/input_method_auralinux.h
@@ -88,6 +88,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_LINUX) InputMethodAuraLinux
// async-mode.
absl::optional<ui::KeyEvent> ime_filtered_key_event_;
+ // Tracks last commit result during one key dispatch event.
+ absl::optional<CommitResult> last_commit_result_;
+
std::u16string result_text_;
ui::CompositionText composition_;
diff --git a/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc b/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc
index f7a8a87fc70..5e80ec1771f 100644
--- a/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc
+++ b/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc
@@ -60,8 +60,10 @@ class TestResult {
class LinuxInputMethodContextForTesting : public LinuxInputMethodContext {
public:
explicit LinuxInputMethodContextForTesting(
- LinuxInputMethodContextDelegate* delegate)
+ LinuxInputMethodContextDelegate* delegate,
+ bool is_simple)
: delegate_(delegate),
+ is_simple_(is_simple),
is_sync_mode_(false),
eat_key_(false),
focused_(false) {}
@@ -91,7 +93,8 @@ class LinuxInputMethodContextForTesting : public LinuxInputMethodContext {
}
TextInputType input_type() const { return input_type_; }
- int input_flags() const { return input_flags_; }
+ TextInputMode input_mode() const { return input_mode_; }
+ uint32_t input_flags() const { return input_flags_; }
bool should_do_learning() const { return should_do_learning_; }
protected:
@@ -141,9 +144,15 @@ class LinuxInputMethodContextForTesting : public LinuxInputMethodContext {
void Reset() override {}
- void Focus() override { focused_ = true; }
-
- void Blur() override { focused_ = false; }
+ void UpdateFocus(bool has_client,
+ TextInputType old_type,
+ TextInputType new_type) override {
+ if (is_simple_) {
+ focused_ = has_client;
+ } else {
+ focused_ = new_type != TEXT_INPUT_TYPE_NONE;
+ }
+ }
void SetCursorLocation(const gfx::Rect& rect) override {
cursor_position_ = rect;
@@ -161,24 +170,28 @@ class LinuxInputMethodContextForTesting : public LinuxInputMethodContext {
TestResult::GetInstance()->RecordAction(base::ASCIIToUTF16(re.str()));
}
- void SetContentType(TextInputType input_type,
- int input_flags,
+ void SetContentType(TextInputType type,
+ TextInputMode mode,
+ uint32_t flags,
bool should_do_learning) override {
- input_type_ = input_type;
- input_flags_ = input_flags;
+ input_type_ = type;
+ input_mode_ = mode;
+ input_flags_ = flags;
should_do_learning_ = should_do_learning;
}
private:
LinuxInputMethodContextDelegate* delegate_;
VirtualKeyboardControllerStub virtual_keyboard_controller_;
+ const bool is_simple_;
std::vector<std::u16string> actions_;
bool is_sync_mode_;
bool eat_key_;
bool focused_;
gfx::Rect cursor_position_;
TextInputType input_type_;
- int input_flags_;
+ TextInputMode input_mode_;
+ uint32_t input_flags_;
bool should_do_learning_;
};
@@ -195,8 +208,8 @@ class LinuxInputMethodContextFactoryForTesting
std::unique_ptr<LinuxInputMethodContext> CreateInputMethodContext(
LinuxInputMethodContextDelegate* delegate,
bool is_simple) const override {
- return std::unique_ptr<ui::LinuxInputMethodContext>(
- new LinuxInputMethodContextForTesting(delegate));
+ return std::make_unique<LinuxInputMethodContextForTesting>(delegate,
+ is_simple);
}
};
@@ -505,11 +518,50 @@ TEST_F(InputMethodAuraLinuxTest, IBusPinyinTest) {
test_result_->ExpectAction("keydown:229");
test_result_->ExpectAction("compositionend");
- test_result_->ExpectAction("keydown:229");
test_result_->ExpectAction("textinput:A");
test_result_->Verify();
}
+TEST_F(InputMethodAuraLinuxTest, JapaneseCommit) {
+ context_->SetSyncMode(false);
+ context_->SetEatKey(true);
+
+ std::unique_ptr<TextInputClientForTesting> client(
+ new TextInputClientForTesting(TEXT_INPUT_TYPE_TEXT));
+ input_method_auralinux_->SetFocusedTextInputClient(client.get());
+ input_method_auralinux_->OnTextInputTypeChanged(client.get());
+ KeyEvent key(ET_KEY_PRESSED, VKEY_A, 0);
+ key.set_character(L'a');
+ input_method_auralinux_->DispatchKeyEvent(&key);
+
+ // IBus issues a standalone set_composition action.
+ input_method_auralinux_->OnPreeditStart();
+ CompositionText comp;
+ comp.text = u"a";
+ input_method_auralinux_->OnPreeditChanged(comp);
+
+ test_result_->ExpectAction("keydown:229");
+ test_result_->ExpectAction("compositionstart");
+ test_result_->ExpectAction("compositionupdate:a");
+ test_result_->Verify();
+
+ // IBus issues a commit text with composition after muting the space key down.
+ // Typing return issues a commit, followed by preedit change (to make
+ // composition empty), then preedit end.
+ KeyEvent key_up(ET_KEY_PRESSED, VKEY_RETURN, 0);
+ input_method_auralinux_->DispatchKeyEvent(&key_up);
+
+ input_method_auralinux_->OnCommit(u"a");
+ comp.text = u"";
+ input_method_auralinux_->OnPreeditChanged(comp);
+ input_method_auralinux_->OnPreeditEnd();
+
+ test_result_->ExpectAction("keydown:229");
+ test_result_->ExpectAction("compositionend");
+ test_result_->ExpectAction("textinput:a");
+ test_result_->Verify();
+}
+
// crbug.com/463491
void DeadKeyTest(TextInputType text_input_type,
InputMethodAuraLinux* input_method_auralinux,
diff --git a/chromium/ui/base/ime/linux/linux_input_method_context.h b/chromium/ui/base/ime/linux/linux_input_method_context.h
index 708d6c98ac5..b34965cdc23 100644
--- a/chromium/ui/base/ime/linux/linux_input_method_context.h
+++ b/chromium/ui/base/ime/linux/linux_input_method_context.h
@@ -5,10 +5,13 @@
#ifndef UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_
#define UI_BASE_IME_LINUX_LINUX_INPUT_METHOD_CONTEXT_H_
+#include <stdint.h>
+
#include <string>
#include <vector>
#include "base/component_export.h"
+#include "ui/base/ime/text_input_mode.h"
#include "ui/base/ime/text_input_type.h"
namespace gfx {
@@ -46,19 +49,19 @@ class COMPONENT_EXPORT(UI_BASE_IME_LINUX) LinuxInputMethodContext {
const gfx::Range& selection_range) = 0;
// Tells the system IME the content type of the text input client is changed.
- virtual void SetContentType(TextInputType input_type,
- int input_flags,
+ virtual void SetContentType(TextInputType type,
+ TextInputMode mode,
+ uint32_t flags,
bool should_do_learning) = 0;
// Resets the context. A client needs to call OnTextInputTypeChanged() again
// before calling DispatchKeyEvent().
virtual void Reset() = 0;
- // Focuses the context.
- virtual void Focus() = 0;
-
- // Blurs the context.
- virtual void Blur() = 0;
+ // Called when text input focus is changed.
+ virtual void UpdateFocus(bool has_client,
+ TextInputType old_type,
+ TextInputType new_type) = 0;
// Returns the corresponding VirtualKeyboardController instance.
// Or nullptr, if not supported.
diff --git a/chromium/ui/base/ime/text_input_client.cc b/chromium/ui/base/ime/text_input_client.cc
index 212a598d922..b5275dc63c2 100644
--- a/chromium/ui/base/ime/text_input_client.cc
+++ b/chromium/ui/base/ime/text_input_client.cc
@@ -9,9 +9,9 @@ namespace ui {
TextInputClient::~TextInputClient() {
}
-#if BUILDFLAG(IS_CHROMEOS_ASH)
-absl::optional<GrammarFragment> TextInputClient::GetGrammarFragment(
- const gfx::Range& range) {
+#if BUILDFLAG(IS_CHROMEOS)
+absl::optional<GrammarFragment> TextInputClient::GetGrammarFragmentAtCursor()
+ const {
return absl::nullopt;
}
diff --git a/chromium/ui/base/ime/text_input_client.h b/chromium/ui/base/ime/text_input_client.h
index 1155e4857d3..7c1d74e195f 100644
--- a/chromium/ui/base/ime/text_input_client.h
+++ b/chromium/ui/base/ime/text_input_client.h
@@ -55,7 +55,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) TextInputClient {
FOCUS_REASON_OTHER,
};
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
enum SubClass {
kRenderWidgetHostViewAura = 0,
kArcImeService = 1,
@@ -248,7 +248,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) TextInputClient {
const std::vector<ui::ImeTextSpan>& ui_ime_text_spans) = 0;
#endif
-#if BUILDFLAG(IS_CHROMEOS_ASH)
+#if BUILDFLAG(IS_CHROMEOS)
// Return the start and end index of the autocorrect range. If non-existent,
// return an empty Range.
virtual gfx::Range GetAutocorrectRange() const = 0;
@@ -266,10 +266,9 @@ class COMPONENT_EXPORT(UI_BASE_IME) TextInputClient {
// no modifications are made and this function returns false.
virtual bool SetAutocorrectRange(const gfx::Range& range) = 0;
- // Returns the grammar fragment which contains |range|. If non-existent,
- // returns an empty Fragment.
- virtual absl::optional<GrammarFragment> GetGrammarFragment(
- const gfx::Range& range);
+ // Returns the grammar fragment which contains the current cursor. If
+ // non-existent, returns nullopt.
+ virtual absl::optional<GrammarFragment> GetGrammarFragmentAtCursor() const;
// Clears all the grammar fragments in |range|, returns whether the operation
// is successful. Should return true if the there is no fragment in the range.
diff --git a/chromium/ui/base/ime/utf_offset_unittest.cc b/chromium/ui/base/ime/utf_offset_unittest.cc
index 6b67e6689dd..9e888aff277 100644
--- a/chromium/ui/base/ime/utf_offset_unittest.cc
+++ b/chromium/ui/base/ime/utf_offset_unittest.cc
@@ -21,58 +21,58 @@ TEST(UtfOffsetTest, Utf16OffsetFromUtf8Offset) {
absl::optional<size_t> expect;
} kTestCases[] = {
// 1 byte letters.
- {u8"ab", 0, 0},
- {u8"ab", 1, 1},
- {u8"ab", 2, 2},
- {u8"ab", 3, absl::nullopt},
+ {"ab", 0, 0},
+ {"ab", 1, 1},
+ {"ab", 2, 2},
+ {"ab", 3, absl::nullopt},
// 2 byte letters. \u03A9=\xCE\xA9 is greek OMEGA.
- {u8"\u03A9\u03A9", 0, 0},
- {u8"\u03A9\u03A9", 1, absl::nullopt},
- {u8"\u03A9\u03A9", 2, 1},
- {u8"\u03A9\u03A9", 3, absl::nullopt},
- {u8"\u03A9\u03A9", 4, 2},
- {u8"\u03A9\u03A9", 5, absl::nullopt},
+ {"\u03A9\u03A9", 0, 0},
+ {"\u03A9\u03A9", 1, absl::nullopt},
+ {"\u03A9\u03A9", 2, 1},
+ {"\u03A9\u03A9", 3, absl::nullopt},
+ {"\u03A9\u03A9", 4, 2},
+ {"\u03A9\u03A9", 5, absl::nullopt},
// 3 byte letters. \u3042=\xE3\x81\x82 is Japanese "A".
- {u8"\u3042\u3042", 0, 0},
- {u8"\u3042\u3042", 1, absl::nullopt},
- {u8"\u3042\u3042", 2, absl::nullopt},
- {u8"\u3042\u3042", 3, 1},
- {u8"\u3042\u3042", 4, absl::nullopt},
- {u8"\u3042\u3042", 5, absl::nullopt},
- {u8"\u3042\u3042", 6, 2},
- {u8"\u3042\u3042", 7, absl::nullopt},
+ {"\u3042\u3042", 0, 0},
+ {"\u3042\u3042", 1, absl::nullopt},
+ {"\u3042\u3042", 2, absl::nullopt},
+ {"\u3042\u3042", 3, 1},
+ {"\u3042\u3042", 4, absl::nullopt},
+ {"\u3042\u3042", 5, absl::nullopt},
+ {"\u3042\u3042", 6, 2},
+ {"\u3042\u3042", 7, absl::nullopt},
// 4 byte letters. \U0001F3B7=\xF0\x9F\x8E\xB7 is "SAXOPHONE" emoji.
// Note that a surrogate pair advances by 2 in UTF16.
- {u8"\U0001F3B7\U0001F3B7", 0, 0},
- {u8"\U0001F3B7\U0001F3B7", 1, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 2, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 3, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 4, 2},
- {u8"\U0001F3B7\U0001F3B7", 5, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 6, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 7, absl::nullopt},
- {u8"\U0001F3B7\U0001F3B7", 8, 4},
- {u8"\U0001F3B7\U0001F3B7", 9, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 0, 0},
+ {"\U0001F3B7\U0001F3B7", 1, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 2, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 3, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 4, 2},
+ {"\U0001F3B7\U0001F3B7", 5, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 6, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 7, absl::nullopt},
+ {"\U0001F3B7\U0001F3B7", 8, 4},
+ {"\U0001F3B7\U0001F3B7", 9, absl::nullopt},
// Mix case.
- {u8"a\u03A9b\u3042c\U0001F3B7d", 0, 0},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 1, 1},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 2, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 3, 2},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 4, 3},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 5, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 6, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 7, 4},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 8, 5},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 9, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 10, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 11, absl::nullopt},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 12, 7},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 13, 8},
- {u8"a\u03A9b\u3042c\U0001F3B7d", 14, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 0, 0},
+ {"a\u03A9b\u3042c\U0001F3B7d", 1, 1},
+ {"a\u03A9b\u3042c\U0001F3B7d", 2, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 3, 2},
+ {"a\u03A9b\u3042c\U0001F3B7d", 4, 3},
+ {"a\u03A9b\u3042c\U0001F3B7d", 5, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 6, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 7, 4},
+ {"a\u03A9b\u3042c\U0001F3B7d", 8, 5},
+ {"a\u03A9b\u3042c\U0001F3B7d", 9, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 10, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 11, absl::nullopt},
+ {"a\u03A9b\u3042c\U0001F3B7d", 12, 7},
+ {"a\u03A9b\u3042c\U0001F3B7d", 13, 8},
+ {"a\u03A9b\u3042c\U0001F3B7d", 14, absl::nullopt},
};
for (const auto& test_case : kTestCases) {
diff --git a/chromium/ui/base/ime/win/tsf_text_store.cc b/chromium/ui/base/ime/win/tsf_text_store.cc
index ceec7a1397e..e4f43e94ba4 100644
--- a/chromium/ui/base/ime/win/tsf_text_store.cc
+++ b/chromium/ui/base/ime/win/tsf_text_store.cc
@@ -357,10 +357,7 @@ HRESULT TSFTextStore::GetTextExt(TsViewCookie view_cookie,
tmp_rect.set_width(0);
result_rect = gfx::Rect(tmp_rect);
} else {
- // PPAPI flash does not support GetCompositionCharacterBounds. We need
- // to call GetCaretBounds instead to get correct text bounds info.
- // TODO(https://crbug.com/963706): Remove this hack.
- result_rect = gfx::Rect(text_input_client_->GetCaretBounds());
+ return TS_E_NOLAYOUT;
}
} else if (text_input_client_->GetCompositionCharacterBounds(
start_pos - 1, &tmp_rect)) {
@@ -390,19 +387,9 @@ HRESULT TSFTextStore::GetTextExt(TsViewCookie view_cookie,
// first character bounds instead of returning TS_E_NOLAYOUT.
}
} else {
- // PPAPI flash does not support GetCompositionCharacterBounds. We need
- // to call GetCaretBounds instead to get correct text bounds info.
- // TODO(https://crbug.com/963706): Remove this hack.
- if (start_pos == 0) {
- result_rect = gfx::Rect(text_input_client_->GetCaretBounds());
- } else {
- return TS_E_NOLAYOUT;
- }
+ return TS_E_NOLAYOUT;
}
} else {
- // Caret Bounds may be incorrect if focus is in flash control and
- // |start_pos| is not equal to |end_pos|. In this case, it's better to
- // return previous caret rectangle instead.
result_rect = gfx::Rect(text_input_client_->GetCaretBounds());
}
}
diff --git a/chromium/ui/base/ime/win/tsf_text_store_unittest.cc b/chromium/ui/base/ime/win/tsf_text_store_unittest.cc
index 80d12aecfe4..7481c3f7f5b 100644
--- a/chromium/ui/base/ime/win/tsf_text_store_unittest.cc
+++ b/chromium/ui/base/ime/win/tsf_text_store_unittest.cc
@@ -1405,14 +1405,6 @@ class GetTextExtTestCallback : public TSFTextStoreTestCallback {
has_composition_text_ = true;
GetTextExtTest(view_cookie, 0, 0, 11, 12, 11, 20);
- // TODO(nona, kinaba): Remove following test case after PPAPI supporting
- // GetCompositionCharacterBounds.
- SetInternalState(u"a", 0, 0, 1);
- layout_prepared_character_num_ = 0;
- GetTextExtTest(view_cookie, 0, 1, 1, 2, 4, 6);
- SetInternalState(u"abc", 0, 0, 3);
- GetTextExtNoLayoutTest(view_cookie, 2, 3);
-
return S_OK;
}