Title: [214364] trunk
Revision
214364
Author
mmaxfi...@apple.com
Date
2017-03-24 12:01:54 -0700 (Fri, 24 Mar 2017)

Log Message

Implement font-optical-sizing
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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214363 => 214364)


--- trunk/LayoutTests/ChangeLog	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/LayoutTests/ChangeLog	2017-03-24 19:01:54 UTC (rev 214364)
@@ -1,3 +1,13 @@
+2017-03-24  Myles C. Maxfield  <mmaxfi...@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  <y...@yoav.ws>
 
         Add a warning for unused link preloads.

Added: trunk/LayoutTests/fast/text/variations/optical-sizing-expected.txt (0 => 214364)


--- trunk/LayoutTests/fast/text/variations/optical-sizing-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/optical-sizing-expected.txt	2017-03-24 19:01:54 UTC (rev 214364)
@@ -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
Property changes on: trunk/LayoutTests/fast/text/variations/optical-sizing-expected.txt
___________________________________________________________________

Added: svn:eol-style

+native \ No newline at end of property

Added: svn:keywords

+Author Date Id Rev URL \ No newline at end of property

Added: trunk/LayoutTests/fast/text/variations/optical-sizing.html (0 => 214364)


--- trunk/LayoutTests/fast/text/variations/optical-sizing.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/variations/optical-sizing.html	2017-03-24 19:01:54 UTC (rev 214364)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</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=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (214363 => 214364)


--- trunk/Source/WebCore/ChangeLog	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/ChangeLog	2017-03-24 19:01:54 UTC (rev 214364)
@@ -1,3 +1,42 @@
+2017-03-24  Myles C. Maxfield  <mmaxfi...@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  <cdu...@apple.com>
 
         Unreviewed, rolling out r214329.

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (214363 => 214364)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-03-24 19:01:54 UTC (rev 214364)
@@ -2949,6 +2949,8 @@
                 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();

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (214363 => 214364)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2017-03-24 19:01:54 UTC (rev 214364)
@@ -5616,4 +5616,36 @@
     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;
+}
+
+}

Modified: trunk/Source/WebCore/css/CSSProperties.json (214363 => 214364)


--- trunk/Source/WebCore/css/CSSProperties.json	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/css/CSSProperties.json	2017-03-24 19:01:54 UTC (rev 214364)
@@ -520,6 +520,70 @@
                 "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": {
@@ -655,18 +719,6 @@
                 "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": [
@@ -2017,41 +2069,6 @@
                 "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": {

Modified: trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp (214363 => 214364)


--- trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp	2017-03-24 19:01:54 UTC (rev 214364)
@@ -800,6 +800,10 @@
     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 @@
     case CSSPropertyApplePayButtonStyle:
     case CSSPropertyApplePayButtonType:
 #endif
+#if ENABLE(VARIATION_FONTS)
+    case CSSPropertyFontOpticalSizing:
+#endif
         return true;
     case CSSPropertyJustifyContent:
     case CSSPropertyAlignContent:

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (214363 => 214364)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-03-24 19:01:54 UTC (rev 214364)
@@ -122,7 +122,8 @@
     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 @@
     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);

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (214363 => 214364)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-03-24 19:01:54 UTC (rev 214364)
@@ -95,6 +95,7 @@
             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 @@
     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 @@
     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 @@
         && 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 @@
     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:

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (214363 => 214364)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-03-24 19:01:54 UTC (rev 214364)
@@ -430,7 +430,7 @@
 }
 #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 @@
     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 @@
     };
 
     // 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 @@
     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 @@
     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 @@
 {
     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 @@
         // 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 @@
 
     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);
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (214363 => 214364)


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-03-24 19:01:54 UTC (rev 214364)
@@ -40,7 +40,7 @@
     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());
 }

Modified: trunk/Source/WebCore/platform/text/TextFlags.h (214363 => 214364)


--- trunk/Source/WebCore/platform/text/TextFlags.h	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebCore/platform/text/TextFlags.h	2017-03-24 19:01:54 UTC (rev 214364)
@@ -351,4 +351,9 @@
     NoShift
 };
 
+enum class FontOpticalSizing {
+    Enabled,
+    Disabled
+};
+
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js (214363 => 214364)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2017-03-24 19:01:26 UTC (rev 214363)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSKeywordCompletions.js	2017-03-24 19:01:54 UTC (rev 214364)
@@ -92,7 +92,7 @@
 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 @@
         "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"
     ],
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to