[CSS] Add stub for font-variation-settings.

This commit is contained in:
Fedor 2020-03-12 20:42:32 +03:00
parent 2fbdf05c68
commit 1373e8207c
6 changed files with 48 additions and 3 deletions

View File

@ -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()
{

View File

@ -2036,6 +2036,20 @@ CSS_PROP_FONT(
kFontVariantPositionKTable,
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,

View File

@ -674,9 +674,9 @@ nsComputedDOMStyle::UpdateCurrentStyleSources(bool aNeedsLayoutFlush)
mPresShell->GetPresContext()->GetRestyleGeneration();
if (mStyleContext) {
// We can't rely on the undisplayed restyle generation if mElement is
// out-of-document, since that generation is not incremented for DOM changes
// on out-of-document elements.
// We can't rely on the undisplayed restyle generation if mElement is
// out-of-document, since that generation is not incremented for DOM changes
// on out-of-document elements.
if (mStyleContextGeneration == currentGeneration &&
mElement->IsInComposedDoc()) {
// Our cached style context is still valid.
@ -1619,6 +1619,16 @@ nsComputedDOMStyle::DoGetFontFeatureSettings()
return val.forget();
}
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()
{

View File

@ -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();

View File

@ -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)

View File

@ -2535,6 +2535,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);