From 850dc81ab23e953cc2b43d415e752ca8b6870337 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 10 Nov 2010 07:49:52 -0800 Subject: [PATCH] Remove support (style system only) for 'wider' and 'narrower' values of 'font-stretch'. (Bug 604816) r=jdaggett a2.0=joedrew --- gfx/thebes/gfxFontConstants.h | 4 --- layout/base/nsStyleConsts.h | 2 -- layout/style/nsCSSParser.cpp | 6 ++-- layout/style/nsCSSProps.cpp | 2 -- layout/style/nsComputedDOMStyle.cpp | 20 ++----------- layout/style/nsRuleNode.cpp | 28 ++++--------------- layout/style/test/property_database.js | 2 +- .../test/test_transitions_per_property.html | 5 ++-- 8 files changed, 13 insertions(+), 56 deletions(-) diff --git a/gfx/thebes/gfxFontConstants.h b/gfx/thebes/gfxFontConstants.h index c13948141f5..bfc9b5d2fda 100644 --- a/gfx/thebes/gfxFontConstants.h +++ b/gfx/thebes/gfxFontConstants.h @@ -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 diff --git a/layout/base/nsStyleConsts.h b/layout/base/nsStyleConsts.h index c40f4b335c7..5771ea90932 100644 --- a/layout/base/nsStyleConsts.h +++ b/layout/base/nsStyleConsts.h @@ -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 diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 04f738bda84..f04d492f299 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -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: diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index df3088eaf32..4ff9919e35e 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -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, diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 8d9df4c3405..294abfa7460 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -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; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index a7fb517605d..3c27686fa95 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -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 diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index d4882b44cab..1e55b283ae0 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -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": { diff --git a/layout/style/test/test_transitions_per_property.html b/layout/style/test/test_transitions_per_property.html index 097384e8a5c..52f6187bed5 100644 --- a/layout/style/test/test_transitions_per_property.html +++ b/layout/style/test/test_transitions_per_property.html @@ -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");