Handle -moz-initial for 'font' shorthand (and fix bugs in some of its subproperties). b=377521 r+sr=bzbarsky

This commit is contained in:
dbaron@dbaron.org 2007-05-14 22:13:49 -07:00
parent 386c331ac3
commit 0b1ce291e2
4 changed files with 13 additions and 12 deletions

View File

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

View File

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

View File

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

View File

@ -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 + "'");