Implement font-optical-sizing
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Mar 2017 19:01:54 +0000 (19:01 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Mar 2017 19:01:54 +0000 (19:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168895

Reviewed by Dean Jackson.

Source/WebCore:

Upon advice from Microsoft, the only input to optical sizing is just the
font-size computed value. It is implemented by setting the 'opsz' font
variation axis. Because the propery has such a simple grammar, the
implementation is quite straightforward.

Test: fast/text/variations/optical-sizing.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::propertyValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator FontOpticalSizing):
* css/CSSProperties.json:
* css/parser/CSSParserFastPaths.cpp:
(WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
(WebCore::CSSParserFastPaths::isKeywordPropertyID):
* platform/graphics/FontCache.h:
(WebCore::FontDescriptionKey::makeFlagsKey):
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::opticalSizing):
(WebCore::FontDescription::setOpticalSizing):
(WebCore::FontDescription::operator==):
(WebCore::FontCascadeDescription::initialOpticalSizing):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* platform/text/TextFlags.h:

LayoutTests:

* fast/text/variations/optical-sizing-expected.txt: Added.
* fast/text/variations/optical-sizing.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214364 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/variations/optical-sizing-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/variations/optical-sizing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSProperties.json
Source/WebCore/css/parser/CSSParserFastPaths.cpp
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
Source/WebCore/platform/text/TextFlags.h
Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js

index 3a71801..f02b96a 100644 (file)
@@ -1,3 +1,13 @@
+2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Implement font-optical-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=168895
+
+        Reviewed by Dean Jackson.
+
+        * fast/text/variations/optical-sizing-expected.txt: Added.
+        * fast/text/variations/optical-sizing.html: Added.
+
 2017-03-24  Yoav Weiss  <yoav@yoav.ws>
 
         Add a warning for unused link preloads.
diff --git a/LayoutTests/fast/text/variations/optical-sizing-expected.txt b/LayoutTests/fast/text/variations/optical-sizing-expected.txt
new file mode 100644 (file)
index 0000000..0eb0168
--- /dev/null
@@ -0,0 +1,23 @@
+This test makes sure that font-optical-sizing works as expected.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(document.getElementById('test1')).getPropertyValue('font-optical-sizing') is "auto"
+PASS window.getComputedStyle(document.getElementById('test2')).getPropertyValue('font-optical-sizing') is "auto"
+PASS window.getComputedStyle(document.getElementById('test3')).getPropertyValue('font-optical-sizing') is "auto"
+PASS window.getComputedStyle(document.getElementById('test4')).getPropertyValue('font-optical-sizing') is "none"
+PASS window.getComputedStyle(document.getElementById('test5')).getPropertyValue('font-optical-sizing') is "none"
+PASS document.getElementById('test1').style.fontOpticalSizing is ""
+PASS document.getElementById('test2').style.fontOpticalSizing is "initial"
+PASS document.getElementById('test3').style.fontOpticalSizing is "auto"
+PASS document.getElementById('test4').style.fontOpticalSizing is "none"
+PASS document.getElementById('test5').style.fontOpticalSizing is "inherit"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Hello
+Hello
+Hello
+Hello
+Hello
diff --git a/LayoutTests/fast/text/variations/optical-sizing.html b/LayoutTests/fast/text/variations/optical-sizing.html
new file mode 100644 (file)
index 0000000..19b177a
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<div id="test1">Hello</div>
+<div id="test2" style="font-optical-sizing: initial;">Hello</div>
+<div id="test3" style="font-optical-sizing: auto;">Hello</div>
+<div id="test4" style="font-optical-sizing: none;">Hello</div>
+<div style="font-optical-sizing: none;"><div id="test5" style="font-optical-sizing: inherit;">Hello</div></div>
+
+<script>
+description("This test makes sure that font-optical-sizing works as expected.");
+
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).getPropertyValue('font-optical-sizing')", "auto");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).getPropertyValue('font-optical-sizing')", "auto");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test3')).getPropertyValue('font-optical-sizing')", "auto");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test4')).getPropertyValue('font-optical-sizing')", "none");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test5')).getPropertyValue('font-optical-sizing')", "none");
+
+shouldBeEqualToString("document.getElementById('test1').style.fontOpticalSizing", "");
+shouldBeEqualToString("document.getElementById('test2').style.fontOpticalSizing", "initial");
+shouldBeEqualToString("document.getElementById('test3').style.fontOpticalSizing", "auto");
+shouldBeEqualToString("document.getElementById('test4').style.fontOpticalSizing", "none");
+shouldBeEqualToString("document.getElementById('test5').style.fontOpticalSizing", "inherit");
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
\ No newline at end of file
index b8be41e..f624493 100644 (file)
@@ -1,3 +1,42 @@
+2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Implement font-optical-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=168895
+
+        Reviewed by Dean Jackson.
+
+        Upon advice from Microsoft, the only input to optical sizing is just the
+        font-size computed value. It is implemented by setting the 'opsz' font
+        variation axis. Because the propery has such a simple grammar, the
+        implementation is quite straightforward.
+
+        Test: fast/text/variations/optical-sizing.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::propertyValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator FontOpticalSizing):
+        * css/CSSProperties.json:
+        * css/parser/CSSParserFastPaths.cpp:
+        (WebCore::CSSParserFastPaths::isValidKeywordPropertyAndValue):
+        (WebCore::CSSParserFastPaths::isKeywordPropertyID):
+        * platform/graphics/FontCache.h:
+        (WebCore::FontDescriptionKey::makeFlagsKey):
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::opticalSizing):
+        (WebCore::FontDescription::setOpticalSizing):
+        (WebCore::FontDescription::operator==):
+        (WebCore::FontCascadeDescription::initialOpticalSizing):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        (WebCore::fontWithFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * platform/text/TextFlags.h:
+
 2017-03-24  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, rolling out r214329.
index b879e67..07b679e 100644 (file)
@@ -2949,6 +2949,8 @@ RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID,
                 list->append(CSSFontVariationValue::create(feature.tag(), feature.value()));
             return WTFMove(list);
         }
