Title: [217742] trunk
Revision
217742
Author
mmaxfi...@apple.com
Date
2017-06-02 16:40:07 -0700 (Fri, 02 Jun 2017)

Log Message

REGRESSION(r213464): [iOS] Fonts get too bold when the "Bold Text" accessibility setting is enabled
https://bugs.webkit.org/show_bug.cgi?id=172737
Source/WebCore:

Reviewed by Simon Fraser.

Revert the part of r213464 which changed how we calculate the weights of system fonts.

Add an InternalSetting to trigger our mock of the accessbility "Bold Text" setting. We can't
use the real setting, so instead we just ask for bold fonts instead of regular fonts when this
setting is true.

Tests: fast/text/accessibility-bold-system-font.html
       fast/text/accessibility-bold-system-font-2.html

* platform/graphics/FontCache.h:
(WebCore::FontCache::shouldMockBoldSystemFontForAccessibility):
(WebCore::FontCache::setShouldMockBoldSystemFontForAccessibility):
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::platformFontWithFamilySpecialCase):
* rendering/RenderTheme.h:
(WebCore::RenderTheme::shouldMockBoldSystemFontForAccessibility):
(WebCore::RenderTheme::setShouldMockBoldSystemFontForAccessibility):
* rendering/RenderThemeIOS.h:
* rendering/RenderThemeIOS.mm:
(WebCore::cssWeightOfSystemFont):
(WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setShouldMockBoldSystemFontForAccessibility):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:

LayoutTests:

<rdar://problem/31608236>

Reviewed by Simon Fraser.

* fast/text/accessibility-bold-system-font-2-expected.html: Added.
* fast/text/accessibility-bold-system-font-2.html: Added.
* fast/text/accessibility-bold-system-font-expected.txt: Added.
* fast/text/accessibility-bold-system-font.html: Added.
* platform/mac/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217741 => 217742)


--- trunk/LayoutTests/ChangeLog	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/LayoutTests/ChangeLog	2017-06-02 23:40:07 UTC (rev 217742)
@@ -1,3 +1,17 @@
+2017-06-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(r213464): [iOS] Fonts get too bold when the "Bold Text" accessibility setting is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=172737
+        <rdar://problem/31608236>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/accessibility-bold-system-font-2-expected.html: Added.
+        * fast/text/accessibility-bold-system-font-2.html: Added.
+        * fast/text/accessibility-bold-system-font-expected.txt: Added.
+        * fast/text/accessibility-bold-system-font.html: Added.
+        * platform/mac/TestExpectations:
+
 2017-06-02  Ryan Haddad  <ryanhad...@apple.com>
 
         Mark webrtc/captureCanvas-webrtc.html as flaky on iOS.

Added: trunk/LayoutTests/fast/text/accessibility-bold-system-font-2-expected.html (0 => 217742)


--- trunk/LayoutTests/fast/text/accessibility-bold-system-font-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/accessibility-bold-system-font-2-expected.html	2017-06-02 23:40:07 UTC (rev 217742)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body style="font: -apple-system-body; font-weight: 600;">
+<div id="target" style="font-size: 400%;">Hello</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/accessibility-bold-system-font-2.html (0 => 217742)


--- trunk/LayoutTests/fast/text/accessibility-bold-system-font-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/accessibility-bold-system-font-2.html	2017-06-02 23:40:07 UTC (rev 217742)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    internals.settings.setShouldMockBoldSystemFontForAccessibility(true);
+</script>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+</head>
+<body style="font: -apple-system-body;">
+<div id="target" style="font-size: 400%;">Hello</div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/accessibility-bold-system-font-expected.txt (0 => 217742)


--- trunk/LayoutTests/fast/text/accessibility-bold-system-font-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/accessibility-bold-system-font-expected.txt	2017-06-02 23:40:07 UTC (rev 217742)
@@ -0,0 +1,10 @@
+This test makes sure that text using the accessibility bold functionality has the correct weight.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(target).getPropertyValue('font-weight') is "normal"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Hello

