[M108 Migration][API] Add ewk_settings_tizen_compatibility_mode_set API 11/287911/8
authorBakka Uday Kiran <b.kiran@samsung.com>
Fri, 3 Feb 2023 07:26:33 +0000 (12:56 +0530)
committerBot Blink <blinkbot@samsung.com>
Fri, 10 Feb 2023 13:13:22 +0000 (13:13 +0000)
This API allows rendering the pages as if they are run with the
specified engine version. The compatibility mode changes behavior of
web features since they follow the newest specifications resulting in
different behavior for content delivered for earlier engines.

API will be applied by WRT/XWalk to support product patches for
chromium-efl in compatibility mode with WebKit/Tizen 2.4.

WebCore patches will be applied once compatibility mode is set.
Checking whether engine has been launched with compatibility mode:

* renderer:
    content::WebSettings::TizenCompatibilityModeEnabled()
    Blink::Settings::TizenCompatibilityModeEnabled()
* ui:
    WebPreferencesEfl::TizenVersion::{major|minor|release|}

Applying WebCore changes immediately after changing compatibility
mode can be done inside Page::settingsChanged(TizenVersionChange).

Ewk API can be tested with ubrowser by passing tizen-version | -t flag,
for example,
$ ubrowser -t 2.4

Also, this patch exposes TizenVersion on blink::web_pref::WebPreferences
to allow client to check if compatibility mode is turned on.
Struct TizenVersion has been replaced with individual elements in
web_preferences.mojom for simplicity.

Reference: https://review.tizen.org/gerrit/c/279762

Change-Id: I4c720a371846fdef4d01dada80723d32bd5ef2fa
Signed-off-by: Bakka Uday Kiran <b.kiran@samsung.com>
16 files changed:
third_party/blink/public/common/web_preferences/web_preferences.h
third_party/blink/public/common/web_preferences/web_preferences_mojom_traits.h
third_party/blink/public/mojom/webpreferences/web_preferences.mojom
third_party/blink/public/platform/web_runtime_features.h
third_party/blink/public/web/web_settings.h
third_party/blink/renderer/core/exported/web_settings_impl.cc
third_party/blink/renderer/core/exported/web_settings_impl.h
third_party/blink/renderer/core/exported/web_view_impl.cc
third_party/blink/renderer/core/frame/settings.cc
third_party/blink/renderer/core/frame/settings.h
third_party/blink/renderer/core/frame/settings_delegate.h
third_party/blink/renderer/core/page/page.cc
third_party/blink/renderer/platform/exported/web_runtime_features.cc
third_party/blink/renderer/platform/runtime_enabled_features.json5
tizen_src/ewk/efl_integration/public/ewk_settings.cc
tizen_src/ewk/ubrowser/window.cc

index f908293..651f9e7 100644 (file)
@@ -271,6 +271,15 @@ struct BLINK_COMMON_EXPORT WebPreferences {
   float default_minimum_page_scale_factor;
   float default_maximum_page_scale_factor;
 
+#if BUILDFLAG(IS_EFL)
+  bool TizenCompatibilityModeEnabled() const {
+    return (tizen_version_major && tizen_version_major < 3);
+  }
+  unsigned tizen_version_major = 7;
+  unsigned tizen_version_minor = 5;
+  unsigned tizen_version_release = 0;
+#endif
+
   // Whether download UI should be hidden on this page.
   bool hide_download_ui;
 
index e3290de..2b741fd 100644 (file)
@@ -764,6 +764,23 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
     return r.strict_mime_type_check_for_worker_scripts_enabled;
   }
 
+#if BUILDFLAG(IS_EFL)
+  static uint64_t tizen_version_major(
+      const blink::web_pref::WebPreferences& r) {
+    return r.tizen_version_major;
+  }
+
+  static uint64_t tizen_version_minor(
+      const blink::web_pref::WebPreferences& r) {
+    return r.tizen_version_minor;
+  }
+
+  static uint64_t tizen_version_release(
+      const blink::web_pref::WebPreferences& r) {
+    return r.tizen_version_release;
+  }
+#endif
+
   static bool Read(blink::mojom::WebPreferencesDataView r,
                    blink::web_pref::WebPreferences* out);
 };
index b370a37..a7a39da 100644 (file)
@@ -361,6 +361,15 @@ struct WebPreferences {
   float default_minimum_page_scale_factor;
   float default_maximum_page_scale_factor;
 
+  [EnableIf=is_efl]
+  uint64 tizen_version_major;
+
+  [EnableIf=is_efl]
+  uint64 tizen_version_minor;
+
+  [EnableIf=is_efl]
+  uint64 tizen_version_release;
+
   // Whether download UI should be hidden on this page.
   bool hide_download_ui;
 
index 62b3f1f..85bd157 100644 (file)
@@ -70,6 +70,7 @@ class BLINK_PLATFORM_EXPORT WebRuntimeFeatures : public WebRuntimeFeaturesBase {
 #if BUILDFLAG(IS_EFL)
   static void EnableInputMultipleFieldsUI(bool);
   static void EnableAcceleratedSmallCanvases(bool);
+  BLINK_PLATFORM_EXPORT static void SetTizenCompatibilityModeEnabled(bool);
 #endif
 
   WebRuntimeFeatures() = delete;
index 32b1451..fe65679 100644 (file)
@@ -276,6 +276,10 @@ class WebSettings {
   virtual void SetSelectionClipboardBufferAvailable(bool) = 0;
   virtual void SetAccessibilityIncludeSvgGElement(bool) = 0;
   virtual void SetWebXRImmersiveArAllowed(bool) = 0;
+#if BUILDFLAG(IS_EFL)
+  virtual void SetTizenVersion(unsigned, unsigned, unsigned) = 0;
+  virtual bool TizenCompatibilityModeEnabled() const = 0;
+#endif
 
  protected:
   ~WebSettings() = default;
index 4ede738..3e280f5 100644 (file)
@@ -777,4 +777,16 @@ void WebSettingsImpl::SetWebXRImmersiveArAllowed(
   settings_->SetWebXRImmersiveArAllowed(webxr_immersive_ar_allowed);
 }
 
+#if BUILDFLAG(IS_EFL)
+void WebSettingsImpl::SetTizenVersion(unsigned major,
+                                      unsigned minor,
+                                      unsigned release) {
+  settings_->SetTizenVersion(major, minor, release);
+}
+
+bool WebSettingsImpl::TizenCompatibilityModeEnabled() const {
+  return settings_->TizenCompatibilityModeEnabled();
+}
+#endif
+
 }  // namespace blink
index dded9b3..25e4c72 100644 (file)
@@ -225,6 +225,11 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
   void SetAccessibilityIncludeSvgGElement(bool) override;
   void SetWebXRImmersiveArAllowed(bool webxr_immersive_ar_allowed) override;
 
+#if BUILDFLAG(IS_EFL)
+  void SetTizenVersion(unsigned, unsigned, unsigned) override;
+  bool TizenCompatibilityModeEnabled() const override;
+#endif
+
   bool RenderVSyncNotificationEnabled() const {
     return render_v_sync_notification_enabled_;
   }
index 5fc7eb1..0a7d9aa 100644 (file)
@@ -1659,6 +1659,12 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
       prefs.dont_send_key_events_to_javascript);
   settings->SetWebAppScope(WebString::FromASCII(prefs.web_app_scope.spec()));
 
+#if BUILDFLAG(IS_EFL)
+  settings->SetTizenVersion(prefs.tizen_version_major,
+                            prefs.tizen_version_minor,
+                            prefs.tizen_version_release);
+#endif
+
 #if BUILDFLAG(IS_ANDROID)
   settings->SetAllowCustomScrollbarInMainFrame(false);
   settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor);
index aac12e9..1b6c129 100644 (file)
@@ -118,4 +118,25 @@ void Settings::Invalidate(SettingsDelegate::ChangeType change_type) {
     delegate_->SettingsChanged(change_type);
 }
 
+#if BUILDFLAG(IS_EFL)
+void Settings::SetTizenVersion(unsigned major,
+                               unsigned minor,
+                               unsigned release) {
+  if (tizen_compatibility_settings_.major == major &&
+      tizen_compatibility_settings_.minor == minor &&
+      tizen_compatibility_settings_.release == release)
+    return;
+
+  tizen_compatibility_settings_.major = major;
+  tizen_compatibility_settings_.minor = minor;
+  tizen_compatibility_settings_.release = release;
+
+  Invalidate(SettingsDelegate::ChangeType::kTizenVersionChange);
+}
+
+bool Settings::TizenCompatibilityModeEnabled() const {
+  return tizen_compatibility_settings_.TizenCompatibilityModeEnabled();
+}
+#endif
+
 }  // namespace blink
