123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
- From: Kyrylo Hrechykhin <[email protected]>
- Date: Thu, 6 Oct 2022 18:30:53 +0200
- Subject: fix: on-screen-keyboard hides on input blur in webview
- Work around OSK not hiding by notifying RenderWidgetHostViewAura of
- focus node change via TextInputManager.
- chromium-bug: https://crbug.com/1369605
- diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
- index d2454381351253e76c48d651ac09cecc9b9d219b..c8cb26dba6d166b8bf6aa0894002b8da4d5bcf1c 100644
- --- a/content/browser/renderer_host/render_widget_host_view_aura.cc
- +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
- @@ -3121,6 +3121,12 @@ void RenderWidgetHostViewAura::OnTextSelectionChanged(
- }
- }
-
- +void RenderWidgetHostViewAura::OnFocusedInputElementChanged(
- + TextInputManager* text_input_manager,
- + RenderWidgetHostViewBase* view) {
- + FocusedNodeChanged(false, {});
- +}
- +
- void RenderWidgetHostViewAura::SetPopupChild(
- RenderWidgetHostViewAura* popup_child_host_view) {
- popup_child_host_view_ = popup_child_host_view;
- diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h
- index 74e38cd40248181b2ffd71a51cf3714e6b2b0692..90d9922dacc8b74d36ffbc19e1fd483dde768af7 100644
- --- a/content/browser/renderer_host/render_widget_host_view_aura.h
- +++ b/content/browser/renderer_host/render_widget_host_view_aura.h
- @@ -650,6 +650,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
- RenderWidgetHostViewBase* updated_view) override;
- void OnTextSelectionChanged(TextInputManager* text_input_mangager,
- RenderWidgetHostViewBase* updated_view) override;
- + void OnFocusedInputElementChanged(TextInputManager* text_input_manager,
- + RenderWidgetHostViewBase* view) override;
-
- // Detaches |this| from the input method object.
- // is_removed flag is true if this is called while the window is
- diff --git a/content/browser/renderer_host/text_input_manager.cc b/content/browser/renderer_host/text_input_manager.cc
- index 8b6bfb7c6678b321b410a004bd8d24dc00033aca..b630baee31b9f1a99c5f87a90818ab2a2023e40f 100644
- --- a/content/browser/renderer_host/text_input_manager.cc
- +++ b/content/browser/renderer_host/text_input_manager.cc
- @@ -184,6 +184,7 @@ void TextInputManager::UpdateTextInputState(
-
- if (text_input_state.type == ui::TEXT_INPUT_TYPE_NONE &&
- active_view_ != view) {
- + NotifyFocusedInputElementChanged(active_view_);
- // We reached here because an IPC is received to reset the TextInputState
- // for |view|. But |view| != |active_view_|, which suggests that at least
- // one other view has become active and we have received the corresponding
- @@ -486,6 +487,12 @@ void TextInputManager::NotifyObserversAboutInputStateUpdate(
- observer.OnUpdateTextInputStateCalled(this, updated_view, did_update_state);
- }
-
- +void TextInputManager::NotifyFocusedInputElementChanged(
- + RenderWidgetHostViewBase* view) {
- + for (auto& observer : observer_list_)
- + observer.OnFocusedInputElementChanged(this, view);
- +}
- +
- TextInputManager::SelectionRegion::SelectionRegion() = default;
-
- TextInputManager::SelectionRegion::SelectionRegion(
- diff --git a/content/browser/renderer_host/text_input_manager.h b/content/browser/renderer_host/text_input_manager.h
- index 51522e60d6dc14f1113cc438558b6b393c3fe73a..153ed02f493a83ef9ca354cc18736f9394fc9a72 100644
- --- a/content/browser/renderer_host/text_input_manager.h
- +++ b/content/browser/renderer_host/text_input_manager.h
- @@ -72,6 +72,10 @@ class CONTENT_EXPORT TextInputManager {
- virtual void OnTextSelectionChanged(
- TextInputManager* text_input_manager,
- RenderWidgetHostViewBase* updated_view) {}
- + // Called when focused input element has changed
- + virtual void OnFocusedInputElementChanged(
- + TextInputManager* text_input_manager,
- + RenderWidgetHostViewBase* updated_view) {}
- };
-
- // Text selection bounds.
- @@ -308,6 +312,7 @@ class CONTENT_EXPORT TextInputManager {
-
- void NotifyObserversAboutInputStateUpdate(RenderWidgetHostViewBase* view,
- bool did_update_state);
- + void NotifyFocusedInputElementChanged(RenderWidgetHostViewBase* view);
-
- // The view with active text input state, i.e., a focused <input> element.
- // It will be nullptr if no such view exists. Note that the active view
- diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
- index 5f0411754e6bcdf323f55c89c959b5f1e2028f42..b1d6040688ab7eba8e81f753ec7138e9f0bf0e65 100644
- --- a/content/browser/web_contents/web_contents_impl.cc
- +++ b/content/browser/web_contents/web_contents_impl.cc
- @@ -9362,7 +9362,7 @@ void WebContentsImpl::OnFocusedElementChangedInFrame(
- "WebContentsImpl::OnFocusedElementChangedInFrame",
- "render_frame_host", frame);
- RenderWidgetHostViewBase* root_view =
- - static_cast<RenderWidgetHostViewBase*>(GetRenderWidgetHostView());
- + static_cast<RenderWidgetHostViewBase*>(GetTopLevelRenderWidgetHostView());
- if (!root_view || !frame->GetView()) {
- return;
- }
|