Bug 554704: Rename "aCanCache" param (for nsISMILAttr::ValueFromString), r=dholbert, r=jwatt

This commit is contained in:
Felipe Corrêa da Silva Sanches 2010-06-23 17:30:55 -07:00
parent 6da3ab3084
commit ac6104327b
29 changed files with 86 additions and 76 deletions

View File

@ -69,16 +69,17 @@ public:
* animateTransform where the 'type' attribute is needed to
* parse the value.
* @param[out] aValue Outparam for storing the parsed value.
* @param[out] aCanCache Outparam for indicating whether the parsed value
* can be reused in future samples -- i.e. whether the
* given string is always guaranteed to compute
* to the same nsSMILValue.
* @param[out] aPreventCachingOfSandwich
* Outparam to indicate whether the attribute contains
* dependencies on its context that should prevent the
* result of the animation sandwich from being cached and
* reused in future samples.
* @return NS_OK on success or an error code if creation failed.
*/
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const = 0;
PRBool& aPreventCachingOfSandwich) const = 0;
/**
* Gets the underlying value of this attribute.

View File

@ -694,10 +694,12 @@ nsSMILAnimationFunction::GetAttr(nsIAtom* aAttName, nsAString& aResult) const
* @param aAttName The attribute name (in the global namespace).
* @param aSMILAttr The SMIL attribute to perform the parsing.
* @param[out] aResult The resulting nsSMILValue.
* @param[out] aCanCacheSoFar If |aResult| cannot be cached (as reported by
* nsISMILAttr::ValueFromString), then this outparam
* will be set to PR_FALSE. Otherwise, this outparam
* won't be modified.
* @param[out] aPreventCachingOfSandwich
* If |aResult| contains dependencies on its context that
* should prevent the result of the animation sandwich from
* being cached and reused in future samples (as reported
* by nsISMILAttr::ValueFromString), then this outparam
* will be set to PR_TRUE. Otherwise it is left unmodified.
*
* Returns PR_FALSE if a parse error occurred, otherwise returns PR_TRUE.
*/
@ -705,18 +707,18 @@ PRBool
nsSMILAnimationFunction::ParseAttr(nsIAtom* aAttName,
const nsISMILAttr& aSMILAttr,
nsSMILValue& aResult,
PRBool& aCanCacheSoFar) const
PRBool& aPreventCachingOfSandwich) const
{
nsAutoString attValue;
if (GetAttr(aAttName, attValue)) {
PRBool canCache;
PRBool preventCachingOfSandwich;
nsresult rv = aSMILAttr.ValueFromString(attValue, mAnimationElement,
aResult, canCache);
aResult, preventCachingOfSandwich);
if (NS_FAILED(rv))
return PR_FALSE;
if (!canCache) {
aCanCacheSoFar = PR_FALSE;
if (preventCachingOfSandwich) {
aPreventCachingOfSandwich = PR_TRUE;
}
}
return PR_TRUE;
@ -750,25 +752,29 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
if (HasAttr(nsGkAtoms::values)) {
nsAutoString attValue;
GetAttr(nsGkAtoms::values, attValue);
PRBool canCache;
PRBool preventCachingOfSandwich;
nsresult rv = nsSMILParserUtils::ParseValues(attValue, mAnimationElement,
aSMILAttr, result, canCache);
aSMILAttr, result,
preventCachingOfSandwich);
if (NS_FAILED(rv))
return rv;
if (!canCache) {
if (preventCachingOfSandwich) {
mValueNeedsReparsingEverySample = PR_TRUE;
}
// Else try to/from/by
} else {
PRBool canCacheSoFar = PR_TRUE;
PRBool preventCachingOfSandwich = PR_FALSE;
PRBool parseOk = PR_TRUE;
nsSMILValue to, from, by;
parseOk &= ParseAttr(nsGkAtoms::to, aSMILAttr, to, canCacheSoFar);
parseOk &= ParseAttr(nsGkAtoms::from, aSMILAttr, from, canCacheSoFar);
parseOk &= ParseAttr(nsGkAtoms::by, aSMILAttr, by, canCacheSoFar);
parseOk &= ParseAttr(nsGkAtoms::to, aSMILAttr, to,
preventCachingOfSandwich);
parseOk &= ParseAttr(nsGkAtoms::from, aSMILAttr, from,
preventCachingOfSandwich);
parseOk &= ParseAttr(nsGkAtoms::by, aSMILAttr, by,
preventCachingOfSandwich);
if (!canCacheSoFar) {
if (preventCachingOfSandwich) {
mValueNeedsReparsingEverySample = PR_TRUE;
}

View File

@ -321,7 +321,8 @@ protected:
nsAString& aResult) const;
PRBool ParseAttr(nsIAtom* aAttName, const nsISMILAttr& aSMILAttr,
nsSMILValue& aResult, PRBool& aCanCacheSoFar) const;
nsSMILValue& aResult,
PRBool& aPreventCachingOfSandwich) const;
virtual nsresult GetValues(const nsISMILAttr& aSMILAttr,
nsSMILValueArray& aResult);

View File

@ -155,7 +155,7 @@ nsresult
nsSMILCSSProperty::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
@ -168,11 +168,12 @@ nsSMILCSSProperty::ValueFromString(const nsAString& aStr,
// reparsed every sample. This prevents us from doing the "nothing's changed
// so don't recompose" optimization (bug 533291) for CSS properties & mapped
// attributes. If it ends up being expensive to always recompose those, we
// can be a little smarter here. We really only need to disable aCanCache
// for "inherit" & "currentColor" (whose values could change at any time), as
// well as for length-valued types (particularly those with em/ex/percent
// units, since their conversion ratios can change at any time).
aCanCache = PR_FALSE;
// can be a little smarter here. We really only need to set
// aPreventCachingOfSandwich to true for "inherit" & "currentColor" (whose
// values could change at any time), for length-valued types (particularly
// those with em/ex/percent units, since their conversion ratios can change
// at any time), and for any value for 'font-family'.
aPreventCachingOfSandwich = PR_TRUE;
return NS_OK;
}

View File

@ -73,7 +73,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual nsresult SetAnimValue(const nsSMILValue& aValue);
virtual void ClearAnimValue();

View File

@ -62,7 +62,7 @@ nsresult
nsSMILMappedAttribute::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
@ -73,7 +73,7 @@ nsSMILMappedAttribute::ValueFromString(const nsAString& aStr,
// XXXdholbert: For simplicity, just assume that all CSS values have to
// reparsed every sample. See note in nsSMILCSSProperty::ValueFromString.
aCanCache = PR_FALSE;
aPreventCachingOfSandwich = PR_TRUE;
return NS_OK;
}

View File

@ -73,7 +73,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual nsresult SetAnimValue(const nsSMILValue& aValue);
virtual void ClearAnimValue();

View File

@ -548,26 +548,26 @@ public:
SMILValueParser(const nsISMILAnimationElement* aSrcElement,
const nsISMILAttr* aSMILAttr,
nsTArray<nsSMILValue>* aValuesArray,
PRBool* aCanCache) :
PRBool* aPreventCachingOfSandwich) :
mSrcElement(aSrcElement),
mSMILAttr(aSMILAttr),
mValuesArray(aValuesArray),
mCanCache(aCanCache)
mPreventCachingOfSandwich(aPreventCachingOfSandwich)
{}
virtual nsresult Parse(const nsAString& aValueStr) {
nsSMILValue newValue;
PRBool tmpCanCache;
nsresult rv = mSMILAttr->ValueFromString(aValueStr, mSrcElement,
newValue, tmpCanCache);
PRBool tmpPreventCachingOfSandwich;
nsresult rv = mSMILAttr->ValueFromString(aValueStr, mSrcElement, newValue,
tmpPreventCachingOfSandwich);
if (NS_FAILED(rv))
return rv;
if (!mValuesArray->AppendElement(newValue)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (!tmpCanCache) {
*mCanCache = PR_FALSE;
if (tmpPreventCachingOfSandwich) {
*mPreventCachingOfSandwich = PR_TRUE;
}
return NS_OK;
}
@ -575,7 +575,7 @@ protected:
const nsISMILAnimationElement* mSrcElement;
const nsISMILAttr* mSMILAttr;
nsTArray<nsSMILValue>* mValuesArray;
PRBool* mCanCache;
PRBool* mPreventCachingOfSandwich;
};
nsresult
@ -583,12 +583,12 @@ nsSMILParserUtils::ParseValues(const nsAString& aSpec,
const nsISMILAnimationElement* aSrcElement,
const nsISMILAttr& aAttribute,
nsTArray<nsSMILValue>& aValuesArray,
PRBool& aCanCache)
PRBool& aPreventCachingOfSandwich)
{
// Assume all results can be cached, until we find one that can't.
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
SMILValueParser valueParser(aSrcElement, &aAttribute,
&aValuesArray, &aCanCache);
&aValuesArray, &aPreventCachingOfSandwich);
return ParseValuesGeneric(aSpec, valueParser);
}

View File

@ -75,7 +75,7 @@ public:
const nsISMILAnimationElement* aSrcElement,
const nsISMILAttr& aAttribute,
nsTArray<nsSMILValue>& aValuesArray,
PRBool& aCanCache);
PRBool& aPreventCachingOfSandwich);
// Generic method that will run some code on each sub-section of an animation
// element's "values" list.

View File

@ -54,7 +54,7 @@ nsresult
SVGMotionSMILAttr::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
NS_NOTREACHED("Shouldn't using nsISMILAttr::ValueFromString for parsing "
"animateMotion's SMIL values.");

View File

@ -62,7 +62,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual nsresult SetAnimValue(const nsSMILValue& aValue);
virtual void ClearAnimValue();

View File

@ -440,7 +440,7 @@ nsresult
nsSVGAngle::SMILOrient::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
nsSMILValue val(&SVGOrientSMILType::sSingleton);
if (aStr.EqualsLiteral("auto")) {
@ -457,7 +457,7 @@ nsSVGAngle::SMILOrient::ValueFromString(const nsAString& aStr,
val.mU.mOrient.mOrientType = nsIDOMSVGMarkerElement::SVG_MARKER_ORIENT_ANGLE;
}
aValue.Swap(val);
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -226,7 +226,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -146,7 +146,7 @@ nsresult
nsSVGBoolean::SMILBool::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
nsSMILValue val(&SMILBoolType::sSingleton);
@ -158,7 +158,7 @@ nsSVGBoolean::SMILBool::ValueFromString(const nsAString& aStr,
return NS_ERROR_FAILURE;
aValue = val;
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -124,7 +124,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -177,7 +177,7 @@ nsresult
nsSVGEnum::SMILEnum::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
nsCOMPtr<nsIAtom> valAtom = do_GetAtom(aStr);
nsSVGEnumMapping *mapping = mVal->GetMapping(mSVGElement);
@ -187,7 +187,7 @@ nsSVGEnum::SMILEnum::ValueFromString(const nsAString& aStr,
nsSMILValue val(&SMILEnumType::sSingleton);
val.mU.mUint = mapping->mVal;
aValue = val;
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}
mapping++;

View File

@ -134,7 +134,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -140,7 +140,7 @@ nsresult
nsSVGInteger::SMILInteger::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
NS_ConvertUTF16toUTF8 value(aStr);
const char *str = value.get();
@ -157,7 +157,7 @@ nsSVGInteger::SMILInteger::ValueFromString(const nsAString& aStr,
nsSMILValue smilVal(&SMILIntegerType::sSingleton);
smilVal.mU.mInt = val;
aValue = smilVal;
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -124,7 +124,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -522,7 +522,7 @@ nsresult
nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
float value;
PRUint16 unitType;
@ -535,9 +535,10 @@ nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr,
nsSMILValue val(&nsSMILFloatType::sSingleton);
val.mU.mDouble = value / mVal->GetUnitScaleFactor(mSVGElement, unitType);
aValue = val;
aCanCache = (unitType != nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE &&
unitType != nsIDOMSVGLength::SVG_LENGTHTYPE_EMS &&
unitType != nsIDOMSVGLength::SVG_LENGTHTYPE_EXS);
aPreventCachingOfSandwich =
(unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EMS ||
unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_EXS);
return NS_OK;
}

View File

@ -282,7 +282,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue &aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -175,7 +175,7 @@ nsresult
nsSVGNumber2::SMILNumber::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
float value;
@ -187,7 +187,7 @@ nsSVGNumber2::SMILNumber::ValueFromString(const nsAString& aStr,
nsSMILValue val(&nsSMILFloatType::sSingleton);
val.mU.mDouble = value;
aValue = val;
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -134,7 +134,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -350,7 +350,7 @@ nsSVGPreserveAspectRatio::SMILPreserveAspectRatio
::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
PreserveAspectRatio par;
nsresult res = ToPreserveAspectRatio(aStr, &par);
@ -359,7 +359,7 @@ nsSVGPreserveAspectRatio::SMILPreserveAspectRatio
nsSMILValue val(&SMILEnumType::sSingleton);
val.mU.mUint = PackPreserveAspectRatio(par);
aValue = val;
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -225,7 +225,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -55,7 +55,7 @@ nsresult
nsSVGTransformSMILAttr::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
NS_ENSURE_TRUE(aSrcElement, NS_ERROR_FAILURE);
NS_ASSERTION(aValue.IsNull(),
@ -67,7 +67,7 @@ nsSVGTransformSMILAttr::ValueFromString(const nsAString& aStr,
: nsGkAtoms::translate;
ParseValue(aStr, transformType, aValue);
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return aValue.IsNull() ? NS_ERROR_FAILURE : NS_OK;
}

View File

@ -60,7 +60,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);

View File

@ -282,7 +282,7 @@ nsSVGViewBox::SMILViewBox
::ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* /*aSrcElement*/,
nsSMILValue& aValue,
PRBool& aCanCache) const
PRBool& aPreventCachingOfSandwich) const
{
nsSVGViewBoxRect viewBox;
nsresult res = ToSVGViewBoxRect(aStr, &viewBox);
@ -292,7 +292,7 @@ nsSVGViewBox::SMILViewBox
nsSMILValue val(&SVGViewBoxSMILType::sSingleton);
*static_cast<nsSVGViewBoxRect*>(val.mU.mPtr) = viewBox;
aValue.Swap(val);
aCanCache = PR_TRUE;
aPreventCachingOfSandwich = PR_FALSE;
return NS_OK;
}

View File

@ -211,7 +211,7 @@ public:
virtual nsresult ValueFromString(const nsAString& aStr,
const nsISMILAnimationElement* aSrcElement,
nsSMILValue& aValue,
PRBool& aCanCache) const;
PRBool& aPreventCachingOfSandwich) const;
virtual nsSMILValue GetBaseValue() const;
virtual void ClearAnimValue();
virtual nsresult SetAnimValue(const nsSMILValue& aValue);