+        case CSSPropertyFontOpticalSizing:
+            return cssValuePool.createValue(style->fontDescription().opticalSizing());
 #endif
         case CSSPropertyGridAutoFlow: {
             auto list = CSSValueList::createSpaceSeparated();
index bf0da25..35c5caf 100644 (file)
@@ -5616,4 +5616,36 @@ template<> inline CSSPrimitiveValue::operator FontVariantAlternates() const
     return FontVariantAlternates::Normal;
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontOpticalSizing sizing)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_VALUE_ID;
+    switch (sizing) {
+    case FontOpticalSizing::Enabled:
+        m_value.valueID = CSSValueAuto;
+        break;
+    case FontOpticalSizing::Disabled:
+        m_value.valueID = CSSValueNone;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator FontOpticalSizing() const
+{
+    ASSERT(isValueID());
+    switch (m_value.valueID) {
+    case CSSValueAuto:
+        return FontOpticalSizing::Enabled;
+    case CSSValueNone:
+        return FontOpticalSizing::Disabled;
+    default:
+        break;
+    }
+    ASSERT_NOT_REACHED();
+    return FontOpticalSizing::Enabled;
+}
+
 }
index 55bd550..0a104be 100644 (file)
                 "url": "https://drafts.csswg.org/css-fonts-3/#font-variant-east-asian-prop"
             }
         },
