Bug 570555 - CSS animation on font-size should not require units. r=dholbert,sr=roc

This commit is contained in:
Robert Longson 2010-06-09 20:51:31 +01:00
parent e3a42e09d9
commit 1abdca25bd
8 changed files with 64 additions and 15 deletions

View File

@ -145,8 +145,8 @@ nsSMILCSSProperty::GetBaseValue() const
// (4) Populate our nsSMILValue from the computed style // (4) Populate our nsSMILValue from the computed style
if (didGetComputedVal) { if (didGetComputedVal) {
nsSMILCSSValueType::ValueFromString(mPropID, mElement, computedStyleVal, nsSMILCSSValueType::ValueFromString(mPropID, mElement,
PR_FALSE, baseValue); computedStyleVal, baseValue);
} }
return baseValue; return baseValue;
} }
@ -159,8 +159,7 @@ nsSMILCSSProperty::ValueFromString(const nsAString& aStr,
{ {
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE); NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue);
PR_FALSE, aValue);
if (aValue.IsNull()) { if (aValue.IsNull()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

View File

@ -337,7 +337,6 @@ ValueFromStringHelper(nsCSSProperty aPropID,
nsIContent* aTargetElement, nsIContent* aTargetElement,
nsPresContext* aPresContext, nsPresContext* aPresContext,
const nsAString& aString, const nsAString& aString,
PRBool aUseSVGMode,
nsStyleAnimation::Value& aStyleAnimValue) nsStyleAnimation::Value& aStyleAnimValue)
{ {
// If value is negative, we'll strip off the "-" so the CSS parser won't // If value is negative, we'll strip off the "-" so the CSS parser won't
@ -353,7 +352,7 @@ ValueFromStringHelper(nsCSSProperty aPropID,
} }
nsDependentSubstring subString(aString, subStringBegin); nsDependentSubstring subString(aString, subStringBegin);
if (!nsStyleAnimation::ComputeValue(aPropID, aTargetElement, subString, if (!nsStyleAnimation::ComputeValue(aPropID, aTargetElement, subString,
aUseSVGMode, aStyleAnimValue)) { PR_TRUE, aStyleAnimValue)) {
return PR_FALSE; return PR_FALSE;
} }
if (isNegative) { if (isNegative) {
@ -376,7 +375,6 @@ void
nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID, nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
nsIContent* aTargetElement, nsIContent* aTargetElement,
const nsAString& aString, const nsAString& aString,
PRBool aUseSVGMode,
nsSMILValue& aValue) nsSMILValue& aValue)
{ {
// XXXbz aTargetElement should be an Element // XXXbz aTargetElement should be an Element
@ -389,7 +387,7 @@ nsSMILCSSValueType::ValueFromString(nsCSSProperty aPropID,
nsStyleAnimation::Value parsedValue; nsStyleAnimation::Value parsedValue;
if (ValueFromStringHelper(aPropID, aTargetElement, presContext, if (ValueFromStringHelper(aPropID, aTargetElement, presContext,
aString, aUseSVGMode, parsedValue)) { aString, parsedValue)) {
sSingleton.Init(aValue); sSingleton.Init(aValue);
aValue.mU.mPtr = new ValueWrapper(aPropID, parsedValue, presContext); aValue.mU.mPtr = new ValueWrapper(aPropID, parsedValue, presContext);
if (!aValue.mU.mPtr) { if (!aValue.mU.mPtr) {

View File

@ -91,8 +91,6 @@ public:
* @param aTargetElement The target element to whom the property/value * @param aTargetElement The target element to whom the property/value
* setting applies. * setting applies.
* @param aString The string to be parsed as a CSS value. * @param aString The string to be parsed as a CSS value.
* @param aUseSVGMode A flag to indicate whether we should parse
* |aString| in SVG mode.
* @param [out] aValue The nsSMILValue to be populated. Should * @param [out] aValue The nsSMILValue to be populated. Should
* initially be null-typed. * initially be null-typed.
* @pre aValue.IsNull() * @pre aValue.IsNull()
@ -101,7 +99,6 @@ public:
static void ValueFromString(nsCSSProperty aPropID, static void ValueFromString(nsCSSProperty aPropID,
nsIContent* aTargetElement, nsIContent* aTargetElement,
const nsAString& aString, const nsAString& aString,
PRBool aUseSVGMode,
nsSMILValue& aValue); nsSMILValue& aValue);
/** /**

View File

@ -66,8 +66,7 @@ nsSMILMappedAttribute::ValueFromString(const nsAString& aStr,
{ {
NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE); NS_ENSURE_TRUE(IsPropertyAnimatable(mPropID), NS_ERROR_FAILURE);
nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, nsSMILCSSValueType::ValueFromString(mPropID, mElement, aStr, aValue);
PR_TRUE, aValue);
if (aValue.IsNull()) { if (aValue.IsNull()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@ -87,8 +86,8 @@ nsSMILMappedAttribute::GetBaseValue() const
baseStringValue); baseStringValue);
nsSMILValue baseValue; nsSMILValue baseValue;
if (success) { if (success) {
nsSMILCSSValueType::ValueFromString(mPropID, mElement, baseStringValue, nsSMILCSSValueType::ValueFromString(mPropID, mElement,
PR_TRUE, baseValue); baseStringValue, baseValue);
} else { } else {
// Attribute is unset -- use computed value. // Attribute is unset -- use computed value.
// FIRST: Temporarily clear animated value, to make sure it doesn't pollute // FIRST: Temporarily clear animated value, to make sure it doesn't pollute

View File

@ -0,0 +1,17 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
style="font-size: 2px"
class="reftest-wait"
onload="go()">
<script xlink:href="../smil-grid.js" type="text/javascript"/>
<script xlink:href="../smil-util.js" type="text/javascript"/>
<script>
function go() {
var animAttrHash = { "attributeName" : "font-size",
"attributeType" : "CSS",
"from" : "10",
"to" : "30" };
testAnimatedTextGrid("animate", [animAttrHash]);
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 615 B

View File

@ -0,0 +1,17 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
style="font-size: 2px"
class="reftest-wait"
onload="go()">
<script xlink:href="../smil-grid.js" type="text/javascript"/>
<script xlink:href="../smil-util.js" type="text/javascript"/>
<script>
function go() {
var animAttrHash = { "attributeName" : "font-size",
"attributeType" : "CSS",
"from" : "10",
"to" : "30px" };
testAnimatedTextGrid("animate", [animAttrHash]);
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 617 B

View File

@ -0,0 +1,17 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
style="font-size: 2px"
class="reftest-wait"
onload="go()">
<script xlink:href="../smil-grid.js" type="text/javascript"/>
<script xlink:href="../smil-util.js" type="text/javascript"/>
<script>
function go() {
var animAttrHash = { "attributeName" : "font-size",
"attributeType" : "CSS",
"from" : "10px",
"to" : "30" };
testAnimatedTextGrid("animate", [animAttrHash]);
}
</script>
</svg>

After

Width:  |  Height:  |  Size: 617 B

View File

@ -72,6 +72,11 @@ fails == anim-css-fillopacity-3-clamp-big.svg anim-css-fillopacity-3-ref.svg
== anim-css-fontsize-1-from-by-px-px.svg anim-css-fontsize-1-ref.svg == anim-css-fontsize-1-from-by-px-px.svg anim-css-fontsize-1-ref.svg
== anim-css-fontsize-1-from-to-px-px.svg anim-css-fontsize-1-ref.svg == anim-css-fontsize-1-from-to-px-px.svg anim-css-fontsize-1-ref.svg
# 'font-size' property (accepts unitless values)
== anim-css-fontsize-1-from-to-no-no.svg anim-css-fontsize-1-ref.svg
== anim-css-fontsize-1-from-to-no-px.svg anim-css-fontsize-1-ref.svg
== anim-css-fontsize-1-from-to-px-no.svg anim-css-fontsize-1-ref.svg
# 'font-size' mapped attribute (accepts unitless values) # 'font-size' mapped attribute (accepts unitless values)
== anim-mapped-fontsize-1-from-to-no-no.svg anim-css-fontsize-1-ref.svg == anim-mapped-fontsize-1-from-to-no-no.svg anim-css-fontsize-1-ref.svg
== anim-mapped-fontsize-1-from-to-no-px.svg anim-css-fontsize-1-ref.svg == anim-mapped-fontsize-1-from-to-no-px.svg anim-css-fontsize-1-ref.svg