diff --git a/layout/style/Declaration.cpp b/layout/style/Declaration.cpp index 42131474b9f..be5cf21bce7 100644 --- a/layout/style/Declaration.cpp +++ b/layout/style/Declaration.cpp @@ -13,6 +13,7 @@ #include "mozilla/css/Declaration.h" #include "nsPrintfCString.h" +#include "mozilla/Preferences.h" namespace mozilla { namespace css { @@ -178,6 +179,9 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const // The system-font subproperty and the *-source properties don't count. continue; } + if (!nsCSSProps::IsEnabled(*p)) { + continue; + } ++totalCount; const nsCSSValue *val = mData->ValueFor(*p); NS_ABORT_IF_FALSE(!val || !mImportantData || !mImportantData->ValueFor(*p), @@ -564,6 +568,9 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const const nsCSSValue &fontVariantPosition = *data->ValueFor(eCSSProperty_font_variant_position); + bool fontFeaturesEnabled = + mozilla::Preferences::GetBool("layout.css.font-features.enabled"); + if (systemFont && systemFont->GetUnit() != eCSSUnit_None && systemFont->GetUnit() != eCSSUnit_Null) { @@ -577,39 +584,38 @@ Declaration::GetValue(nsCSSProperty aProperty, nsAString& aValue) const sizeAdjust.GetUnit() != eCSSUnit_System_Font || featureSettings.GetUnit() != eCSSUnit_System_Font || languageOverride.GetUnit() != eCSSUnit_System_Font || - fontKerning.GetUnit() != eCSSUnit_System_Font || - fontSynthesis.GetUnit() != eCSSUnit_System_Font || - fontVariantAlternates.GetUnit() != eCSSUnit_System_Font || - fontVariantCaps.GetUnit() != eCSSUnit_System_Font || - fontVariantEastAsian.GetUnit() != eCSSUnit_System_Font || - fontVariantLigatures.GetUnit() != eCSSUnit_System_Font || - fontVariantNumeric.GetUnit() != eCSSUnit_System_Font || - fontVariantPosition.GetUnit() != eCSSUnit_System_Font) { + (fontFeaturesEnabled && + (fontKerning.GetUnit() != eCSSUnit_System_Font || + fontSynthesis.GetUnit() != eCSSUnit_System_Font || + fontVariantAlternates.GetUnit() != eCSSUnit_System_Font || + fontVariantCaps.GetUnit() != eCSSUnit_System_Font || + fontVariantEastAsian.GetUnit() != eCSSUnit_System_Font || + fontVariantLigatures.GetUnit() != eCSSUnit_System_Font || + fontVariantNumeric.GetUnit() != eCSSUnit_System_Font || + fontVariantPosition.GetUnit() != eCSSUnit_System_Font))) { // This can't be represented as a shorthand. return; } systemFont->AppendToString(eCSSProperty__x_system_font, aValue); } else { - // The font-stretch, font-size-adjust, - // -moz-font-feature-settings, -moz-font-language-override - // along with kerning, synthesis and other font-variant - // subproperties are reset by this shorthand property to their - // initial values, but can't be represented in its syntax. + // properties reset by this shorthand property to their + // initial values but not represented in its syntax if (stretch.GetUnit() != eCSSUnit_Enumerated || stretch.GetIntValue() != NS_STYLE_FONT_STRETCH_NORMAL || sizeAdjust.GetUnit() != eCSSUnit_None || featureSettings.GetUnit() != eCSSUnit_Normal || languageOverride.GetUnit() != eCSSUnit_Normal || - fontKerning.GetIntValue() != NS_FONT_KERNING_AUTO || - fontSynthesis.GetUnit() != eCSSUnit_Enumerated || - fontSynthesis.GetIntValue() != - (NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE) || - fontVariantAlternates.GetUnit() != eCSSUnit_Normal || - fontVariantCaps.GetUnit() != eCSSUnit_Normal || - fontVariantEastAsian.GetUnit() != eCSSUnit_Normal || - fontVariantLigatures.GetUnit() != eCSSUnit_Normal || - fontVariantNumeric.GetUnit() != eCSSUnit_Normal || - fontVariantPosition.GetUnit() != eCSSUnit_Normal) { + (fontFeaturesEnabled && + (fontKerning.GetIntValue() != NS_FONT_KERNING_AUTO || + fontSynthesis.GetUnit() != eCSSUnit_Enumerated || + fontSynthesis.GetIntValue() != + (NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE) || + fontVariantAlternates.GetUnit() != eCSSUnit_Normal || + fontVariantCaps.GetUnit() != eCSSUnit_Normal || + fontVariantEastAsian.GetUnit() != eCSSUnit_Normal || + fontVariantLigatures.GetUnit() != eCSSUnit_Normal || + fontVariantNumeric.GetUnit() != eCSSUnit_Normal || + fontVariantPosition.GetUnit() != eCSSUnit_Normal))) { return; } @@ -956,6 +962,9 @@ Declaration::ToString(nsAString& aString) const nsAutoTArray shorthandsUsed; for (index = 0; index < count; index++) { nsCSSProperty property = OrderValueAt(index); + if (!nsCSSProps::IsEnabled(property)) { + continue; + } bool doneProperty = false; // If we already used this property in a shorthand, skip it. diff --git a/layout/style/test/test_font_feature_values_parsing.html b/layout/style/test/test_font_feature_values_parsing.html index a5d4a683406..8fcc1b67fc9 100644 --- a/layout/style/test/test_font_feature_values_parsing.html +++ b/layout/style/test/test_font_feature_values_parsing.html @@ -335,6 +335,10 @@ function testOneRule(testrule) { } function testFontFeatureValuesRuleParsing() { + // Gecko-specific check - if pref not set, skip these tests + if (window.SpecialPowers && !window.SpecialPowers.getBoolPref("layout.css.font-features.enabled")) { + return; + } var i; for (i = 0; i < testrules.length; i++) { var testrule = testrules[i]; diff --git a/layout/style/test/test_specified_value_serialization.html b/layout/style/test/test_specified_value_serialization.html index 9cc2f9b2f14..c0369d3b0a6 100644 --- a/layout/style/test/test_specified_value_serialization.html +++ b/layout/style/test/test_specified_value_serialization.html @@ -50,11 +50,13 @@ is(elt.style.getPropertyValue("transform"), "translateX(5px) translateY(10px) translateZ(2px) rotateX(30deg) rotateY(30deg) rotateZ(5deg) skewX(10deg) skewY(10deg) scaleX(2) scaleY(0.5) scaleZ(2)", "expected case canonicalization of transform functions"); -elt.setAttribute("style", - "font-variant-alternates: SWASH(fOo) stYLIStiC(Bar)"); -is(elt.style.getPropertyValue("font-variant-alternates"), - "swash(fOo) stylistic(Bar)", - "expected case canonicalization of transform functions"); +if (SpecialPowers.getBoolPref("layout.css.font-features.enabled")) { + elt.setAttribute("style", + "font-variant-alternates: SWASH(fOo) stYLIStiC(Bar)"); + is(elt.style.getPropertyValue("font-variant-alternates"), + "swash(fOo) stylistic(Bar)", + "expected case canonicalization of transform functions"); +} elt.setAttribute("style", ""); // leave the page in a useful state