Commit 1f37a5ee authored by Robbie Gibson's avatar Robbie Gibson Committed by Commit Bot

[iOS] Decouple Text Zoom flag from Dynamic Text size as default zoom

Before, this happened by default. However, this was confusing, so now
there are two separate flags, so zoom can be enabled without changing
the default zoom level.

Bug: 1113270
Change-Id: I912dbbec72ad527b515ffab151a3a57c9fd76fe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2339346Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Commit-Queue: Robbie Gibson <rkgibson@google.com>
Cr-Commit-Position: refs/heads/master@{#795523}
parent 53f42f5e
...@@ -4441,9 +4441,14 @@ ...@@ -4441,9 +4441,14 @@
"owners": [ "ayui", "goto" ], "owners": [ "ayui", "goto" ],
"expiry_milestone": 86 "expiry_milestone": 86
}, },
{
"name": "webpage-default-zoom-from-dynamic-type",
"owners": [ "rkgibson", "bling-flags" ],
"expiry_milestone": 87
},
{ {
"name": "webpage-text-accessibility", "name": "webpage-text-accessibility",
"owners": [ "rkgibson" ], "owners": [ "rkgibson", "bling-flags" ],
"expiry_milestone": 86 "expiry_milestone": 86
}, },
{ {
......
...@@ -380,6 +380,11 @@ const flags_ui::FeatureEntry kFeatureEntries[] = { ...@@ -380,6 +380,11 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flag_descriptions::kAutofillEnableCompanyNameName, flag_descriptions::kAutofillEnableCompanyNameName,
flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos, flag_descriptions::kAutofillEnableCompanyNameDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)}, FEATURE_VALUE_TYPE(autofill::features::kAutofillEnableCompanyName)},
{"webpage-default-zoom-from-dynamic-type",
flag_descriptions::kWebPageDefaultZoomFromDynamicTypeName,
flag_descriptions::kWebPageDefaultZoomFromDynamicTypeDescription,
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(web::kWebPageDefaultZoomFromDynamicType)},
{"webpage-text-accessibility", {"webpage-text-accessibility",
flag_descriptions::kWebPageTextAccessibilityName, flag_descriptions::kWebPageTextAccessibilityName,
flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos, flag_descriptions::kWebPageTextAccessibilityDescription, flags_ui::kOsIos,
......
...@@ -503,12 +503,17 @@ const char kWalletServiceUseSandboxName[] = "Use Google Payments sandbox"; ...@@ -503,12 +503,17 @@ const char kWalletServiceUseSandboxName[] = "Use Google Payments sandbox";
const char kWalletServiceUseSandboxDescription[] = const char kWalletServiceUseSandboxDescription[] =
"Uses the sandbox service for Google Payments API calls."; "Uses the sandbox service for Google Payments API calls.";
const char kWebPageDefaultZoomFromDynamicTypeName[] =
"Use dynamic type size for default text zoom level";
const char kWebPageDefaultZoomFromDynamicTypeDescription[] =
"When enabled, the default text zoom level for a website comes from the "
"current dynamic type setting.";
const char kWebPageTextAccessibilityName[] = const char kWebPageTextAccessibilityName[] =
"Enable text accessibility in web pages"; "Enable text accessibility in web pages";
const char kWebPageTextAccessibilityDescription[] = const char kWebPageTextAccessibilityDescription[] =
"When enabled, text in web pages will respect the user's Dynamic Type " "When enabled, text in web pages will respect the user's Dynamic Type "
"setting."; "setting.";
// Please insert your name/description above in alphabetical order. // Please insert your name/description above in alphabetical order.
} // namespace flag_descriptions } // namespace flag_descriptions
...@@ -442,6 +442,11 @@ extern const char kUseJSForErrorPageDescription[]; ...@@ -442,6 +442,11 @@ extern const char kUseJSForErrorPageDescription[];
extern const char kWalletServiceUseSandboxName[]; extern const char kWalletServiceUseSandboxName[];
extern const char kWalletServiceUseSandboxDescription[]; extern const char kWalletServiceUseSandboxDescription[];
// Title and description for the flag to tie the default text zoom level to
// the dynamic type setting.
extern const char kWebPageDefaultZoomFromDynamicTypeName[];
extern const char kWebPageDefaultZoomFromDynamicTypeDescription[];
// Title and description for the flag to enable text accessibility in webpages. // Title and description for the flag to enable text accessibility in webpages.
extern const char kWebPageTextAccessibilityName[]; extern const char kWebPageTextAccessibilityName[];
extern const char kWebPageTextAccessibilityDescription[]; extern const char kWebPageTextAccessibilityDescription[];
......
...@@ -9,6 +9,9 @@ namespace web { ...@@ -9,6 +9,9 @@ namespace web {
const base::Feature kWebPageTextAccessibility{"WebPageTextAccessibility", const base::Feature kWebPageTextAccessibility{"WebPageTextAccessibility",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kWebPageDefaultZoomFromDynamicType{
"WebPageDefaultZoomFromDynamicType", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kMobileGoogleSRP{"MobileGoogleSRP", const base::Feature kMobileGoogleSRP{"MobileGoogleSRP",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -13,6 +13,10 @@ namespace web { ...@@ -13,6 +13,10 @@ namespace web {
// Used to control the state of the WebPageTextAccessibility feature. // Used to control the state of the WebPageTextAccessibility feature.
extern const base::Feature kWebPageTextAccessibility; extern const base::Feature kWebPageTextAccessibility;
// Feature flag to tie the default zoom level for webpages to the current
// dynamic type setting.
extern const base::Feature kWebPageDefaultZoomFromDynamicType;
// Feature flag to keep the mobile version for Google SRP. Should be used when // Feature flag to keep the mobile version for Google SRP. Should be used when
// the desktop version is requested by default. // the desktop version is requested by default.
extern const base::Feature kMobileGoogleSRP; extern const base::Feature kMobileGoogleSRP;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ios/chrome/browser/application_context.h" #include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/pref_names.h" #include "ios/chrome/browser/pref_names.h"
#include "ios/chrome/browser/web/features.h"
#include "ios/components/ui_util/dynamic_type_util.h" #include "ios/components/ui_util/dynamic_type_util.h"
#include "ios/web/public/js_messaging/web_frame.h" #include "ios/web/public/js_messaging/web_frame.h"
#include "ios/web/public/js_messaging/web_frame_util.h" #include "ios/web/public/js_messaging/web_frame_util.h"
...@@ -240,9 +241,13 @@ bool FontSizeTabHelper::CurrentPageSupportsTextZoom() const { ...@@ -240,9 +241,13 @@ bool FontSizeTabHelper::CurrentPageSupportsTextZoom() const {
} }
int FontSizeTabHelper::GetFontSize() const { int FontSizeTabHelper::GetFontSize() const {
// Only add in the dynamic type multiplier if the flag is enabled.
double dynamic_type_multiplier =
base::FeatureList::IsEnabled(web::kWebPageDefaultZoomFromDynamicType)
? ui_util::SystemSuggestedFontSizeMultiplier()
: 1;
// Multiply by 100 as the web property needs a percentage. // Multiply by 100 as the web property needs a percentage.
return ui_util::SystemSuggestedFontSizeMultiplier() * return dynamic_type_multiplier * GetCurrentUserZoomMultiplier() * 100;
GetCurrentUserZoomMultiplier() * 100;
} }
void FontSizeTabHelper::WebStateDestroyed(web::WebState* web_state) { void FontSizeTabHelper::WebStateDestroyed(web::WebState* web_state) {
...@@ -298,9 +303,14 @@ PrefService* FontSizeTabHelper::GetPrefService() const { ...@@ -298,9 +303,14 @@ PrefService* FontSizeTabHelper::GetPrefService() const {
} }
std::string FontSizeTabHelper::GetCurrentUserZoomMultiplierKey() const { std::string FontSizeTabHelper::GetCurrentUserZoomMultiplierKey() const {
std::string content_size_category = base::SysNSStringToUTF8( UIContentSizeCategory content_size_category =
UIApplication.sharedApplication.preferredContentSizeCategory); base::FeatureList::IsEnabled(web::kWebPageDefaultZoomFromDynamicType)
return base::StringPrintf("%s.%s", content_size_category.c_str(), ? UIApplication.sharedApplication.preferredContentSizeCategory
: UIContentSizeCategoryLarge;
std::string content_size_category_key =
base::SysNSStringToUTF8(content_size_category);
return base::StringPrintf("%s.%s", content_size_category_key.c_str(),
GetUserZoomMultiplierKeyUrlPart().c_str()); GetUserZoomMultiplierKeyUrlPart().c_str());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment