Bug 886691 - make tests and serialization code sensitive to font features pref. r=dbaron

This commit is contained in:
John Daggett 2013-07-25 15:01:41 +09:00
Родитель 8f997ff582
Коммит e2baf5a4ad
3 изменённых файлов: 43 добавлений и 28 удалений

Просмотреть файл

@ -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<nsCSSProperty, 16> 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.

Просмотреть файл

@ -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];

Просмотреть файл

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