+        "font-synthesis": {
+            "inherited": true,
+            "codegen-properties": {
+                "converter": "FontSynthesis",
+                "font-property": true,
+                "high-priority": true
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://drafts.csswg.org/css-fonts-3/#font-synthesis-prop"
+            }
+        },
+        "font-optical-sizing": {
+            "inherited": true,
+            "values": [
+                "auto",
+                "none"
+            ],
+            "codegen-properties": {
+                "name-for-methods": "OpticalSizing",
+                "font-property": true,
+                "high-priority": true,
+                "enable-if": "ENABLE_VARIATION_FONTS"
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://drafts.csswg.org/css-fonts-4/#optical-sizing-control-the-font-optical-sizing-property"
+            }
+        },
+        "font": {
+            "inherited": true,
+            "codegen-properties": {
+                "longhands": [
+                              "font-family",
+                              "font-size",
+                              "font-style",
+                              "font-variant-caps",
+                              "font-weight",
+                              "font-stretch",
+                              "line-height"
+                              ]
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://www.w3.org/TR/css-fonts-3/#font-prop"
+            }
+        },
+        "font-variant": {
+            "inherited": true,
+            "codegen-properties": {
+                "longhands": [
+                              "font-variant-ligatures",
+                              "font-variant-position",
+                              "font-variant-caps",
+                              "font-variant-numeric",
+                              "font-variant-alternates",
+                              "font-variant-east-asian"
+                              ]
+            },
+            "specification": {
+                "category": "css-fonts",
+                "url": "https://www.w3.org/TR/css-fonts-3/#propdef-font-variant"
+            }
+        },
         "-webkit-locale": {
             "inherited": true,
             "codegen-properties": {
                 "url": "https://msdn.microsoft.com/en-us/library/ms531189(v=vs.85).aspx"
             }
         },
-        "font-synthesis": {
-            "inherited": true,
-            "codegen-properties": {
-                "converter": "FontSynthesis",
-                "font-property": true,
-                "high-priority": true
-            },
-            "specification": {
-                "category": "css-fonts",
-                "url": "https://drafts.csswg.org/css-fonts-3/#font-synthesis-prop"
-            }
-        },
         "-webkit-ruby-position": {
             "inherited": true,
             "values": [
                 "url": "https://www.w3.org/TR/SVG/filters.html#FloodOpacityProperty"
             }
         },
-        "font": {
-            "inherited": true,
-            "codegen-properties": {
-                "longhands": [
-                    "font-family",
-                    "font-size",
-                    "font-style",
-                    "font-variant-caps",
-                    "font-weight",
-                    "font-stretch",
-                    "line-height"
-                ]
-            },
-            "specification": {
-                "category": "css-fonts",
-                "url": "https://www.w3.org/TR/css-fonts-3/#font-prop"
-            }
-        },
-        "font-variant": {
-            "inherited": true,
-            "codegen-properties": {
-                "longhands": [
-                    "font-variant-ligatures",
-                    "font-variant-position",
-                    "font-variant-caps",
-                    "font-variant-numeric",
-                    "font-variant-alternates",
-                    "font-variant-east-asian"
-                ]
-            },
-            "specification": {
-                "category": "css-fonts",
-                "url": "https://www.w3.org/TR/css-fonts-3/#propdef-font-variant"
-            }
-        },
         "glyph-orientation-horizontal": {
             "inherited": true,
             "codegen-properties": {
index e0440d6..b58560d 100644 (file)
@@ -800,6 +800,10 @@ bool CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyID propertyId
     case CSSPropertyWebkitOverflowScrolling:
         return valueID == CSSValueAuto || valueID == CSSValueTouch;
 #endif
+#if ENABLE(VARIATION_FONTS)
+    case CSSPropertyFontOpticalSizing:
+        return valueID == CSSValueAuto || valueID == CSSValueNone;
+#endif
     default:
         ASSERT_NOT_REACHED();
         return false;
@@ -962,6 +966,9 @@ bool CSSParserFastPaths::isKeywordPropertyID(CSSPropertyID propertyId)
     case CSSPropertyApplePayButtonStyle:
     case CSSPropertyApplePayButtonType:
 #endif
+#if ENABLE(VARIATION_FONTS)
+    case CSSPropertyFontOpticalSizing:
+#endif
         return true;
     case CSSPropertyJustifyContent:
     case CSSPropertyAlignContent:
index e79f3db..53824dd 100644 (file)
@@ -122,7 +122,8 @@ private:
     static std::array<unsigned, 2> makeFlagsKey(const FontDescription& description)
     {
         static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags");
-        unsigned first = static_cast<unsigned>(description.script()) << 11
+        unsigned first = static_cast<unsigned>(description.script()) << 12
+            | static_cast<unsigned>(description.opticalSizing()) << 11
             | static_cast<unsigned>(description.textRenderingMode()) << 9
             | static_cast<unsigned>(description.fontSynthesis()) << 6
             | static_cast<unsigned>(description.widthVariant()) << 4
@@ -275,7 +276,7 @@ struct SynthesisPair {
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&, FontOpticalSizing, float size);
 SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
 RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);
index 5e03cbb..c108dbb 100644 (file)
@@ -95,6 +95,7 @@ public:
             variantEastAsianWidth(),
             variantEastAsianRuby() };
     }
