[M108 Migration] Support encoding property for WRT config.xml 10/288710/4
authorayush.k123 <ayush.k123@samsung.com>
Wed, 22 Feb 2023 03:08:59 +0000 (08:38 +0530)
committerBot Blink <blinkbot@samsung.com>
Thu, 23 Feb 2023 10:39:03 +0000 (10:39 +0000)
ewk_settings_default_text_encoding_name_set() was not affected
due to |usesEncodingDetector| in TextResourceDecoder.
If |defaultTextEncodingName| is changed by ewk_settings API,
|usesEncodingDetector| will be disabled.

References: https://review.tizen.org/gerrit/280599/

Change-Id: Ib1295cd52b07cdf5fa6284e706d46a70d10448c8
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
12 files changed:
third_party/blink/common/web_preferences/web_preferences_mojom_traits.cc
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/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.json5
third_party/blink/renderer/core/html/parser/text_resource_decoder_builder.cc
tizen_src/ewk/efl_integration/private/ewk_settings_private.cc
wrt/src/browser/wrt_browser_client.cc

index acbc8b2..7bb384f 100644 (file)
@@ -180,13 +180,12 @@ bool StructTraits<blink::mojom::WebPreferencesDataView,
 #if BUILDFLAG(IS_EFL)
   out->force_enable_zoom = data.force_enable_zoom();
   out->link_effect_enabled = data.link_effect_enabled();
+  out->uses_encoding_detector = data.uses_encoding_detector();
+  out->atk_enabled = data.atk_enabled();
 #endif
 #if BUILDFLAG(IS_TIZEN)
   out->max_refresh_rate = data.max_refresh_rate();
 #endif
-#if BUILDFLAG(IS_EFL)
-  out->atk_enabled = data.atk_enabled();
-#endif
 #if BUILDFLAG(IS_ANDROID)
   out->font_scale_factor = data.font_scale_factor();
   out->device_scale_adjustment = data.device_scale_adjustment();
