mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bug 629200 part 12 - Remove unnecessary serialisation from setting nsSVGInteger; r=jwatt
This commit is contained in:
parent
d81431bbb1
commit
1f3dd3edf9
@ -331,6 +331,13 @@ nsAttrValue::SetTo(PRInt16 aInt)
|
||||
SetIntValueAndType(aInt, eInteger, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrValue::SetTo(PRInt32 aInt, const nsAString* aSerialized)
|
||||
{
|
||||
ResetIfSet();
|
||||
SetIntValueAndType(aInt, eInteger, aSerialized);
|
||||
}
|
||||
|
||||
void
|
||||
nsAttrValue::SetTo(double aValue, const nsAString* aSerialized)
|
||||
{
|
||||
|
@ -143,6 +143,7 @@ public:
|
||||
void SetTo(const nsAString& aValue);
|
||||
void SetTo(nsIAtom* aValue);
|
||||
void SetTo(PRInt16 aInt);
|
||||
void SetTo(PRInt32 aInt, const nsAString* aSerialized);
|
||||
void SetTo(double aValue, const nsAString* aSerialized);
|
||||
void SetTo(mozilla::css::StyleRule* aValue, const nsAString* aSerialized);
|
||||
void SetTo(const nsIntMargin& aValue);
|
||||
|
@ -430,6 +430,9 @@ nsSVGElement::ParseAttribute(PRInt32 aNamespaceID,
|
||||
rv = integerInfo.mIntegers[i].SetBaseValueString(aValue, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
integerInfo.Reset(i);
|
||||
} else {
|
||||
aResult.SetTo(integerInfo.mIntegers[i].GetBaseValue(), &aValue);
|
||||
didSetResult = true;
|
||||
}
|
||||
foundMatch = true;
|
||||
break;
|
||||
@ -689,7 +692,6 @@ nsSVGElement::UnsetAttrInternal(PRInt32 aNamespaceID, nsIAtom* aName,
|
||||
for (PRUint32 i = 0; i < intInfo.mIntegerCount; i++) {
|
||||
if (aName == *intInfo.mIntegerInfo[i].mName) {
|
||||
intInfo.Reset(i);
|
||||
DidChangeInteger(i, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1914,22 +1916,17 @@ void nsSVGElement::IntegerAttributesInfo::Reset(PRUint8 aAttrEnum)
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGElement::DidChangeInteger(PRUint8 aAttrEnum, bool aDoSetAttr)
|
||||
nsSVGElement::DidChangeInteger(PRUint8 aAttrEnum)
|
||||
{
|
||||
if (!aDoSetAttr)
|
||||
return;
|
||||
|
||||
IntegerAttributesInfo info = GetIntegerInfo();
|
||||
|
||||
NS_ASSERTION(info.mIntegerCount > 0,
|
||||
"DidChangeInteger on element with no integer attribs");
|
||||
|
||||
NS_ASSERTION(aAttrEnum < info.mIntegerCount, "aAttrEnum out of range");
|
||||
|
||||
nsAutoString serializedValue;
|
||||
info.mIntegers[aAttrEnum].GetBaseValueString(serializedValue);
|
||||
nsAttrValue attrValue;
|
||||
attrValue.SetTo(info.mIntegers[aAttrEnum].GetBaseValue(), nsnull);
|
||||
|
||||
nsAttrValue attrValue(serializedValue);
|
||||
SetParsedAttr(kNameSpaceID_None, *info.mIntegerInfo[aAttrEnum].mName, nsnull,
|
||||
attrValue, true);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public:
|
||||
void DidChangeNumber(PRUint8 aAttrEnum);
|
||||
void DidChangeNumberPair(PRUint8 aAttrEnum,
|
||||
const nsAttrValue& aEmptyOrOldValue);
|
||||
virtual void DidChangeInteger(PRUint8 aAttrEnum, bool aDoSetAttr);
|
||||
void DidChangeInteger(PRUint8 aAttrEnum);
|
||||
virtual void DidChangeIntegerPair(PRUint8 aAttrEnum, bool aDoSetAttr);
|
||||
virtual void DidChangeAngle(PRUint8 aAttrEnum, bool aDoSetAttr);
|
||||
virtual void DidChangeBoolean(PRUint8 aAttrEnum, bool aDoSetAttr);
|
||||
|
@ -106,9 +106,16 @@ nsSVGInteger::GetBaseValueString(nsAString & aValueAsString)
|
||||
}
|
||||
|
||||
void
|
||||
nsSVGInteger::SetBaseValue(int aValue,
|
||||
nsSVGElement *aSVGElement)
|
||||
nsSVGInteger::SetBaseValue(int aValue, nsSVGElement *aSVGElement)
|
||||
{
|
||||
// We can't just rely on SetParsedAttrValue (as called by DidChangeInteger)
|
||||
// detecting redundant changes since it will compare false if the existing
|
||||
// attribute value has an associated serialized version (a string value) even
|
||||
// if the integers match due to the way integers are stored in nsAttrValue.
|
||||
if (aValue == mBaseVal && mIsBaseSet) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBaseVal = aValue;
|
||||
mIsBaseSet = true;
|
||||
if (!mIsAnimated) {
|
||||
@ -117,7 +124,7 @@ nsSVGInteger::SetBaseValue(int aValue,
|
||||
else {
|
||||
aSVGElement->AnimationNeedsResample();
|
||||
}
|
||||
aSVGElement->DidChangeInteger(mAttrEnum, true);
|
||||
aSVGElement->DidChangeInteger(mAttrEnum);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -114,6 +114,10 @@ function runTests()
|
||||
convolve.targetX.baseVal = 7;
|
||||
is(convolve.targetX.animVal, 7, "integer animVal");
|
||||
is(convolve.getAttribute("targetX"), "7", "integer attribute");
|
||||
convolve.setAttribute("targetX", "");
|
||||
ok(convolve.getAttribute("targetX") === "", "empty integer attribute");
|
||||
convolve.removeAttribute("targetX");
|
||||
ok(convolve.getAttribute("targetX") === null, "removed integer attribute");
|
||||
|
||||
// integer-optional-integer attribute
|
||||
|
||||
|
@ -91,6 +91,24 @@ function runTests()
|
||||
blur.stdDeviationY.baseVal = 3;
|
||||
blur.setAttribute("stdDeviation", "2, 3");
|
||||
|
||||
// integer attribute
|
||||
|
||||
eventChecker.watchAttr(convolve, "targetX");
|
||||
eventChecker.expect("add modify remove add");
|
||||
convolve.setAttribute("targetX", "12");
|
||||
convolve.targetX.baseVal = 6;
|
||||
convolve.removeAttribute("targetX");
|
||||
convolve.targetX.baseVal = 8;
|
||||
|
||||
// Check redundant change when comparing typed value to attribute value
|
||||
eventChecker.expect("");
|
||||
convolve.setAttribute("targetX", "8");
|
||||
// Check redundant change when comparing attribute value to typed value
|
||||
eventChecker.expect("remove add");
|
||||
convolve.removeAttribute("targetX");
|
||||
convolve.setAttribute("targetX", "8");
|
||||
convolve.targetX.baseVal = 8;
|
||||
|
||||
// enum attribute
|
||||
|
||||
eventChecker.watchAttr(convolve, "edgeMode");
|
||||
|
Loading…
Reference in New Issue
Block a user