From 9107378744171945e92e87c05b4cd003b673afff Mon Sep 17 00:00:00 2001 From: liuxd Date: Tue, 28 Feb 2023 14:37:33 +0800 Subject: [PATCH] [M108 Migration][VD] Fix FocusInOutCallbacks not handled issue FocusInOutCallbacks been set on RenderViewReady, and been handled on OnFocusIn/OnFocusOut. On below case, the FocusInOutCallbacks not handled. 1. open office365 word: open office365 word will CreateNewWindow, and on the process without PostRenderViewReady, cause FocusInOutCallbacks without set. So add PostRenderViewReady when CreateNewWindow. 2. open website by deeplink: ewk_view_focus_set set after PostRenderViewReady. Becasue it takes a long time from PostRenderViewReady to receiving RenderViewReady, cause EWebView receive RenderViewReady later than ewk_view_focus_set. It cause FocusInOutCallbacks set later then OnFocusIn/OnFocusOut, cause FocusInOutCallbacks not handled. So call RenderViewReady directly on PostRenderViewReady. 3. open website by window.open: ewk_view_focus_set set before RenderViewReady, It cause FocusInOutCallbacks set later then OnFocusIn/OnFocusOut, cause FocusInOutCallbacks not handled. So pending setfocus when RenderView is not Live. Refer: https://review.tizen.org/gerrit/#/c/284765 Change-Id: I591ce004f418dca05b56a22c42c7d196a3337024 Signed-off-by: liuxd --- .../renderer_host/render_frame_host_impl.cc | 6 ++++++ .../renderer_host/render_view_host_impl.cc | 4 ++++ tizen_src/ewk/efl_integration/eweb_view.cc | 21 +++++++++++++++++++ tizen_src/ewk/efl_integration/eweb_view.h | 7 +++++++ 4 files changed, 38 insertions(+) diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index cf3daa141a93..eab33b2b8a53 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -7630,6 +7630,12 @@ void RenderFrameHostImpl::CreateNewWindow( // The mojom reply callback with kSuccess causes the renderer to create the // renderer-side objects. new_main_rfh->render_view_host()->RenderViewCreated(new_main_rfh); + +#if BUILDFLAG(IS_TIZEN_TV) + // This must be posted after the RenderViewHost is marked live, with + // `renderer_view_created_`. + new_main_rfh->render_view_host()->PostRenderViewReady(); +#endif } void RenderFrameHostImpl::CreatePortal( diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc index 726013ff8042..a406a517cf16 100644 --- a/content/browser/renderer_host/render_view_host_impl.cc +++ b/content/browser/renderer_host/render_view_host_impl.cc @@ -913,8 +913,12 @@ void RenderViewHostImpl::EnablePreferredSizeMode() { } void RenderViewHostImpl::PostRenderViewReady() { +#if BUILDFLAG(IS_TIZEN_TV) + RenderViewReady(); +#else GetProcess()->PostTaskWhenProcessIsReady(base::BindOnce( &RenderViewHostImpl::RenderViewReady, weak_factory_.GetWeakPtr())); +#endif } void RenderViewHostImpl::OnGpuSwitched(gl::GpuPreference active_gpu_heuristic) { diff --git a/tizen_src/ewk/efl_integration/eweb_view.cc b/tizen_src/ewk/efl_integration/eweb_view.cc index 350352113069..ae7d8273c717 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.cc +++ b/tizen_src/ewk/efl_integration/eweb_view.cc @@ -539,11 +539,32 @@ void EWebView::ResetContextMenuController() { return context_menu_.reset(); } +#if BUILDFLAG(IS_TIZEN_TV) +void EWebView::RunPendingSetFocus(Eina_Bool focus) { + if (!web_contents_ || !rwhva() || (HasFocus() == focus)) + return; + rwhva()->offscreen_helper()->Focus(focus); +} +#endif + void EWebView::SetFocus(Eina_Bool focus) { if (!web_contents_ || !rwhva() || (HasFocus() == focus)) return; +#if BUILDFLAG(IS_TIZEN_TV) + if (web_contents_->GetPrimaryMainFrame()->IsRenderFrameLive()) { + rwhva()->offscreen_helper()->Focus(focus); + + if (pending_setfocus_closure_) + pending_setfocus_closure_.Reset(); + } else { + LOG(ERROR) << "SEND DELAY SET FOCUS BIND"; + pending_setfocus_closure_ = base::BindOnce(&EWebView::RunPendingSetFocus, + base::Unretained(this), focus); + } +#else rwhva()->offscreen_helper()->Focus(focus); +#endif } Eina_Bool EWebView::HasFocus() const { diff --git a/tizen_src/ewk/efl_integration/eweb_view.h b/tizen_src/ewk/efl_integration/eweb_view.h index 6f05ceb76eb5..2a65608b043f 100644 --- a/tizen_src/ewk/efl_integration/eweb_view.h +++ b/tizen_src/ewk/efl_integration/eweb_view.h @@ -789,6 +789,9 @@ class EWebView { void UpdateContextMenuWithParams(const content::ContextMenuParams& params); static Eina_Bool DelayedPopulateAndShowContextMenu(void* data); +#if BUILDFLAG(IS_TIZEN_TV) + void RunPendingSetFocus(Eina_Bool focus); +#endif scoped_refptr evas_event_handler_; scoped_refptr context_; @@ -944,6 +947,10 @@ class EWebView { #endif Ecore_Timer* delayed_show_context_menu_timer_ = nullptr; + +#if BUILDFLAG(IS_TIZEN_TV) + base::OnceClosure pending_setfocus_closure_; +#endif }; const unsigned int g_default_tilt_motion_sensitivity = 3; -- 2.34.1