This commit is contained in:
Daniel Holbert 2010-03-25 09:20:35 -07:00
commit 3d7797465b
2 changed files with 7 additions and 17 deletions

View File

@ -96,11 +96,6 @@ nsSMILCSSProperty::nsSMILCSSProperty(nsCSSProperty aPropID,
nsSMILValue nsSMILValue
nsSMILCSSProperty::GetBaseValue() const nsSMILCSSProperty::GetBaseValue() const
{ {
// To benefit from Return Value Optimization and avoid copy constructor calls
// due to our use of return-by-value, we must return the exact same object
// from ALL return points. This function must only return THIS variable:
nsSMILValue baseValue;
// SPECIAL CASE: Shorthands // SPECIAL CASE: Shorthands
if (nsCSSProps::IsShorthand(mPropID)) { if (nsCSSProps::IsShorthand(mPropID)) {
// We can't look up the base (computed-style) value of shorthand // We can't look up the base (computed-style) value of shorthand
@ -111,12 +106,10 @@ nsSMILCSSProperty::GetBaseValue() const
// properties we know about don't support those operations. So, we can just // properties we know about don't support those operations. So, we can just
// return a dummy value (initialized with the right type, so as not to // return a dummy value (initialized with the right type, so as not to
// indicate failure). // indicate failure).
nsSMILValue tmpVal(&nsSMILCSSValueType::sSingleton); return nsSMILValue(&nsSMILCSSValueType::sSingleton);
baseValue.Swap(tmpVal);
return baseValue;
} }
// GENERAL CASE: Non-Shorthands // GENERAL CASE: Non-Shorthands
// (1) Put empty string in override style for property mPropID // (1) Put empty string in override style for property mPropID
// (saving old override style value, so we can set it again when we're done) // (saving old override style value, so we can set it again when we're done)
nsCOMPtr<nsIDOMCSSStyleDeclaration> overrideStyle; nsCOMPtr<nsIDOMCSSStyleDeclaration> overrideStyle;
@ -141,7 +134,8 @@ nsSMILCSSProperty::GetBaseValue() const
overrideDecl->SetPropertyValue(mPropID, cachedOverrideStyleVal); overrideDecl->SetPropertyValue(mPropID, cachedOverrideStyleVal);
} }
// (4) Populate our nsSMILValue from the computed style // (4) Create a nsSMILValue from the computed style
nsSMILValue baseValue;
if (didGetComputedVal) { if (didGetComputedVal) {
nsSMILCSSValueType::ValueFromString(mPropID, mElement, nsSMILCSSValueType::ValueFromString(mPropID, mElement,
computedStyleVal, baseValue); computedStyleVal, baseValue);

View File

@ -74,10 +74,9 @@ nsSVGTransformSMILAttr::ValueFromString(const nsAString& aStr,
nsSMILValue nsSMILValue
nsSVGTransformSMILAttr::GetBaseValue() const nsSVGTransformSMILAttr::GetBaseValue() const
{ {
// To benefit from Return Value Optimization and avoid copy constructor calls
// due to our use of return-by-value, we must return the exact same object
// from ALL return points. This function must only return THIS variable:
nsSMILValue val(&nsSVGTransformSMILType::sSingleton); nsSMILValue val(&nsSVGTransformSMILType::sSingleton);
if (val.IsNull())
return val; // Initialization failed
nsIDOMSVGTransformList *list = mVal->mBaseVal.get(); nsIDOMSVGTransformList *list = mVal->mBaseVal.get();
@ -88,10 +87,7 @@ nsSVGTransformSMILAttr::GetBaseValue() const
nsresult rv = list->GetItem(i, getter_AddRefs(transform)); nsresult rv = list->GetItem(i, getter_AddRefs(transform));
if (NS_SUCCEEDED(rv) && transform) { if (NS_SUCCEEDED(rv) && transform) {
rv = AppendSVGTransformToSMILValue(transform.get(), val); rv = AppendSVGTransformToSMILValue(transform.get(), val);
if (NS_FAILED(rv)) { // Appending to |val| failed (OOM?) NS_ENSURE_SUCCESS(rv, nsSMILValue());
val = nsSMILValue();
break;
}
} }
} }