Remove support (style system only) for 'wider' and 'narrower' values of 'font-stretch'. (Bug 604816) r=jdaggett a2.0=joedrew

This commit is contained in:
L. David Baron 2010-11-10 07:49:52 -08:00
parent abe5e4d05f
commit a31dcce1eb
8 changed files with 13 additions and 56 deletions

View File

@ -62,9 +62,5 @@
#define NS_FONT_STRETCH_EXPANDED 2
#define NS_FONT_STRETCH_EXTRA_EXPANDED 3
#define NS_FONT_STRETCH_ULTRA_EXPANDED 4
// These need to be more than double all of the values above so that we
// can add any multiple of any of these values to the values above.
#define NS_FONT_STRETCH_WIDER 10
#define NS_FONT_STRETCH_NARROWER (-10)
#endif

View File

@ -448,8 +448,6 @@ static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
#define NS_STYLE_FONT_STRETCH_EXPANDED NS_FONT_STRETCH_EXPANDED
#define NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED NS_FONT_STRETCH_EXTRA_EXPANDED
#define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED NS_FONT_STRETCH_ULTRA_EXPANDED
#define NS_STYLE_FONT_STRETCH_WIDER NS_FONT_STRETCH_WIDER
#define NS_STYLE_FONT_STRETCH_NARROWER NS_FONT_STRETCH_NARROWER
// See nsStyleFont - system fonts
#define NS_STYLE_FONT_CAPTION 1 // css2

View File

@ -6060,10 +6060,8 @@ CSSParserImpl::ParseFontDescriptorValue(nsCSSFontDesc aDescID,
case eCSSFontDesc_Stretch:
// property is VARIANT_HK|VARIANT_SYSFONT
return (ParseVariant(aValue, VARIANT_KEYWORD,
nsCSSProps::kFontStretchKTable) &&
(aValue.GetIntValue() != NS_STYLE_FONT_STRETCH_WIDER &&
aValue.GetIntValue() != NS_STYLE_FONT_STRETCH_NARROWER));
return ParseVariant(aValue, VARIANT_KEYWORD,
nsCSSProps::kFontStretchKTable);
// These two are unique to @font-face and have their own special grammar.
case eCSSFontDesc_Src:

View File

@ -927,8 +927,6 @@ const PRInt32 nsCSSProps::kFontSizeKTable[] = {
};
const PRInt32 nsCSSProps::kFontStretchKTable[] = {
eCSSKeyword_wider, NS_STYLE_FONT_STRETCH_WIDER,
eCSSKeyword_narrower, NS_STYLE_FONT_STRETCH_NARROWER,
eCSSKeyword_ultra_condensed, NS_STYLE_FONT_STRETCH_ULTRA_CONDENSED,
eCSSKeyword_extra_condensed, NS_STYLE_FONT_STRETCH_EXTRA_CONDENSED,
eCSSKeyword_condensed, NS_STYLE_FONT_STRETCH_CONDENSED,

View File

@ -1276,24 +1276,8 @@ nsComputedDOMStyle::DoGetFontStretch(nsIDOMCSSValue** aValue)
nsROCSSPrimitiveValue* val = GetROCSSPrimitiveValue();
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
const nsStyleFont* font = GetStyleFont();
// The computed value space isn't actually representable in string
// form, so just represent anything with widers or narrowers in it as
// 'wider' or 'narrower'.
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER % 2 == 0);
PR_STATIC_ASSERT(NS_FONT_STRETCH_WIDER % 2 == 0);
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER + NS_FONT_STRETCH_WIDER == 0);
PR_STATIC_ASSERT(NS_FONT_STRETCH_NARROWER < 0);
PRInt16 stretch = font->mFont.stretch;
if (stretch <= NS_FONT_STRETCH_NARROWER / 2) {
val->SetIdent(eCSSKeyword_narrower);
} else if (stretch >= NS_FONT_STRETCH_WIDER / 2) {
val->SetIdent(eCSSKeyword_wider);
} else {
val->SetIdent(
nsCSSProps::ValueToKeywordEnum(stretch, nsCSSProps::kFontStretchKTable));
}
val->SetIdent(nsCSSProps::ValueToKeywordEnum(GetStyleFont()->mFont.stretch,
nsCSSProps::kFontStretchKTable));
NS_ADDREF(*aValue = val);
return NS_OK;

View File

@ -1367,9 +1367,6 @@ CheckFontCallback(const nsRuleDataStruct& aData,
#ifdef MOZ_MATHML
fontData.mScriptLevel.GetUnit() == eCSSUnit_Integer ||
#endif
(stretch.GetUnit() == eCSSUnit_Enumerated &&
(stretch.GetIntValue() == NS_FONT_STRETCH_NARROWER ||
stretch.GetIntValue() == NS_FONT_STRETCH_WIDER)) ||
(weight.GetUnit() == eCSSUnit_Enumerated &&
(weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_BOLDER ||
weight.GetIntValue() == NS_STYLE_FONT_WEIGHT_LIGHTER))) {
@ -3021,25 +3018,12 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext,
defaultVariableFont->weight,
0, 0, 0, systemFont.weight);
// font-stretch: enum, inherit
if (eCSSUnit_Enumerated == aFontData.mStretch.GetUnit()) {
PRInt32 value = aFontData.mStretch.GetIntValue();
switch (value) {
case NS_FONT_STRETCH_WIDER:
case NS_FONT_STRETCH_NARROWER:
aCanStoreInRuleTree = PR_FALSE;
aFont->mFont.stretch = aParentFont->mFont.stretch + value;
break;
default:
aFont->mFont.stretch = value;
break;
}
} else
SetDiscrete(aFontData.mStretch, aFont->mFont.stretch, aCanStoreInRuleTree,
SETDSC_SYSTEM_FONT,
aParentFont->mFont.stretch,
defaultVariableFont->stretch,
0, 0, 0, systemFont.stretch);
// font-stretch: enum, inherit, initial, -moz-system-font
SetDiscrete(aFontData.mStretch, aFont->mFont.stretch, aCanStoreInRuleTree,
SETDSC_SYSTEM_FONT | SETDSC_ENUMERATED,
aParentFont->mFont.stretch,
defaultVariableFont->stretch,
0, 0, 0, systemFont.stretch);
#ifdef MOZ_MATHML
// Compute scriptlevel, scriptminsize and scriptsizemultiplier now so

View File

@ -1774,7 +1774,7 @@ var gCSSProperties = {
inherited: true,
type: CSS_TYPE_LONGHAND,
initial_values: [ "normal" ],
other_values: [ "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" ],
other_values: [ "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" ],
invalid_values: []
},
"font-style": {

View File

@ -647,12 +647,11 @@ function test_font_stretch(prop) {
is(cs.getPropertyValue(prop), "semi-expanded",
"font-stretch property " + prop + ": interpolation of font-stretches");
check_distance(prop, "normal", "semi-expanded", "ultra-expanded");
div.style.setProperty(prop, "wider", "");
is(cs.getPropertyValue(prop), "wider",
"font-stretch property " + prop + ": can't interpolate wider/narrower");
div.style.setProperty("-moz-transition-property", "none", "");
div.style.setProperty(prop, "expanded", "");
is(cs.getPropertyValue(prop), "expanded",
"font-stretch property " + prop + ": computed value before transition");
div.style.setProperty("-moz-transition-property", prop, "");
div.style.setProperty(prop, "extra-condensed", "");
is(cs.getPropertyValue(prop), "normal",
"font-stretch property " + prop + ": interpolation of font-stretches");