зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1216843 - Part 3: Use nsCSSValue instead of nscolor to store over 1.0 color components as an accumulated value so that we can correctly calculate intermediate values in interpolation. r=dholbert
MozReview-Commit-ID: GYdqYZA4xXf
This commit is contained in:
Родитель
f98523cf02
Коммит
447019c813
|
@ -566,8 +566,8 @@ StyleAnimationValue::ComputeDistance(nsCSSPropertyID aProperty,
|
||||||
// colors are premultiplied, but things work better when they are,
|
// colors are premultiplied, but things work better when they are,
|
||||||
// so use premultiplication. Spec issue is still open per
|
// so use premultiplication. Spec issue is still open per
|
||||||
// http://lists.w3.org/Archives/Public/www-style/2009Jul/0050.html
|
// http://lists.w3.org/Archives/Public/www-style/2009Jul/0050.html
|
||||||
nscolor startColor = aStartValue.GetColorValue();
|
nscolor startColor = aStartValue.GetCSSValueValue()->GetColorValue();
|
||||||
nscolor endColor = aEndValue.GetColorValue();
|
nscolor endColor = aEndValue.GetCSSValueValue()->GetColorValue();
|
||||||
|
|
||||||
// Get a color component on a 0-1 scale, which is much easier to
|
// Get a color component on a 0-1 scale, which is much easier to
|
||||||
// deal with when working with alpha.
|
// deal with when working with alpha.
|
||||||
|
@ -1268,7 +1268,8 @@ AddShadowItems(double aCoeff1, const nsCSSValue &aValue1,
|
||||||
aCoeff2, color2Value,
|
aCoeff2, color2Value,
|
||||||
resultColorValue);
|
resultColorValue);
|
||||||
MOZ_ASSERT(ok, "should not fail");
|
MOZ_ASSERT(ok, "should not fail");
|
||||||
resultArray->Item(4).SetColorValue(resultColorValue.GetColorValue());
|
resultArray->Item(4).SetColorValue(
|
||||||
|
resultColorValue.GetCSSValueValue()->GetColorValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(inset1 == inset2, "should match");
|
MOZ_ASSERT(inset1 == inset2, "should match");
|
||||||
|
@ -2408,8 +2409,8 @@ StyleAnimationValue::AddWeighted(nsCSSPropertyID aProperty,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case eUnit_Color: {
|
case eUnit_Color: {
|
||||||
nscolor color1 = aValue1.GetColorValue();
|
nscolor color1 = aValue1.GetCSSValueValue()->GetColorValue();
|
||||||
nscolor color2 = aValue2.GetColorValue();
|
nscolor color2 = aValue2.GetCSSValueValue()->GetColorValue();
|
||||||
nscolor resultColor;
|
nscolor resultColor;
|
||||||
|
|
||||||
// We are using AddWeighted() with a zero aCoeff2 for colors to
|
// We are using AddWeighted() with a zero aCoeff2 for colors to
|
||||||
|
@ -3118,14 +3119,11 @@ StyleAnimationValue::UncomputeValue(nsCSSPropertyID aProperty,
|
||||||
aSpecifiedValue.
|
aSpecifiedValue.
|
||||||
SetFloatValue(aComputedValue.GetFloatValue(), eCSSUnit_Number);
|
SetFloatValue(aComputedValue.GetFloatValue(), eCSSUnit_Number);
|
||||||
break;
|
break;
|
||||||
case eUnit_Color:
|
|
||||||
// colors can be alone, or part of a paint server
|
|
||||||
aSpecifiedValue.SetColorValue(aComputedValue.GetColorValue());
|
|
||||||
break;
|
|
||||||
case eUnit_CurrentColor:
|
case eUnit_CurrentColor:
|
||||||
aSpecifiedValue.SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);
|
aSpecifiedValue.SetIntValue(NS_COLOR_CURRENTCOLOR, eCSSUnit_EnumColor);
|
||||||
break;
|
break;
|
||||||
case eUnit_Calc:
|
case eUnit_Calc:
|
||||||
|
case eUnit_Color:
|
||||||
case eUnit_ObjectPosition:
|
case eUnit_ObjectPosition:
|
||||||
case eUnit_URL:
|
case eUnit_URL:
|
||||||
case eUnit_DiscreteCSSValue: {
|
case eUnit_DiscreteCSSValue: {
|
||||||
|
@ -3133,6 +3131,8 @@ StyleAnimationValue::UncomputeValue(nsCSSPropertyID aProperty,
|
||||||
// Sanity-check that the underlying unit in the nsCSSValue is what we
|
// Sanity-check that the underlying unit in the nsCSSValue is what we
|
||||||
// expect for our StyleAnimationValue::Unit:
|
// expect for our StyleAnimationValue::Unit:
|
||||||
MOZ_ASSERT((unit == eUnit_Calc && val->GetUnit() == eCSSUnit_Calc) ||
|
MOZ_ASSERT((unit == eUnit_Calc && val->GetUnit() == eCSSUnit_Calc) ||
|
||||||
|
(unit == eUnit_Color &&
|
||||||
|
nsCSSValue::IsNumericColorUnit(val->GetUnit())) ||
|
||||||
(unit == eUnit_ObjectPosition &&
|
(unit == eUnit_ObjectPosition &&
|
||||||
val->GetUnit() == eCSSUnit_Array) ||
|
val->GetUnit() == eCSSUnit_Array) ||
|
||||||
(unit == eUnit_URL && val->GetUnit() == eCSSUnit_URL) ||
|
(unit == eUnit_URL && val->GetUnit() == eCSSUnit_URL) ||
|
||||||
|
@ -4356,7 +4356,8 @@ StyleAnimationValue::StyleAnimationValue(float aFloat, FloatConstructorType)
|
||||||
StyleAnimationValue::StyleAnimationValue(nscolor aColor, ColorConstructorType)
|
StyleAnimationValue::StyleAnimationValue(nscolor aColor, ColorConstructorType)
|
||||||
{
|
{
|
||||||
mUnit = eUnit_Color;
|
mUnit = eUnit_Color;
|
||||||
mValue.mColor = aColor;
|
mValue.mCSSValue = new nsCSSValue();
|
||||||
|
mValue.mCSSValue->SetColorValue(aColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
StyleAnimationValue&
|
StyleAnimationValue&
|
||||||
|
@ -4389,10 +4390,8 @@ StyleAnimationValue::operator=(const StyleAnimationValue& aOther)
|
||||||
mValue.mFloat = aOther.mValue.mFloat;
|
mValue.mFloat = aOther.mValue.mFloat;
|
||||||
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
|
MOZ_ASSERT(!mozilla::IsNaN(mValue.mFloat));
|
||||||
break;
|
break;
|
||||||
case eUnit_Color:
|
|
||||||
mValue.mColor = aOther.mValue.mColor;
|
|
||||||
break;
|
|
||||||
case eUnit_Calc:
|
case eUnit_Calc:
|
||||||
|
case eUnit_Color:
|
||||||
case eUnit_ObjectPosition:
|
case eUnit_ObjectPosition:
|
||||||
case eUnit_URL:
|
case eUnit_URL:
|
||||||
case eUnit_DiscreteCSSValue:
|
case eUnit_DiscreteCSSValue:
|
||||||
|
@ -4514,7 +4513,8 @@ StyleAnimationValue::SetColorValue(nscolor aColor)
|
||||||
{
|
{
|
||||||
FreeValue();
|
FreeValue();
|
||||||
mUnit = eUnit_Color;
|
mUnit = eUnit_Color;
|
||||||
mValue.mColor = aColor;
|
mValue.mCSSValue = new nsCSSValue();
|
||||||
|
mValue.mCSSValue->SetColorValue(aColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -4668,9 +4668,8 @@ StyleAnimationValue::operator==(const StyleAnimationValue& aOther) const
|
||||||
case eUnit_Percent:
|
case eUnit_Percent:
|
||||||
case eUnit_Float:
|
case eUnit_Float:
|
||||||
return mValue.mFloat == aOther.mValue.mFloat;
|
return mValue.mFloat == aOther.mValue.mFloat;
|
||||||
case eUnit_Color:
|
|
||||||
return mValue.mColor == aOther.mValue.mColor;
|
|
||||||
case eUnit_Calc:
|
case eUnit_Calc:
|
||||||
|
case eUnit_Color:
|
||||||
case eUnit_ObjectPosition:
|
case eUnit_ObjectPosition:
|
||||||
case eUnit_URL:
|
case eUnit_URL:
|
||||||
case eUnit_DiscreteCSSValue:
|
case eUnit_DiscreteCSSValue:
|
||||||
|
|
|
@ -305,7 +305,8 @@ public:
|
||||||
eUnit_Coord,
|
eUnit_Coord,
|
||||||
eUnit_Percent,
|
eUnit_Percent,
|
||||||
eUnit_Float,
|
eUnit_Float,
|
||||||
eUnit_Color,
|
eUnit_Color, // nsCSSValue* (never null), always with an nscolor or
|
||||||
|
// an nsCSSValueFloatColor
|
||||||
eUnit_CurrentColor,
|
eUnit_CurrentColor,
|
||||||
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
eUnit_Calc, // nsCSSValue* (never null), always with a single
|
||||||
// calc() expression that's either length or length+percent
|
// calc() expression that's either length or length+percent
|
||||||
|
@ -332,7 +333,6 @@ private:
|
||||||
int32_t mInt;
|
int32_t mInt;
|
||||||
nscoord mCoord;
|
nscoord mCoord;
|
||||||
float mFloat;
|
float mFloat;
|
||||||
nscolor mColor;
|
|
||||||
nsCSSValue* mCSSValue;
|
nsCSSValue* mCSSValue;
|
||||||
nsCSSValuePair* mCSSValuePair;
|
nsCSSValuePair* mCSSValuePair;
|
||||||
nsCSSValueTriplet* mCSSValueTriplet;
|
nsCSSValueTriplet* mCSSValueTriplet;
|
||||||
|
@ -372,10 +372,6 @@ public:
|
||||||
NS_ASSERTION(mUnit == eUnit_Float, "unit mismatch");
|
NS_ASSERTION(mUnit == eUnit_Float, "unit mismatch");
|
||||||
return mValue.mFloat;
|
return mValue.mFloat;
|
||||||
}
|
}
|
||||||
nscolor GetColorValue() const {
|
|
||||||
NS_ASSERTION(mUnit == eUnit_Color, "unit mismatch");
|
|
||||||
return mValue.mColor;
|
|
||||||
}
|
|
||||||
nsCSSValue* GetCSSValueValue() const {
|
nsCSSValue* GetCSSValueValue() const {
|
||||||
NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch");
|
NS_ASSERTION(IsCSSValueUnit(mUnit), "unit mismatch");
|
||||||
return mValue.mCSSValue;
|
return mValue.mCSSValue;
|
||||||
|
@ -511,7 +507,8 @@ private:
|
||||||
aUnit == eUnit_Integer;
|
aUnit == eUnit_Integer;
|
||||||
}
|
}
|
||||||
static bool IsCSSValueUnit(Unit aUnit) {
|
static bool IsCSSValueUnit(Unit aUnit) {
|
||||||
return aUnit == eUnit_Calc ||
|
return aUnit == eUnit_Color ||
|
||||||
|
aUnit == eUnit_Calc ||
|
||||||
aUnit == eUnit_ObjectPosition ||
|
aUnit == eUnit_ObjectPosition ||
|
||||||
aUnit == eUnit_URL ||
|
aUnit == eUnit_URL ||
|
||||||
aUnit == eUnit_DiscreteCSSValue;
|
aUnit == eUnit_DiscreteCSSValue;
|
||||||
|
|
|
@ -1484,7 +1484,8 @@ ExtractColor(nsCSSPropertyID aProperty,
|
||||||
StyleAnimationValue val;
|
StyleAnimationValue val;
|
||||||
ExtractAnimationValue(aProperty, aStyleContext, val);
|
ExtractAnimationValue(aProperty, aStyleContext, val);
|
||||||
return val.GetUnit() == StyleAnimationValue::eUnit_CurrentColor
|
return val.GetUnit() == StyleAnimationValue::eUnit_CurrentColor
|
||||||
? aStyleContext->StyleColor()->mColor : val.GetColorValue();
|
? aStyleContext->StyleColor()->mColor
|
||||||
|
: val.GetCSSValueValue()->GetColorValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
static nscolor
|
static nscolor
|
||||||
|
@ -1494,7 +1495,7 @@ ExtractColorLenient(nsCSSPropertyID aProperty,
|
||||||
StyleAnimationValue val;
|
StyleAnimationValue val;
|
||||||
ExtractAnimationValue(aProperty, aStyleContext, val);
|
ExtractAnimationValue(aProperty, aStyleContext, val);
|
||||||
if (val.GetUnit() == StyleAnimationValue::eUnit_Color) {
|
if (val.GetUnit() == StyleAnimationValue::eUnit_Color) {
|
||||||
return val.GetColorValue();
|
return val.GetCSSValueValue()->GetColorValue();
|
||||||
} else if (val.GetUnit() == StyleAnimationValue::eUnit_CurrentColor) {
|
} else if (val.GetUnit() == StyleAnimationValue::eUnit_CurrentColor) {
|
||||||
return aStyleContext->StyleColor()->mColor;
|
return aStyleContext->StyleColor()->mColor;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче