diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-02-11 23:59:53 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:42:10 +0200 |
commit | 0e2b0db4d75f8fca6871da14f59f859fcf2f89ca (patch) | |
tree | aa33e56de6eb3b912a9ae7c1fa7ccb92590a8204 | |
parent | c4f65de9b2c195ebe090a2f334aa7207c30a8a28 (diff) | |
download | UXP-0e2b0db4d75f8fca6871da14f59f859fcf2f89ca.tar UXP-0e2b0db4d75f8fca6871da14f59f859fcf2f89ca.tar.gz UXP-0e2b0db4d75f8fca6871da14f59f859fcf2f89ca.tar.lz UXP-0e2b0db4d75f8fca6871da14f59f859fcf2f89ca.tar.xz UXP-0e2b0db4d75f8fca6871da14f59f859fcf2f89ca.zip |
[CSS] Add stub for font-variation-settings
This stub is added because websites insist on considering this
very hardware-dependent and O.S.-variable low-level font-control
as a "critical feature" which it isn't as there is 0 guarantee
that font variation settings are supported or honored by any
operating system used by the client.
On top this is a WD status feature that sites shouldn't be using, and
the feature itself is strongly discouraged for use in favor of standard
CSS font manipulation keywords like `font-weight`.
-rw-r--r-- | layout/style/nsCSSParser.cpp | 16 | ||||
-rw-r--r-- | layout/style/nsCSSPropList.h | 14 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.cpp | 10 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStyle.h | 1 | ||||
-rw-r--r-- | layout/style/nsComputedDOMStylePropertyList.h | 1 | ||||
-rw-r--r-- | modules/libpref/init/all.js | 3 |
6 files changed, 45 insertions, 0 deletions
diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index a8309314f..556e35406 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -1056,6 +1056,7 @@ protected: bool ParseOneFamily(nsAString& aFamily, bool& aOneKeyword, bool& aQuoted); bool ParseFamily(nsCSSValue& aValue); bool ParseFontFeatureSettings(nsCSSValue& aValue); + bool ParseFontVariationSettings(nsCSSValue& aValue); bool ParseFontSrc(nsCSSValue& aValue); bool ParseFontSrcFormat(InfallibleTArray<nsCSSValue>& values); bool ParseFontRanges(nsCSSValue& aValue); @@ -12092,6 +12093,8 @@ CSSParserImpl::ParseSingleValuePropertyByFunction(nsCSSValue& aValue, return ParseFontVariantNumeric(aValue); case eCSSProperty_font_feature_settings: return ParseFontFeatureSettings(aValue); + case eCSSProperty_font_variation_settings: + return ParseFontVariationSettings(aValue); case eCSSProperty_font_weight: return ParseFontWeight(aValue); case eCSSProperty_image_orientation: @@ -15315,6 +15318,19 @@ CSSParserImpl::ParseFontFeatureSettings(nsCSSValue& aValue) return true; } +bool
+CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue)
+{
+ // TODO: Actually implement this.
+
+ // This stub is here because websites insist on considering this
+ // very hardware-dependent and O.S.-variable low-level font-control
+ // as a "critical feature" which it isn't as there is 0 guarantee
+ // that font variation settings are supported or honored by any
+ // operating system used by the client.
+ return true;
+} + bool CSSParserImpl::ParseListStyle() { diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 07db6d3dd..411f982a4 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -2037,6 +2037,20 @@ CSS_PROP_FONT( CSS_PROP_NO_OFFSET, eStyleAnimType_Discrete) CSS_PROP_FONT( + font-variation-settings, + font_variation_settings, + FontVariationSettings, + CSS_PROPERTY_PARSE_VALUE | + CSS_PROPERTY_VALUE_PARSER_FUNCTION | + CSS_PROPERTY_VALUE_LIST_USES_COMMAS | + CSS_PROPERTY_APPLIES_TO_FIRST_LETTER_AND_FIRST_LINE | + CSS_PROPERTY_APPLIES_TO_PLACEHOLDER, + "layout.css.font-variations.stub", + 0, + nullptr, + CSS_PROP_NO_OFFSET, + eStyleAnimType_Discrete) +CSS_PROP_FONT( font-weight, font_weight, FontWeight, diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 647f7f6dc..c717d59c8 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1620,6 +1620,16 @@ nsComputedDOMStyle::DoGetFontFeatureSettings() } already_AddRefed<CSSValue> +nsComputedDOMStyle::DoGetFontVariationSettings() +{ + // TODO: This is still a stub, always returning "normal" + RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; + + val->SetIdent(eCSSKeyword_normal); + return val.forget(); +} + +already_AddRefed<CSSValue> nsComputedDOMStyle::DoGetFontKerning() { RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue; diff --git a/layout/style/nsComputedDOMStyle.h b/layout/style/nsComputedDOMStyle.h index 7fbf49afe..e94d8dbf6 100644 --- a/layout/style/nsComputedDOMStyle.h +++ b/layout/style/nsComputedDOMStyle.h @@ -251,6 +251,7 @@ private: already_AddRefed<CSSValue> DoGetColor(); already_AddRefed<CSSValue> DoGetFontFamily(); already_AddRefed<CSSValue> DoGetFontFeatureSettings(); + already_AddRefed<CSSValue> DoGetFontVariationSettings(); already_AddRefed<CSSValue> DoGetFontKerning(); already_AddRefed<CSSValue> DoGetFontLanguageOverride(); already_AddRefed<CSSValue> DoGetFontSize(); diff --git a/layout/style/nsComputedDOMStylePropertyList.h b/layout/style/nsComputedDOMStylePropertyList.h index 825976b58..557281810 100644 --- a/layout/style/nsComputedDOMStylePropertyList.h +++ b/layout/style/nsComputedDOMStylePropertyList.h @@ -144,6 +144,7 @@ COMPUTED_STYLE_PROP(font_variant_east_asian, FontVariantEastAsian) COMPUTED_STYLE_PROP(font_variant_ligatures, FontVariantLigatures) COMPUTED_STYLE_PROP(font_variant_numeric, FontVariantNumeric) COMPUTED_STYLE_PROP(font_variant_position, FontVariantPosition) +COMPUTED_STYLE_PROP(font_variation_settings, FontVariationSettings) COMPUTED_STYLE_PROP(font_weight, FontWeight) COMPUTED_STYLE_PROP(grid_auto_columns, GridAutoColumns) COMPUTED_STYLE_PROP(grid_auto_flow, GridAutoFlow) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index e9f9517e4..b3011b1b1 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2528,6 +2528,9 @@ pref("layout.css.image-orientation.enabled", true); // Is support for the font-display @font-face descriptor enabled? pref("layout.css.font-display.enabled", false); +// Enable the font variation stub code? +pref("layout.css.font-variations.stub", true); + // Are sets of prefixed properties supported? pref("layout.css.prefixes.border-image", true); pref("layout.css.prefixes.transforms", true); |