SMIL:CSS Animation: Difference between revisions
Jump to navigation
Jump to search
Implementing
| Line 1: | Line 1: | ||
= Current status = | = Current status = | ||
There's an existing [http://hg.mozilla.org/users/dholbert_mozilla.com/smil-patches/file/tip/smil_css smil_css patch] in dholbert's [http://hg.mozilla.org/users/dholbert_mozilla.com/index.cgi/smil-patches smil-patches patch-queue]. This patch applies on top of the other patches in the queue, and it makes use of a simple [http://hg.mozilla.org/users/dholbert_mozilla.com/smil-patches/file/tip/getoverridestyle.patch " | There's an existing [http://hg.mozilla.org/users/dholbert_mozilla.com/smil-patches/file/tip/smil_css smil_css patch] in dholbert's [http://hg.mozilla.org/users/dholbert_mozilla.com/index.cgi/smil-patches smil-patches patch-queue]. This patch applies on top of the other patches in the queue, and it makes use of a simple [http://hg.mozilla.org/users/dholbert_mozilla.com/smil-patches/file/tip/getoverridestyle.patch "<code>getOverrideStyle</code>" implementation] in order to set styles. | ||
The smil_css patch is not complete yet -- it currently has these limitations: | The smil_css patch is not complete yet -- it currently has these limitations: | ||
* It can only animate CSS properties of type nsCSSValue. (not nsCSSValuePair / nsCSSValueRect / etc) | * It can only animate CSS properties of type <code>nsCSSValue</code>. (not <code>nsCSSValuePair</code> / <code>nsCSSValueRect</code> / etc) | ||
* It can only currently interpolate between fixed-length units. (inch, mm, pt, etc). (unit-conversion code needs a reference to the PresContext & font-metrics to interpolate/interconvert between fixed-length units / display pixels / em-units / ex-units.) | * It can only currently interpolate between fixed-length units. (inch, mm, pt, etc). (unit-conversion code needs a reference to the PresContext & font-metrics to interpolate/interconvert between fixed-length units / display pixels / em-units / ex-units.) | ||
Revision as of 22:47, 30 October 2008
Current status
There's an existing smil_css patch in dholbert's smil-patches patch-queue. This patch applies on top of the other patches in the queue, and it makes use of a simple "getOverrideStyle" implementation in order to set styles.
The smil_css patch is not complete yet -- it currently has these limitations:
- It can only animate CSS properties of type
nsCSSValue. (notnsCSSValuePair/nsCSSValueRect/ etc) - It can only currently interpolate between fixed-length units. (inch, mm, pt, etc). (unit-conversion code needs a reference to the PresContext & font-metrics to interpolate/interconvert between fixed-length units / display pixels / em-units / ex-units.)
Overview of Proposed Strategy
Animating CSS Style
As suggested in the documentation on the "SMIL Sandwich Model" in the smil-animation spec, I'm proposing that we use an implementation backed by getOverrideStyle().
Here's an overview of the steps required to animate a specific CSS property on a specific element, using getOverrideStyle(), during a SMIL animation sample:
- Call
getOverrideStyle()on the element, and from this, remove any settings for the CSS property in question. (This ensures thatgetComputedStyle()won't reflect any animation effects, so it can be used as a 'base value' for animation in the next step) - Perform SMIL interpolation & compositing for the CSS property, using
getComputedStyle()as the base value. - Store the final composited value of the property in
getOverrideStyle().
Implementing getOverrideStyle()
Note that Gecko doesn't currently implement getOverrideStyle(). Here's a basic outline of how we'd implement this:
- Add a new
nsICSSStyleRulemember variable on eachnsStyledElement, which is used as a backing store for the override style. - Internally, this should mostly behave like SVG's content style rule. (See mContentStyleRule in nsSVGElement.h and nsSVGElement.cpp )
- Add a new