Title: [266686] trunk/Source/WebCore
Revision
266686
Author
[email protected]
Date
2020-09-06 17:00:53 -0700 (Sun, 06 Sep 2020)

Log Message

Remove all non-web-exposed uses of ENABLE(VARIATION_FONTS)
https://bugs.webkit.org/show_bug.cgi?id=216211

Reviewed by Darin Adler.

This is the first step toward enabling variation fonts on all ports.
This patch compiles internal data structures on all ports, keeping care to not make
any web-exposed changes. It also stops consulting with ENABLE(VARIATION_FONTS) on
Cocoa platforms, since the flag is enabled on all Cocoa platforms and we've been
shipping it for years.

No new tests because there is no behavior change.

* css/CSSFontVariationValue.cpp:
* css/CSSFontVariationValue.h:
* css/CSSValue.cpp:
(WebCore::CSSValue::equals const):
(WebCore::CSSValue::cssText const):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isFontFeatureValue const):
(WebCore::CSSValue::isFontVariationValue const):
* platform/graphics/FontCache.h:
(WebCore::FontDescriptionKey::FontDescriptionKey):
(WebCore::FontDescriptionKey::operator== const):
(WebCore::FontDescriptionKey::computeHash const):
* platform/graphics/FontCascadeDescription.cpp:
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::setFeatureSettings):
(WebCore::FontDescription::setVariationSettings):
(WebCore::FontDescription::operator== const):
(WebCore::FontDescription::encode const):
(WebCore::FontDescription::decode):
* platform/graphics/FontTaggedSettings.cpp:
(WebCore::operator<<):
* platform/graphics/FontTaggedSettings.h:
(WebCore::FontVariationSettings::isEmpty const): Deleted.
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::denormalizeVariationWidth):
(WebCore::normalizeVariationWidth):
(WebCore::preparePlatformFont):
(WebCore::extractVariationBounds):
(WebCore::variationCapabilitiesForFontDescriptor):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::supportsFormat):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setFontVariationSettings):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::fontVariationSettings const):
* style/StyleBuilderConverter.h:
(WebCore::Style::BuilderConverter::convertFontVariationSettings):
* style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyInheritFontFeatureSettings):
(WebCore::Style::BuilderCustom::applyInheritFontVariationSettings):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (266685 => 266686)


--- trunk/Source/WebCore/ChangeLog	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/ChangeLog	2020-09-07 00:00:53 UTC (rev 266686)
@@ -1,3 +1,60 @@
+2020-09-06  Myles C. Maxfield  <[email protected]>
+
+        Remove all non-web-exposed uses of ENABLE(VARIATION_FONTS)
+        https://bugs.webkit.org/show_bug.cgi?id=216211
+
+        Reviewed by Darin Adler.
+
+        This is the first step toward enabling variation fonts on all ports.
+        This patch compiles internal data structures on all ports, keeping care to not make
+        any web-exposed changes. It also stops consulting with ENABLE(VARIATION_FONTS) on
+        Cocoa platforms, since the flag is enabled on all Cocoa platforms and we've been
+        shipping it for years.
+
+        No new tests because there is no behavior change.
+
+        * css/CSSFontVariationValue.cpp:
+        * css/CSSFontVariationValue.h:
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::equals const):
+        (WebCore::CSSValue::cssText const):
+        (WebCore::CSSValue::destroy):
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isFontFeatureValue const):
+        (WebCore::CSSValue::isFontVariationValue const):
+        * platform/graphics/FontCache.h:
+        (WebCore::FontDescriptionKey::FontDescriptionKey):
+        (WebCore::FontDescriptionKey::operator== const):
+        (WebCore::FontDescriptionKey::computeHash const):
+        * platform/graphics/FontCascadeDescription.cpp:
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::setFeatureSettings):
+        (WebCore::FontDescription::setVariationSettings):
+        (WebCore::FontDescription::operator== const):
+        (WebCore::FontDescription::encode const):
+        (WebCore::FontDescription::decode):
+        * platform/graphics/FontTaggedSettings.cpp:
+        (WebCore::operator<<):
+        * platform/graphics/FontTaggedSettings.h:
+        (WebCore::FontVariationSettings::isEmpty const): Deleted.
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::denormalizeVariationWidth):
+        (WebCore::normalizeVariationWidth):
+        (WebCore::preparePlatformFont):
+        (WebCore::extractVariationBounds):
+        (WebCore::variationCapabilitiesForFontDescriptor):
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::supportsFormat):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::setFontVariationSettings):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::fontVariationSettings const):
+        * style/StyleBuilderConverter.h:
+        (WebCore::Style::BuilderConverter::convertFontVariationSettings):
+        * style/StyleBuilderCustom.h:
+        (WebCore::Style::BuilderCustom::applyInheritFontFeatureSettings):
+        (WebCore::Style::BuilderCustom::applyInheritFontVariationSettings):
+
 2020-09-06  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Rename Display::LineBox to Display::Line

Modified: trunk/Source/WebCore/css/CSSFontVariationValue.cpp (266685 => 266686)


--- trunk/Source/WebCore/css/CSSFontVariationValue.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/css/CSSFontVariationValue.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -25,8 +25,6 @@
 
 #include "config.h"
 
-#if ENABLE(VARIATION_FONTS)
-
 #include "CSSFontVariationValue.h"
 #include <wtf/text/StringConcatenateNumbers.h>
 
@@ -50,5 +48,3 @@
 }
 
 }
-
-#endif // ENABLE(VARIATION_FONTS)

Modified: trunk/Source/WebCore/css/CSSFontVariationValue.h (266685 => 266686)


--- trunk/Source/WebCore/css/CSSFontVariationValue.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/css/CSSFontVariationValue.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -25,8 +25,6 @@
 
 #pragma once
 
-#if ENABLE(VARIATION_FONTS)
-
 #include "CSSValue.h"
 #include "FontTaggedSettings.h"
 
@@ -55,5 +53,3 @@
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontVariationValue, isFontVariationValue())
-
-#endif // ENABLE(VARIATION_FONTS)

Modified: trunk/Source/WebCore/css/CSSValue.cpp (266685 => 266686)


--- trunk/Source/WebCore/css/CSSValue.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/css/CSSValue.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -166,10 +166,8 @@
             return compareCSSValues<CSSFontFaceSrcValue>(*this, other);
         case FontFeatureClass:
             return compareCSSValues<CSSFontFeatureValue>(*this, other);
-#if ENABLE(VARIATION_FONTS)
         case FontVariationClass:
             return compareCSSValues<CSSFontVariationValue>(*this, other);
-#endif
         case FunctionClass:
             return compareCSSValues<CSSFunctionValue>(*this, other);
         case LinearGradientClass:
@@ -268,10 +266,8 @@
         return downcast<CSSFontFaceSrcValue>(*this).customCSSText();
     case FontFeatureClass:
         return downcast<CSSFontFeatureValue>(*this).customCSSText();
-#if ENABLE(VARIATION_FONTS)
     case FontVariationClass:
         return downcast<CSSFontVariationValue>(*this).customCSSText();
-#endif
     case FunctionClass:
         return downcast<CSSFunctionValue>(*this).customCSSText();
     case LinearGradientClass:
@@ -369,11 +365,9 @@
     case FontFeatureClass:
         delete downcast<CSSFontFeatureValue>(this);
         return;
-#if ENABLE(VARIATION_FONTS)
     case FontVariationClass:
         delete downcast<CSSFontVariationValue>(this);
         return;
-#endif
     case FunctionClass:
         delete downcast<CSSFunctionValue>(this);
         return;

Modified: trunk/Source/WebCore/css/CSSValue.h (266685 => 266686)


--- trunk/Source/WebCore/css/CSSValue.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/css/CSSValue.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -92,9 +92,7 @@
     bool isCustomPropertyValue() const { return m_classType == CustomPropertyClass; }
     bool isFunctionValue() const { return m_classType == FunctionClass; }
     bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
-#if ENABLE(VARIATION_FONTS)
     bool isFontVariationValue() const { return m_classType == FontVariationClass; }
-#endif
     bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; }
     bool isFontValue() const { return m_classType == FontClass; }
     bool isFontStyleValue() const { return m_classType == FontStyleClass; }
@@ -182,9 +180,7 @@
         AspectRatioClass,
         BorderImageSliceClass,
         FontFeatureClass,
-#if ENABLE(VARIATION_FONTS)
         FontVariationClass,
-#endif
         FontClass,
         FontStyleClass,
         FontStyleRangeClass,

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (266685 => 266686)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -80,9 +80,7 @@
         , m_flags(makeFlagsKey(description))
         , m_locale(description.specifiedLocale())
         , m_featureSettings(description.featureSettings())
-#if ENABLE(VARIATION_FONTS)
         , m_variationSettings(description.variationSettings())
-#endif
     { }
 
     explicit FontDescriptionKey(WTF::HashTableDeletedValueType)
@@ -96,9 +94,7 @@
             && m_fontSelectionRequest == other.m_fontSelectionRequest
             && m_flags == other.m_flags
             && m_locale == other.m_locale
-#if ENABLE(VARIATION_FONTS)
             && m_variationSettings == other.m_variationSettings
-#endif
             && m_featureSettings == other.m_featureSettings;
     }
 
@@ -120,9 +116,7 @@
         for (unsigned flagItem : m_flags)
             hasher.add(flagItem);
         hasher.add(m_featureSettings.hash());
-#if ENABLE(VARIATION_FONTS)
         hasher.add(m_variationSettings.hash());
-#endif
         return hasher.hash();
     }
 
@@ -164,9 +158,7 @@
     std::array<unsigned, 2> m_flags {{ 0, 0 }};
     AtomString m_locale;
     FontFeatureSettings m_featureSettings;
-#if ENABLE(VARIATION_FONTS)
     FontVariationSettings m_variationSettings;
-#endif
 };
 
 struct FontDescriptionKeyHash {

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp (266685 => 266686)


--- trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -36,11 +36,7 @@
 
 struct SameSizeAsFontCascadeDescription {
     Vector<void*> vector;
-#if ENABLE(VARIATION_FONTS)
     Vector<void*> vector2;
-#else
-    char c;
-#endif
     AtomString string;
     AtomString string2;
     int16_t fontSelectionRequest[3];

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (266685 => 266686)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -110,9 +110,7 @@
     void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = static_cast<unsigned>(widthVariant); } // Make sure new callers of this sync with FontPlatformData::isForTextCombine()!
     WEBCORE_EXPORT void setSpecifiedLocale(const AtomString&);
     void setFeatureSettings(FontFeatureSettings&& settings) { m_featureSettings = WTFMove(settings); }
-#if ENABLE(VARIATION_FONTS)
     void setVariationSettings(FontVariationSettings&& settings) { m_variationSettings = WTFMove(settings); }
-#endif
     void setFontSynthesis(FontSynthesis fontSynthesis) { m_fontSynthesis = fontSynthesis; }
     void setVariantCommonLigatures(FontVariantLigatures variant) { m_variantCommonLigatures = static_cast<unsigned>(variant); }
     void setVariantDiscretionaryLigatures(FontVariantLigatures variant) { m_variantDiscretionaryLigatures = static_cast<unsigned>(variant); }
@@ -190,9 +188,7 @@
         && m_widthVariant == other.m_widthVariant
         && m_specifiedLocale == other.m_specifiedLocale
         && m_featureSettings == other.m_featureSettings
-#if ENABLE(VARIATION_FONTS)
         && m_variationSettings == other.m_variationSettings
-#endif
         && m_fontSynthesis == other.m_fontSynthesis
         && m_variantCommonLigatures == other.m_variantCommonLigatures
         && m_variantDiscretionaryLigatures == other.m_variantDiscretionaryLigatures
@@ -219,9 +215,7 @@
 void FontDescription::encode(Encoder& encoder) const
 {
     encoder << featureSettings();
-#if ENABLE(VARIATION_FONTS)
     encoder << variationSettings();
-#endif
     encoder << computedLocale();
     encoder << italic();
     encoder << stretch();
@@ -263,12 +257,10 @@
     if (!featureSettings)
         return WTF::nullopt;
 
-#if ENABLE(VARIATION_FONTS)
     Optional<FontVariationSettings> variationSettings;
     decoder >> variationSettings;
     if (!variationSettings)
         return WTF::nullopt;
-#endif
 
     Optional<AtomString> locale;
     decoder >> locale;
@@ -421,9 +413,7 @@
         return WTF::nullopt;
 
     fontDescription.setFeatureSettings(WTFMove(*featureSettings));
-#if ENABLE(VARIATION_FONTS)
     fontDescription.setVariationSettings(WTFMove(*variationSettings));
-#endif
     fontDescription.setSpecifiedLocale(*locale);
     fontDescription.setItalic(*italic);
     fontDescription.setStretch(*stretch);

Modified: trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp (266685 => 266686)


--- trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/FontTaggedSettings.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -44,7 +44,6 @@
     return hasher.hash();
 }
 
-#if ENABLE(VARIATION_FONTS)
 template <>
 unsigned FontVariationSettings::hash() const
 {
@@ -76,6 +75,5 @@
     }
     return ts;
 }
-#endif
 
 }

Modified: trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h (266685 => 266686)


--- trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/FontTaggedSettings.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -216,19 +216,9 @@
 
 template <> unsigned FontFeatureSettings::hash() const;
 
-#if ENABLE(VARIATION_FONTS)
-
 typedef FontTaggedSettings<float> FontVariationSettings;
 WTF::TextStream& operator<<(WTF::TextStream&, const FontVariationSettings&);
 
 template <> unsigned FontVariationSettings::hash() const;
 
-#else
-
-struct FontVariationSettings {
-    bool isEmpty() const { return true; }
-};
-
-#endif
-
 }

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -152,9 +152,7 @@
 }
 
 typedef HashMap<FontTag, int, FourCharacterTagHash, FourCharacterTagHashTraits> FeaturesMap;
-#if ENABLE(VARIATION_FONTS)
 typedef HashMap<FontTag, float, FourCharacterTagHash, FourCharacterTagHashTraits> VariationsMap;
-#endif
 
 static FeaturesMap computeFeatureSettingsFromVariants(const FontVariantSettings& variantSettings)
 {
@@ -377,7 +375,6 @@
     return CFStringGetLength(fontName) > 0 && CFStringGetCharacterAtIndex(fontName, 0) == '.';
 }
 
-#if ENABLE(VARIATION_FONTS)
 struct VariationDefaults {
     float defaultValue;
     float minimumValue;
@@ -462,9 +459,7 @@
         return (value + 125) / 200;
     return (value + 400) / 400;
 }
-#endif
 
-#if ENABLE(VARIATION_FONTS) || !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
 static inline float normalizeVariationWidth(float value)
 {
     if (value <= 1.25)
@@ -473,7 +468,6 @@
         return value * 200 - 125;
     return value * 400 - 400;
 }
-#endif
 
 #if !HAS_CORE_TEXT_WIDTH_ATTRIBUTE
 static inline float normalizeWidth(float value)
@@ -542,7 +536,6 @@
 
     auto fontOpticalSizing = fontDescription.opticalSizing();
 
-#if ENABLE(VARIATION_FONTS)
     auto defaultValues = defaultVariationValues(originalFont);
 
     auto fontSelectionRequest = fontDescription.fontSelectionRequest();
@@ -551,11 +544,6 @@
     bool forceOpticalSizingOn = fontOpticalSizing == FontOpticalSizing::Enabled && fontType.variationType == FontType::VariationType::TrueTypeGX && defaultValues.contains({{'o', 'p', 's', 'z'}});
     bool forceVariations = defaultValues.contains({{'w', 'g', 'h', 't'}}) || defaultValues.contains({{'w', 'd', 't', 'h'}}) || (fontStyleAxis == FontStyleAxis::ital && defaultValues.contains({{'i', 't', 'a', 'l'}})) || (fontStyleAxis == FontStyleAxis::slnt && defaultValues.contains({{'s', 'l', 'n', 't'}}));
     const auto& variations = fontDescription.variationSettings();
-#else
-    UNUSED_PARAM(fontFaceCapabilities);
-    UNUSED_PARAM(applyWeightWidthSlopeVariations);
-    bool forceOpticalSizingOn = false;
-#endif
 
     const auto& features = fontDescription.featureSettings();
     const auto& variantSettings = fontDescription.variantSettings();
@@ -564,11 +552,7 @@
 
     // We might want to check fontType.trackingType == FontType::TrackingType::Manual here, but in order to maintain compatibility with the rest of the system, we don't.
     bool noFontFeatureSettings = features.isEmpty();
-#if ENABLE(VARIATION_FONTS)
     bool noFontVariationSettings = !forceVariations && variations.isEmpty();
-#else
-    bool noFontVariationSettings = true;
-#endif
     bool textRenderingModeIsAuto = textRenderingMode == TextRenderingMode::AutoTextRendering;
     bool variantSettingsIsNormal = variantSettings.isAllNormal();
     bool dontNeedToApplyOpticalSizing = fontOpticalSizing == FontOpticalSizing::Enabled && !forceOpticalSizingOn;
@@ -583,7 +567,18 @@
 
     // This algorithm is described at https://drafts.csswg.org/css-fonts-4/#feature-variation-precedence
     FeaturesMap featuresToBeApplied;
+    VariationsMap variationsToBeApplied;
 
+    bool needsConversion = fontType.variationType == FontType::VariationType::TrueTypeGX;
+
+    auto applyVariation = [&](const FontTag& tag, float value) {
+        auto iterator = defaultValues.find(tag);
+        if (iterator == defaultValues.end())
+            return;
+        float valueToApply = clampTo(value, iterator->value.minimumValue, iterator->value.maximumValue);
+        variationsToBeApplied.set(tag, valueToApply);
+    };
+
     auto applyFeature = [&](const FontTag& tag, int value) {
         // AAT doesn't differentiate between liga and clig. We need to make sure they always agree.
         featuresToBeApplied.set(tag, value);
@@ -597,50 +592,6 @@
 
     // Step 1: CoreText handles default features (such as required ligatures).
 
-    // Step 6: Consult with font-feature-settings inside @font-face
-    if (fontFaceFeatures) {
-        for (auto& fontFaceFeature : *fontFaceFeatures)
-            applyFeature(fontFaceFeature.tag(), fontFaceFeature.value());
-    }
-
-    // Step 10: Font-variant
-    for (auto& newFeature : computeFeatureSettingsFromVariants(variantSettings))
-        applyFeature(newFeature.key, newFeature.value);
-
-    // Step 11: Other properties
-    if (textRenderingMode == TextRenderingMode::OptimizeSpeed) {
-        applyFeature(fontFeatureTag("liga"), 0);
-        applyFeature(fontFeatureTag("clig"), 0);
-        applyFeature(fontFeatureTag("dlig"), 0);
-        applyFeature(fontFeatureTag("hlig"), 0);
-        applyFeature(fontFeatureTag("calt"), 0);
-    }
-    if (shouldDisableLigaturesForSpacing) {
-        applyFeature(fontFeatureTag("liga"), 0);
-        applyFeature(fontFeatureTag("clig"), 0);
-        applyFeature(fontFeatureTag("dlig"), 0);
-        applyFeature(fontFeatureTag("hlig"), 0);
-        // Core Text doesn't disable calt when letter-spacing is applied, so we won't either.
-    }
-
-    // Step 13: Font-feature-settings
-    for (auto& newFeature : features)
-        applyFeature(newFeature.tag(), newFeature.value());
-
-    // The variation fonts are separated from the font features because they don't conflict, and allow us to only have a single ENABLE().
-#if ENABLE(VARIATION_FONTS)
-    VariationsMap variationsToBeApplied;
-
-    bool needsConversion = fontType.variationType == FontType::VariationType::TrueTypeGX;
-
-    auto applyVariation = [&](const FontTag& tag, float value) {
-        auto iterator = defaultValues.find(tag);
-        if (iterator == defaultValues.end())
-            return;
-        float valueToApply = clampTo(value, iterator->value.minimumValue, iterator->value.maximumValue);
-        variationsToBeApplied.set(tag, valueToApply);
-    };
-
     // Step 2: font-weight, font-stretch, and font-style
     // The system font is somewhat magical. Don't mess with its variations.
     if (applyWeightWidthSlopeVariations && !fontIsSystemFont(originalFont)) {
@@ -670,12 +621,41 @@
 
     // FIXME: Implement Step 6: the font-variation-settings descriptor inside @font-face
 
+    // Step 7: Consult with font-feature-settings inside @font-face
+    if (fontFaceFeatures) {
+        for (auto& fontFaceFeature : *fontFaceFeatures)
+            applyFeature(fontFaceFeature.tag(), fontFaceFeature.value());
+    }
+
     // FIXME: Move font-optical-sizing handling here. It should be step 9.
 
+    // Step 10: Font-variant
+    for (auto& newFeature : computeFeatureSettingsFromVariants(variantSettings))
+        applyFeature(newFeature.key, newFeature.value);
+
+    // Step 11: Other properties
+    if (textRenderingMode == TextRenderingMode::OptimizeSpeed) {
+        applyFeature(fontFeatureTag("liga"), 0);
+        applyFeature(fontFeatureTag("clig"), 0);
+        applyFeature(fontFeatureTag("dlig"), 0);
+        applyFeature(fontFeatureTag("hlig"), 0);
+        applyFeature(fontFeatureTag("calt"), 0);
+    }
+    if (shouldDisableLigaturesForSpacing) {
+        applyFeature(fontFeatureTag("liga"), 0);
+        applyFeature(fontFeatureTag("clig"), 0);
+        applyFeature(fontFeatureTag("dlig"), 0);
+        applyFeature(fontFeatureTag("hlig"), 0);
+        // Core Text doesn't disable calt when letter-spacing is applied, so we won't either.
+    }
+
+    // Step 13: Font-feature-settings
+    for (auto& newFeature : features)
+        applyFeature(newFeature.tag(), newFeature.value());
+
     // Step 12: font-variation-settings
     for (auto& newVariation : variations)
         applyVariation(newVariation.tag(), newVariation.value());
-#endif // ENABLE(VARIATION_FONTS)
 
     auto attributes = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
     if (!featuresToBeApplied.isEmpty()) {
@@ -689,8 +669,6 @@
         }
         CFDictionaryAddValue(attributes.get(), kCTFontFeatureSettingsAttribute, featureArray.get());
     }
-
-#if ENABLE(VARIATION_FONTS)
     if (!variationsToBeApplied.isEmpty()) {
         auto variationDictionary = adoptCF(CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
         for (auto& p : variationsToBeApplied) {
@@ -701,7 +679,6 @@
         }
         CFDictionaryAddValue(attributes.get(), kCTFontVariationAttribute, variationDictionary.get());
     }
-#endif
 
     // Step 9: font-optical-sizing
     // FIXME: Apply this before font-variation-settings
@@ -1031,7 +1008,6 @@
     Optional<MinMax> slope;
 };
 
-#if ENABLE(VARIATION_FONTS)
 static Optional<MinMax> extractVariationBounds(CFDictionaryRef axis)
 {
     CFNumberRef minimumValue = static_cast<CFNumberRef>(CFDictionaryGetValue(axis, kCTFontVariationAxisMinimumValueKey));
@@ -1044,13 +1020,11 @@
         return {{ rawMinimumValue, rawMaximumValue }};
     return WTF::nullopt;
 }
-#endif
 
 static VariationCapabilities variationCapabilitiesForFontDescriptor(CTFontDescriptorRef fontDescriptor)
 {
     VariationCapabilities result;
 
-#if ENABLE(VARIATION_FONTS)
     if (!adoptCF(CTFontDescriptorCopyAttribute(fontDescriptor, kCTFontVariationAttribute)))
         return result;
 
@@ -1100,9 +1074,6 @@
         result.width = { };
     if (result.slope && (result.slope.value().minimum < minimum || result.slope.value().maximum > maximum))
         result.slope = { };
-#else
-    UNUSED_PARAM(fontDescriptor);
-#endif
 
     return result;
 }

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


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -93,14 +93,10 @@
     return equalLettersIgnoringASCIICase(format, "truetype")
         || equalLettersIgnoringASCIICase(format, "opentype")
         || equalLettersIgnoringASCIICase(format, "woff2")
-#if ENABLE(VARIATION_FONTS)
         || equalLettersIgnoringASCIICase(format, "woff2-variations")
-#endif
-#if ENABLE(VARIATION_FONTS)
         || equalLettersIgnoringASCIICase(format, "woff-variations")
         || equalLettersIgnoringASCIICase(format, "truetype-variations")
         || equalLettersIgnoringASCIICase(format, "opentype-variations")
-#endif
         || equalLettersIgnoringASCIICase(format, "woff");
 }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (266685 => 266686)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2020-09-07 00:00:53 UTC (rev 266686)
@@ -1852,7 +1852,6 @@
     fontCascade().update(currentFontSelector);
 }
 
-#if ENABLE(VARIATION_FONTS)
 void RenderStyle::setFontVariationSettings(FontVariationSettings settings)
 {
     FontSelector* currentFontSelector = fontCascade().fontSelector();
@@ -1862,7 +1861,6 @@
     setFontDescription(WTFMove(description));
     fontCascade().update(currentFontSelector);
 }
-#endif
 
 void RenderStyle::setFontWeight(FontSelectionValue value)
 {

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (266685 => 266686)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -352,9 +352,7 @@
     unsigned computedFontPixelSize() const;
     std::pair<FontOrientation, NonCJKGlyphOrientation> fontAndGlyphOrientation();
 
-#if ENABLE(VARIATION_FONTS)
     FontVariationSettings fontVariationSettings() const { return fontDescription().variationSettings(); }
-#endif
     FontSelectionValue fontWeight() const { return fontDescription().weight(); }
     FontSelectionValue fontStretch() const { return fontDescription().stretch(); }
     Optional<FontSelectionValue> fontItalic() const { return fontDescription().italic(); }
@@ -913,9 +911,7 @@
     // Only used for blending font sizes when animating, for MathML anonymous blocks, and for text autosizing.
     void setFontSize(float);
 
-#if ENABLE(VARIATION_FONTS)
     void setFontVariationSettings(FontVariationSettings);
-#endif
     void setFontWeight(FontSelectionValue);
     void setFontStretch(FontSelectionValue);
     void setFontItalic(Optional<FontSelectionValue>);

Modified: trunk/Source/WebCore/style/StyleBuilderConverter.h (266685 => 266686)


--- trunk/Source/WebCore/style/StyleBuilderConverter.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/style/StyleBuilderConverter.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -135,9 +135,7 @@
     static FontSelectionValue convertFontWeight(BuilderState&, const CSSValue&);
     static FontSelectionValue convertFontStretch(BuilderState&, const CSSValue&);
     static FontSelectionValue convertFontStyle(BuilderState&, const CSSValue&);
-#if ENABLE(VARIATION_FONTS)
     static FontVariationSettings convertFontVariationSettings(BuilderState&, const CSSValue&);
-#endif
     static SVGLengthValue convertSVGLengthValue(BuilderState&, const CSSValue&);
     static Vector<SVGLengthValue> convertSVGLengthVector(BuilderState&, const CSSValue&);
     static Vector<SVGLengthValue> convertStrokeDashArray(BuilderState&, const CSSValue&);
@@ -1326,7 +1324,6 @@
     return convertFontStretchFromValue(value);
 }
 
-#if ENABLE(VARIATION_FONTS)
 inline FontVariationSettings BuilderConverter::convertFontVariationSettings(BuilderState&, const CSSValue& value)
 {
     if (is<CSSPrimitiveValue>(value)) {
@@ -1341,7 +1338,6 @@
     }
     return settings;
 }
-#endif
 
 #if PLATFORM(IOS_FAMILY)
 inline bool BuilderConverter::convertTouchCallout(BuilderState&, const CSSValue& value)

Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (266685 => 266686)


--- trunk/Source/WebCore/style/StyleBuilderCustom.h	2020-09-06 23:42:25 UTC (rev 266685)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h	2020-09-07 00:00:53 UTC (rev 266686)
@@ -117,10 +117,8 @@
     static void applyInheritWebkitMaskImage(BuilderState&) { }
     static void applyInitialFontFeatureSettings(BuilderState&) { }
     static void applyInheritFontFeatureSettings(BuilderState&) { }
-#if ENABLE(VARIATION_FONTS)
     static void applyInitialFontVariationSettings(BuilderState&) { }
     static void applyInheritFontVariationSettings(BuilderState&) { }
-#endif
 
     // Custom handling of inherit + value setting only.
     static void applyInheritDisplay(BuilderState&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to