Closed Bug 541882 Opened 14 years ago Closed 14 years ago

Add support for SMIL animation of the preserveAspectRatio attribute in SVG

Categories

(Core :: SVG, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jwatt, Assigned: jwatt)

References

Details

Attachments

(1 file)

We should add support for SMIL animation of the preserveAspectRatio attribute in SVG.
Attached patch patchSplinter Review
I'm just reusing SMILEnumType here (stuffing the multiple values into it), since the logic is the same.
Assignee: nobody → jwatt
Status: NEW → ASSIGNED
Attachment #423281 - Flags: review?(dholbert)
Blocks: 436276
Comment on attachment 423281 [details] [diff] [review]
patch

>+nsresult
>+nsSVGPreserveAspectRatio::SetBaseValueString(const nsAString &aValueAsString,

>+#ifdef MOZ_SMIL
>+  if (mIsAnimated) {
>+    aSVGElement->AnimationNeedsResample();
>+  }
>+#endif  return NS_OK;

Put "return NS_OK;" on its own line there.

>+nsresult
>+nsSVGPreserveAspectRatio::SMILPreserveAspectRatio
>+                        ::ValueFromString(const nsAString& aStr,
>+                                          const nsISMILAnimationElement* /*aSrcElement*/,
>+                                          nsSMILValue& aValue) const
[SNIP]
>+  PRUint64 compound = 0;
>+  compound |= PRUint64(par.GetDefer() ? 1 : 0) << 16;
>+  compound |= PRUint64(par.GetAlign()) << 8;
>+  compound |= PRUint64(par.GetMeetOrSlice());

The SMILPreserveAspectRatio implementation has three copies of the above four lines, in various methods.  Can we refactor that out into a helper function that these methods can call? Maybe something like:

  static PRUint64 GetCompoundRepresentation(nsSVGPreserveAspectRatio* par) {
     [the four lines quoted above]
     return compound;
  }

>+++ b/content/svg/content/src/nsSVGPreserveAspectRatio.h
>+  const PreserveAspectRatio &GetAnimValue(nsSVGElement *aSVGElement) const
>+  {
>+  #ifdef MOZ_SMIL
>+    aSVGElement->FlushAnimations();
>+  #endif
>+    return mAnimVal;
>+  }

Remove the indentation on the #ifdef & #endif there.

>+++ b/layout/svg/base/src/nsSVGPatternFrame.cpp
> const nsSVGPreserveAspectRatio &
> nsSVGPatternFrame::GetPreserveAspectRatio()
> {
>+  // XXX this should also check for animated values
>   nsSVGPatternElement *patternElement =
>     GetPatternWithAttr(nsGkAtoms::preserveAspectRatio, mContent);
> 
>   return patternElement->mPreserveAspectRatio;
> }


RE that XXX comment -- do animated values actually present a problem there?  If we're animated, wouldn't they have updated |patternElement| via SetAnimValue already?

Maybe we'd need to call mContent->FlushAnimations() to make sure we're returning a value with up-to-date animation effects... but aside from that, is there anything else problematic there?

r=dholbert with the above addressed
Attachment #423281 - Flags: review?(dholbert) → review+
(In reply to comment #2)
> RE that XXX comment -- do animated values actually present a problem there?  If
> we're animated, wouldn't they have updated |patternElement| via SetAnimValue
> already?

My comment was clearly lacking. I've moved it and expanded it to clarify, and I've filed bug 544809 for the issue.
Pushed http://hg.mozilla.org/mozilla-central/rev/8dc04dca2a59
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Blocks: 546785
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: