From 8fa0776f1f79e91fc9c0b9c1ba11a0a29c05196b Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 4 Feb 2022 17:20:24 +0100 Subject: BASELINE: Update Chromium to 98.0.4758.90 Change-Id: Ib7c41539bf8a8e0376bd639f27d68294de90f3c8 Reviewed-by: Allan Sandfeld Jensen --- chromium/ui/base/ime/ash/BUILD.gn | 2 +- chromium/ui/base/ime/ash/DEPS | 2 +- .../base/ime/ash/component_extension_ime_manager.h | 1 - .../ash/component_extension_ime_manager_delegate.h | 1 - .../component_extension_ime_manager_unittest.cc | 1 - chromium/ui/base/ime/ash/fake_ime_keyboard.h | 2 - .../ui/base/ime/ash/fake_input_method_delegate.h | 2 - chromium/ui/base/ime/ash/ime_bridge.cc | 175 ++++++++------------- chromium/ui/base/ime/ash/ime_bridge.h | 53 +++---- chromium/ui/base/ime/ash/ime_bridge_observer.h | 3 - .../ui/base/ime/ash/ime_engine_handler_interface.h | 4 + chromium/ui/base/ime/ash/ime_keyboard_impl.h | 1 - chromium/ui/base/ime/ash/input_method_ash.cc | 13 +- chromium/ui/base/ime/ash/input_method_ash.h | 2 +- .../ui/base/ime/ash/input_method_ash_unittest.cc | 1 - chromium/ui/base/ime/ash/input_method_delegate.h | 2 - chromium/ui/base/ime/ash/input_method_manager.h | 2 +- chromium/ui/base/ime/ash/input_method_ukm.h | 2 +- chromium/ui/base/ime/ash/input_method_util.h | 19 --- ...mock_component_extension_ime_manager_delegate.h | 1 - .../ui/base/ime/ash/mock_ime_engine_handler.cc | 2 + chromium/ui/base/ime/ash/mock_ime_engine_handler.h | 1 + .../ui/base/ime/ash/mock_input_method_manager.h | 1 - chromium/ui/base/ime/ash/typing_session_manager.h | 1 - chromium/ui/base/ime/candidate_window.h | 1 - chromium/ui/base/ime/character_composer.cc | 28 +++- chromium/ui/base/ime/character_composer.h | 4 +- .../ui/base/ime/character_composer_unittest.cc | 125 ++++++++++++--- chromium/ui/base/ime/dummy_input_method.cc | 2 + chromium/ui/base/ime/dummy_input_method.h | 2 +- chromium/ui/base/ime/dummy_text_input_client.h | 1 - chromium/ui/base/ime/fake_text_input_client.cc | 2 +- chromium/ui/base/ime/fake_text_input_client.h | 1 - .../ui/base/ime/fuchsia/input_method_fuchsia.h | 1 - .../fuchsia/virtual_keyboard_controller_fuchsia.h | 1 - chromium/ui/base/ime/init/input_method_factory.cc | 21 +-- chromium/ui/base/ime/init/input_method_factory.h | 2 - chromium/ui/base/ime/input_method.h | 5 +- chromium/ui/base/ime/input_method_base.cc | 10 +- chromium/ui/base/ime/input_method_base.h | 7 +- chromium/ui/base/ime/input_method_base_unittest.cc | 17 +- chromium/ui/base/ime/input_method_minimal.h | 1 - .../ui/base/ime/input_method_minimal_unittest.cc | 1 - chromium/ui/base/ime/input_method_observer.h | 4 - .../ui/base/ime/linux/fake_input_method_context.cc | 3 + .../ui/base/ime/linux/fake_input_method_context.h | 2 +- .../ime/linux/fake_input_method_context_factory.h | 1 - .../ui/base/ime/linux/input_method_auralinux.cc | 9 ++ .../ui/base/ime/linux/input_method_auralinux.h | 1 + .../ime/linux/input_method_auralinux_unittest.cc | 3 +- .../ui/base/ime/linux/linux_input_method_context.h | 3 + chromium/ui/base/ime/mac/input_method_mac.h | 1 - chromium/ui/base/ime/mock_input_method.cc | 5 +- chromium/ui/base/ime/mock_input_method.h | 9 +- .../ui/base/ime/virtual_keyboard_controller_stub.h | 1 - chromium/ui/base/ime/win/imm32_manager.cc | 1 - chromium/ui/base/ime/win/imm32_manager.h | 1 - chromium/ui/base/ime/win/input_method_win_base.h | 2 - chromium/ui/base/ime/win/input_method_win_imm32.h | 3 - chromium/ui/base/ime/win/input_method_win_tsf.cc | 5 - chromium/ui/base/ime/win/input_method_win_tsf.h | 1 - chromium/ui/base/ime/win/mock_tsf_bridge.h | 8 +- ...on_screen_keyboard_display_manager_input_pane.h | 1 - .../on_screen_keyboard_display_manager_tab_tip.cc | 5 +- .../on_screen_keyboard_display_manager_tab_tip.h | 1 - .../on_screen_keyboard_display_manager_unittest.cc | 1 - chromium/ui/base/ime/win/tsf_bridge.cc | 93 ++++++----- chromium/ui/base/ime/win/tsf_bridge.h | 1 - chromium/ui/base/ime/win/tsf_event_router.cc | 3 +- chromium/ui/base/ime/win/tsf_event_router.h | 5 +- chromium/ui/base/ime/win/tsf_input_scope.cc | 1 - chromium/ui/base/ime/win/tsf_text_store.cc | 11 -- chromium/ui/base/ime/win/tsf_text_store.h | 7 +- .../base/ime/win/virtual_keyboard_debounce_timer.h | 1 - 74 files changed, 369 insertions(+), 350 deletions(-) (limited to 'chromium/ui/base/ime') diff --git a/chromium/ui/base/ime/ash/BUILD.gn b/chromium/ui/base/ime/ash/BUILD.gn index 63681f533c0..79d8a70b5ce 100644 --- a/chromium/ui/base/ime/ash/BUILD.gn +++ b/chromium/ui/base/ime/ash/BUILD.gn @@ -70,8 +70,8 @@ component("ash") { deps = [ ":ime_types", ":typing_session_manager", + "//ash/services/ime/public/mojom", "//build:branding_buildflags", - "//chromeos/services/ime/public/mojom", "//chromeos/system", "//services/metrics/public/cpp:ukm_builders", "//third_party/icu", diff --git a/chromium/ui/base/ime/ash/DEPS b/chromium/ui/base/ime/ash/DEPS index 164c69747c4..9cc91dd60a8 100644 --- a/chromium/ui/base/ime/ash/DEPS +++ b/chromium/ui/base/ime/ash/DEPS @@ -1,6 +1,6 @@ include_rules = [ + "+ash/services/ime/public/mojom", "+chromeos/ime", - "+chromeos/services/ime/public/mojom", "+ui/chromeos/strings", "+ui/ozone/public", ] diff --git a/chromium/ui/base/ime/ash/component_extension_ime_manager.h b/chromium/ui/base/ime/ash/component_extension_ime_manager.h index 9def1699ae3..933c97461c3 100644 --- a/chromium/ui/base/ime/ash/component_extension_ime_manager.h +++ b/chromium/ui/base/ime/ash/component_extension_ime_manager.h @@ -11,7 +11,6 @@ #include "base/component_export.h" #include "base/files/file_path.h" -#include "base/macros.h" #include "ui/base/ime/ash/component_extension_ime_manager_delegate.h" #include "ui/base/ime/ash/input_method_descriptor.h" diff --git a/chromium/ui/base/ime/ash/component_extension_ime_manager_delegate.h b/chromium/ui/base/ime/ash/component_extension_ime_manager_delegate.h index 3f751faa857..978fb5fa35a 100644 --- a/chromium/ui/base/ime/ash/component_extension_ime_manager_delegate.h +++ b/chromium/ui/base/ime/ash/component_extension_ime_manager_delegate.h @@ -7,7 +7,6 @@ #include "base/component_export.h" #include "base/files/file_path.h" -#include "base/macros.h" class Profile; diff --git a/chromium/ui/base/ime/ash/component_extension_ime_manager_unittest.cc b/chromium/ui/base/ime/ash/component_extension_ime_manager_unittest.cc index d289039deae..36980f4b0b6 100644 --- a/chromium/ui/base/ime/ash/component_extension_ime_manager_unittest.cc +++ b/chromium/ui/base/ime/ash/component_extension_ime_manager_unittest.cc @@ -6,7 +6,6 @@ #include -#include "base/macros.h" #include "base/memory/ptr_util.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/ime/ash/extension_ime_util.h" diff --git a/chromium/ui/base/ime/ash/fake_ime_keyboard.h b/chromium/ui/base/ime/ash/fake_ime_keyboard.h index 45fb55813da..c7d40631b51 100644 --- a/chromium/ui/base/ime/ash/fake_ime_keyboard.h +++ b/chromium/ui/base/ime/ash/fake_ime_keyboard.h @@ -9,9 +9,7 @@ #include -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" namespace ash { namespace input_method { diff --git a/chromium/ui/base/ime/ash/fake_input_method_delegate.h b/chromium/ui/base/ime/ash/fake_input_method_delegate.h index a2af77537aa..79fee6c2fee 100644 --- a/chromium/ui/base/ime/ash/fake_input_method_delegate.h +++ b/chromium/ui/base/ime/ash/fake_input_method_delegate.h @@ -8,9 +8,7 @@ #include #include "base/callback.h" -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/ash/input_method_delegate.h" namespace ash { diff --git a/chromium/ui/base/ime/ash/ime_bridge.cc b/chromium/ui/base/ime/ash/ime_bridge.cc index 315072b1295..360bc9daa2a 100644 --- a/chromium/ui/base/ime/ash/ime_bridge.cc +++ b/chromium/ui/base/ime/ash/ime_bridge.cc @@ -4,127 +4,80 @@ #include "ui/base/ime/ash/ime_bridge.h" -#include - -#include "base/macros.h" -#include "base/memory/singleton.h" -#include "base/observer_list.h" -#include "build/build_config.h" - namespace ui { static IMEBridge* g_ime_bridge = nullptr; -// An implementation of IMEBridge. -class IMEBridgeImpl : public IMEBridge { - public: - IMEBridgeImpl() - : current_input_context_(ui::TEXT_INPUT_TYPE_NONE, - ui::TEXT_INPUT_MODE_DEFAULT, - 0, - ui::TextInputClient::FOCUS_REASON_NONE, - false /* should_do_learning */) {} - - IMEBridgeImpl(const IMEBridgeImpl&) = delete; - IMEBridgeImpl& operator=(const IMEBridgeImpl&) = delete; - - ~IMEBridgeImpl() override = default; - - // IMEBridge override. - IMEInputContextHandlerInterface* GetInputContextHandler() const override { - return input_context_handler_; - } - - // IMEBridge override. - void SetInputContextHandler( - IMEInputContextHandlerInterface* handler) override { - input_context_handler_ = handler; - for (auto& observer : observers_) - observer.OnInputContextHandlerChanged(); - } - - // IMEBridge override. - void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) override { - engine_handler_ = handler; - } - - // IMEBridge override. - IMEEngineHandlerInterface* GetCurrentEngineHandler() const override { - return engine_handler_; - } - - // IMEBridge override. - void SetCurrentInputContext( - const IMEEngineHandlerInterface::InputContext& input_context) override { - current_input_context_ = input_context; - } - - // IMEBridge override. - const IMEEngineHandlerInterface::InputContext& GetCurrentInputContext() - const override { - return current_input_context_; - } - - // IMEBridge override. - void AddObserver(ui::IMEBridgeObserver* observer) override { - observers_.AddObserver(observer); - } - - // IMEBridge override. - void RemoveObserver(ui::IMEBridgeObserver* observer) override { - observers_.RemoveObserver(observer); - } - - // IMEBridge override. - void MaybeSwitchEngine() override { - for (auto& observer : observers_) - observer.OnRequestSwitchEngine(); - } - - // IMEBridge override. - void SetCandidateWindowHandler( - ash::IMECandidateWindowHandlerInterface* handler) override { - candidate_window_handler_ = handler; - } - - // IMEBridge override. - ash::IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() - const override { - return candidate_window_handler_; - } - - // IMEBridge override. - void SetAssistiveWindowHandler( - ash::IMEAssistiveWindowHandlerInterface* handler) override { - assistive_window_handler_ = handler; - } - - // IMEBridge override. - ash::IMEAssistiveWindowHandlerInterface* GetAssistiveWindowHandler() - const override { - return assistive_window_handler_; - } - - private: - IMEInputContextHandlerInterface* input_context_handler_ = nullptr; - IMEEngineHandlerInterface* engine_handler_ = nullptr; - base::ObserverList observers_; - IMEEngineHandlerInterface::InputContext current_input_context_; - - ash::IMECandidateWindowHandlerInterface* candidate_window_handler_ = nullptr; - ash::IMEAssistiveWindowHandlerInterface* assistive_window_handler_ = nullptr; -}; - -/////////////////////////////////////////////////////////////////////////////// -// IMEBridge -IMEBridge::IMEBridge() = default; +IMEBridge::IMEBridge() + : current_input_context_(ui::TEXT_INPUT_TYPE_NONE, + ui::TEXT_INPUT_MODE_DEFAULT, + 0, + ui::TextInputClient::FOCUS_REASON_NONE, + false /* should_do_learning */) {} IMEBridge::~IMEBridge() = default; +IMEInputContextHandlerInterface* IMEBridge::GetInputContextHandler() const { + return input_context_handler_; +} + +void IMEBridge::SetInputContextHandler( + IMEInputContextHandlerInterface* handler) { + input_context_handler_ = handler; + for (auto& observer : observers_) + observer.OnInputContextHandlerChanged(); +} + +void IMEBridge::SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) { + engine_handler_ = handler; +} + +IMEEngineHandlerInterface* IMEBridge::GetCurrentEngineHandler() const { + return engine_handler_; +} + +void IMEBridge::SetCurrentInputContext( + const IMEEngineHandlerInterface::InputContext& input_context) { + current_input_context_ = input_context; +} + +const IMEEngineHandlerInterface::InputContext& +IMEBridge::GetCurrentInputContext() const { + return current_input_context_; +} + +void IMEBridge::AddObserver(ui::IMEBridgeObserver* observer) { + observers_.AddObserver(observer); +} + +void IMEBridge::RemoveObserver(ui::IMEBridgeObserver* observer) { + observers_.RemoveObserver(observer); +} + +void IMEBridge::SetCandidateWindowHandler( + ash::IMECandidateWindowHandlerInterface* handler) { + candidate_window_handler_ = handler; +} + +ash::IMECandidateWindowHandlerInterface* IMEBridge::GetCandidateWindowHandler() + const { + return candidate_window_handler_; +} + +void IMEBridge::SetAssistiveWindowHandler( + ash::IMEAssistiveWindowHandlerInterface* handler) { + assistive_window_handler_ = handler; +} + +ash::IMEAssistiveWindowHandlerInterface* IMEBridge::GetAssistiveWindowHandler() + const { + return assistive_window_handler_; +} + // static. void IMEBridge::Initialize() { if (!g_ime_bridge) - g_ime_bridge = new IMEBridgeImpl(); + g_ime_bridge = new IMEBridge(); } // static. diff --git a/chromium/ui/base/ime/ash/ime_bridge.h b/chromium/ui/base/ime/ash/ime_bridge.h index 491fe8dc6dd..b46ae9ece69 100644 --- a/chromium/ui/base/ime/ash/ime_bridge.h +++ b/chromium/ui/base/ime/ash/ime_bridge.h @@ -6,8 +6,7 @@ #define UI_BASE_IME_ASH_IME_BRIDGE_H_ #include "base/component_export.h" -#include "base/macros.h" -#include "build/build_config.h" +#include "base/observer_list.h" #include "ui/base/ime/ash/ime_assistive_window_handler_interface.h" #include "ui/base/ime/ash/ime_bridge_observer.h" #include "ui/base/ime/ash/ime_candidate_window_handler_interface.h" @@ -25,8 +24,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMEBridge { public: IMEBridge(const IMEBridge&) = delete; IMEBridge& operator=(const IMEBridge&) = delete; - - virtual ~IMEBridge(); + ~IMEBridge(); // Allocates the global instance. Must be called before any calls to Get(). static void Initialize(); @@ -39,55 +37,56 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMEBridge { // Returns current InputContextHandler. This function returns nullptr if input // context is not ready to use. - virtual IMEInputContextHandlerInterface* GetInputContextHandler() const = 0; + IMEInputContextHandlerInterface* GetInputContextHandler() const; // Updates current InputContextHandler. If there is no active input context, // pass nullptr for |handler|. Caller must release |handler|. - virtual void SetInputContextHandler( - IMEInputContextHandlerInterface* handler) = 0; + void SetInputContextHandler(IMEInputContextHandlerInterface* handler); // Updates current EngineHandler. If there is no active engine service, pass // nullptr for |handler|. Caller must release |handler|. - virtual void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler) = 0; + void SetCurrentEngineHandler(IMEEngineHandlerInterface* handler); // Returns current EngineHandler. This function returns nullptr if current // engine is not ready to use. - virtual IMEEngineHandlerInterface* GetCurrentEngineHandler() const = 0; + IMEEngineHandlerInterface* GetCurrentEngineHandler() const; // Updates the current input context. // This is called from `InputMethodAsh`. - virtual void SetCurrentInputContext( - const IMEEngineHandlerInterface::InputContext& input_context) = 0; + void SetCurrentInputContext( + const IMEEngineHandlerInterface::InputContext& input_context); // Returns the current input context. // This is called from InputMethodEngine. - virtual const IMEEngineHandlerInterface::InputContext& - GetCurrentInputContext() const = 0; + const IMEEngineHandlerInterface::InputContext& GetCurrentInputContext() const; // Add or remove observers of events such as switching engines, etc. - virtual void AddObserver(ui::IMEBridgeObserver* observer) = 0; - virtual void RemoveObserver(ui::IMEBridgeObserver* observer) = 0; - - // Switches the engine handler upon top level window focus change. - virtual void MaybeSwitchEngine() = 0; + void AddObserver(ui::IMEBridgeObserver* observer); + void RemoveObserver(ui::IMEBridgeObserver* observer); // Returns current CandidateWindowHandler. This function returns nullptr if // current candidate window is not ready to use. - virtual ash::IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() - const = 0; + ash::IMECandidateWindowHandlerInterface* GetCandidateWindowHandler() const; // Updates current CandidatWindowHandler. If there is no active candidate // window service, pass nullptr for |handler|. Caller must release |handler|. - virtual void SetCandidateWindowHandler( - ash::IMECandidateWindowHandlerInterface* handler) = 0; + void SetCandidateWindowHandler( + ash::IMECandidateWindowHandlerInterface* handler); - virtual ash::IMEAssistiveWindowHandlerInterface* GetAssistiveWindowHandler() - const = 0; - virtual void SetAssistiveWindowHandler( - ash::IMEAssistiveWindowHandlerInterface* handler) = 0; + ash::IMEAssistiveWindowHandlerInterface* GetAssistiveWindowHandler() const; + void SetAssistiveWindowHandler( + ash::IMEAssistiveWindowHandlerInterface* handler); - protected: + private: IMEBridge(); + + IMEInputContextHandlerInterface* input_context_handler_ = nullptr; + IMEEngineHandlerInterface* engine_handler_ = nullptr; + base::ObserverList observers_; + IMEEngineHandlerInterface::InputContext current_input_context_; + + ash::IMECandidateWindowHandlerInterface* candidate_window_handler_ = nullptr; + ash::IMEAssistiveWindowHandlerInterface* assistive_window_handler_ = nullptr; }; } // namespace ui diff --git a/chromium/ui/base/ime/ash/ime_bridge_observer.h b/chromium/ui/base/ime/ash/ime_bridge_observer.h index 45dc95f8cce..3816e3d71c7 100644 --- a/chromium/ui/base/ime/ash/ime_bridge_observer.h +++ b/chromium/ui/base/ime/ash/ime_bridge_observer.h @@ -14,9 +14,6 @@ namespace ui { class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMEBridgeObserver : public base::CheckedObserver { public: - // Called when requesting to switch the engine handler from ui::InputMethod. - virtual void OnRequestSwitchEngine() = 0; - // Called when the input context handler has changed, a signal of IME change. virtual void OnInputContextHandlerChanged() = 0; }; diff --git a/chromium/ui/base/ime/ash/ime_engine_handler_interface.h b/chromium/ui/base/ime/ash/ime_engine_handler_interface.h index d808769bc81..320b081b1cc 100644 --- a/chromium/ui/base/ime/ash/ime_engine_handler_interface.h +++ b/chromium/ui/base/ime/ash/ime_engine_handler_interface.h @@ -17,6 +17,7 @@ #include "ui/base/ime/text_input_client.h" #include "ui/base/ime/text_input_mode.h" #include "ui/base/ime/text_input_type.h" +#include "ui/events/event_constants.h" namespace gfx { class Rect; @@ -66,6 +67,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) IMEEngineHandlerInterface { // Called when an input field gains focus. virtual void FocusIn(const InputContext& input_context) = 0; + // Called on touch inside an input field which already has focus. + virtual void OnTouch(ui::EventPointerType pointerType) = 0; + // Called when the currently focused input field loses the focus. virtual void FocusOut() = 0; diff --git a/chromium/ui/base/ime/ash/ime_keyboard_impl.h b/chromium/ui/base/ime/ash/ime_keyboard_impl.h index 9946f08d0ad..e3e1284e54a 100644 --- a/chromium/ui/base/ime/ash/ime_keyboard_impl.h +++ b/chromium/ui/base/ime/ash/ime_keyboard_impl.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_ASH_IME_KEYBOARD_IMPL_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/ash/ime_keyboard.h" namespace ui { diff --git a/chromium/ui/base/ime/ash/input_method_ash.cc b/chromium/ui/base/ime/ash/input_method_ash.cc index 19e32239a09..3cf9e5373e8 100644 --- a/chromium/ui/base/ime/ash/input_method_ash.cc +++ b/chromium/ui/base/ime/ash/input_method_ash.cc @@ -15,6 +15,7 @@ #include "base/bind.h" #include "base/check.h" #include "base/i18n/char_iterator.h" +#include "base/ignore_result.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/third_party/icu/icu_utf.h" @@ -305,7 +306,17 @@ void InputMethodAsh::OnFocus() { ui::IMEBridge* bridge = ui::IMEBridge::Get(); if (bridge) { bridge->SetInputContextHandler(this); - bridge->MaybeSwitchEngine(); + } +} + +void InputMethodAsh::OnTouch(ui::EventPointerType pointerType) { + TextInputClient* client = GetTextInputClient(); + if (!client || !IsTextInputClientFocused(client)) { + return; + } + ui::IMEEngineHandlerInterface* engine = GetEngine(); + if (engine) { + engine->OnTouch(pointerType); } } diff --git a/chromium/ui/base/ime/ash/input_method_ash.h b/chromium/ui/base/ime/ash/input_method_ash.h index 0c572517674..fad27b38940 100644 --- a/chromium/ui/base/ime/ash/input_method_ash.h +++ b/chromium/ui/base/ime/ash/input_method_ash.h @@ -13,7 +13,6 @@ #include "base/callback_forward.h" #include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" #include "base/memory/weak_ptr.h" #include "ui/base/ime/ash/ime_input_context_handler_interface.h" #include "ui/base/ime/ash/typing_session_manager.h" @@ -47,6 +46,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodAsh // Overridden from InputMethodBase: void OnFocus() override; void OnBlur() override; + void OnTouch(ui::EventPointerType pointerType) override; void OnWillChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) override; void OnDidChangeFocusedClient(TextInputClient* focused_before, 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 830c11c94c8..7575d372e1a 100644 --- a/chromium/ui/base/ime/ash/input_method_ash_unittest.cc +++ b/chromium/ui/base/ime/ash/input_method_ash_unittest.cc @@ -12,7 +12,6 @@ #include #include "base/i18n/char_iterator.h" -#include "base/macros.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind.h" #include "base/test/task_environment.h" diff --git a/chromium/ui/base/ime/ash/input_method_delegate.h b/chromium/ui/base/ime/ash/input_method_delegate.h index 416680d9259..40d1b6659c3 100644 --- a/chromium/ui/base/ime/ash/input_method_delegate.h +++ b/chromium/ui/base/ime/ash/input_method_delegate.h @@ -7,8 +7,6 @@ #include -#include "base/macros.h" - namespace ash { namespace input_method { diff --git a/chromium/ui/base/ime/ash/input_method_manager.h b/chromium/ui/base/ime/ash/input_method_manager.h index e74b774e722..8ef1c1b5420 100644 --- a/chromium/ui/base/ime/ash/input_method_manager.h +++ b/chromium/ui/base/ime/ash/input_method_manager.h @@ -12,9 +12,9 @@ #include #include +#include "ash/services/ime/public/mojom/ime_service.mojom.h" #include "base/component_export.h" #include "base/memory/ref_counted.h" -#include "chromeos/services/ime/public/mojom/ime_service.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "ui/base/ime/ash/ime_keyset.h" #include "ui/base/ime/ash/input_method_descriptor.h" diff --git a/chromium/ui/base/ime/ash/input_method_ukm.h b/chromium/ui/base/ime/ash/input_method_ukm.h index 2cb5d55d45d..df5784717ab 100644 --- a/chromium/ui/base/ime/ash/input_method_ukm.h +++ b/chromium/ui/base/ime/ash/input_method_ukm.h @@ -5,8 +5,8 @@ #ifndef UI_BASE_IME_ASH_INPUT_METHOD_UKM_H_ #define UI_BASE_IME_ASH_INPUT_METHOD_UKM_H_ +#include "ash/services/ime/public/mojom/input_method_host.mojom-shared.h" #include "base/component_export.h" -#include "chromeos/services/ime/public/mojom/input_method_host.mojom-shared.h" #include "services/metrics/public/cpp/ukm_source_id.h" #include "ui/base/ime/text_input_type.h" diff --git a/chromium/ui/base/ime/ash/input_method_util.h b/chromium/ui/base/ime/ash/input_method_util.h index 25c9847a115..95d5a9ce45e 100644 --- a/chromium/ui/base/ime/ash/input_method_util.h +++ b/chromium/ui/base/ime/ash/input_method_util.h @@ -13,7 +13,6 @@ #include "base/component_export.h" #include "base/containers/flat_map.h" -#include "base/macros.h" #include "base/threading/thread_checker.h" #include "ui/base/ime/ash/input_method_descriptor.h" @@ -37,12 +36,6 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodUtil { ~InputMethodUtil(); - // Converts an input method ID to a display name of the IME. Returns - // an empty strng when |input_method_id| is unknown. - // Examples: "pinyin" => "Pinyin" - std::string GetInputMethodDisplayNameFromId( - const std::string& input_method_id) const; - std::u16string GetInputMethodMediumName( const InputMethodDescriptor& input_method) const; std::u16string GetInputMethodLongNameStripped( @@ -162,18 +155,6 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) InputMethodUtil { std::vector* out_input_method_ids) const; private: - // Converts a string sent from IBus IME engines, which is written in English, - // into Chrome's string ID, then pulls internationalized resource string from - // the resource bundle and returns it. These functions are not thread-safe. - // Non-UI threads are not allowed to call them. - // The english_string to should be a xkb id with "xkb:...:...:..." format. - // TODO(shuchen): this method should be removed when finish the wrapping of - // xkb to extension. - std::u16string TranslateString(const std::string& english_string) const; - - bool TranslateStringInternal(const std::string& english_string, - std::u16string* out_string) const; - // Get long name of the given input method. |short_name| is to specify whether // to get the long name for OOBE screen, because OOBE screen displays shorter // name (e.g. 'US' instead of 'US keyboard'). diff --git a/chromium/ui/base/ime/ash/mock_component_extension_ime_manager_delegate.h b/chromium/ui/base/ime/ash/mock_component_extension_ime_manager_delegate.h index e7c28c55376..df34a84109c 100644 --- a/chromium/ui/base/ime/ash/mock_component_extension_ime_manager_delegate.h +++ b/chromium/ui/base/ime/ash/mock_component_extension_ime_manager_delegate.h @@ -8,7 +8,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/ash/component_extension_ime_manager_delegate.h" namespace ash { diff --git a/chromium/ui/base/ime/ash/mock_ime_engine_handler.cc b/chromium/ui/base/ime/ash/mock_ime_engine_handler.cc index 446fab2fb5e..5325a4bd3f2 100644 --- a/chromium/ui/base/ime/ash/mock_ime_engine_handler.cc +++ b/chromium/ui/base/ime/ash/mock_ime_engine_handler.cc @@ -29,6 +29,8 @@ void MockIMEEngineHandler::FocusIn(const InputContext& input_context) { ++focus_in_call_count_; } +void MockIMEEngineHandler::OnTouch(ui::EventPointerType pointerType) {} + void MockIMEEngineHandler::FocusOut() { if (last_text_input_context_.type != ui::TEXT_INPUT_TYPE_NONE) ++focus_out_call_count_; diff --git a/chromium/ui/base/ime/ash/mock_ime_engine_handler.h b/chromium/ui/base/ime/ash/mock_ime_engine_handler.h index 26c5edc5e87..2d6ccc7c24c 100644 --- a/chromium/ui/base/ime/ash/mock_ime_engine_handler.h +++ b/chromium/ui/base/ime/ash/mock_ime_engine_handler.h @@ -23,6 +23,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_ASH) MockIMEEngineHandler // ui::IMEEngineHandlerInterface: void FocusIn(const InputContext& input_context) override; + void OnTouch(ui::EventPointerType pointerType) override; void FocusOut() override; void Enable(const std::string& component_id) override; void Disable() override; 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 dc8083cbfde..953365486c6 100644 --- a/chromium/ui/base/ime/ash/mock_input_method_manager.h +++ b/chromium/ui/base/ime/ash/mock_input_method_manager.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_ASH_MOCK_INPUT_METHOD_MANAGER_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/ash/input_method_manager.h" // TODO(https://crbug.com/1164001): remove and use forward declaration. #include "ui/base/ime/ash/input_method_util.h" diff --git a/chromium/ui/base/ime/ash/typing_session_manager.h b/chromium/ui/base/ime/ash/typing_session_manager.h index 53a3451f149..aa2f819ed97 100644 --- a/chromium/ui/base/ime/ash/typing_session_manager.h +++ b/chromium/ui/base/ime/ash/typing_session_manager.h @@ -7,7 +7,6 @@ #include -#include "base/macros.h" #include "base/time/default_clock.h" #include "base/time/time.h" diff --git a/chromium/ui/base/ime/candidate_window.h b/chromium/ui/base/ime/candidate_window.h index e67dc804fee..6ad0eee09a5 100644 --- a/chromium/ui/base/ime/candidate_window.h +++ b/chromium/ui/base/ime/candidate_window.h @@ -12,7 +12,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/infolist_entry.h" namespace ui { diff --git a/chromium/ui/base/ime/character_composer.cc b/chromium/ui/base/ime/character_composer.cc index 891dacb5cde..24ede0feb13 100644 --- a/chromium/ui/base/ime/character_composer.cc +++ b/chromium/ui/base/ime/character_composer.cc @@ -123,6 +123,7 @@ bool CharacterComposer::FilterKeyPressSequenceMode(const KeyEvent& event) { compose_buffer_.clear(); UTF32CharacterToUTF16(composed_character_utf32, &composed_character_); } + UpdatePreeditStringSequenceMode(); return true; } // Key press is not a part of composition. @@ -149,11 +150,27 @@ bool CharacterComposer::FilterKeyPressSequenceMode(const KeyEvent& event) { } } compose_buffer_.clear(); + UpdatePreeditStringSequenceMode(); return true; } return false; } +void CharacterComposer::UpdatePreeditStringSequenceMode() { + for (auto key : compose_buffer_) { + if (key.IsCharacter()) { + base::WriteUnicodeCharacter(key.ToCharacter(), &preedit_string_); + } else if (key.IsDeadKey()) { + base::WriteUnicodeCharacter(key.ToDeadKeyCombiningCharacter(), + &preedit_string_); + } else if (key.IsComposeKey() && (compose_buffer_.size() == 1)) { + // The U+00B7 "middle dot" character is also used by GTK to represent the + // compose key in preedit strings. + base::WriteUnicodeCharacter(0xB7, &preedit_string_); + } + } +} + bool CharacterComposer::FilterKeyPressHexMode(const KeyEvent& event) { DCHECK(composition_mode_ == HEX_MODE); const size_t kMaxHexSequenceLength = 8; @@ -234,12 +251,17 @@ ComposeChecker::CheckSequenceResult TreeComposeChecker::CheckSequence( for (const auto& keystroke : sequence) { DCHECK(tree_index < data_.tree_entries); - // If we are looking up a dead key, skip over the character tables. + // If we are looking up a dead key or the Compose key, skip over the + // character tables. int32_t character = -1; - if (keystroke.IsDeadKey()) { + if (keystroke.IsDeadKey() || keystroke.IsComposeKey()) { tree_index += 2 * data_.tree[tree_index] + 1; // internal unicode table tree_index += 2 * data_.tree[tree_index] + 1; // leaf unicode table - character = keystroke.ToDeadKeyCombiningCharacter(); + // The generate_character_composer_data.py script assigns 0 to the Compose + // key. + character = keystroke.IsComposeKey() + ? 0 + : keystroke.ToDeadKeyCombiningCharacter(); } else if (keystroke.IsCharacter()) { character = keystroke.ToCharacter(); } diff --git a/chromium/ui/base/ime/character_composer.h b/chromium/ui/base/ime/character_composer.h index cb408ea9644..64536181193 100644 --- a/chromium/ui/base/ime/character_composer.h +++ b/chromium/ui/base/ime/character_composer.h @@ -11,7 +11,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "base/strings/string_util.h" #include "ui/events/keycodes/dom/dom_key.h" @@ -61,6 +60,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_TYPES) CharacterComposer { // Filters keypress in key sequence mode. bool FilterKeyPressSequenceMode(const ui::KeyEvent& event); + // Updates preedit string in key sequence mode. + void UpdatePreeditStringSequenceMode(); + // Filters keypress in hexadecimal mode. bool FilterKeyPressHexMode(const ui::KeyEvent& event); diff --git a/chromium/ui/base/ime/character_composer_unittest.cc b/chromium/ui/base/ime/character_composer_unittest.cc index 247f509d3b6..6aebbea928d 100644 --- a/chromium/ui/base/ime/character_composer_unittest.cc +++ b/chromium/ui/base/ime/character_composer_unittest.cc @@ -59,15 +59,30 @@ class CharacterComposerTest : public testing::Test { EXPECT_EQ(expected_character, character_composer_.composed_character()); } + // Returns a |KeyEvent| for a Compose key press. + std::unique_ptr ComposeKeyPress() const { + // Which physical key is used as the Compose key can usually be configured + // and should therefore be irrelevant. + return std::make_unique( + ET_KEY_PRESSED, KeyboardCode::VKEY_COMPOSE, DomCode::ALT_RIGHT, EF_NONE, + DomKey::COMPOSE, EventTimeForNow()); + } + + // Expects key is filtered and no character is composed. + void ExpectComposeKeyFiltered() { + auto event = ComposeKeyPress(); + EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); + EXPECT_TRUE(character_composer_.composed_character().empty()); + } + // Returns a |KeyEvent| for a character key press. - KeyEvent* UnicodeKeyPress(KeyboardCode vkey, - DomCode code, - int flags, - char16_t character) const { - KeyEvent* event = - new KeyEvent(ET_KEY_PRESSED, vkey, code, flags, - DomKey::FromCharacter(character), EventTimeForNow()); - return event; + std::unique_ptr UnicodeKeyPress(KeyboardCode vkey, + DomCode code, + int flags, + char16_t character) const { + return std::make_unique(ET_KEY_PRESSED, vkey, code, flags, + DomKey::FromCharacter(character), + EventTimeForNow()); } // Expects key is not filtered and no character is composed. @@ -75,8 +90,7 @@ class CharacterComposerTest : public testing::Test { DomCode code, int flags, char16_t character) { - std::unique_ptr event( - UnicodeKeyPress(vkey, code, flags, character)); + auto event = UnicodeKeyPress(vkey, code, flags, character); EXPECT_FALSE(character_composer_.FilterKeyPress(*event)); EXPECT_TRUE(character_composer_.composed_character().empty()); } @@ -86,8 +100,7 @@ class CharacterComposerTest : public testing::Test { DomCode code, int flags, char16_t character) { - std::unique_ptr event( - UnicodeKeyPress(vkey, code, flags, character)); + auto event = UnicodeKeyPress(vkey, code, flags, character); EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); EXPECT_TRUE(character_composer_.composed_character().empty()); } @@ -98,8 +111,7 @@ class CharacterComposerTest : public testing::Test { int flags, char16_t character, const std::u16string& expected_character) { - std::unique_ptr event( - UnicodeKeyPress(vkey, code, flags, character)); + auto event = UnicodeKeyPress(vkey, code, flags, character); EXPECT_TRUE(character_composer_.FilterKeyPress(*event)); EXPECT_EQ(expected_character, character_composer_.composed_character()); } @@ -126,44 +138,97 @@ TEST_F(CharacterComposerTest, PartiallyMatchingSequence) { ExpectDeadKeyFiltered(kCombiningAcute); ExpectUnicodeKeyFiltered(VKEY_1, DomCode::DIGIT1, 0, '1'); + // Composition with sequence ['compose', '\'', '1'] will fail. + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyFiltered(VKEY_1, DomCode::DIGIT1, 0, '1'); + // Composition with sequence ['dead acute', 'dead circumflex', '1'] will fail. ExpectDeadKeyFiltered(kCombiningAcute); ExpectDeadKeyFiltered(kCombiningCircumflex); ExpectUnicodeKeyFiltered(VKEY_1, DomCode::DIGIT1, 0, '1'); + + // Composition with sequence ['compose', '\'', '^', '1'] will fail. + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyFiltered(VKEY_6, DomCode::DIGIT6, EF_SHIFT_DOWN, '^'); + ExpectUnicodeKeyFiltered(VKEY_1, DomCode::DIGIT1, 0, '1'); } TEST_F(CharacterComposerTest, FullyMatchingSequences) { // LATIN SMALL LETTER A WITH ACUTE ExpectDeadKeyFiltered(kCombiningAcute); + ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', + std::u16string(1, 0x00E1)); + // LATIN SMALL LETTER A WITH ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', std::u16string(1, 0x00E1)); // LATIN CAPITAL LETTER A WITH ACUTE ExpectDeadKeyFiltered(kCombiningAcute); + ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'A', + std::u16string(1, 0x00C1)); + // LATIN CAPITAL LETTER A WITH ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'A', std::u16string(1, 0x00C1)); // GRAVE ACCENT ExpectDeadKeyFiltered(kCombiningGrave); ExpectDeadKeyComposed(kCombiningGrave, std::u16string(1, 0x0060)); + // ACUTE ACCENT (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyComposed(VKEY_OEM_7, DomCode::QUOTE, 0, '\'', + std::u16string(1, 0x00B4)); // LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE ExpectDeadKeyFiltered(kCombiningAcute); ExpectDeadKeyFiltered(kCombiningCircumflex); + ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', + std::u16string(1, 0x1EA5)); + // LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyFiltered(VKEY_6, DomCode::DIGIT6, EF_SHIFT_DOWN, '^'); ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', std::u16string(1, 0x1EA5)); // LATIN CAPITAL LETTER U WITH HORN AND GRAVE ExpectDeadKeyFiltered(kCombiningGrave); ExpectDeadKeyFiltered(kCombiningHorn); + ExpectUnicodeKeyComposed(VKEY_U, DomCode::US_U, EF_NONE, 'U', + std::u16string(1, 0x1EEA)); + // LATIN CAPITAL LETTER U WITH HORN AND GRAVE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_3, DomCode::BACKQUOTE, 0, '`'); + ExpectUnicodeKeyFiltered(VKEY_OEM_PLUS, DomCode::EQUAL, EF_SHIFT_DOWN, '+'); ExpectUnicodeKeyComposed(VKEY_U, DomCode::US_U, EF_NONE, 'U', std::u16string(1, 0x1EEA)); // LATIN CAPITAL LETTER C WITH ACUTE ExpectDeadKeyFiltered(kCombiningAcute); + ExpectUnicodeKeyComposed(VKEY_C, DomCode::US_C, EF_NONE, 'C', + std::u16string(1, 0x0106)); + // LATIN CAPITAL LETTER C WITH ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); ExpectUnicodeKeyComposed(VKEY_C, DomCode::US_C, EF_NONE, 'C', std::u16string(1, 0x0106)); // LATIN SMALL LETTER C WITH ACUTE ExpectDeadKeyFiltered(kCombiningAcute); + ExpectUnicodeKeyComposed(VKEY_C, DomCode::US_C, EF_NONE, 'c', + std::u16string(1, 0x0107)); + // LATIN SMALL LETTER C WITH ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); ExpectUnicodeKeyComposed(VKEY_C, DomCode::US_C, EF_NONE, 'c', std::u16string(1, 0x0107)); // GREEK SMALL LETTER EPSILON WITH TONOS ExpectDeadKeyFiltered(kCombiningAcute); + ExpectUnicodeKeyComposed(VKEY_E, DomCode::US_E, EF_NONE, 0x03B5, + std::u16string(1, 0x03AD)); + // GREEK SMALL LETTER EPSILON WITH TONOS (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); ExpectUnicodeKeyComposed(VKEY_E, DomCode::US_E, EF_NONE, 0x03B5, std::u16string(1, 0x03AD)); @@ -201,6 +266,18 @@ TEST_F(CharacterComposerTest, FullyMatchingSequencesAfterMatchingFailure) { ExpectDeadKeyFiltered(kCombiningCircumflex); ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', std::u16string(1, 0x1EA5)); + + // Composition with sequence ['compose', '\'', '^', '1'] will fail. + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyFiltered(VKEY_6, DomCode::DIGIT6, EF_SHIFT_DOWN, '^'); + ExpectUnicodeKeyFiltered(VKEY_1, DomCode::DIGIT1, 0, '1'); + // LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE (via Compose key) + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyFiltered(VKEY_6, DomCode::DIGIT6, EF_SHIFT_DOWN, '^'); + ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', + std::u16string(1, 0x1EA5)); } TEST_F(CharacterComposerTest, ComposedCharacterIsClearedAfterReset) { @@ -209,6 +286,13 @@ TEST_F(CharacterComposerTest, ComposedCharacterIsClearedAfterReset) { std::u16string(1, 0x00E1)); character_composer_.Reset(); EXPECT_TRUE(character_composer_.composed_character().empty()); + + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', + std::u16string(1, 0x00E1)); + character_composer_.Reset(); + EXPECT_TRUE(character_composer_.composed_character().empty()); } TEST_F(CharacterComposerTest, CompositionStateIsClearedAfterReset) { @@ -217,16 +301,11 @@ TEST_F(CharacterComposerTest, CompositionStateIsClearedAfterReset) { ExpectDeadKeyFiltered(kCombiningAcute); character_composer_.Reset(); ExpectUnicodeKeyNotFiltered(VKEY_A, DomCode::US_A, EF_NONE, 'a'); -} -TEST_F(CharacterComposerTest, KeySequenceCompositionPreedit) { - // LATIN SMALL LETTER A WITH ACUTE - // preedit_string() is always empty in key sequence composition mode. - ExpectDeadKeyFiltered(kCombiningAcute); - EXPECT_TRUE(character_composer_.preedit_string().empty()); - ExpectUnicodeKeyComposed(VKEY_A, DomCode::US_A, EF_NONE, 'a', - std::u16string(1, 0x00E1)); - EXPECT_TRUE(character_composer_.preedit_string().empty()); + ExpectComposeKeyFiltered(); + ExpectUnicodeKeyFiltered(VKEY_OEM_7, DomCode::QUOTE, 0, '\''); + character_composer_.Reset(); + ExpectUnicodeKeyNotFiltered(VKEY_A, DomCode::US_A, EF_NONE, 'a'); } // Verify the structure of the primary |TreeComposeChecker| table. diff --git a/chromium/ui/base/ime/dummy_input_method.cc b/chromium/ui/base/ime/dummy_input_method.cc index 08300eed3e7..2ff39bb77ef 100644 --- a/chromium/ui/base/ime/dummy_input_method.cc +++ b/chromium/ui/base/ime/dummy_input_method.cc @@ -20,6 +20,8 @@ void DummyInputMethod::SetDelegate(internal::InputMethodDelegate* delegate) { void DummyInputMethod::OnFocus() { } +void DummyInputMethod::OnTouch(ui::EventPointerType pointerType) {} + void DummyInputMethod::OnBlur() { } diff --git a/chromium/ui/base/ime/dummy_input_method.h b/chromium/ui/base/ime/dummy_input_method.h index ca76e5e6db9..89f00ed5338 100644 --- a/chromium/ui/base/ime/dummy_input_method.h +++ b/chromium/ui/base/ime/dummy_input_method.h @@ -5,7 +5,6 @@ #ifndef UI_BASE_IME_DUMMY_INPUT_METHOD_H_ #define UI_BASE_IME_DUMMY_INPUT_METHOD_H_ -#include "base/macros.h" #include "build/build_config.h" #include "ui/base/ime/input_method.h" @@ -25,6 +24,7 @@ class DummyInputMethod : public InputMethod { // InputMethod overrides: void SetDelegate(internal::InputMethodDelegate* delegate) override; void OnFocus() override; + void OnTouch(ui::EventPointerType pointerType) override; void OnBlur() override; #if defined(OS_WIN) diff --git a/chromium/ui/base/ime/dummy_text_input_client.h b/chromium/ui/base/ime/dummy_text_input_client.h index 3a65081acab..559551a7423 100644 --- a/chromium/ui/base/ime/dummy_text_input_client.h +++ b/chromium/ui/base/ime/dummy_text_input_client.h @@ -8,7 +8,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "ui/base/ime/text_input_client.h" diff --git a/chromium/ui/base/ime/fake_text_input_client.cc b/chromium/ui/base/ime/fake_text_input_client.cc index fd36a9da504..66fb55712f2 100644 --- a/chromium/ui/base/ime/fake_text_input_client.cc +++ b/chromium/ui/base/ime/fake_text_input_client.cc @@ -102,7 +102,7 @@ bool FakeTextInputClient::HasCompositionText() const { } ui::TextInputClient::FocusReason FakeTextInputClient::GetFocusReason() const { - return ui::TextInputClient::FOCUS_REASON_NONE; + return ui::TextInputClient::FOCUS_REASON_MOUSE; } bool FakeTextInputClient::GetTextRange(gfx::Range* range) const { diff --git a/chromium/ui/base/ime/fake_text_input_client.h b/chromium/ui/base/ime/fake_text_input_client.h index 9478727307b..99b670ee4fd 100644 --- a/chromium/ui/base/ime/fake_text_input_client.h +++ b/chromium/ui/base/ime/fake_text_input_client.h @@ -8,7 +8,6 @@ #include #include -#include "base/macros.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "ui/base/ime/text_input_client.h" diff --git a/chromium/ui/base/ime/fuchsia/input_method_fuchsia.h b/chromium/ui/base/ime/fuchsia/input_method_fuchsia.h index eeab62cc6fd..2b901611bbf 100644 --- a/chromium/ui/base/ime/fuchsia/input_method_fuchsia.h +++ b/chromium/ui/base/ime/fuchsia/input_method_fuchsia.h @@ -10,7 +10,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/ime/fuchsia/virtual_keyboard_controller_fuchsia.h" #include "ui/base/ime/input_method_base.h" diff --git a/chromium/ui/base/ime/fuchsia/virtual_keyboard_controller_fuchsia.h b/chromium/ui/base/ime/fuchsia/virtual_keyboard_controller_fuchsia.h index 4f960033764..4bbf3246de9 100644 --- a/chromium/ui/base/ime/fuchsia/virtual_keyboard_controller_fuchsia.h +++ b/chromium/ui/base/ime/fuchsia/virtual_keyboard_controller_fuchsia.h @@ -10,7 +10,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/input_method_base.h" #include "ui/base/ime/virtual_keyboard_controller.h" diff --git a/chromium/ui/base/ime/init/input_method_factory.cc b/chromium/ui/base/ime/init/input_method_factory.cc index 07ee458fbb3..5569351e57f 100644 --- a/chromium/ui/base/ime/init/input_method_factory.cc +++ b/chromium/ui/base/ime/init/input_method_factory.cc @@ -18,13 +18,8 @@ #include "ui/base/ime/win/input_method_win_tsf.h" #elif defined(OS_APPLE) #include "ui/base/ime/mac/input_method_mac.h" -#elif defined(USE_X11) || defined(USE_OZONE) -#if defined(USE_X11) -#include "ui/base/ime/linux/input_method_auralinux.h" -#endif // defined(USE_X11) -#if defined(USE_OZONE) +#elif defined(USE_OZONE) #include "ui/ozone/public/ozone_platform.h" -#endif // defined(USE_OZONE) #else #include "ui/base/ime/input_method_minimal.h" #endif @@ -67,18 +62,8 @@ std::unique_ptr CreateInputMethod( return std::make_unique(delegate, widget); #elif defined(OS_APPLE) return std::make_unique(delegate); -#elif defined(USE_X11) || defined(USE_OZONE) -#if defined(USE_OZONE) - if (features::IsUsingOzonePlatform()) { - return ui::OzonePlatform::GetInstance()->CreateInputMethod(delegate, - widget); - } -#endif // defined(USE_OZONE) -#if defined(USE_X11) - return std::make_unique(delegate); -#endif // defined(USE_X11) - NOTREACHED(); - return nullptr; +#elif defined(USE_OZONE) + return ui::OzonePlatform::GetInstance()->CreateInputMethod(delegate, widget); #else return std::make_unique(delegate); #endif diff --git a/chromium/ui/base/ime/init/input_method_factory.h b/chromium/ui/base/ime/init/input_method_factory.h index efb9aaa4ad4..87c319f2a78 100644 --- a/chromium/ui/base/ime/init/input_method_factory.h +++ b/chromium/ui/base/ime/init/input_method_factory.h @@ -7,9 +7,7 @@ #include -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/init/input_method_initializer.h" #include "ui/gfx/native_widget_types.h" diff --git a/chromium/ui/base/ime/input_method.h b/chromium/ui/base/ime/input_method.h index 9ab11f2abb0..d763c91a45d 100644 --- a/chromium/ui/base/ime/input_method.h +++ b/chromium/ui/base/ime/input_method.h @@ -7,7 +7,7 @@ #include - +#include "base/compiler_specific.h" #include "build/build_config.h" #include "ui/base/ime/text_input_mode.h" #include "ui/base/ime/text_input_type.h" @@ -65,6 +65,9 @@ class InputMethod { // Called when the top-level system window gets keyboard focus. virtual void OnFocus() = 0; + // Called when there is a touch within a text field that has focus. + virtual void OnTouch(ui::EventPointerType pointerType) = 0; + // Called when the top-level system window loses keyboard focus. virtual void OnBlur() = 0; diff --git a/chromium/ui/base/ime/input_method_base.cc b/chromium/ui/base/ime/input_method_base.cc index cb651909850..1c4ed271714 100644 --- a/chromium/ui/base/ime/input_method_base.cc +++ b/chromium/ui/base/ime/input_method_base.cc @@ -7,6 +7,7 @@ #include "base/bind.h" #include "base/callback_helpers.h" #include "base/check.h" +#include "base/ignore_result.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "ui/base/ime/input_method_delegate.h" @@ -41,6 +42,8 @@ void InputMethodBase::OnFocus() { void InputMethodBase::OnBlur() { } +void InputMethodBase::OnTouch(ui::EventPointerType pointerType) {} + #if defined(OS_WIN) bool InputMethodBase::OnUntranslatedIMEMessage( const CHROME_MSG event, @@ -87,10 +90,9 @@ TextInputType InputMethodBase::GetTextInputType() const { } void InputMethodBase::ShowVirtualKeyboardIfEnabled() { - for (InputMethodObserver& observer : observer_list_) - observer.OnShowVirtualKeyboardIfEnabled(); - if (auto* keyboard = GetVirtualKeyboardController()) - keyboard->DisplayVirtualKeyboard(); + // TODO(crbug.com/1275410): Merge this into + // SetVirtualKeyboardVisibilityIfEnabled. + SetVirtualKeyboardVisibilityIfEnabled(true); } void InputMethodBase::SetVirtualKeyboardVisibilityIfEnabled(bool should_show) { diff --git a/chromium/ui/base/ime/input_method_base.h b/chromium/ui/base/ime/input_method_base.h index c61233c292f..c74ec52765c 100644 --- a/chromium/ui/base/ime/input_method_base.h +++ b/chromium/ui/base/ime/input_method_base.h @@ -10,7 +10,7 @@ #include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" +#include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "build/build_config.h" @@ -43,6 +43,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) InputMethodBase // Overriden from InputMethod. void SetDelegate(internal::InputMethodDelegate* delegate) override; void OnFocus() override; + void OnTouch(ui::EventPointerType pointerType) override; void OnBlur() override; #if defined(OS_WIN) @@ -112,11 +113,11 @@ class COMPONENT_EXPORT(UI_BASE_IME) InputMethodBase internal::InputMethodDelegate* delegate() const { return delegate_; } private: - internal::InputMethodDelegate* delegate_; + raw_ptr delegate_; void SetFocusedTextInputClientInternal(TextInputClient* client); - TextInputClient* text_input_client_ = nullptr; + raw_ptr text_input_client_ = nullptr; base::ObserverList::Unchecked observer_list_; diff --git a/chromium/ui/base/ime/input_method_base_unittest.cc b/chromium/ui/base/ime/input_method_base_unittest.cc index 98b9d2f06d4..f1f368b2556 100644 --- a/chromium/ui/base/ime/input_method_base_unittest.cc +++ b/chromium/ui/base/ime/input_method_base_unittest.cc @@ -7,12 +7,12 @@ #include #include "base/gtest_prod_util.h" -#include "base/macros.h" +#include "base/memory/raw_ptr.h" #include "base/run_loop.h" #include "base/scoped_observation.h" #include "base/test/task_environment.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/ime/dummy_text_input_client.h" +#include "ui/base/ime/fake_text_input_client.h" #include "ui/base/ime/input_method_observer.h" #include "ui/events/event.h" @@ -147,7 +147,7 @@ class MockInputMethodBase : public InputMethodBase { } // Not owned. - ClientChangeVerifier* const verifier_; + const raw_ptr verifier_; FRIEND_TEST_ALL_PREFIXES(InputMethodBaseTest, CandidateWindowEvents); }; @@ -170,11 +170,10 @@ class MockInputMethodObserver : public InputMethodObserver { void OnTextInputStateChanged(const TextInputClient* client) override { verifier_->OnTextInputStateChanged(client); } - void OnShowVirtualKeyboardIfEnabled() override {} void OnInputMethodDestroyed(const InputMethod* client) override {} // Not owned. - ClientChangeVerifier* const verifier_; + const raw_ptr verifier_; }; typedef base::ScopedObservation @@ -186,8 +185,8 @@ void SetFocusedTextInputClient(InputMethod* input_method, } TEST_F(InputMethodBaseTest, SetFocusedTextInputClient) { - DummyTextInputClient text_input_client_1st; - DummyTextInputClient text_input_client_2nd; + FakeTextInputClient text_input_client_1st(TEXT_INPUT_TYPE_TEXT); + FakeTextInputClient text_input_client_2nd(TEXT_INPUT_TYPE_TEXT); ClientChangeVerifier verifier; MockInputMethodBase input_method(&verifier); @@ -245,8 +244,8 @@ TEST_F(InputMethodBaseTest, SetFocusedTextInputClient) { } TEST_F(InputMethodBaseTest, DetachTextInputClient) { - DummyTextInputClient text_input_client; - DummyTextInputClient text_input_client_the_other; + FakeTextInputClient text_input_client(TEXT_INPUT_TYPE_TEXT); + FakeTextInputClient text_input_client_the_other(TEXT_INPUT_TYPE_TEXT); ClientChangeVerifier verifier; MockInputMethodBase input_method(&verifier); diff --git a/chromium/ui/base/ime/input_method_minimal.h b/chromium/ui/base/ime/input_method_minimal.h index 5e910ec3b7a..da99a20beb5 100644 --- a/chromium/ui/base/ime/input_method_minimal.h +++ b/chromium/ui/base/ime/input_method_minimal.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_INPUT_METHOD_MINIMAL_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/input_method_base.h" namespace ui { diff --git a/chromium/ui/base/ime/input_method_minimal_unittest.cc b/chromium/ui/base/ime/input_method_minimal_unittest.cc index 42e7846fbaa..a74e45481ad 100644 --- a/chromium/ui/base/ime/input_method_minimal_unittest.cc +++ b/chromium/ui/base/ime/input_method_minimal_unittest.cc @@ -4,7 +4,6 @@ #include "ui/base/ime/input_method_minimal.h" -#include "base/macros.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/ime/dummy_text_input_client.h" #include "ui/base/ime/init/input_method_initializer.h" diff --git a/chromium/ui/base/ime/input_method_observer.h b/chromium/ui/base/ime/input_method_observer.h index f35d69229a8..57955d7f4bd 100644 --- a/chromium/ui/base/ime/input_method_observer.h +++ b/chromium/ui/base/ime/input_method_observer.h @@ -35,10 +35,6 @@ class COMPONENT_EXPORT(UI_BASE_IME) InputMethodObserver { // Called when the observed InputMethod is being destroyed. virtual void OnInputMethodDestroyed(const InputMethod* input_method) = 0; - // Called when a user gesture should trigger showing the virtual keyboard - // or alternate input view (e.g. handwriting palette). Used in ChromeOS. - virtual void OnShowVirtualKeyboardIfEnabled() = 0; - // Called when an API call is used to explicitly show / hide the virtual // keyboard. virtual void OnVirtualKeyboardVisibilityChangedIfEnabled(bool should_show) {} 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 a864a6e79ff..2f8e3ea179a 100644 --- a/chromium/ui/base/ime/linux/fake_input_method_context.cc +++ b/chromium/ui/base/ime/linux/fake_input_method_context.cc @@ -35,4 +35,7 @@ void FakeInputMethodContext::SetSurroundingText( const std::u16string& text, const gfx::Range& selection_range) {} +void FakeInputMethodContext::SetContentType(TextInputType input_type, + int input_flags) {} + } // namespace ui 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 e18f012c374..5b9ad9f7508 100644 --- a/chromium/ui/base/ime/linux/fake_input_method_context.h +++ b/chromium/ui/base/ime/linux/fake_input_method_context.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_LINUX_FAKE_INPUT_METHOD_CONTEXT_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/linux/linux_input_method_context.h" namespace ui { @@ -29,6 +28,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_LINUX) FakeInputMethodContext 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) override; }; } // namespace ui diff --git a/chromium/ui/base/ime/linux/fake_input_method_context_factory.h b/chromium/ui/base/ime/linux/fake_input_method_context_factory.h index ca7943f81ba..55ddddf07f1 100644 --- a/chromium/ui/base/ime/linux/fake_input_method_context_factory.h +++ b/chromium/ui/base/ime/linux/fake_input_method_context_factory.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_LINUX_FAKE_INPUT_METHOD_CONTEXT_FACTORY_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/linux/linux_input_method_context_factory.h" namespace ui { diff --git a/chromium/ui/base/ime/linux/input_method_auralinux.cc b/chromium/ui/base/ime/linux/input_method_auralinux.cc index 81769b2a456..bd09a8f5042 100644 --- a/chromium/ui/base/ime/linux/input_method_auralinux.cc +++ b/chromium/ui/base/ime/linux/input_method_auralinux.cc @@ -11,6 +11,7 @@ #include "ui/base/ime/constants.h" #include "ui/base/ime/linux/linux_input_method_context_factory.h" #include "ui/base/ime/text_input_client.h" +#include "ui/base/ime/text_input_flags.h" #include "ui/events/event.h" namespace { @@ -367,6 +368,14 @@ void InputMethodAuraLinux::OnTextInputTypeChanged( const TextInputClient* client) { UpdateContextFocusState(); InputMethodBase::OnTextInputTypeChanged(client); + + 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); // TODO(yoichio): Support inputmode HTML attribute. } diff --git a/chromium/ui/base/ime/linux/input_method_auralinux.h b/chromium/ui/base/ime/linux/input_method_auralinux.h index 6477c4cb4fe..9b0a584683d 100644 --- a/chromium/ui/base/ime/linux/input_method_auralinux.h +++ b/chromium/ui/base/ime/linux/input_method_auralinux.h @@ -7,6 +7,7 @@ #include +#include "base/compiler_specific.h" #include "base/component_export.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/ime/composition_text.h" 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 8d064838da4..bf4770ce3ab 100644 --- a/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc +++ b/chromium/ui/base/ime/linux/input_method_auralinux_unittest.cc @@ -6,7 +6,6 @@ #include -#include "base/macros.h" #include "base/memory/singleton.h" #include "base/strings/string_split.h" #include "base/strings/utf_string_conversions.h" @@ -153,6 +152,8 @@ class LinuxInputMethodContextForTesting : public LinuxInputMethodContext { TestResult::GetInstance()->RecordAction(base::ASCIIToUTF16(re.str())); } + void SetContentType(TextInputType input_type, int input_flags) override {} + private: LinuxInputMethodContextDelegate* delegate_; std::vector actions_; 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 3c11d7bab90..c179180b78a 100644 --- a/chromium/ui/base/ime/linux/linux_input_method_context.h +++ b/chromium/ui/base/ime/linux/linux_input_method_context.h @@ -44,6 +44,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_LINUX) LinuxInputMethodContext { virtual void SetSurroundingText(const std::u16string& text, 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) = 0; + // Resets the context. A client needs to call OnTextInputTypeChanged() again // before calling DispatchKeyEvent(). virtual void Reset() = 0; diff --git a/chromium/ui/base/ime/mac/input_method_mac.h b/chromium/ui/base/ime/mac/input_method_mac.h index 7c6082103be..7e606b05f20 100644 --- a/chromium/ui/base/ime/mac/input_method_mac.h +++ b/chromium/ui/base/ime/mac/input_method_mac.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_MAC_INPUT_METHOD_MAC_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/input_method_base.h" namespace ui { diff --git a/chromium/ui/base/ime/mock_input_method.cc b/chromium/ui/base/ime/mock_input_method.cc index bdf06b12718..8fb4a36d2e4 100644 --- a/chromium/ui/base/ime/mock_input_method.cc +++ b/chromium/ui/base/ime/mock_input_method.cc @@ -62,6 +62,8 @@ void MockInputMethod::OnFocus() { observer.OnFocus(); } +void MockInputMethod::OnTouch(ui::EventPointerType pointerType) {} + void MockInputMethod::OnBlur() { for (InputMethodObserver& observer : observer_list_) observer.OnBlur(); @@ -104,8 +106,7 @@ bool MockInputMethod::IsCandidatePopupOpen() const { } void MockInputMethod::ShowVirtualKeyboardIfEnabled() { - for (InputMethodObserver& observer : observer_list_) - observer.OnShowVirtualKeyboardIfEnabled(); + SetVirtualKeyboardVisibilityIfEnabled(true); } void MockInputMethod::SetVirtualKeyboardVisibilityIfEnabled(bool should_show) { diff --git a/chromium/ui/base/ime/mock_input_method.h b/chromium/ui/base/ime/mock_input_method.h index 8eb94205004..1f5fa3b898b 100644 --- a/chromium/ui/base/ime/mock_input_method.h +++ b/chromium/ui/base/ime/mock_input_method.h @@ -5,10 +5,9 @@ #ifndef UI_BASE_IME_MOCK_INPUT_METHOD_H_ #define UI_BASE_IME_MOCK_INPUT_METHOD_H_ - #include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" +#include "base/memory/raw_ptr.h" #include "base/observer_list.h" #include "build/build_config.h" #include "ui/base/ime/input_method.h" @@ -37,6 +36,7 @@ class COMPONENT_EXPORT(UI_BASE_IME) MockInputMethod : public InputMethod { void SetDelegate(internal::InputMethodDelegate* delegate) override; void OnFocus() override; void OnBlur() override; + void OnTouch(ui::EventPointerType pointerType) override; #if defined(OS_WIN) bool OnUntranslatedIMEMessage(const CHROME_MSG event, @@ -61,10 +61,9 @@ class COMPONENT_EXPORT(UI_BASE_IME) MockInputMethod : public InputMethod { VirtualKeyboardController* GetVirtualKeyboardController() override; private: - - TextInputClient* text_input_client_; + raw_ptr text_input_client_; base::ObserverList::Unchecked observer_list_; - internal::InputMethodDelegate* delegate_; + raw_ptr delegate_; VirtualKeyboardControllerStub keyboard_controller_; }; diff --git a/chromium/ui/base/ime/virtual_keyboard_controller_stub.h b/chromium/ui/base/ime/virtual_keyboard_controller_stub.h index f74f6b33379..f0b9a88858a 100644 --- a/chromium/ui/base/ime/virtual_keyboard_controller_stub.h +++ b/chromium/ui/base/ime/virtual_keyboard_controller_stub.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_VIRTUAL_KEYBOARD_CONTROLLER_STUB_H_ #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/virtual_keyboard_controller.h" namespace ui { diff --git a/chromium/ui/base/ime/win/imm32_manager.cc b/chromium/ui/base/ime/win/imm32_manager.cc index f0588dd4dbc..31f953ba0bc 100644 --- a/chromium/ui/base/ime/win/imm32_manager.cc +++ b/chromium/ui/base/ime/win/imm32_manager.cc @@ -9,7 +9,6 @@ #include #include -#include "base/macros.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "third_party/skia/include/core/SkColor.h" diff --git a/chromium/ui/base/ime/win/imm32_manager.h b/chromium/ui/base/ime/win/imm32_manager.h index 2a51ef6ebfa..2c53915c111 100644 --- a/chromium/ui/base/ime/win/imm32_manager.h +++ b/chromium/ui/base/ime/win/imm32_manager.h @@ -12,7 +12,6 @@ #include "base/component_export.h" #include "base/i18n/rtl.h" -#include "base/macros.h" #include "ui/base/ime/text_input_mode.h" #include "ui/gfx/geometry/rect.h" diff --git a/chromium/ui/base/ime/win/input_method_win_base.h b/chromium/ui/base/ime/win/input_method_win_base.h index 89d2c00887d..68fb3fbf8c5 100644 --- a/chromium/ui/base/ime/win/input_method_win_base.h +++ b/chromium/ui/base/ime/win/input_method_win_base.h @@ -7,9 +7,7 @@ #include -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/input_method_base.h" #include "ui/base/ime/win/imm32_manager.h" diff --git a/chromium/ui/base/ime/win/input_method_win_imm32.h b/chromium/ui/base/ime/win/input_method_win_imm32.h index e4cc080192e..8c4500b28ec 100644 --- a/chromium/ui/base/ime/win/input_method_win_imm32.h +++ b/chromium/ui/base/ime/win/input_method_win_imm32.h @@ -7,10 +7,7 @@ #include - -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" #include "ui/base/ime/win/imm32_manager.h" #include "ui/base/ime/win/input_method_win_base.h" diff --git a/chromium/ui/base/ime/win/input_method_win_tsf.cc b/chromium/ui/base/ime/win/input_method_win_tsf.cc index 6222701b0de..00322bd7e30 100644 --- a/chromium/ui/base/ime/win/input_method_win_tsf.cc +++ b/chromium/ui/base/ime/win/input_method_win_tsf.cc @@ -176,9 +176,4 @@ void InputMethodWinTSF::ConfirmCompositionText() { ui::TSFBridge::GetInstance()->ConfirmComposition(); } -void InputMethodWinTSF::ShowVirtualKeyboardIfEnabled() { - if (auto* controller = GetVirtualKeyboardController()) - controller->DisplayVirtualKeyboard(); -} - } // namespace ui diff --git a/chromium/ui/base/ime/win/input_method_win_tsf.h b/chromium/ui/base/ime/win/input_method_win_tsf.h index 7c0b7d72726..0da95f43ad0 100644 --- a/chromium/ui/base/ime/win/input_method_win_tsf.h +++ b/chromium/ui/base/ime/win/input_method_win_tsf.h @@ -43,7 +43,6 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) InputMethodWinTSF TextInputClient* focused) override; void OnDidChangeFocusedClient(TextInputClient* focused_before, TextInputClient* focused) override; - void ShowVirtualKeyboardIfEnabled() override; private: void ConfirmCompositionText(); diff --git a/chromium/ui/base/ime/win/mock_tsf_bridge.h b/chromium/ui/base/ime/win/mock_tsf_bridge.h index 25b72430214..c5e531bf1df 100644 --- a/chromium/ui/base/ime/win/mock_tsf_bridge.h +++ b/chromium/ui/base/ime/win/mock_tsf_bridge.h @@ -8,7 +8,7 @@ #include #include -#include "base/compiler_specific.h" +#include "base/memory/raw_ptr.h" #include "ui/base/ime/input_method_delegate.h" #include "ui/base/ime/text_input_type.h" #include "ui/base/ime/win/tsf_bridge.h" @@ -99,12 +99,12 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) MockTSFBridge : public TSFBridge { unsigned associate_focus_call_count_ = 0; unsigned set_focused_client_call_count_ = 0; unsigned remove_focused_client_call_count_ = 0; - TextInputClient* text_input_client_ = nullptr; - internal::InputMethodDelegate* input_method_delegate_ = nullptr; + raw_ptr text_input_client_ = nullptr; + raw_ptr input_method_delegate_ = nullptr; HWND focused_window_ = nullptr; TextInputType latest_text_input_type_ = TEXT_INPUT_TYPE_NONE; Microsoft::WRL::ComPtr thread_manager_; - TSFTextStore* tsf_text_store_ = nullptr; + raw_ptr tsf_text_store_ = nullptr; }; } // namespace ui diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h index 48abd5f0f8f..ba74a099955 100644 --- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h +++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h @@ -13,7 +13,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" #include "base/observer_list.h" #include "base/threading/thread_task_runner_handle.h" #include "base/win/windows_types.h" diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc index 0cbbba95190..0ccd278599e 100644 --- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc +++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.cc @@ -13,8 +13,9 @@ #include "base/bind.h" #include "base/location.h" #include "base/logging.h" -#include "base/single_thread_task_runner.h" +#include "base/memory/raw_ptr.h" #include "base/strings/string_util.h" +#include "base/task/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "base/win/registry.h" #include "base/win/scoped_co_mem.h" @@ -88,7 +89,7 @@ class OnScreenKeyboardDetector { // The observer list is cleared out after this notification. void HandleKeyboardHidden(); - OnScreenKeyboardDisplayManagerTabTip* display_manager_; + raw_ptr display_manager_; // The main window which displays the on screen keyboard. HWND main_window_ = nullptr; diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.h b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.h index a143cca57c0..b71b340a067 100644 --- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.h +++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_tab_tip.h @@ -9,7 +9,6 @@ #include "base/component_export.h" #include "base/gtest_prod_util.h" -#include "base/macros.h" #include "base/observer_list.h" #include "ui/base/ime/virtual_keyboard_controller.h" #include "ui/gfx/geometry/rect.h" diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc index dd2bce19106..6a65830ab28 100644 --- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc +++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc @@ -9,7 +9,6 @@ #include "base/files/file_path.h" #include "base/files/file_util.h" -#include "base/macros.h" #include "base/test/task_environment.h" #include "base/win/windows_version.h" #include "testing/gmock/include/gmock/gmock.h" diff --git a/chromium/ui/base/ime/win/tsf_bridge.cc b/chromium/ui/base/ime/win/tsf_bridge.cc index 88df706892d..e180d8ab886 100644 --- a/chromium/ui/base/ime/win/tsf_bridge.cc +++ b/chromium/ui/base/ime/win/tsf_bridge.cc @@ -8,6 +8,7 @@ #include "base/cxx17_backports.h" #include "base/logging.h" +#include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "base/no_destructor.h" #include "base/task/current_thread.h" @@ -70,7 +71,9 @@ class TSFBridgeImpl : public TSFBridge { HRESULT CreateDocumentManager(TSFTextStore* text_store, ITfDocumentMgr** document_manager, ITfContext** context, - DWORD* source_cookie); + DWORD* source_cookie, + DWORD* key_trace_sink_cookie, + DWORD* language_profile_cookie); // Returns true if |document_manager| is the focused document manager. bool IsFocused(ITfDocumentMgr* document_manager); @@ -101,12 +104,20 @@ class TSFBridgeImpl : public TSFBridge { // minimum working set of an editable document in TSF. struct TSFDocument { public: - TSFDocument() : cookie(TF_INVALID_COOKIE) {} + TSFDocument() + : source_cookie(TF_INVALID_COOKIE), + key_trace_sink_cookie(TF_INVALID_COOKIE), + language_profile_cookie(TF_INVALID_COOKIE) {} TSFDocument(const TSFDocument& src) - : document_manager(src.document_manager), cookie(src.cookie) {} + : document_manager(src.document_manager), + source_cookie(src.source_cookie), + key_trace_sink_cookie(src.key_trace_sink_cookie), + language_profile_cookie(src.language_profile_cookie) {} Microsoft::WRL::ComPtr document_manager; scoped_refptr text_store; - DWORD cookie; + DWORD source_cookie; + DWORD key_trace_sink_cookie; + DWORD language_profile_cookie; }; // Returns a pointer to TSFDocument that is associated with the current @@ -135,19 +146,13 @@ class TSFBridgeImpl : public TSFBridge { TfClientId client_id_ = TF_CLIENTID_NULL; // Current focused text input client. Do not free |client_|. - TextInputClient* client_ = nullptr; + raw_ptr client_ = nullptr; // Input Type of current focused text input client. TextInputType input_type_ = TEXT_INPUT_TYPE_NONE; // Represents the window that is currently owns text input focus. HWND attached_window_handle_ = nullptr; - - // Handle to ITfKeyTraceEventSink. - DWORD key_trace_sink_cookie_ = 0; - - // Handle to ITfLanguageProfileNotifySink - DWORD language_profile_cookie_ = 0; }; TSFBridgeImpl::TSFBridgeImpl() = default; @@ -157,26 +162,26 @@ TSFBridgeImpl::~TSFBridgeImpl() { if (!IsInitialized()) return; - if (thread_manager_ != nullptr) { - Microsoft::WRL::ComPtr source; - if (SUCCEEDED(thread_manager_->QueryInterface(IID_PPV_ARGS(&source)))) { - source->UnadviseSink(key_trace_sink_cookie_); - } - Microsoft::WRL::ComPtr language_source; - if (SUCCEEDED(input_processor_profiles_->QueryInterface( - IID_PPV_ARGS(&language_source)))) { - language_source->UnadviseSink(language_profile_cookie_); - } - } - - for (TSFDocumentMap::iterator it = tsf_document_map_.begin(); - it != tsf_document_map_.end(); ++it) { + for (auto& pair : tsf_document_map_) { + TSFDocument& document = pair.second; Microsoft::WRL::ComPtr context; Microsoft::WRL::ComPtr source; - if (it->second.cookie != TF_INVALID_COOKIE && - SUCCEEDED(it->second.document_manager->GetBase(&context)) && + if (document.source_cookie != TF_INVALID_COOKIE && + SUCCEEDED(document.document_manager->GetBase(&context)) && SUCCEEDED(context.As(&source))) { - source->UnadviseSink(it->second.cookie); + source->UnadviseSink(document.source_cookie); + } + if (thread_manager_ != nullptr) { + Microsoft::WRL::ComPtr key_trace_sink_source; + if (document.key_trace_sink_cookie != TF_INVALID_COOKIE && + SUCCEEDED(thread_manager_.As(&key_trace_sink_source))) { + key_trace_sink_source->UnadviseSink(document.key_trace_sink_cookie); + } + Microsoft::WRL::ComPtr language_profile_source; + if (document.language_profile_cookie != TF_INVALID_COOKIE && + SUCCEEDED(input_processor_profiles_.As(&language_profile_source))) { + language_profile_source->UnadviseSink(document.language_profile_cookie); + } } } tsf_document_map_.clear(); @@ -398,15 +403,19 @@ Microsoft::WRL::ComPtr TSFBridgeImpl::GetThreadManager() { HRESULT TSFBridgeImpl::CreateDocumentManager(TSFTextStore* text_store, ITfDocumentMgr** document_manager, ITfContext** context, - DWORD* source_cookie) { + DWORD* source_cookie, + DWORD* key_trace_sink_cookie, + DWORD* language_profile_cookie) { HRESULT hr = thread_manager_->CreateDocumentMgr(document_manager); if (FAILED(hr)) { DVLOG(1) << "Failed to create Document Manager."; return hr; } - if (!text_store || !source_cookie) + if (!text_store || !source_cookie || !key_trace_sink_cookie || + !language_profile_cookie) { return S_OK; + } DWORD edit_cookie = TF_INVALID_EDIT_COOKIE; hr = (*document_manager) @@ -448,7 +457,7 @@ HRESULT TSFBridgeImpl::CreateDocumentManager(TSFTextStore* text_store, hr = source_ITfThreadMgr->AdviseSink( IID_ITfKeyTraceEventSink, static_cast(text_store), - &key_trace_sink_cookie_); + key_trace_sink_cookie); if (FAILED(hr)) { DVLOG(1) << "AdviseSink for ITfKeyTraceEventSink failed."; return hr; @@ -464,7 +473,7 @@ HRESULT TSFBridgeImpl::CreateDocumentManager(TSFTextStore* text_store, hr = language_source->AdviseSink(IID_ITfLanguageProfileNotifySink, static_cast(text_store), - &language_profile_cookie_); + language_profile_cookie); if (FAILED(hr)) { DVLOG(1) << "AdviseSink for language profile notify sink failed."; return hr; @@ -488,9 +497,15 @@ HRESULT TSFBridgeImpl::InitializeDocumentMapInternal() { const TextInputType input_type = kTextInputTypes[i]; Microsoft::WRL::ComPtr context; Microsoft::WRL::ComPtr document_manager; - DWORD cookie = TF_INVALID_COOKIE; + DWORD source_cookie = TF_INVALID_COOKIE; + DWORD key_trace_sink_cookie = TF_INVALID_COOKIE; + DWORD language_profile_cookie = TF_INVALID_COOKIE; const bool use_null_text_store = (input_type == TEXT_INPUT_TYPE_NONE); - DWORD* cookie_ptr = use_null_text_store ? nullptr : &cookie; + DWORD* source_cookie_ptr = use_null_text_store ? nullptr : &source_cookie; + DWORD* key_trace_sink_cookie_ptr = + use_null_text_store ? nullptr : &key_trace_sink_cookie; + DWORD* language_profile_cookie_ptr = + use_null_text_store ? nullptr : &language_profile_cookie; scoped_refptr text_store = use_null_text_store ? nullptr : new TSFTextStore(); if (text_store) { @@ -498,8 +513,9 @@ HRESULT TSFBridgeImpl::InitializeDocumentMapInternal() { if (FAILED(hr)) return hr; } - HRESULT hr = CreateDocumentManager(text_store.get(), &document_manager, - &context, cookie_ptr); + HRESULT hr = CreateDocumentManager( + text_store.get(), &document_manager, &context, source_cookie_ptr, + key_trace_sink_cookie_ptr, language_profile_cookie_ptr); if (FAILED(hr)) return hr; if (input_type == TEXT_INPUT_TYPE_PASSWORD) { @@ -509,7 +525,10 @@ HRESULT TSFBridgeImpl::InitializeDocumentMapInternal() { } tsf_document_map_[input_type].text_store = text_store; tsf_document_map_[input_type].document_manager = document_manager; - tsf_document_map_[input_type].cookie = cookie; + tsf_document_map_[input_type].source_cookie = source_cookie; + tsf_document_map_[input_type].key_trace_sink_cookie = key_trace_sink_cookie; + tsf_document_map_[input_type].language_profile_cookie = + language_profile_cookie; if (text_store) text_store->OnContextInitialized(context.Get()); } diff --git a/chromium/ui/base/ime/win/tsf_bridge.h b/chromium/ui/base/ime/win/tsf_bridge.h index 3b20e3cebb2..072fe0881bd 100644 --- a/chromium/ui/base/ime/win/tsf_bridge.h +++ b/chromium/ui/base/ime/win/tsf_bridge.h @@ -10,7 +10,6 @@ #include #include "base/component_export.h" -#include "base/macros.h" namespace ui { class TextInputClient; diff --git a/chromium/ui/base/ime/win/tsf_event_router.cc b/chromium/ui/base/ime/win/tsf_event_router.cc index 174b70f677a..a1d7e6b0df6 100644 --- a/chromium/ui/base/ime/win/tsf_event_router.cc +++ b/chromium/ui/base/ime/win/tsf_event_router.cc @@ -9,6 +9,7 @@ #include #include "base/bind.h" +#include "base/memory/raw_ptr.h" #include "base/win/atl.h" #include "ui/base/win/atl_module.h" #include "ui/gfx/range/range.h" @@ -87,7 +88,7 @@ class ATL_NO_VTABLE TSFEventRouter::Delegate // The cookie for |ui_source_|. DWORD ui_source_cookie_ = TF_INVALID_COOKIE; - TSFEventRouter* router_ = nullptr; + raw_ptr router_ = nullptr; gfx::Range previous_composition_range_; }; diff --git a/chromium/ui/base/ime/win/tsf_event_router.h b/chromium/ui/base/ime/win/tsf_event_router.h index 355c064b394..844f7c7cd29 100644 --- a/chromium/ui/base/ime/win/tsf_event_router.h +++ b/chromium/ui/base/ime/win/tsf_event_router.h @@ -8,10 +8,9 @@ #include #include - #include "base/callback.h" -#include "base/compiler_specific.h" #include "base/component_export.h" +#include "base/memory/raw_ptr.h" #include "ui/base/ime/text_input_type.h" #include "ui/gfx/range/range.h" @@ -70,7 +69,7 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) TSFEventRouter { Microsoft::WRL::ComPtr delegate_; - TSFEventRouterObserver* observer_; + raw_ptr observer_; }; } // namespace ui diff --git a/chromium/ui/base/ime/win/tsf_input_scope.cc b/chromium/ui/base/ime/win/tsf_input_scope.cc index a3b2f8cee01..696e70def46 100644 --- a/chromium/ui/base/ime/win/tsf_input_scope.cc +++ b/chromium/ui/base/ime/win/tsf_input_scope.cc @@ -9,7 +9,6 @@ #include "base/check.h" #include "base/compiler_specific.h" #include "base/containers/contains.h" -#include "base/macros.h" #include "base/task/current_thread.h" #include "base/win/windows_version.h" diff --git a/chromium/ui/base/ime/win/tsf_text_store.cc b/chromium/ui/base/ime/win/tsf_text_store.cc index 1c9cb57579f..686a749259c 100644 --- a/chromium/ui/base/ime/win/tsf_text_store.cc +++ b/chromium/ui/base/ime/win/tsf_text_store.cc @@ -330,19 +330,8 @@ HRESULT TSFTextStore::GetTextExt(TsViewCookie view_cookie, // TODO(IME): add tests for scenario that left position is bigger than right // position. absl::optional result_rect; - absl::optional tmp_opt_rect; const uint32_t start_pos = acp_start - composition_start_; const uint32_t end_pos = acp_end - composition_start_; - // If there is an active EditContext, then fetch the layout bounds from it. - text_input_client_->GetActiveTextInputControlLayoutBounds(&tmp_opt_rect, - &result_rect); - if (result_rect) { - *rect = display::win::ScreenWin::DIPToScreenRect(window_handle_, - result_rect.value()) - .ToRECT(); - *clipped = FALSE; - return S_OK; - } gfx::Rect tmp_rect; if (start_pos == end_pos) { diff --git a/chromium/ui/base/ime/win/tsf_text_store.h b/chromium/ui/base/ime/win/tsf_text_store.h index 8565b2f3b03..968b72d134b 100644 --- a/chromium/ui/base/ime/win/tsf_text_store.h +++ b/chromium/ui/base/ime/win/tsf_text_store.h @@ -10,9 +10,8 @@ #include #include -#include "base/compiler_specific.h" #include "base/component_export.h" -#include "base/macros.h" +#include "base/memory/raw_ptr.h" #include "ui/base/ime/ime_text_span.h" #include "ui/base/ime/input_method_delegate.h" #include "ui/events/event_utils.h" @@ -326,10 +325,10 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN) TSFTextStore HWND window_handle_ = nullptr; // Current TextInputClient which is set in SetFocusedTextInputClient. - TextInputClient* text_input_client_ = nullptr; + raw_ptr text_input_client_ = nullptr; // InputMethodDelegate instance which is used dispatch key events. - internal::InputMethodDelegate* input_method_delegate_ = nullptr; + raw_ptr input_method_delegate_ = nullptr; // |string_buffer_document_| contains all string in current active view. // |string_pending_insertion_| contains only string in current edit session. diff --git a/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h index 6f59c351b09..fc8db7abb41 100644 --- a/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h +++ b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h @@ -6,7 +6,6 @@ #define UI_BASE_IME_WIN_VIRTUAL_KEYBOARD_DEBOUNCE_TIMER_H_ #include "base/callback.h" -#include "base/macros.h" #include "base/time/time.h" #include "base/timer/timer.h" -- cgit v1.2.1