Bug 641393 patch 3: Make SVGLengthListSMILType logic match other list types. r=jwatt

This commit is contained in:
Daniel Holbert 2011-04-14 11:47:27 -07:00
Родитель 8628380e49
Коммит bafc722919
1 изменённых файлов: 38 добавлений и 12 удалений

Просмотреть файл

@ -122,16 +122,41 @@ SVGLengthListSMILType::Add(nsSMILValue& aDest,
// should be, not zeros, and those values are not explicit or otherwise // should be, not zeros, and those values are not explicit or otherwise
// available. // available.
NS_ABORT_IF_FALSE(!dest.IsEmpty() || !valueToAdd.IsEmpty(),
"Expecting at least one non-identity operand");
if (!valueToAdd.Element()) { // Adding identity value - no-op
NS_ABORT_IF_FALSE(valueToAdd.IsEmpty(),
"Identity values should be empty");
return NS_OK;
}
if (!dest.Element()) { // Adding *to* an identity value
NS_ABORT_IF_FALSE(dest.IsEmpty(),
"Identity values should be empty");
if (!dest.SetLength(valueToAdd.Length())) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (PRUint32 i = 0; i < dest.Length(); ++i) {
dest[i].SetValueAndUnit(valueToAdd[i].GetValueInCurrentUnits() * aCount,
valueToAdd[i].GetUnit());
}
dest.SetInfo(valueToAdd.Element(), valueToAdd.Axis(),
valueToAdd.CanZeroPadList()); // propagate target element info!
return NS_OK;
}
NS_ABORT_IF_FALSE(dest.Element() == valueToAdd.Element(),
"adding values from different elements...?");
// Zero-pad our |dest| list, if necessary.
if (dest.Length() < valueToAdd.Length()) { if (dest.Length() < valueToAdd.Length()) {
if (!dest.CanZeroPadList()) { if (!dest.CanZeroPadList()) {
// nsSVGUtils::ReportToConsole // nsSVGUtils::ReportToConsole
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_ASSERTION(valueToAdd.CanZeroPadList() || dest.Length() == 0, NS_ABORT_IF_FALSE(valueToAdd.CanZeroPadList(),
"Only \"zero\" nsSMILValues from the SMIL engine should " "values disagree about attribute's zero-paddibility");
"return PR_TRUE for CanZeroPadList() when the attribute "
"being animated can't be zero padded");
PRUint32 i = dest.Length(); PRUint32 i = dest.Length();
if (!dest.SetLength(valueToAdd.Length())) { if (!dest.SetLength(valueToAdd.Length())) {
@ -153,13 +178,14 @@ SVGLengthListSMILType::Add(nsSMILValue& aDest,
dest.Element(), dest.Element(),
dest.Axis()); dest.Axis());
} }
dest[i].SetValueAndUnit(dest[i].GetValueInCurrentUnits() + valToAdd, dest[i].SetValueAndUnit(
dest[i].GetUnit()); dest[i].GetValueInCurrentUnits() + valToAdd * aCount,
dest[i].GetUnit());
} }
// propagate flag: // propagate target element info!
dest.SetCanZeroPadList(dest.CanZeroPadList() && dest.SetInfo(valueToAdd.Element(), valueToAdd.Axis(),
valueToAdd.CanZeroPadList()); dest.CanZeroPadList() && valueToAdd.CanZeroPadList());
return NS_OK; return NS_OK;
} }
@ -299,9 +325,9 @@ SVGLengthListSMILType::Interpolate(const nsSMILValue& aStartVal,
end[i].GetUnit()); end[i].GetUnit());
} }
// propagate flag: // propagate target element info!
result.SetCanZeroPadList(start.CanZeroPadList() && result.SetInfo(end.Element(), end.Axis(),
end.CanZeroPadList()); start.CanZeroPadList() && end.CanZeroPadList());
return NS_OK; return NS_OK;
} }