From 0b1ce291e2f55ed73131295a51beb7b2d1fae790 Mon Sep 17 00:00:00 2001 From: "dbaron@dbaron.org" Date: Mon, 14 May 2007 22:13:49 -0700 Subject: [PATCH] Handle -moz-initial for 'font' shorthand (and fix bugs in some of its subproperties). b=377521 r+sr=bzbarsky --- layout/style/nsCSSParser.cpp | 3 ++- layout/style/nsRuleNode.cpp | 16 ++++++++++------ layout/style/test/test_initial_computation.html | 3 --- layout/style/test/test_initial_storage.html | 3 +-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 09180938f3f..b1f39df47a4 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -5591,7 +5591,8 @@ PRBool CSSParserImpl::ParseFont(nsresult& aErrorCode) nsCSSValue family; if (ParseVariant(aErrorCode, family, VARIANT_HK, nsCSSProps::kFontKTable)) { if (ExpectEndProperty(aErrorCode, PR_TRUE)) { - if (eCSSUnit_Inherit == family.GetUnit()) { + if (eCSSUnit_Inherit == family.GetUnit() || + eCSSUnit_Initial == family.GetUnit()) { AppendValue(eCSSProperty_font_family, family); AppendValue(eCSSProperty_font_style, family); AppendValue(eCSSProperty_font_variant, family); diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 7eeee63df62..b72f2d459b2 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1993,7 +1993,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext, aFont->mFont.familyNameQuirks = aParentFont->mFont.familyNameQuirks; } else if (eCSSUnit_Initial == aFontData.mFamily.GetUnit()) { - aFont->mFont.name = aDefaultFont.name; + aFont->mFont.name = defaultVariableFont->name; aFont->mFont.familyNameQuirks = PR_FALSE; } @@ -2009,7 +2009,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext, aFont->mFont.style = aParentFont->mFont.style; } else if (eCSSUnit_Initial == aFontData.mStyle.GetUnit()) { - aFont->mFont.style = aDefaultFont.style; + aFont->mFont.style = defaultVariableFont->style; } // font-variant: enum, normal, inherit @@ -2024,7 +2024,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext, aFont->mFont.variant = aParentFont->mFont.variant; } else if (eCSSUnit_Initial == aFontData.mVariant.GetUnit()) { - aFont->mFont.variant = aDefaultFont.variant; + aFont->mFont.variant = defaultVariableFont->variant; } // font-weight: int, enum, normal, inherit @@ -2053,7 +2053,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext, aFont->mFont.weight = aParentFont->mFont.weight; } else if (eCSSUnit_Initial == aFontData.mWeight.GetUnit()) { - aFont->mFont.weight = aDefaultFont.weight; + aFont->mFont.weight = defaultVariableFont->weight; } // font-size: enum, length, percent, inherit @@ -2114,7 +2114,7 @@ nsRuleNode::SetFont(nsPresContext* aPresContext, nsStyleContext* aContext, zoom = PR_FALSE; } else if (eCSSUnit_Initial == aFontData.mSize.GetUnit()) { - aFont->mSize = aDefaultFont.size; + aFont->mSize = defaultVariableFont->size; zoom = PR_TRUE; } @@ -2349,7 +2349,11 @@ nsRuleNode::ComputeTextData(nsStyleStruct* aStartStruct, text->mLineHeight.SetCoordValue( nscoord(float(aContext->GetStyleFont()->mFont.size) * textData.mLineHeight.GetPercentValue())); - } else { + } + else if (eCSSUnit_Initial == textData.mLineHeight.GetUnit()) { + text->mLineHeight.SetNormalValue(); + } + else { SetCoord(textData.mLineHeight, text->mLineHeight, parentText->mLineHeight, SETCOORD_LH | SETCOORD_FACTOR | SETCOORD_NORMAL, aContext, mPresContext, inherited); diff --git a/layout/style/test/test_initial_computation.html b/layout/style/test/test_initial_computation.html index dc58d838142..6a239b71748 100644 --- a/layout/style/test/test_initial_computation.html +++ b/layout/style/test/test_initial_computation.html @@ -128,12 +128,9 @@ var gBrokenInitial = { "direction": true, "display": true, "empty-cells": true, - "font": true, // XXX This one is weird. - "font-family": true, // XXX This one is weird. "height": true, "left": true, "letter-spacing": true, - "line-height": true, "list-style": true, "list-style-image": true, "list-style-position": true, diff --git a/layout/style/test/test_initial_storage.html b/layout/style/test/test_initial_storage.html index 52c22d40de8..85675fa5321 100644 --- a/layout/style/test/test_initial_storage.html +++ b/layout/style/test/test_initial_storage.html @@ -87,8 +87,7 @@ function test_property(property) var sinfo = gCSSProperties[sproperty]; val = gDeclaration.getPropertyValue(sproperty); var func = is; - if ((sproperty == property && property in gKnownFails) || - (property == "font" && sproperty != "font-family")) /* bug 377521 */ + if (sproperty == property && property in gKnownFails) func = todo_is; func(val, "-moz-initial", "-moz-initial reported back for property '" + sproperty + "'");