Bug 921731 - Part 1: Add new eCSSUnit_Unset unit for nsCSSValues. r=bzbarsky

This commit is contained in:
Cameron McCormack 2013-10-04 04:49:17 +10:00
parent b95c636898
commit 48fc905829
2 changed files with 33 additions and 11 deletions

View File

@ -397,7 +397,9 @@ void nsCSSValue::SetPairValue(const nsCSSValuePair* aValue)
aValue->mXValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mYValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial,
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate pair value");
Reset();
mUnit = eCSSUnit_Pair;
@ -413,7 +415,9 @@ void nsCSSValue::SetPairValue(const nsCSSValue& xValue,
xValue.GetUnit() != eCSSUnit_Inherit &&
yValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial,
yValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset,
"inappropriate pair value");
Reset();
mUnit = eCSSUnit_Pair;
@ -433,7 +437,10 @@ void nsCSSValue::SetTripletValue(const nsCSSValueTriplet* aValue)
aValue->mZValue.GetUnit() != eCSSUnit_Inherit &&
aValue->mXValue.GetUnit() != eCSSUnit_Initial &&
aValue->mYValue.GetUnit() != eCSSUnit_Initial &&
aValue->mZValue.GetUnit() != eCSSUnit_Initial,
aValue->mZValue.GetUnit() != eCSSUnit_Initial &&
aValue->mXValue.GetUnit() != eCSSUnit_Unset &&
aValue->mYValue.GetUnit() != eCSSUnit_Unset &&
aValue->mZValue.GetUnit() != eCSSUnit_Unset,
"missing or inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
@ -453,7 +460,10 @@ void nsCSSValue::SetTripletValue(const nsCSSValue& xValue,
zValue.GetUnit() != eCSSUnit_Inherit &&
xValue.GetUnit() != eCSSUnit_Initial &&
yValue.GetUnit() != eCSSUnit_Initial &&
zValue.GetUnit() != eCSSUnit_Initial,
zValue.GetUnit() != eCSSUnit_Initial &&
xValue.GetUnit() != eCSSUnit_Unset &&
yValue.GetUnit() != eCSSUnit_Unset &&
zValue.GetUnit() != eCSSUnit_Unset,
"inappropriate triplet value");
Reset();
mUnit = eCSSUnit_Triplet;
@ -524,6 +534,12 @@ void nsCSSValue::SetInitialValue()
mUnit = eCSSUnit_Initial;
}
void nsCSSValue::SetUnsetValue()
{
Reset();
mUnit = eCSSUnit_Unset;
}
void nsCSSValue::SetNoneValue()
{
Reset();
@ -1165,6 +1181,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
case eCSSUnit_Auto: aResult.AppendLiteral("auto"); break;
case eCSSUnit_Inherit: aResult.AppendLiteral("inherit"); break;
case eCSSUnit_Initial: aResult.AppendLiteral("initial"); break;
case eCSSUnit_Unset: aResult.AppendLiteral("unset"); break;
case eCSSUnit_None: aResult.AppendLiteral("none"); break;
case eCSSUnit_Normal: aResult.AppendLiteral("normal"); break;
case eCSSUnit_System_Font: aResult.AppendLiteral("-moz-use-system-font"); break;
@ -1253,6 +1270,7 @@ nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
case eCSSUnit_Auto:
case eCSSUnit_Inherit:
case eCSSUnit_Initial:
case eCSSUnit_Unset:
case eCSSUnit_None:
case eCSSUnit_Normal:
case eCSSUnit_System_Font:
@ -1491,7 +1509,8 @@ nsCSSRect::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const
{
NS_ABORT_IF_FALSE(mTop.GetUnit() != eCSSUnit_Null &&
mTop.GetUnit() != eCSSUnit_Inherit &&
mTop.GetUnit() != eCSSUnit_Initial,
mTop.GetUnit() != eCSSUnit_Initial &&
mTop.GetUnit() != eCSSUnit_Unset,
"parser should have used a bare value");
if (eCSSProperty_border_image_slice == aProperty ||
@ -1642,6 +1661,7 @@ nsCSSValuePairList::AppendToString(nsCSSProperty aProperty,
item->mXValue.AppendToString(aProperty, aResult);
if (item->mXValue.GetUnit() != eCSSUnit_Inherit &&
item->mXValue.GetUnit() != eCSSUnit_Initial &&
item->mXValue.GetUnit() != eCSSUnit_Unset &&
item->mYValue.GetUnit() != eCSSUnit_Null) {
aResult.Append(PRUnichar(' '));
item->mYValue.AppendToString(aProperty, aResult);

View File

@ -139,13 +139,14 @@ enum nsCSSUnit {
eCSSUnit_Auto = 1, // (n/a) value is algorithmic
eCSSUnit_Inherit = 2, // (n/a) value is inherited
eCSSUnit_Initial = 3, // (n/a) value is default UA value
eCSSUnit_None = 4, // (n/a) value is none
eCSSUnit_Normal = 5, // (n/a) value is normal (algorithmic, different than auto)
eCSSUnit_System_Font = 6, // (n/a) value is -moz-use-system-font
eCSSUnit_All = 7, // (n/a) value is all
eCSSUnit_Dummy = 8, // (n/a) a fake but specified value, used
eCSSUnit_Unset = 4, // (n/a) value equivalent to 'initial' if on a reset property, 'inherit' otherwise
eCSSUnit_None = 5, // (n/a) value is none
eCSSUnit_Normal = 6, // (n/a) value is normal (algorithmic, different than auto)
eCSSUnit_System_Font = 7, // (n/a) value is -moz-use-system-font
eCSSUnit_All = 8, // (n/a) value is all
eCSSUnit_Dummy = 9, // (n/a) a fake but specified value, used
// only in temporary values
eCSSUnit_DummyInherit = 9, // (n/a) a fake but specified value, used
eCSSUnit_DummyInherit = 10, // (n/a) a fake but specified value, used
// only in temporary values
eCSSUnit_String = 11, // (PRUnichar*) a string value
@ -492,6 +493,7 @@ public:
void SetAutoValue();
void SetInheritValue();
void SetInitialValue();
void SetUnsetValue();
void SetNoneValue();
void SetAllValue();
void SetNormalValue();