Added: trunk/LayoutTests/fast/text/accessibility-bold-system-font.html (0 => 217742)


--- trunk/LayoutTests/fast/text/accessibility-bold-system-font.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/accessibility-bold-system-font.html	2017-06-02 23:40:07 UTC (rev 217742)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals)
+    internals.settings.setShouldMockBoldSystemFontForAccessibility(true);
+</script>
+<script src=""
+</head>
+<body style="font: -apple-system-body;">
+<div id="target" style="font-size: 400%;">Hello</div>
+<script>
+description("This test makes sure that text using the accessibility bold functionality has the correct weight.");
+var target = document.getElementById("target");
+shouldBeEqualToString("window.getComputedStyle(target).getPropertyValue('font-weight')", "normal");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac/TestExpectations (217741 => 217742)


--- trunk/LayoutTests/platform/mac/TestExpectations	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2017-06-02 23:40:07 UTC (rev 217742)
@@ -1543,3 +1543,6 @@
 webkit.org/b/172469 [ ElCapitan ] imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_rsa_importKey.https.html [ Timeout ]
 
 webkit.org/b/172720 [ Sierra+ ] js/intl-datetimeformat.html [ Failure ]
+
+# This test tests a feature that only exists on iOS.
+webkit.org/b/172737 fast/text/accessibility-bold-system-font-2.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (217741 => 217742)


--- trunk/Source/WebCore/ChangeLog	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/ChangeLog	2017-06-02 23:40:07 UTC (rev 217742)
@@ -1,3 +1,38 @@
+2017-06-02  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        REGRESSION(r213464): [iOS] Fonts get too bold when the "Bold Text" accessibility setting is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=172737
+
+        Reviewed by Simon Fraser.
+
+        Revert the part of r213464 which changed how we calculate the weights of system fonts.
+
+        Add an InternalSetting to trigger our mock of the accessbility "Bold Text" setting. We can't
+        use the real setting, so instead we just ask for bold fonts instead of regular fonts when this
+        setting is true.
+
+        Tests: fast/text/accessibility-bold-system-font.html
+               fast/text/accessibility-bold-system-font-2.html
+
+        * platform/graphics/FontCache.h:
+        (WebCore::FontCache::shouldMockBoldSystemFontForAccessibility):
+        (WebCore::FontCache::setShouldMockBoldSystemFontForAccessibility):
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::platformFontWithFamilySpecialCase):
+        * rendering/RenderTheme.h:
+        (WebCore::RenderTheme::shouldMockBoldSystemFontForAccessibility):
+        (WebCore::RenderTheme::setShouldMockBoldSystemFontForAccessibility):
+        * rendering/RenderThemeIOS.h:
+        * rendering/RenderThemeIOS.mm:
+        (WebCore::cssWeightOfSystemFont):
+        (WebCore::RenderThemeIOS::updateCachedSystemFontDescription):
+        * testing/InternalSettings.cpp:
+        (WebCore::InternalSettings::Backup::Backup):
+        (WebCore::InternalSettings::Backup::restoreTo):
+        (WebCore::InternalSettings::setShouldMockBoldSystemFontForAccessibility):
+        * testing/InternalSettings.h:
+        * testing/InternalSettings.idl:
+
 2017-06-02  Brady Eidson  <beid...@apple.com>
 
         Prevent scheme handlers from handling all built-in URL schemes.

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (217741 => 217742)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-06-02 23:40:07 UTC (rev 217742)
@@ -226,6 +226,9 @@
 #endif
 
     std::unique_ptr<FontPlatformData> createFontPlatformDataForTesting(const FontDescription&, const AtomicString& family);