index a4d0d88..ed4731e 100644 (file)
@@ -67,6 +67,11 @@ class CORE_EXPORT Settings {
 
   SETTINGS_GETTERS_AND_SETTERS
 
+#if BUILDFLAG(IS_EFL)
+  void SetTizenVersion(unsigned major, unsigned minor, unsigned release);
+  bool TizenCompatibilityModeEnabled() const;
+#endif
+
   void SetDelegate(SettingsDelegate*);
 
  private:
@@ -76,6 +81,15 @@ class CORE_EXPORT Settings {
 
   GenericFontFamilySettings generic_font_family_settings_;
 
+#if BUILDFLAG(IS_EFL)
+  struct {
+    unsigned major;
+    unsigned minor;
+    unsigned release;
+    bool TizenCompatibilityModeEnabled() const { return (major && major < 3); }
+  } tizen_compatibility_settings_;
+#endif
+
   SETTINGS_MEMBER_VARIABLES
 };
 
index cfe54a2..745fbbd 100644 (file)
@@ -73,6 +73,9 @@ class CORE_EXPORT SettingsDelegate {
     kSpatialNavigation,
     kUniversalAccess,
     kVisionDeficiency,
+#if BUILDFLAG(IS_EFL)
+    kTizenVersionChange,
+#endif
   };
 
   virtual void SettingsChanged(ChangeType) = 0;
index 28e6d7a..2ad0cb0 100644 (file)
 #include "third_party/blink/public/common/features.h"
 #include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink-forward.h"
 #include "third_party/blink/public/platform/platform.h"
+
+#if BUILDFLAG(IS_EFL)
+#include "third_party/blink/public/platform/web_runtime_features.h"
+#endif
+
 #include "third_party/blink/public/web/blink.h"
 #include "third_party/blink/renderer/bindings/core/v8/script_controller.h"
 #include "third_party/blink/renderer/core/core_export.h"
@@ -833,6 +838,13 @@ void Page::SettingsChanged(ChangeType change_type) {
         main_local_frame->GetDocument()->VisionDeficiencyChanged();
       break;
     }
+#if BUILDFLAG(IS_EFL)
+    case ChangeType::kTizenVersionChange: {
+      WebRuntimeFeatures::SetTizenCompatibilityModeEnabled(
+          GetSettings().TizenCompatibilityModeEnabled());
+      break;
+    }
+#endif
   }
 }
 
index 263302a..2853781 100644 (file)
@@ -73,6 +73,11 @@ void WebRuntimeFeatures::EnableInputMultipleFieldsUI(bool enable) {
 void WebRuntimeFeatures::EnableAcceleratedSmallCanvases(bool enable) {
   RuntimeEnabledFeatures::SetAcceleratedSmallCanvasesEnabled(enable);
 }
+
+void WebRuntimeFeatures::SetTizenCompatibilityModeEnabled(bool enable) {
+  RuntimeEnabledFeatures::SetTizenCompatibilityModeEnabled(enable);
+}
+
 #endif
 
 }  // namespace blink
index dd4b5b2..503c566 100644 (file)
       status: "stable",
     },
     {
+      name: "TizenCompatibilityMode",
+    },
+    {
       name: "TimeZoneChangeEvent",
       status: "experimental",
     },
index 57ea4cc..90de189 100644 (file)
@@ -774,8 +774,12 @@ void ewk_settings_extra_feature_set(Ewk_Settings* settings, const char* feature,
 
 Eina_Bool ewk_settings_tizen_compatibility_mode_set(Ewk_Settings* settings, unsigned major, unsigned minor, unsigned release)
 {
-  LOG_EWK_API_MOCKUP();
-  return false;
+  EINA_SAFETY_ON_NULL_RETURN_VAL(settings, false);
+  settings->getPreferences().tizen_version_major = major;
+  settings->getPreferences().tizen_version_minor = minor;
+  settings->getPreferences().tizen_version_release = release;
+  ewkUpdateWebkitPreferences(settings->getEvasObject());
+  return true;
 }
 
 Eina_Bool ewk_settings_webkit_text_size_adjust_enabled_get(const Ewk_Settings* settings)
index 393a104..a414ce0 100644 (file)
@@ -121,6 +121,15 @@ Window::Window(Browser& browser, int width, int height, bool incognito)
   evas_object_smart_callback_add(web_view_elm_host_, "unfocused",
                                  &Window::OnHostFocusedOut, this);
 
+  std::string tizen_version = browser_.GetTizenVersion();
+  if (!tizen_version.empty()) {
+    std::vector<unsigned> parsed_tizen_version =
+        ParseTizenVersion(tizen_version);
+    ewk_settings_tizen_compatibility_mode_set(
+        GetEwkSettings(), parsed_tizen_version[0], parsed_tizen_version[1],
+        parsed_tizen_version[2]);
+  }
+
   evas_object_smart_callback_add(web_view_, "title,changed",
                                  &Window::OnTitleChanged, this);
   evas_object_smart_callback_add(web_view_, "url,changed",