index b8115fb..0b1b1e8 100644 (file)
@@ -238,6 +238,7 @@ struct BLINK_COMMON_EXPORT WebPreferences {
   bool text_zoom_enabled = false;
   bool selection_magnifier_enabled = false;
   bool long_press_enabled = false;
+  bool uses_encoding_detector = true;
 #endif
 
   bool double_tap_to_zoom_enabled;
index b004407..f63111c 100644 (file)
@@ -595,6 +595,10 @@ struct BLINK_COMMON_EXPORT StructTraits<blink::mojom::WebPreferencesDataView,
   static bool force_enable_zoom(const blink::web_pref::WebPreferences& r) {
     return r.force_enable_zoom;
   }
+
+  static bool uses_encoding_detector(const blink::web_pref::WebPreferences& r) {
+    return r.uses_encoding_detector;
+  }
 #endif
 
 #if BUILDFLAG(IS_TIZEN)
index 64eb02a..42ecc37 100644 (file)
@@ -309,6 +309,9 @@ struct WebPreferences {
   [EnableIf=is_efl]
   bool force_enable_zoom;
 
+  [EnableIf=is_efl]
+  bool uses_encoding_detector;
+
   // Representation of the Web App Manifest scope if any.
   url.mojom.Url web_app_scope;
 
index 617094f..93a21b8 100644 (file)
@@ -279,11 +279,10 @@ class WebSettings {
 #if BUILDFLAG(IS_EFL)
   virtual void SetTizenVersion(unsigned, unsigned, unsigned) = 0;
   virtual bool TizenCompatibilityModeEnabled() const = 0;
-#endif
-
-#if BUILDFLAG(IS_EFL)
   virtual void SetLinkEffectEnabled(bool) = 0;
   virtual bool LinkEffectEnabled() const = 0;
+  virtual void SetUsesEncodingDetector(bool) = 0;
+  virtual bool UsesEncodingDetector() const = 0;
 #endif
 
 #if defined(TIZEN_ATK_SUPPORT)
index 7ff759c..ffe4a2c 100644 (file)
@@ -795,6 +795,14 @@ bool WebSettingsImpl::LinkEffectEnabled() const {
 bool WebSettingsImpl::TizenCompatibilityModeEnabled() const {
   return settings_->TizenCompatibilityModeEnabled();
 }
+
+void WebSettingsImpl::SetUsesEncodingDetector(bool uses_encoding_detector) {
+  settings_->SetUsesEncodingDetector(uses_encoding_detector);
+}
+
+bool WebSettingsImpl::UsesEncodingDetector() const {
+  return settings_->GetUsesEncodingDetector();
+}
 #endif
 
 #if defined(TIZEN_ATK_SUPPORT)
index f316fa7..3d896b7 100644 (file)
@@ -230,6 +230,8 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
   void SetLinkEffectEnabled(bool) override;
   bool LinkEffectEnabled() const override;
   bool TizenCompatibilityModeEnabled() const override;
+  void SetUsesEncodingDetector(bool) override;
+  bool UsesEncodingDetector() const override;
 #endif
 
 #if defined(TIZEN_ATK_SUPPORT)
index b2d3d6c..06b1fac 100644 (file)
@@ -1709,6 +1709,7 @@ void WebView::ApplyWebPreferences(const web_pref::WebPreferences& prefs,
                             prefs.tizen_version_release);
   web_view_impl->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom);
   settings->SetLoadWithOverviewMode(prefs.shrinks_viewport_contents_to_fit);
+  settings->SetUsesEncodingDetector(prefs.uses_encoding_detector);
 #endif
 
 #if BUILDFLAG(IS_TIZEN)
index 0025005..5331ed9 100644 (file)
     },
 
     {
+      name: "usesEncodingDetector",
+      initial: false,
+    },
+
+    {
       name: "presentationRequiresUserGesture",
       initial: true,
     },
index 006d0cb..d789152 100644 (file)
@@ -142,14 +142,25 @@ std::unique_ptr<TextResourceDecoder> BuildTextResourceDecoder(
               TextResourceDecoderOptions::kJSONContent, default_encoding));
       use_hint_encoding = false;
     } else {
-      WTF::TextEncoding hint_encoding;
-      if (use_hint_encoding &&
-          parent_frame->GetDocument()->EncodingWasDetectedHeuristically())
-        hint_encoding = parent_frame->GetDocument()->Encoding();
-      decoder = std::make_unique<TextResourceDecoder>(
-          TextResourceDecoderOptions::CreateWithAutoDetection(
-              DetermineContentType(mime_type), default_encoding, hint_encoding,
-              url));
+#if BUILDFLAG(IS_EFL)
+      if (!encoding_from_domain.IsValid() &&
+          !frame->GetSettings()->GetUsesEncodingDetector()) {
+        decoder =
+            std::make_unique<TextResourceDecoder>(TextResourceDecoderOptions(
+                DetermineContentType(mime_type), default_encoding));
+      } else {
+#endif
+        WTF::TextEncoding hint_encoding;
+        if (use_hint_encoding &&
+            parent_frame->GetDocument()->EncodingWasDetectedHeuristically())
+          hint_encoding = parent_frame->GetDocument()->Encoding();
+        decoder = std::make_unique<TextResourceDecoder>(
+            TextResourceDecoderOptions::CreateWithAutoDetection(
+                DetermineContentType(mime_type), default_encoding, hint_encoding,
+                url));
+#if BUILDFLAG(IS_EFL)
+      }
+#endif
     }
   } else {
     decoder = std::make_unique<TextResourceDecoder>(TextResourceDecoderOptions(
index 6112948..607544f 100644 (file)
@@ -18,6 +18,7 @@ void Ewk_Settings::setCurrentLegacyFontSizeMode(Ewk_Legacy_Font_Size_Mode mode)
 }
 
 void Ewk_Settings::setDefaultTextEncoding(const char* encoding) {
+  m_preferences.uses_encoding_detector = !(encoding && *encoding);
   if (encoding)
     m_preferences.default_encoding = encoding;
 }
index 0bdee4c..0cf861c 100755 (executable)
@@ -236,9 +236,9 @@ void WRTBrowserClient::OverrideWebkitPrefs(
 
   auto& runtime = NativeWebRuntime::GetInstance();
   prefs->default_encoding = runtime.GetEncodingType();
-#if !defined(WRT_JS_BRINGUP)
   prefs->uses_encoding_detector = false;
 
+#if !defined(WRT_JS_BRINGUP)
   if (IsWearableProfile() &&
       WRTNativeWindow::GetWindowShape() == WRTNativeWindow::Shape::SQUARE) {
     prefs->mirror_blur_enabled = true;