[M108 Migration][API] Re-implement ewk_view_visibility_set 08/287208/13
authorBakka Uday Kiran <b.kiran@samsung.com>
Mon, 23 Jan 2023 18:34:12 +0000 (00:04 +0530)
committerBot Blink <blinkbot@samsung.com>
Wed, 1 Feb 2023 09:04:26 +0000 (09:04 +0000)
1. In w3c spec as [1]"The Page Visibility" specification defines a means
for site developers to programmatically determine the current
visibility of a document and be notified of visibility changes.

Also, it does not mean directly showing or hiding the current webview.

Previous codes have an unnecessary behavior. This patch will just set
visibility to |WasShown| or |WasHidden| without evas_object_show
(or hide) in webview.

And ewk_view_page_visibility_state_set() was already changed by [2]
like current patch.

2. This patch implements ewk_view_page_visibility_state_set.
It just supports 'visible' and 'hidden' for now.

3. In aura, calling WebContents::{WasShown|WasHidden} eventually invokes
RWHVA's ShowWithVisibility() / Hide() functions which has additional
functionality related to page visibility, compared to tizen branch.
Hence make the changes suitable to new architecture.
Also show / hide content image evas object in sync with RWHVA's visibility.

References:
[1] https://www.w3.org/TR/page-visibility/
[2] https://review.tizen.org/gerrit/c/77637
https://review.tizen.org/gerrit/c/277832
https://review.tizen.org/gerrit/c/279282
https://review.tizen.org/gerrit/c/282642

Change-Id: I0e9df5734b3a2e14a3ad82c75e8eaf50b33e368f
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
content/browser/renderer_host/render_widget_host_view_aura.cc
tizen_src/ewk/efl_integration/eweb_view.cc
tizen_src/ewk/efl_integration/eweb_view.h
tizen_src/ewk/efl_integration/public/ewk_view.cc

index ff3614d..1eee933 100644 (file)
@@ -876,6 +876,11 @@ void RenderWidgetHostViewAura::ShowWithVisibility(
   // properties, in case they have changed or this is the initial show.
   UpdateScreenInfo();
 
+#if BUILDFLAG(IS_EFL)
+  if (offscreen_helper_)
+    offscreen_helper_->Show();
+#endif
+
   // If the viz::LocalSurfaceId is invalid, we may have been evicted,
   // and no other visual properties have since been changed. Allocate a new id
   // and start synchronizing.
index b7b1f6a..f966854 100644 (file)
@@ -347,6 +347,30 @@ Eina_Bool EWebView::AddJavaScriptMessageHandler(
                                                             name);
 }
 
+bool EWebView::SetPageVisibility(
+    Ewk_Page_Visibility_State page_visibility_state) {
+  if (!rwhva())
+    return false;
+
+  // TODO: We should able to set 'prerender' or 'unloaded' as visibility state.
+  // http://www.w3.org/TR/page-visibility/#dom-document-visibilitystate
+  switch (page_visibility_state) {
+    case EWK_PAGE_VISIBILITY_STATE_VISIBLE:
+      rwhva()->offscreen_helper()->SetPageVisibility(true);
+      break;
+    case EWK_PAGE_VISIBILITY_STATE_HIDDEN:
+      rwhva()->offscreen_helper()->SetPageVisibility(false);
+      break;
+    case EWK_PAGE_VISIBILITY_STATE_PRERENDER:
+      NOTIMPLEMENTED();
+      break;
+    default:
+      return false;
+  }
+
+  return true;
+}
+
 bool EWebView::CreateNewWindow(
     content::WebContentsEflDelegate::WebContentsCreateCallback cb) {
   create_new_window_web_contents_cb_ = cb;
@@ -2582,3 +2606,15 @@ void EWebView::ExceededIndexedDatabaseQuotaReply(bool allow) {
   }
   exceeded_indexed_db_quota_origin_.reset();
 }
+
+bool EWebView::SetVisibility(bool enable) {
+  if (!web_contents_)
+    return false;
+
+  if (enable)
+    web_contents_->WasShown();
+  else
+    web_contents_->WasHidden();
+
+  return true;
+}
\ No newline at end of file
index 5f12841..29c9703 100755 (executable)
@@ -507,6 +507,7 @@ class EWebView {
       const {
     return gin_native_bridge_dispatcher_host_.get();
   }
+  bool SetPageVisibility(Ewk_Page_Visibility_State page_visibility_state);
 
   void SetExceededIndexedDatabaseQuotaCallback(
       Ewk_View_Exceeded_Indexed_Database_Quota_Callback callback,
@@ -541,6 +542,8 @@ class EWebView {
   void OnOverscrolled(const gfx::Vector2dF& accumulated_overscroll,
                       const gfx::Vector2dF& latest_overscroll_delta);
 
+  bool SetVisibility(bool enable);
+
   content::DateTimeChooserEfl* GetDateTimeChooser() {
     return date_time_chooser_;
   }
index 9f595df..8ee0632 100644 (file)
@@ -364,19 +364,7 @@ Eina_Bool ewk_view_page_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visi
   // isInitialState parameter seems be true only in the constructor of WebViewImpl.
   EWK_VIEW_IMPL_GET_OR_RETURN(ewkView, impl, false);
 
-  // TODO: We should able to set 'prerender' or 'unloaded' as visibility state.
-  // http://www.w3.org/TR/page-visibility/#dom-document-visibilitystate
-  switch (page_visibility_state) {
-    case EWK_PAGE_VISIBILITY_STATE_VISIBLE:
-      impl->Show();
-      break;
-    case EWK_PAGE_VISIBILITY_STATE_HIDDEN:
-      impl->Hide();
-      break;
-    default:
-      return EINA_FALSE;
-  }
-  return EINA_TRUE;
+  return impl->SetPageVisibility(page_visibility_state);
 }
 
 Eina_Bool ewk_view_user_agent_set(Evas_Object* ewkView, const char* user_agent)
@@ -434,13 +422,7 @@ Eina_Bool ewk_view_custom_header_clear(const Evas_Object* ewkView)
 Eina_Bool ewk_view_visibility_set(Evas_Object* view, Eina_Bool enable)
 {
   EWK_VIEW_IMPL_GET_OR_RETURN(view, impl, EINA_FALSE);
-
-  if (enable)
-    impl->Show();
-  else
-    impl->Hide();
-
-  return EINA_TRUE;
+  return impl->SetVisibility(enable);
 }
 
 Evas_Object* ewk_view_screenshot_contents_get(const Evas_Object* view, Eina_Rectangle view_area, float scale_factor, Evas* canvas)