From 466cbd900fd1345e16151291208758c451d818aa Mon Sep 17 00:00:00 2001 From: "b.kiran" Date: Wed, 25 Jan 2023 10:26:48 +0530 Subject: [PATCH] [M108 Migration] Implement view port setting and zoom factor API This patch implement below preference setting and API for content scale. 1. As default meta view port enabling for mobile 2. Implement ewk api for view port set/get Reference: https://review.tizen.org/gerrit/c/278887 Change-Id: Id030ba049d55d46e55aaa2b8c75e27f3c7ed5fe9 Signed-off-by: Bakka Uday Kiran --- content/browser/web_contents/web_contents_impl.cc | 8 ++++++++ tizen_src/ewk/efl_integration/eweb_context.cc | 22 ++++++++++++++++++++++ tizen_src/ewk/efl_integration/eweb_context.h | 3 +++ .../efl_integration/private/ewk_context_private.cc | 8 ++++++++ .../efl_integration/private/ewk_context_private.h | 4 ++++ .../ewk/efl_integration/public/ewk_context.cc | 16 +++++++++++----- 6 files changed, 56 insertions(+), 5 deletions(-) diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 0f16da0..c2cd303 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -189,6 +189,7 @@ #if BUILDFLAG(IS_EFL) #include "content/browser/date_time_chooser_efl.h" +#include "tizen/system_info.h" #endif #if BUILDFLAG(IS_ANDROID) @@ -2829,6 +2830,13 @@ const blink::web_pref::WebPreferences WebContentsImpl::ComputeWebPreferences() { prefs.viewport_meta_enabled = false; } +#if BUILDFLAG(IS_EFL) + if (IsMobileProfile()) + prefs.viewport_meta_enabled = true; + + prefs.viewport_enabled |= prefs.viewport_meta_enabled; +#endif + prefs.spatial_navigation_enabled = command_line.HasSwitch(switches::kEnableSpatialNavigation); diff --git a/tizen_src/ewk/efl_integration/eweb_context.cc b/tizen_src/ewk/efl_integration/eweb_context.cc index e74e8a3..6e0ef15 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.cc +++ b/tizen_src/ewk/efl_integration/eweb_context.cc @@ -21,6 +21,7 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/dom_storage_context.h" +#include "content/public/browser/host_zoom_map.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_usage_info.h" @@ -31,6 +32,7 @@ #include "storage/browser/database/database_quota_client.h" #include "storage/browser/file_system/file_system_quota_client.h" #include "storage/browser/quota/quota_manager.h" +#include "third_party/blink/public/common/page/page_zoom.h" #include "ui/gl/gl_shared_context_efl.h" #if defined(ENABLE_PLUGINS) @@ -799,6 +801,26 @@ bool EWebContext::GetExtensibleAPI(const std::string& api_name) { return TizenExtensibleHost::GetInstance()->GetExtensibleAPI(api_name); } +void EWebContext::SetDefaultZoomFactor(double zoom_factor) { + content::HostZoomMap* host_zoom_map = + content::HostZoomMap::GetDefaultForBrowserContext(browser_context_.get()); + if (host_zoom_map) { + host_zoom_map->SetDefaultZoomLevel( + blink::PageZoomFactorToZoomLevel(zoom_factor)); + } +} + +double EWebContext::GetDefaultZoomFactor() const { + content::HostZoomMap* host_zoom_map = + content::HostZoomMap::GetDefaultForBrowserContext(browser_context_.get()); + if (host_zoom_map) { + return blink::PageZoomLevelToZoomFactor( + host_zoom_map->GetDefaultZoomLevel()); + } + + return -1.0; +} + void EWebContext::SetInterceptRequestCallback( Ewk_Context* ewk_context, Ewk_Context_Intercept_Request_Callback callback, diff --git a/tizen_src/ewk/efl_integration/eweb_context.h b/tizen_src/ewk/efl_integration/eweb_context.h index 04812da..560b3aa 100644 --- a/tizen_src/ewk/efl_integration/eweb_context.h +++ b/tizen_src/ewk/efl_integration/eweb_context.h @@ -174,6 +174,9 @@ class EWebContext { bool SetExtensibleAPI(const std::string& api_name, bool enable); bool GetExtensibleAPI(const std::string& api_name); + void SetDefaultZoomFactor(double zoom_factor); + double GetDefaultZoomFactor() const; + void SetInterceptRequestCallback( Ewk_Context* ewk_context, Ewk_Context_Intercept_Request_Callback callback, diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc index cd4e31d..f10f434 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.cc +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.cc @@ -269,6 +269,14 @@ void Ewk_Context::SetContextInterceptRequestCallback( impl->SetInterceptRequestCallback(this, callback, user_data); } +void Ewk_Context::SetDefaultZoomFactor(double zoom_factor) { + impl->SetDefaultZoomFactor(zoom_factor); +} + +double Ewk_Context::GetDefaultZoomFactor() const { + return impl->GetDefaultZoomFactor(); +} + #if BUILDFLAG(IS_TIZEN_TV) void Ewk_Context::SetApplicationType( const Ewk_Application_Type application_type) { diff --git a/tizen_src/ewk/efl_integration/private/ewk_context_private.h b/tizen_src/ewk/efl_integration/private/ewk_context_private.h index dce8618..d6daffc 100644 --- a/tizen_src/ewk/efl_integration/private/ewk_context_private.h +++ b/tizen_src/ewk/efl_integration/private/ewk_context_private.h @@ -134,6 +134,10 @@ struct Ewk_Context : public base::RefCounted { Ewk_Context_Notification_Cancel_Callback cancel_callback, void* user_data); + // default zoom factor + void SetDefaultZoomFactor(double zoom_factor); + double GetDefaultZoomFactor() const; + void SetContextInterceptRequestCallback( Ewk_Context_Intercept_Request_Callback callback, void* user_data); diff --git a/tizen_src/ewk/efl_integration/public/ewk_context.cc b/tizen_src/ewk/efl_integration/public/ewk_context.cc index 3e3d06f..358a9679 100644 --- a/tizen_src/ewk/efl_integration/public/ewk_context.cc +++ b/tizen_src/ewk/efl_integration/public/ewk_context.cc @@ -974,11 +974,6 @@ void ewk_context_form_autofill_credit_card_changed_callback_set( LOG_EWK_API_MOCKUP(); } -void ewk_context_default_zoom_factor_set(Ewk_Context* context, - double zoom_factor) { - LOG_EWK_API_MOCKUP(); -} - void ewk_context_application_type_set( Ewk_Context* ewkContext, const Ewk_Application_Type applicationType) { @@ -1002,3 +997,14 @@ Ewk_Application_Type ewk_context_application_type_get(Ewk_Context* ewkContext) { return EWK_APPLICATION_TYPE_OTHER; #endif } + +void ewk_context_default_zoom_factor_set(Ewk_Context* context, + double zoom_factor) { + EINA_SAFETY_ON_NULL_RETURN(context); + context->SetDefaultZoomFactor(zoom_factor); +} + +double ewk_context_default_zoom_factor_get(Ewk_Context* context) { + EINA_SAFETY_ON_NULL_RETURN_VAL(context, -1.0); + return context->GetDefaultZoomFactor(); +} -- 2.7.4