[M120 Migration][VD] Fix window lost focus after dialog close 30/307530/3
authorfangfengrong <fr.fang@samsung.com>
Tue, 12 Mar 2024 00:40:21 +0000 (08:40 +0800)
committerfangfengrong <fr.fang@samsung.com>
Wed, 13 Mar 2024 01:43:26 +0000 (09:43 +0800)
Here an issue:
When dialog show and hide, app only receive the window.blur event,
without the window.focus event.

when dialog show, chromium set Process blocked(IsIgnoringInputEvents is true);
when dialog hide, chromium reset Process block(IsIgnoringInputEvents is false);
Once app set focus before Process block reset, the focus will been blocked.

OnWindowFocused Function, only IgnoringInputEvents for gained_focus case,
don't IgnoringInputEvents for lost_focus case, it cause the blur event
been delivered to app, but the focus event don't.

Whenever dialog show, chromium ignores the input event to avoid dismissing dialog.
While app might forcefully set focus on webview even if dialog are being shown.
So don't check IgnoringInputEvents both for gained_focus and lost_focus.

refer:
https://review.tizen.org/gerrit/#/c/304248

Change-Id: Ia998518560b7816129518a51c779d728168d8190
Signed-off-by: fangfengrong <fr.fang@samsung.com>
content/browser/renderer_host/render_frame_host_impl.cc
content/browser/renderer_host/render_widget_host_view_aura.cc
third_party/blink/renderer/core/dom/document.cc
third_party/blink/renderer/core/page/focus_controller.cc

index adba3364532b8399fdbd79c9e68d1663dea21a6d..7cb8e7266eab7ee940ccc58f390204f2b0be0c0f 100644 (file)
@@ -5652,6 +5652,7 @@ void RenderFrameHostImpl::RunJavaScriptDialog(
 
   // While a JS message dialog is showing, tabs in the same process shouldn't
   // process input events.
+  LOG(INFO) << "RunJavaScriptDialog,SetBlocked TRUE";
   GetProcess()->SetBlocked(true);
 
   delegate_->RunJavaScriptDialog(
@@ -10046,6 +10047,7 @@ void RenderFrameHostImpl::JavaScriptDialogClosed(
     JavaScriptDialogCallback dialog_closed_callback,
     bool success,
     const std::u16string& user_input) {
+  LOG(INFO) << "JavaScriptDialogClosed,SetBlocked FALSE";
   GetProcess()->SetBlocked(false);
   std::move(dialog_closed_callback).Run(success, user_input);
   // If executing as part of beforeunload event handling, there may have been
index 9bfdcaf60bac79980d61a04d4c2a905f51c7f1fa..d73784591d46f73d2d7d8f2a2cd5c057149883ed 100644 (file)
@@ -2366,11 +2366,13 @@ void RenderWidgetHostViewAura::OnWindowFocused(aura::Window* gained_focus,
   LOG(INFO) << "OnWindowFocused, Gained : " << gained_focus
             << ", Lost : " << lost_focus;
   if (window_ == gained_focus) {
+#if !BUILDFLAG(IS_TIZEN_TV)
     // We need to honor input bypass if the associated tab does not want input.
     // This gives the current focused window a chance to be the text input
     // client and handle events.
     if (host()->IsIgnoringInputEvents())
       return;
+#endif
 
     host()->GotFocus();
     UpdateActiveState(true);
index c057ad2ae03c811ceffbe27c0be0d28cdf2a21d4..0bd12e64b543ee046d57e8c15868727622407be7 100644 (file)
@@ -5218,6 +5218,7 @@ bool Document::SetFocusedElement(Element* new_focused_element,
   DCHECK(!lifecycle_.InDetach());
 
   clear_focused_element_timer_.Stop();
+  LOG(INFO) << "setFocusedElement to element " << (void*)new_focused_element;
 
   // Make sure new_focused_element is actually in this document.
   if (new_focused_element) {
@@ -5391,6 +5392,14 @@ bool Document::SetFocusedElement(Element* new_focused_element,
   }
 
   if (!focus_change_blocked) {
+    LOG(INFO) << "setFocusedElement focus changed from: "
+              << (old_focused_element
+                      ? old_focused_element->outerHTML().Utf8().data()
+                      : "nullptr");
+    LOG(INFO) << "setFocusedElement focus changed to: "
+              << (new_focused_element
+                      ? new_focused_element->outerHTML().Utf8().data()
+                      : "nullptr");
     NotifyFocusedElementChanged(old_focused_element, focused_element_.Get(),
                                 params.type);
   }
index 6ac3b81b32f2ca6e094c8bdca101118fa62006dc..bc5bf512597cec89a42d86870b69702fbe53f581 100644 (file)
@@ -465,6 +465,7 @@ inline void DispatchEventsOnWindowAndFocusedElement(Document* document,
     if (page->Paused())
       return;
   }
+  LOG(INFO) << "DispatchEventsOnWindowAndFocusedElement,focused:" << focused;
 
   if (!focused && document->FocusedElement()) {
     Element* focused_element = document->FocusedElement();