+    FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); }
 
     void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
     void setItalic(FontSelectionValue italic) { m_fontSelectionRequest.slope = italic; }
@@ -127,6 +128,7 @@ public:
     void setVariantEastAsianVariant(FontVariantEastAsianVariant variant) { m_variantEastAsianVariant = static_cast<unsigned>(variant); }
     void setVariantEastAsianWidth(FontVariantEastAsianWidth variant) { m_variantEastAsianWidth = static_cast<unsigned>(variant); }
     void setVariantEastAsianRuby(FontVariantEastAsianRuby variant) { m_variantEastAsianRuby = static_cast<unsigned>(variant); }
+    void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); }
 
 private:
     // FIXME: Investigate moving these into their own object on the heap (to save memory).
@@ -158,6 +160,7 @@ private:
     unsigned m_variantEastAsianVariant : 3; // FontVariantEastAsianVariant
     unsigned m_variantEastAsianWidth : 2; // FontVariantEastAsianWidth
     unsigned m_variantEastAsianRuby : 1; // FontVariantEastAsianRuby
+    unsigned m_opticalSizing : 1; // FontOpticalSizing
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -189,7 +192,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_variantAlternates == other.m_variantAlternates
         && m_variantEastAsianVariant == other.m_variantEastAsianVariant
         && m_variantEastAsianWidth == other.m_variantEastAsianWidth
-        && m_variantEastAsianRuby == other.m_variantEastAsianRuby;
+        && m_variantEastAsianRuby == other.m_variantEastAsianRuby
+        && m_opticalSizing == other.m_opticalSizing;
 }
 
 // FIXME: Move to a file of its own.
@@ -271,6 +275,7 @@ public:
     static FontVariantPosition initialVariantPosition() { return FontVariantPosition::Normal; }
     static FontVariantCaps initialVariantCaps() { return FontVariantCaps::Normal; }
     static FontVariantAlternates initialVariantAlternates() { return FontVariantAlternates::Normal; }
+    static FontOpticalSizing initialOpticalSizing() { return FontOpticalSizing::Enabled; }
     static const AtomicString& initialLocale() { return nullAtom; }
 
 private:
index 8cba35e..bb6709c 100644 (file)
@@ -430,7 +430,7 @@ static inline bool fontIsSystemFont(CTFontRef font)
 }
 #endif
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations, FontOpticalSizing fontOpticalSizing, float size)
 {
     bool alwaysAddVariations = false;
 
@@ -440,6 +440,8 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMo
     alwaysAddVariations = !defaultValues.isEmpty();
 #else
     UNUSED_PARAM(fontSelectionRequest);
+    UNUSED_PARAM(fontOpticalSizing);
+    UNUSED_PARAM(size);
 #endif
 
     if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
@@ -504,12 +506,17 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMo
     };
 
     // The system font is somewhat magical. Don't mess with its variations.