+    
+    bool shouldMockBoldSystemFontForAccessibility() const { return m_shouldMockBoldSystemFontForAccessibility; }
+    void setShouldMockBoldSystemFontForAccessibility(bool shouldMockBoldSystemFontForAccessibility) { m_shouldMockBoldSystemFontForAccessibility = shouldMockBoldSystemFontForAccessibility; }
 
 private:
     FontCache();
@@ -246,6 +249,8 @@
     static const AtomicString& platformAlternateFamilyName(const AtomicString&);
 
     Timer m_purgeTimer;
+    
+    bool m_shouldMockBoldSystemFontForAccessibility { false };
 
 #if PLATFORM(COCOA)
     friend class ComplexTextController;

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (217741 => 217742)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2017-06-02 23:40:07 UTC (rev 217742)
@@ -151,7 +151,7 @@
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest request, float size)
 {
     if (family.startsWith("UICTFontTextStyle")) {
-        CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
+        CTFontSymbolicTraits traits = (isFontWeightBold(request.weight) || FontCache::singleton().shouldMockBoldSystemFontForAccessibility() ? kCTFontTraitBold : 0) | (isItalic(request.slope) ? kCTFontTraitItalic : 0);
         RetainPtr<CFStringRef> familyNameStr = family.string().createCFString();
         RetainPtr<CTFontDescriptorRef> fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(familyNameStr.get(), RenderThemeIOS::contentSizeCategory(), nullptr));
         if (traits)

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (217741 => 217742)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2017-06-02 23:40:07 UTC (rev 217742)
@@ -63,7 +63,7 @@
 
     // This function is to be implemented in your platform-specific theme implementation to hand back the
     // appropriate platform theme.
-    static RenderTheme& singleton();
+    WEBCORE_EXPORT static RenderTheme& singleton();
 
     virtual void purgeCaches() { }
 
@@ -253,6 +253,9 @@
     enum class InnerSpinButtonLayout { Vertical, HorizontalUpLeft, HorizontalUpRight };
     virtual InnerSpinButtonLayout innerSpinButtonLayout(const RenderObject&) const { return InnerSpinButtonLayout::Vertical; }
 
+    virtual bool shouldMockBoldSystemFontForAccessibility() const { return false; }
+    virtual void setShouldMockBoldSystemFontForAccessibility(bool) { }
+
 protected:
     virtual FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
     virtual void updateCachedSystemFontDescription(CSSValueID systemFontID, FontCascadeDescription&) const = 0;

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (217741 => 217742)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.h	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h	2017-06-02 23:40:07 UTC (rev 217742)
@@ -39,8 +39,6 @@
 public:
     static Ref<RenderTheme> create();
 
-    LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
-
     static void adjustRoundBorderRadius(RenderStyle&, RenderBox&);
 
     static CFStringRef contentSizeCategory();
@@ -48,6 +46,8 @@
     WEBCORE_EXPORT static void setContentSizeCategory(const String&);
 
 protected:
+    LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
+    
     FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const override;
     void updateCachedSystemFontDescription(CSSValueID, FontCascadeDescription&) const override;
     int baselinePosition(const RenderBox&) const override;
@@ -118,6 +118,9 @@
     bool paintAttachment(const RenderObject&, const PaintInfo&, const IntRect&) override;
 #endif
 
+    bool shouldMockBoldSystemFontForAccessibility() const override { return m_shouldMockBoldSystemFontForAccessibility; }
+    void setShouldMockBoldSystemFontForAccessibility(bool shouldMockBoldSystemFontForAccessibility) override { m_shouldMockBoldSystemFontForAccessibility = shouldMockBoldSystemFontForAccessibility; }
+
 private:
     RenderThemeIOS();
     virtual ~RenderThemeIOS() { }
@@ -135,6 +138,8 @@
     String m_mediaControlsStyleSheet;
 
     mutable HashMap<int, Color> m_systemColorCache;
+
+    bool m_shouldMockBoldSystemFontForAccessibility { false };
 };
 
 }

Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (217741 => 217742)


