зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1403405 - Don't create a temporary nsAngle object just to parse an angle r=birtles
This commit is contained in:
Родитель
c296ed9811
Коммит
7e327c39d3
|
@ -431,20 +431,14 @@ SVGMotionSMILAnimationFunction::SetRotate(const nsAString& aRotate,
|
|||
} else {
|
||||
mRotateType = eRotateType_Explicit;
|
||||
|
||||
// Parse numeric angle string, with the help of a temp nsSVGAngle.
|
||||
nsSVGAngle svgAngle;
|
||||
svgAngle.Init();
|
||||
nsresult rv = svgAngle.SetBaseValueString(aRotate, nullptr, false);
|
||||
if (NS_FAILED(rv)) { // Parse error
|
||||
uint16_t angleUnit;
|
||||
if (!nsSVGAngle::GetValueFromString(aRotate, mRotateAngle, &angleUnit)) {
|
||||
mRotateAngle = 0.0f; // set default rotate angle
|
||||
// XXX report to console?
|
||||
return rv;
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
}
|
||||
|
||||
mRotateAngle = svgAngle.GetBaseValInSpecifiedUnits();
|
||||
|
||||
// Convert to radian units, if we're not already in radians.
|
||||
uint8_t angleUnit = svgAngle.GetBaseValueUnit();
|
||||
if (angleUnit != SVG_ANGLETYPE_RAD) {
|
||||
mRotateAngle *= nsSVGAngle::GetDegreesPerUnit(angleUnit) /
|
||||
nsSVGAngle::GetDegreesPerUnit(SVG_ANGLETYPE_RAD);
|
||||
|
|
|
@ -90,10 +90,10 @@ GetValueString(nsAString &aValueAsString, float aValue, uint16_t aUnitType)
|
|||
aValueAsString.Append(unitString);
|
||||
}
|
||||
|
||||
static bool
|
||||
GetValueFromString(const nsAString& aString,
|
||||
float& aValue,
|
||||
uint16_t* aUnitType)
|
||||
/* static */ bool
|
||||
nsSVGAngle::GetValueFromString(const nsAString& aString,
|
||||
float& aValue,
|
||||
uint16_t* aUnitType)
|
||||
{
|
||||
RangedPtr<const char16_t> iter =
|
||||
SVGContentUtils::GetStartRangedPtr(aString);
|
||||
|
|
|
@ -73,6 +73,9 @@ public:
|
|||
ToDOMAnimatedAngle(nsSVGElement* aSVGElement);
|
||||
mozilla::UniquePtr<nsISMILAttr> ToSMILAttr(nsSVGElement* aSVGElement);
|
||||
|
||||
static bool GetValueFromString(const nsAString& aString,
|
||||
float& aValue,
|
||||
uint16_t* aUnitType);
|
||||
static float GetDegreesPerUnit(uint8_t aUnit);
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче