dom/smil/nsSMILTimedElement.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/smil/nsSMILTimedElement.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,628 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef NS_SMILTIMEDELEMENT_H_
    1.10 +#define NS_SMILTIMEDELEMENT_H_
    1.11 +
    1.12 +#include "nsSMILInterval.h"
    1.13 +#include "nsSMILInstanceTime.h"
    1.14 +#include "nsSMILMilestone.h"
    1.15 +#include "nsSMILTimeValueSpec.h"
    1.16 +#include "nsSMILRepeatCount.h"
    1.17 +#include "nsSMILTypes.h"
    1.18 +#include "nsTArray.h"
    1.19 +#include "nsTHashtable.h"
    1.20 +#include "nsHashKeys.h"
    1.21 +#include "nsAutoPtr.h"
    1.22 +#include "nsAttrValue.h"
    1.23 +
    1.24 +class nsSMILAnimationFunction;
    1.25 +class nsSMILTimeContainer;
    1.26 +class nsSMILTimeValue;
    1.27 +class nsIAtom;
    1.28 +
    1.29 +namespace mozilla {
    1.30 +namespace dom {
    1.31 +class SVGAnimationElement;
    1.32 +}
    1.33 +}
    1.34 +
    1.35 +//----------------------------------------------------------------------
    1.36 +// nsSMILTimedElement
    1.37 +
    1.38 +class nsSMILTimedElement
    1.39 +{
    1.40 +public:
    1.41 +  nsSMILTimedElement();
    1.42 +  ~nsSMILTimedElement();
    1.43 +
    1.44 +  typedef mozilla::dom::Element Element;
    1.45 +
    1.46 +  /*
    1.47 +   * Sets the owning animation element which this class uses to convert between
    1.48 +   * container times and to register timebase elements.
    1.49 +   */
    1.50 +  void SetAnimationElement(mozilla::dom::SVGAnimationElement* aElement);
    1.51 +
    1.52 +  /*
    1.53 +   * Returns the time container with which this timed element is associated or
    1.54 +   * nullptr if it is not associated with a time container.
    1.55 +   */
    1.56 +  nsSMILTimeContainer* GetTimeContainer();
    1.57 +
    1.58 +  /*
    1.59 +   * Returns the element targeted by the animation element. Needed for
    1.60 +   * registering event listeners against the appropriate element.
    1.61 +   */
    1.62 +  mozilla::dom::Element* GetTargetElement();
    1.63 +
    1.64 +  /**
    1.65 +   * Methods for supporting the nsIDOMElementTimeControl interface.
    1.66 +   */
    1.67 +
    1.68 +  /*
    1.69 +   * Adds a new begin instance time at the current container time plus or minus
    1.70 +   * the specified offset.
    1.71 +   *
    1.72 +   * @param aOffsetSeconds A real number specifying the number of seconds to add
    1.73 +   *                       to the current container time.
    1.74 +   * @return NS_OK if the operation succeeeded, or an error code otherwise.
    1.75 +   */
    1.76 +  nsresult BeginElementAt(double aOffsetSeconds);
    1.77 +
    1.78 +  /*
    1.79 +   * Adds a new end instance time at the current container time plus or minus
    1.80 +   * the specified offset.
    1.81 +   *
    1.82 +   * @param aOffsetSeconds A real number specifying the number of seconds to add
    1.83 +   *                       to the current container time.
    1.84 +   * @return NS_OK if the operation succeeeded, or an error code otherwise.
    1.85 +   */
    1.86 +  nsresult EndElementAt(double aOffsetSeconds);
    1.87 +
    1.88 +  /**
    1.89 +   * Methods for supporting the nsSVGAnimationElement interface.
    1.90 +   */
    1.91 +
    1.92 +  /**
    1.93 +   * According to SVG 1.1 SE this returns
    1.94 +   *
    1.95 +   *   the begin time, in seconds, for this animation element's current
    1.96 +   *   interval, if it exists, regardless of whether the interval has begun yet.
    1.97 +   *
    1.98 +   * @return the start time as defined above in milliseconds or an unresolved
    1.99 +   * time if there is no current interval.
   1.100 +   */
   1.101 +  nsSMILTimeValue GetStartTime() const;
   1.102 +
   1.103 +  /**
   1.104 +   * Returns the simple duration of this element.
   1.105 +   *
   1.106 +   * @return the simple duration in milliseconds or INDEFINITE.
   1.107 +   */
   1.108 +  nsSMILTimeValue GetSimpleDuration() const
   1.109 +  {
   1.110 +    return mSimpleDur;
   1.111 +  }
   1.112 +
   1.113 +  /**
   1.114 +   * Methods for supporting hyperlinking
   1.115 +   */
   1.116 +
   1.117 +  /**
   1.118 +   * Internal SMIL methods
   1.119 +   */
   1.120 +
   1.121 +  /**
   1.122 +   * Returns the time to seek the document to when this element is targetted by
   1.123 +   * a hyperlink.
   1.124 +   *
   1.125 +   * The behavior is defined here:
   1.126 +   *   http://www.w3.org/TR/smil-animation/#HyperlinkSemantics
   1.127 +   *
   1.128 +   * It is very similar to GetStartTime() with the exception that when the
   1.129 +   * element is not active, the begin time of the *first* interval is returned.
   1.130 +   *
   1.131 +   * @return the time to seek the documen to in milliseconds or an unresolved
   1.132 +   * time if there is no resolved interval.
   1.133 +   */
   1.134 +  nsSMILTimeValue GetHyperlinkTime() const;
   1.135 +
   1.136 +  /**
   1.137 +   * Adds an instance time object this element's list of instance times.
   1.138 +   * These instance times are used when creating intervals.
   1.139 +   *
   1.140 +   * This method is typically called by an nsSMILTimeValueSpec.
   1.141 +   *
   1.142 +   * @param aInstanceTime   The time to add, expressed in container time.
   1.143 +   * @param aIsBegin        true if the time to be added represents a begin
   1.144 +   *                        time or false if it represents an end time.
   1.145 +   */
   1.146 +  void AddInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
   1.147 +
   1.148 +  /**
   1.149 +   * Requests this element update the given instance time.
   1.150 +   *
   1.151 +   * This method is typically called by a child nsSMILTimeValueSpec.
   1.152 +   *
   1.153 +   * @param aInstanceTime   The instance time to update.
   1.154 +   * @param aUpdatedTime    The time to update aInstanceTime with.
   1.155 +   * @param aDependentTime  The instance time upon which aInstanceTime should be
   1.156 +   *                        based.
   1.157 +   * @param aIsBegin        true if the time to be updated represents a begin
   1.158 +   *                        instance time or false if it represents an end
   1.159 +   *                        instance time.
   1.160 +   */
   1.161 +  void UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime,
   1.162 +                          nsSMILTimeValue& aUpdatedTime,
   1.163 +                          bool aIsBegin);
   1.164 +
   1.165 +  /**
   1.166 +   * Removes an instance time object from this element's list of instance times.
   1.167 +   *
   1.168 +   * This method is typically called by a child nsSMILTimeValueSpec.
   1.169 +   *
   1.170 +   * @param aInstanceTime   The instance time to remove.
   1.171 +   * @param aIsBegin        true if the time to be removed represents a begin
   1.172 +   *                        time or false if it represents an end time.
   1.173 +   */
   1.174 +  void RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
   1.175 +
   1.176 +  /**
   1.177 +   * Removes all the instance times associated with the given
   1.178 +   * nsSMILTimeValueSpec object. Used when an ID assignment changes and hence
   1.179 +   * all the previously associated instance times become invalid.
   1.180 +   *
   1.181 +   * @param aSpec    The nsSMILTimeValueSpec object whose created
   1.182 +   *                 nsSMILInstanceTime's should be removed.
   1.183 +   * @param aIsBegin true if the times to be removed represent begin
   1.184 +   *                 times or false if they are end times.
   1.185 +   */
   1.186 +  void RemoveInstanceTimesForCreator(const nsSMILTimeValueSpec* aSpec,
   1.187 +                                     bool aIsBegin);
   1.188 +
   1.189 +  /**
   1.190 +   * Sets the object that will be called by this timed element each time it is
   1.191 +   * sampled.
   1.192 +   *
   1.193 +   * In Schmitz's model it is possible to associate several time clients with
   1.194 +   * a timed element but for now we only allow one.
   1.195 +   *
   1.196 +   * @param aClient   The time client to associate. Any previous time client
   1.197 +   *                  will be disassociated and no longer sampled. Setting this
   1.198 +   *                  to nullptr will simply disassociate the previous client, if
   1.199 +   *                  any.
   1.200 +   */
   1.201 +  void SetTimeClient(nsSMILAnimationFunction* aClient);
   1.202 +
   1.203 +  /**
   1.204 +   * Samples the object at the given container time. Timing intervals are
   1.205 +   * updated and if this element is active at the given time the associated time
   1.206 +   * client will be sampled with the appropriate simple time.
   1.207 +   *
   1.208 +   * @param aContainerTime The container time at which to sample.
   1.209 +   */
   1.210 +  void SampleAt(nsSMILTime aContainerTime);
   1.211 +
   1.212 +  /**
   1.213 +   * Performs a special sample for the end of an interval. Such a sample should
   1.214 +   * only advance the timed element (and any dependent elements) to the waiting
   1.215 +   * or postactive state. It should not cause a transition to the active state.
   1.216 +   * Transition to the active state is only performed on a regular SampleAt.
   1.217 +   *
   1.218 +   * This allows all interval ends at a given time to be processed first and
   1.219 +   * hence the new interval can be established based on full information of the
   1.220 +   * available instance times.
   1.221 +   *
   1.222 +   * @param aContainerTime The container time at which to sample.
   1.223 +   */
   1.224 +  void SampleEndAt(nsSMILTime aContainerTime);
   1.225 +
   1.226 +  /**
   1.227 +   * Informs the timed element that its time container has changed time
   1.228 +   * relative to document time. The timed element therefore needs to update its
   1.229 +   * dependent elements (which may belong to a different time container) so they
   1.230 +   * can re-resolve their times.
   1.231 +   */
   1.232 +  void HandleContainerTimeChange();
   1.233 +
   1.234 +  /**
   1.235 +   * Resets this timed element's accumulated times and intervals back to start
   1.236 +   * up state.
   1.237 +   *
   1.238 +   * This is used for backwards seeking where rather than accumulating
   1.239 +   * historical timing state and winding it back, we reset the element and seek
   1.240 +   * forwards.
   1.241 +   */
   1.242 +  void Rewind();
   1.243 +
   1.244 +  /**
   1.245 +   * Attempts to set an attribute on this timed element.
   1.246 +   *
   1.247 +   * @param aAttribute  The name of the attribute to set. The namespace of this
   1.248 +   *                    attribute is not specified as it is checked by the host
   1.249 +   *                    element. Only attributes in the namespace defined for
   1.250 +   *                    SMIL attributes in the host language are passed to the
   1.251 +   *                    timed element.
   1.252 +   * @param aValue      The attribute value.
   1.253 +   * @param aResult     The nsAttrValue object that may be used for storing the
   1.254 +   *                    parsed result.
   1.255 +   * @param aContextNode The element to use for context when resolving
   1.256 +   *                     references to other elements.
   1.257 +   * @param[out] aParseResult The result of parsing the attribute. Will be set
   1.258 +   *                          to NS_OK if parsing is successful.
   1.259 +   *
   1.260 +   * @return true if the given attribute is a timing attribute, false
   1.261 +   * otherwise.
   1.262 +   */
   1.263 +  bool SetAttr(nsIAtom* aAttribute, const nsAString& aValue,
   1.264 +                 nsAttrValue& aResult, Element* aContextNode,
   1.265 +                 nsresult* aParseResult = nullptr);
   1.266 +
   1.267 +  /**
   1.268 +   * Attempts to unset an attribute on this timed element.
   1.269 +   *
   1.270 +   * @param aAttribute  The name of the attribute to set. As with SetAttr the
   1.271 +   *                    namespace of the attribute is not specified (see
   1.272 +   *                    SetAttr).
   1.273 +   *
   1.274 +   * @return true if the given attribute is a timing attribute, false
   1.275 +   * otherwise.
   1.276 +   */
   1.277 +  bool UnsetAttr(nsIAtom* aAttribute);
   1.278 +
   1.279 +  /**
   1.280 +   * Adds a syncbase dependency to the list of dependents that will be notified
   1.281 +   * when this timed element creates, deletes, or updates its current interval.
   1.282 +   *
   1.283 +   * @param aDependent  The nsSMILTimeValueSpec object to notify. A raw pointer
   1.284 +   *                    to this object will be stored. Therefore it is necessary
   1.285 +   *                    for the object to be explicitly unregistered (with
   1.286 +   *                    RemoveDependent) when it is destroyed.
   1.287 +   */
   1.288 +  void AddDependent(nsSMILTimeValueSpec& aDependent);
   1.289 +
   1.290 +  /**
   1.291 +   * Removes a syncbase dependency from the list of dependents that are notified
   1.292 +   * when the current interval is modified.
   1.293 +   *
   1.294 +   * @param aDependent  The nsSMILTimeValueSpec object to unregister.
   1.295 +   */
   1.296 +  void RemoveDependent(nsSMILTimeValueSpec& aDependent);
   1.297 +
   1.298 +  /**
   1.299 +   * Determines if this timed element is dependent on the given timed element's
   1.300 +   * begin time for the interval currently in effect. Whilst the element is in
   1.301 +   * the active state this is the current interval and in the postactive or
   1.302 +   * waiting state this is the previous interval if one exists. In all other
   1.303 +   * cases the element is not considered a time dependent of any other element.
   1.304 +   *
   1.305 +   * @param aOther    The potential syncbase element.
   1.306 +   * @return true if this timed element's begin time for the currently
   1.307 +   * effective interval is directly or indirectly derived from aOther, false
   1.308 +   * otherwise.
   1.309 +   */
   1.310 +  bool IsTimeDependent(const nsSMILTimedElement& aOther) const;
   1.311 +
   1.312 +  /**
   1.313 +   * Called when the timed element has been bound to the document so that
   1.314 +   * references from this timed element to other elements can be resolved.
   1.315 +   *
   1.316 +   * @param aContextNode  The node which provides the necessary context for
   1.317 +   *                      resolving references. This is typically the element in
   1.318 +   *                      the host language that owns this timed element. Should
   1.319 +   *                      not be null.
   1.320 +   */
   1.321 +  void BindToTree(nsIContent* aContextNode);
   1.322 +
   1.323 +  /**
   1.324 +   * Called when the target of the animation has changed so that event
   1.325 +   * registrations can be updated.
   1.326 +   */
   1.327 +  void HandleTargetElementChange(mozilla::dom::Element* aNewTarget);
   1.328 +
   1.329 +  /**
   1.330 +   * Called when the timed element has been removed from a document so that
   1.331 +   * references to other elements can be broken.
   1.332 +   */
   1.333 +  void DissolveReferences() { Unlink(); }
   1.334 +
   1.335 +  // Cycle collection
   1.336 +  void Traverse(nsCycleCollectionTraversalCallback* aCallback);
   1.337 +  void Unlink();
   1.338 +
   1.339 +  typedef bool (*RemovalTestFunction)(nsSMILInstanceTime* aInstance);
   1.340 +
   1.341 +protected:
   1.342 +  // Typedefs
   1.343 +  typedef nsTArray<nsAutoPtr<nsSMILTimeValueSpec> > TimeValueSpecList;
   1.344 +  typedef nsTArray<nsRefPtr<nsSMILInstanceTime> >   InstanceTimeList;
   1.345 +  typedef nsTArray<nsAutoPtr<nsSMILInterval> >      IntervalList;
   1.346 +  typedef nsPtrHashKey<nsSMILTimeValueSpec> TimeValueSpecPtrKey;
   1.347 +  typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
   1.348 +
   1.349 +  // Helper classes
   1.350 +  class InstanceTimeComparator {
   1.351 +    public:
   1.352 +      bool Equals(const nsSMILInstanceTime* aElem1,
   1.353 +                    const nsSMILInstanceTime* aElem2) const;
   1.354 +      bool LessThan(const nsSMILInstanceTime* aElem1,
   1.355 +                      const nsSMILInstanceTime* aElem2) const;
   1.356 +  };
   1.357 +
   1.358 +  struct NotifyTimeDependentsParams {
   1.359 +    nsSMILTimedElement*  mTimedElement;
   1.360 +    nsSMILTimeContainer* mTimeContainer;
   1.361 +  };
   1.362 +
   1.363 +  // Templated helper functions
   1.364 +  template <class TestFunctor>
   1.365 +  void RemoveInstanceTimes(InstanceTimeList& aArray, TestFunctor& aTest);
   1.366 +
   1.367 +  //
   1.368 +  // Implementation helpers
   1.369 +  //
   1.370 +
   1.371 +  nsresult          SetBeginSpec(const nsAString& aBeginSpec,
   1.372 +                                 Element* aContextNode,
   1.373 +                                 RemovalTestFunction aRemove);
   1.374 +  nsresult          SetEndSpec(const nsAString& aEndSpec,
   1.375 +                               Element* aContextNode,
   1.376 +                               RemovalTestFunction aRemove);
   1.377 +  nsresult          SetSimpleDuration(const nsAString& aDurSpec);
   1.378 +  nsresult          SetMin(const nsAString& aMinSpec);
   1.379 +  nsresult          SetMax(const nsAString& aMaxSpec);
   1.380 +  nsresult          SetRestart(const nsAString& aRestartSpec);
   1.381 +  nsresult          SetRepeatCount(const nsAString& aRepeatCountSpec);
   1.382 +  nsresult          SetRepeatDur(const nsAString& aRepeatDurSpec);
   1.383 +  nsresult          SetFillMode(const nsAString& aFillModeSpec);
   1.384 +
   1.385 +  void              UnsetBeginSpec(RemovalTestFunction aRemove);
   1.386 +  void              UnsetEndSpec(RemovalTestFunction aRemove);
   1.387 +  void              UnsetSimpleDuration();
   1.388 +  void              UnsetMin();
   1.389 +  void              UnsetMax();
   1.390 +  void              UnsetRestart();
   1.391 +  void              UnsetRepeatCount();
   1.392 +  void              UnsetRepeatDur();
   1.393 +  void              UnsetFillMode();
   1.394 +
   1.395 +  nsresult          SetBeginOrEndSpec(const nsAString& aSpec,
   1.396 +                                      Element* aContextNode,
   1.397 +                                      bool aIsBegin,
   1.398 +                                      RemovalTestFunction aRemove);
   1.399 +  void              ClearSpecs(TimeValueSpecList& aSpecs,
   1.400 +                               InstanceTimeList& aInstances,
   1.401 +                               RemovalTestFunction aRemove);
   1.402 +  void              ClearIntervals();
   1.403 +  void              DoSampleAt(nsSMILTime aContainerTime, bool aEndOnly);
   1.404 +
   1.405 +  /**
   1.406 +   * Helper function to check for an early end and, if necessary, update the
   1.407 +   * current interval accordingly.
   1.408 +   *
   1.409 +   * See SMIL 3.0, section 5.4.5, Element life cycle, "Active Time - Playing an
   1.410 +   * interval" for a description of ending early.
   1.411 +   *
   1.412 +   * @param aSampleTime The current sample time. Early ends should only be
   1.413 +   *                    applied at the last possible moment (i.e. if they are at
   1.414 +   *                    or before the current sample time) and only if the
   1.415 +   *                    current interval is not already ending.
   1.416 +   * @return true if the end time of the current interval was updated,
   1.417 +   *         false otherwise.
   1.418 +   */
   1.419 +  bool ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime);
   1.420 +
   1.421 +  /**
   1.422 +   * Clears certain state in response to the element restarting.
   1.423 +   *
   1.424 +   * This state is described in SMIL 3.0, section 5.4.3, Resetting element state
   1.425 +   */
   1.426 +  void Reset();
   1.427 +
   1.428 +  /**
   1.429 +   * Completes a seek operation by sending appropriate events and, in the case
   1.430 +   * of a backwards seek, updating the state of timing information that was
   1.431 +   * previously considered historical.
   1.432 +   */
   1.433 +  void DoPostSeek();
   1.434 +
   1.435 +  /**
   1.436 +   * Unmarks instance times that were previously preserved because they were
   1.437 +   * considered important historical milestones but are no longer such because
   1.438 +   * a backwards seek has been performed.
   1.439 +   */
   1.440 +  void UnpreserveInstanceTimes(InstanceTimeList& aList);
   1.441 +
   1.442 +  /**
   1.443 +   * Helper function to iterate through this element's accumulated timing
   1.444 +   * information (specifically old nsSMILIntervals and nsSMILTimeInstanceTimes)
   1.445 +   * and discard items that are no longer needed or exceed some threshold of
   1.446 +   * accumulated state.
   1.447 +   */
   1.448 +  void FilterHistory();
   1.449 +
   1.450 +  // Helper functions for FilterHistory to clear old nsSMILIntervals and
   1.451 +  // nsSMILInstanceTimes respectively.
   1.452 +  void FilterIntervals();
   1.453 +  void FilterInstanceTimes(InstanceTimeList& aList);
   1.454 +
   1.455 +  /**
   1.456 +   * Calculates the next acceptable interval for this element after the
   1.457 +   * specified interval, or, if no previous interval is specified, it will be
   1.458 +   * the first interval with an end time after t=0.
   1.459 +   *
   1.460 +   * @see SMILANIM 3.6.8
   1.461 +   *
   1.462 +   * @param aPrevInterval   The previous interval used. If supplied, the first
   1.463 +   *                        interval that begins after aPrevInterval will be
   1.464 +   *                        returned. May be nullptr.
   1.465 +   * @param aReplacedInterval The interval that is being updated (if any). This
   1.466 +   *                        used to ensure we don't return interval endpoints
   1.467 +   *                        that are dependent on themselves. May be nullptr.
   1.468 +   * @param aFixedBeginTime The time to use for the start of the interval. This
   1.469 +   *                        is used when only the endpoint of the interval
   1.470 +   *                        should be updated such as when the animation is in
   1.471 +   *                        the ACTIVE state. May be nullptr.
   1.472 +   * @param[out] aResult    The next interval. Will be unchanged if no suitable
   1.473 +   *                        interval was found (in which case false will be
   1.474 +   *                        returned).
   1.475 +   * @return  true if a suitable interval was found, false otherwise.
   1.476 +   */
   1.477 +  bool              GetNextInterval(const nsSMILInterval* aPrevInterval,
   1.478 +                                    const nsSMILInterval* aReplacedInterval,
   1.479 +                                    const nsSMILInstanceTime* aFixedBeginTime,
   1.480 +                                    nsSMILInterval& aResult) const;
   1.481 +  nsSMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
   1.482 +                                     const nsSMILTimeValue& aBase,
   1.483 +                                     int32_t& aPosition) const;
   1.484 +  nsSMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
   1.485 +                                            const nsSMILTimeValue& aBase,
   1.486 +                                            int32_t& aPosition) const;
   1.487 +  nsSMILTimeValue   CalcActiveEnd(const nsSMILTimeValue& aBegin,
   1.488 +                                  const nsSMILTimeValue& aEnd) const;
   1.489 +  nsSMILTimeValue   GetRepeatDuration() const;
   1.490 +  nsSMILTimeValue   ApplyMinAndMax(const nsSMILTimeValue& aDuration) const;
   1.491 +  nsSMILTime        ActiveTimeToSimpleTime(nsSMILTime aActiveTime,
   1.492 +                                           uint32_t& aRepeatIteration);
   1.493 +  nsSMILInstanceTime* CheckForEarlyEnd(
   1.494 +                        const nsSMILTimeValue& aContainerTime) const;
   1.495 +  void              UpdateCurrentInterval(bool aForceChangeNotice = false);
   1.496 +  void              SampleSimpleTime(nsSMILTime aActiveTime);
   1.497 +  void              SampleFillValue();
   1.498 +  nsresult          AddInstanceTimeFromCurrentTime(nsSMILTime aCurrentTime,
   1.499 +                        double aOffsetSeconds, bool aIsBegin);
   1.500 +  void              RegisterMilestone();
   1.501 +  bool              GetNextMilestone(nsSMILMilestone& aNextMilestone) const;
   1.502 +
   1.503 +  // Notification methods. Note that these notifications can result in nested
   1.504 +  // calls to this same object. Therefore,
   1.505 +  // (i)  we should not perform notification until this object is in
   1.506 +  //      a consistent state to receive callbacks, and
   1.507 +  // (ii) after calling these methods we must assume that the state of the
   1.508 +  //      element may have changed.
   1.509 +  void              NotifyNewInterval();
   1.510 +  void              NotifyChangedInterval(nsSMILInterval* aInterval,
   1.511 +                                          bool aBeginObjectChanged,
   1.512 +                                          bool aEndObjectChanged);
   1.513 +
   1.514 +  void              FireTimeEventAsync(uint32_t aMsg, int32_t aDetail);
   1.515 +  const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
   1.516 +  const nsSMILInterval* GetPreviousInterval() const;
   1.517 +  bool              HasPlayed() const { return !mOldIntervals.IsEmpty(); }
   1.518 +  bool              HasClientInFillRange() const;
   1.519 +  bool              EndHasEventConditions() const;
   1.520 +  bool              AreEndTimesDependentOn(
   1.521 +                      const nsSMILInstanceTime* aBase) const;
   1.522 +
   1.523 +  // Reset the current interval by first passing ownership to a temporary
   1.524 +  // variable so that if Unlink() results in us receiving a callback,
   1.525 +  // mCurrentInterval will be nullptr and we will be in a consistent state.
   1.526 +  void ResetCurrentInterval()
   1.527 +  {
   1.528 +    if (mCurrentInterval) {
   1.529 +      // Transfer ownership to temp var. (This sets mCurrentInterval to null.)
   1.530 +      nsAutoPtr<nsSMILInterval> interval(mCurrentInterval);
   1.531 +      interval->Unlink();
   1.532 +    }
   1.533 +  }
   1.534 +
   1.535 +  // Hashtable callback methods
   1.536 +  static PLDHashOperator NotifyNewIntervalCallback(
   1.537 +      TimeValueSpecPtrKey* aKey, void* aData);
   1.538 +
   1.539 +  //
   1.540 +  // Members
   1.541 +  //
   1.542 +  mozilla::dom::SVGAnimationElement* mAnimationElement; // [weak] won't outlive
   1.543 +                                                        // owner
   1.544 +  TimeValueSpecList               mBeginSpecs; // [strong]
   1.545 +  TimeValueSpecList               mEndSpecs; // [strong]
   1.546 +
   1.547 +  nsSMILTimeValue                 mSimpleDur;
   1.548 +
   1.549 +  nsSMILRepeatCount               mRepeatCount;
   1.550 +  nsSMILTimeValue                 mRepeatDur;
   1.551 +
   1.552 +  nsSMILTimeValue                 mMin;
   1.553 +  nsSMILTimeValue                 mMax;
   1.554 +
   1.555 +  enum nsSMILFillMode
   1.556 +  {
   1.557 +    FILL_REMOVE,
   1.558 +    FILL_FREEZE
   1.559 +  };
   1.560 +  nsSMILFillMode                  mFillMode;
   1.561 +  static nsAttrValue::EnumTable   sFillModeTable[];
   1.562 +
   1.563 +  enum nsSMILRestartMode
   1.564 +  {
   1.565 +    RESTART_ALWAYS,
   1.566 +    RESTART_WHENNOTACTIVE,
   1.567 +    RESTART_NEVER
   1.568 +  };
   1.569 +  nsSMILRestartMode               mRestartMode;
   1.570 +  static nsAttrValue::EnumTable   sRestartModeTable[];
   1.571 +
   1.572 +  InstanceTimeList                mBeginInstances;
   1.573 +  InstanceTimeList                mEndInstances;
   1.574 +  uint32_t                        mInstanceSerialIndex;
   1.575 +
   1.576 +  nsSMILAnimationFunction*        mClient;
   1.577 +  nsAutoPtr<nsSMILInterval>       mCurrentInterval;
   1.578 +  IntervalList                    mOldIntervals;
   1.579 +  uint32_t                        mCurrentRepeatIteration;
   1.580 +  nsSMILMilestone                 mPrevRegisteredMilestone;
   1.581 +  static const nsSMILMilestone    sMaxMilestone;
   1.582 +  static const uint8_t            sMaxNumIntervals;
   1.583 +  static const uint8_t            sMaxNumInstanceTimes;
   1.584 +
   1.585 +  // Set of dependent time value specs to be notified when establishing a new
   1.586 +  // current interval. Change notifications and delete notifications are handled
   1.587 +  // by the interval.
   1.588 +  //
   1.589 +  // [weak] The nsSMILTimeValueSpec objects register themselves and unregister
   1.590 +  // on destruction. Likewise, we notify them when we are destroyed.
   1.591 +  TimeValueSpecHashSet mTimeDependents;
   1.592 +
   1.593 +  /**
   1.594 +   * The state of the element in its life-cycle. These states are based on the
   1.595 +   * element life-cycle described in SMILANIM 3.6.8
   1.596 +   */
   1.597 +  enum nsSMILElementState
   1.598 +  {
   1.599 +    STATE_STARTUP,
   1.600 +    STATE_WAITING,
   1.601 +    STATE_ACTIVE,
   1.602 +    STATE_POSTACTIVE
   1.603 +  };
   1.604 +  nsSMILElementState              mElementState;
   1.605 +
   1.606 +  enum nsSMILSeekState
   1.607 +  {
   1.608 +    SEEK_NOT_SEEKING,
   1.609 +    SEEK_FORWARD_FROM_ACTIVE,
   1.610 +    SEEK_FORWARD_FROM_INACTIVE,
   1.611 +    SEEK_BACKWARD_FROM_ACTIVE,
   1.612 +    SEEK_BACKWARD_FROM_INACTIVE
   1.613 +  };
   1.614 +  nsSMILSeekState                 mSeekState;
   1.615 +
   1.616 +  // Used to batch updates to the timing model
   1.617 +  class AutoIntervalUpdateBatcher;
   1.618 +  bool mDeferIntervalUpdates;
   1.619 +  bool mDoDeferredUpdate; // Set if an update to the current interval was
   1.620 +                          // requested while mDeferIntervalUpdates was set
   1.621 +
   1.622 +  // Stack-based helper class to call UpdateCurrentInterval when it is destroyed
   1.623 +  class AutoIntervalUpdater;
   1.624 +
   1.625 +  // Recursion depth checking
   1.626 +  uint8_t              mDeleteCount;
   1.627 +  uint8_t              mUpdateIntervalRecursionDepth;
   1.628 +  static const uint8_t sMaxUpdateIntervalRecursionDepth;
   1.629 +};
   1.630 +
   1.631 +#endif // NS_SMILTIMEDELEMENT_H_

mercurial