--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm	2017-06-02 23:40:07 UTC (rev 217742)
@@ -1210,6 +1210,21 @@
     }
 }
 
+static inline FontSelectionValue cssWeightOfSystemFont(CTFontRef font)
+{
+    RetainPtr<CFDictionaryRef> traits = adoptCF(CTFontCopyTraits(font));
+    CFNumberRef resultRef = (CFNumberRef)CFDictionaryGetValue(traits.get(), kCTFontWeightTrait);
+    float result = 0;
+    CFNumberGetValue(resultRef, kCFNumberFloatType, &result);
+    // These numbers were experimentally gathered from weights of the system font.
+    static float weightThresholds[] = { -0.6, -0.365, -0.115, 0.130, 0.235, 0.350, 0.5, 0.7 };
+    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(weightThresholds); ++i) {
+        if (result < weightThresholds[i])
+            return FontSelectionValue((static_cast<int>(i) + 1) * 100);
+    }
+    return FontSelectionValue(900);
+}
+
 void RenderThemeIOS::updateCachedSystemFontDescription(CSSValueID valueID, FontCascadeDescription& fontDescription) const
 {
     RetainPtr<CTFontDescriptorRef> fontDescriptor;
@@ -1217,79 +1232,79 @@
     switch (valueID) {
     case CSSValueAppleSystemHeadline:
         textStyle = kCTUIFontTextStyleHeadline;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemBody:
         textStyle = kCTUIFontTextStyleBody;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     case CSSValueAppleSystemTitle0:
         textStyle = kCTUIFontTextStyleTitle0;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 #endif
     case CSSValueAppleSystemTitle1:
         textStyle = kCTUIFontTextStyleTitle1;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemTitle2:
         textStyle = kCTUIFontTextStyleTitle2;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemTitle3:
         textStyle = kCTUIFontTextStyleTitle3;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     case CSSValueAppleSystemTitle4:
         textStyle = kCTUIFontTextStyleTitle4;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 #endif
     case CSSValueAppleSystemSubheadline:
         textStyle = kCTUIFontTextStyleSubhead;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemFootnote:
         textStyle = kCTUIFontTextStyleFootnote;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemCaption1:
         textStyle = kCTUIFontTextStyleCaption1;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemCaption2:
         textStyle = kCTUIFontTextStyleCaption2;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 
     // Short version.
     case CSSValueAppleSystemShortHeadline:
         textStyle = kCTUIFontTextStyleShortHeadline;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemShortBody:
         textStyle = kCTUIFontTextStyleShortBody;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemShortSubheadline:
         textStyle = kCTUIFontTextStyleShortSubhead;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemShortFootnote:
         textStyle = kCTUIFontTextStyleShortFootnote;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
     case CSSValueAppleSystemShortCaption1:
         textStyle = kCTUIFontTextStyleShortCaption1;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 
     // Tall version.
     case CSSValueAppleSystemTallBody:
         textStyle = kCTUIFontTextStyleTallBody;
-        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
+        fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), nullptr));
         break;
 
     default:
@@ -1302,8 +1317,7 @@
     fontDescription.setIsAbsoluteSize(true);
     fontDescription.setOneFamily(textStyle);
     fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
-    auto capabilities = capabilitiesForFontDescriptor(adoptCF(CTFontCopyFontDescriptor(font.get())).get());
-    fontDescription.setWeight(capabilities.weight.minimum);
+    fontDescription.setWeight(cssWeightOfSystemFont(font.get()));
     fontDescription.setItalic(normalItalicValue());
 }
 

Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (217741 => 217742)


--- trunk/Source/WebCore/testing/InternalSettings.cpp	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp	2017-06-02 23:40:07 UTC (rev 217742)
@@ -30,6 +30,7 @@
 #include "CaptionUserPreferences.h"
 #include "Document.h"
 #include "ExceptionCode.h"