-    if (!fontIsSystemFont(originalFont))
-    {
+    if (!fontIsSystemFont(originalFont)) {
         applyVariation({{'w', 'g', 'h', 't'}}, static_cast<float>(fontSelectionRequest.weight));
         applyVariation({{'w', 'd', 't', 'h'}}, static_cast<float>(fontSelectionRequest.width));
         applyVariation({{'s', 'l', 'n', 't'}}, static_cast<float>(fontSelectionRequest.slope));
     }
+
+    if (fontOpticalSizing == FontOpticalSizing::Enabled) {
+        const float pxToPtRatio = 3.0f / 4;
+        applyVariation({{'o', 'p', 's', 'z'}}, size * pxToPtRatio);
+    }
+
     for (auto& newVariation : variations)
         applyVariation(newVariation.tag(), newVariation.value());
 
@@ -1037,7 +1044,7 @@ static void invalidateFontCache()
     FontCache::singleton().invalidate();
 }
 
-static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, float size)
+static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, FontOpticalSizing fontOpticalSizing, float size)
 {
     if (family.isEmpty())
         return nullptr;
@@ -1045,7 +1052,7 @@ static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelec
     auto foundFont = platformFontWithFamilySpecialCase(family, request, size);
     if (!foundFont)
         foundFont = platformFontLookupWithFamily(family, request, size);
-    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, fontSelectionRequest, variationSettings);
+    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings, fontSelectionRequest, variationSettings, fontOpticalSizing, size);
 }
 
 #if PLATFORM(MAC)
@@ -1084,7 +1091,7 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
 {
     float size = fontDescription.computedPixelSize();
 
-    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), size);
+    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
 
 #if PLATFORM(MAC)
     if (!font) {
@@ -1095,7 +1102,7 @@ std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
         // Ignore the result because we want to use our own algorithm to actually find the font.
         autoActivateFont(family.string(), size);
 
-        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), size);
+        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
     }
 #endif
 
@@ -1183,7 +1190,7 @@ RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& descr
 
     const FontPlatformData& platformData = originalFontData->platformData();
     auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
-    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings());
+    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings(), description.opticalSizing(), description.computedSize());
     if (!result)
         return lastResortFallbackFont(description);
 
index 932f3db..4b3a982 100644 (file)
@@ -40,7 +40,7 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(const FontDescription&
     FontOrientation orientation = fontDescription.orientation();
     FontWidthVariant widthVariant = fontDescription.widthVariant();
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
-    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings(), fontDescription.opticalSizing(), fontDescription.computedSize());
     ASSERT(font);
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 }
index 63a9f8c..c7087ff 100644 (file)
@@ -351,4 +351,9 @@ enum class Kerning {
     NoShift
 };
 
+enum class FontOpticalSizing {
+    Enabled,
+    Disabled
+};
+
 }
index 0b669c1..0057354 100644 (file)
@@ -92,7 +92,7 @@ WebInspector.CSSKeywordCompletions.AllPropertyNamesPlaceholder = "__all-properti
 WebInspector.CSSKeywordCompletions.InheritedProperties = [
     "azimuth", "border-collapse", "border-spacing", "caption-side", "clip-rule", "color", "color-interpolation",
     "color-interpolation-filters", "color-rendering", "cursor", "direction", "elevation", "empty-cells", "fill",
-    "fill-opacity", "fill-rule", "font", "font-family", "font-size", "font-style", "font-variant", "font-variant-numeric", "font-weight",
+    "fill-opacity", "fill-rule", "font", "font-family", "font-size", "font-style", "font-variant", "font-variant-numeric", "font-weight", "font-optical-sizing",
     "glyph-orientation-horizontal", "glyph-orientation-vertical", "hanging-punctuation", "image-rendering", "kerning", "letter-spacing",
     "line-height", "list-style", "list-style-image", "list-style-position", "list-style-type", "marker", "marker-end",
     "marker-mid", "marker-start", "orphans", "pitch", "pitch-range", "pointer-events", "quotes", "resize", "richness",
@@ -195,6 +195,9 @@ WebInspector.CSSKeywordCompletions._propertyKeywordMap = {
         "normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
         "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
     ],
+    "font-optical-sizing": [
+        "auto", "none",
+    ],
     "-webkit-color-correction": [
         "default", "srgb"
     ],