+#include "FontCache.h"
 #include "FrameView.h"
 #include "Language.h"
 #include "LocaleToScriptMapping.h"
@@ -36,6 +37,7 @@
 #include "MainFrame.h"
 #include "Page.h"
 #include "PageGroup.h"
+#include "RenderTheme.h"
 #include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
 #include "Supplementable.h"
@@ -108,6 +110,7 @@
 #if ENABLE(WEBGPU)
     , m_webGPUEnabled(RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())
 #endif
+    , m_shouldMockBoldSystemFontForAccessibility(RenderTheme::singleton().shouldMockBoldSystemFontForAccessibility())
 {
 }
 
@@ -185,6 +188,8 @@
     settings.setForcedDisplayIsMonochromeAccessibilityValue(m_forcedDisplayIsMonochromeAccessibilityValue);
     settings.setForcedPrefersReducedMotionAccessibilityValue(m_forcedPrefersReducedMotionAccessibilityValue);
     Settings::setAllowsAnySSLCertificate(false);
+    RenderTheme::singleton().setShouldMockBoldSystemFontForAccessibility(m_shouldMockBoldSystemFontForAccessibility);
+    FontCache::singleton().setShouldMockBoldSystemFontForAccessibility(m_shouldMockBoldSystemFontForAccessibility);
 
 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)
     RuntimeEnabledFeatures::sharedFeatures().setIndexedDBWorkersEnabled(m_indexedDBWorkersEnabled);
@@ -677,6 +682,15 @@
     return { };
 }
 
+ExceptionOr<void> InternalSettings::setShouldMockBoldSystemFontForAccessibility(bool requires)
+{
+    if (!m_page)
+        return Exception { INVALID_ACCESS_ERR };
+    RenderTheme::singleton().setShouldMockBoldSystemFontForAccessibility(requires);
+    FontCache::singleton().setShouldMockBoldSystemFontForAccessibility(requires);
+    return { };
+}
+
 void InternalSettings::setIndexedDBWorkersEnabled(bool enabled)
 {
 #if ENABLE(INDEXED_DATABASE_IN_WORKERS)

Modified: trunk/Source/WebCore/testing/InternalSettings.h (217741 => 217742)


--- trunk/Source/WebCore/testing/InternalSettings.h	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/testing/InternalSettings.h	2017-06-02 23:40:07 UTC (rev 217742)
@@ -95,6 +95,7 @@
     ExceptionOr<void> setUserInterfaceDirectionPolicy(const String&);
     ExceptionOr<String> systemLayoutDirection();
     ExceptionOr<void> setSystemLayoutDirection(const String&);
+    ExceptionOr<void> setShouldMockBoldSystemFontForAccessibility(bool);
     
     static void setAllowsAnySSLCertificate(bool);
 
@@ -191,6 +192,8 @@
         bool m_cssGridLayoutEnabled;
         bool m_webGL2Enabled;
         bool m_webGPUEnabled;
+        
+        bool m_shouldMockBoldSystemFontForAccessibility;
     };
 
     Page* m_page;

Modified: trunk/Source/WebCore/testing/InternalSettings.idl (217741 => 217742)


--- trunk/Source/WebCore/testing/InternalSettings.idl	2017-06-02 23:11:44 UTC (rev 217741)
+++ trunk/Source/WebCore/testing/InternalSettings.idl	2017-06-02 23:40:07 UTC (rev 217742)
@@ -95,6 +95,8 @@
 
     [MayThrowException] boolean deferredCSSParserEnabled();
     [MayThrowException] void setDeferredCSSParserEnabled(boolean enabled);
+    
+    [MayThrowException] void setShouldMockBoldSystemFontForAccessibility(boolean shouldMock);
 
     attribute ForcedAccessibilityValue forcedColorsAreInvertedAccessibilityValue;
     attribute ForcedAccessibilityValue forcedDisplayIsMonochromeAccessibilityValue;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to