LCOV - app.info - content/smil/nsSMILTimedElement.h

LCOV - code coverage report
| Current view: | directory - content/smil - nsSMILTimedElement.h (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 12 | 0 | 0.0 %
| Date: | 2012-04-21 | Functions: | 5 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is the Mozilla SMIL module.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is Brian Birtles.
          18                 :  * Portions created by the Initial Developer are Copyright (C) 2005
          19                 :  * the Initial Developer. All Rights Reserved.
          20                 :  *
          21                 :  * Contributor(s):
          22                 :  *   Brian Birtles <birtles@gmail.com>
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
          26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : #ifndef NS_SMILTIMEDELEMENT_H_
          39                 : #define NS_SMILTIMEDELEMENT_H_
          40                 :
          41                 : #include "nsSMILInterval.h"
          42                 : #include "nsSMILInstanceTime.h"
          43                 : #include "nsSMILMilestone.h"
          44                 : #include "nsSMILTimeValueSpec.h"
          45                 : #include "nsSMILRepeatCount.h"
          46                 : #include "nsSMILTypes.h"
          47                 : #include "nsTArray.h"
          48                 : #include "nsTHashtable.h"
          49                 : #include "nsHashKeys.h"
          50                 : #include "nsAutoPtr.h"
          51                 : #include "nsAttrValue.h"
          52                 :
          53                 : class nsISMILAnimationElement;
          54                 : class nsSMILAnimationFunction;
          55                 : class nsSMILTimeContainer;
          56                 : class nsSMILTimeValue;
          57                 : class nsIAtom;
          58                 :
          59                 : //----------------------------------------------------------------------
          60                 : // nsSMILTimedElement
          61                 :
          62                 : class nsSMILTimedElement
          63                 : {
          64                 : public:
          65                 :   nsSMILTimedElement();
          66                 :   ~nsSMILTimedElement();
          67                 :
          68                 :   typedef mozilla::dom::Element Element;
          69                 :
          70                 :   /*
          71                 :    * Sets the owning animation element which this class uses to convert between
          72                 :    * container times and to register timebase elements.
          73                 :    */
          74                 :   void SetAnimationElement(nsISMILAnimationElement* aElement);
          75                 :
          76                 :   /*
          77                 :    * Returns the time container with which this timed element is associated or
          78                 :    * nsnull if it is not associated with a time container.
          79                 :    */
          80                 :   nsSMILTimeContainer* GetTimeContainer();
          81                 :
          82                 :   /*
          83                 :    * Returns the element targeted by the animation element. Needed for
          84                 :    * registering event listeners against the appropriate element.
          85                 :    */
          86               0 :   mozilla::dom::Element* GetTargetElement()
          87                 :   {
          88                 :     return mAnimationElement ?
          89               0 :         mAnimationElement->GetTargetElementContent() :
          90               0 :         nsnull;
          91                 :   }
          92                 :
          93                 :   /**
          94                 :    * Methods for supporting the nsIDOMElementTimeControl interface.
          95                 :    */
          96                 :
          97                 :   /*
          98                 :    * Adds a new begin instance time at the current container time plus or minus
          99                 :    * the specified offset.
         100                 :    *
         101                 :    * @param aOffsetSeconds A real number specifying the number of seconds to add
         102                 :    *                       to the current container time.
         103                 :    * @return NS_OK if the operation succeeeded, or an error code otherwise.
         104                 :    */
         105                 :   nsresult BeginElementAt(double aOffsetSeconds);
         106                 :
         107                 :   /*
         108                 :    * Adds a new end instance time at the current container time plus or minus
         109                 :    * the specified offset.
         110                 :    *
         111                 :    * @param aOffsetSeconds A real number specifying the number of seconds to add
         112                 :    *                       to the current container time.
         113                 :    * @return NS_OK if the operation succeeeded, or an error code otherwise.
         114                 :    */
         115                 :   nsresult EndElementAt(double aOffsetSeconds);
         116                 :
         117                 :   /**
         118                 :    * Methods for supporting the nsSVGAnimationElement interface.
         119                 :    */
         120                 :
         121                 :   /**
         122                 :    * According to SVG 1.1 SE this returns
         123                 :    *
         124                 :    *   the begin time, in seconds, for this animation element's current
         125                 :    *   interval, if it exists, regardless of whether the interval has begun yet.
         126                 :    *
         127                 :    * @return the start time as defined above in milliseconds or an unresolved
         128                 :    * time if there is no current interval.
         129                 :    */
         130                 :   nsSMILTimeValue GetStartTime() const;
         131                 :
         132                 :   /**
         133                 :    * Returns the simple duration of this element.
         134                 :    *
         135                 :    * @return the simple duration in milliseconds or INDEFINITE.
         136                 :    */
         137               0 :   nsSMILTimeValue GetSimpleDuration() const
         138                 :   {
         139               0 :     return mSimpleDur;
         140                 :   }
         141                 :
         142                 :   /**
         143                 :    * Internal SMIL methods
         144                 :    */
         145                 :
         146                 :   /**
         147                 :    * Adds an instance time object this element's list of instance times.
         148                 :    * These instance times are used when creating intervals.
         149                 :    *
         150                 :    * This method is typically called by an nsSMILTimeValueSpec.
         151                 :    *
         152                 :    * @param aInstanceTime   The time to add, expressed in container time.
         153                 :    * @param aIsBegin        true if the time to be added represents a begin
         154                 :    *                        time or false if it represents an end time.
         155                 :    */
         156                 :   void AddInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
         157                 :
         158                 :   /**
         159                 :    * Requests this element update the given instance time.
         160                 :    *
         161                 :    * This method is typically called by a child nsSMILTimeValueSpec.
         162                 :    *
         163                 :    * @param aInstanceTime   The instance time to update.
         164                 :    * @param aUpdatedTime    The time to update aInstanceTime with.
         165                 :    * @param aDependentTime  The instance time upon which aInstanceTime should be
         166                 :    *                        based.
         167                 :    * @param aIsBegin        true if the time to be updated represents a begin
         168                 :    *                        instance time or false if it represents an end
         169                 :    *                        instance time.
         170                 :    */
         171                 :   void UpdateInstanceTime(nsSMILInstanceTime* aInstanceTime,
         172                 :                           nsSMILTimeValue& aUpdatedTime,
         173                 :                           bool aIsBegin);
         174                 :
         175                 :   /**
         176                 :    * Removes an instance time object from this element's list of instance times.
         177                 :    *
         178                 :    * This method is typically called by a child nsSMILTimeValueSpec.
         179                 :    *
         180                 :    * @param aInstanceTime   The instance time to remove.
         181                 :    * @param aIsBegin        true if the time to be removed represents a begin
         182                 :    *                        time or false if it represents an end time.
         183                 :    */
         184                 :   void RemoveInstanceTime(nsSMILInstanceTime* aInstanceTime, bool aIsBegin);
         185                 :
         186                 :   /**
         187                 :    * Removes all the instance times associated with the given
         188                 :    * nsSMILTimeValueSpec object. Used when an ID assignment changes and hence
         189                 :    * all the previously associated instance times become invalid.
         190                 :    *
         191                 :    * @param aSpec    The nsSMILTimeValueSpec object whose created
         192                 :    *                 nsSMILInstanceTime's should be removed.
         193                 :    * @param aIsBegin true if the times to be removed represent begin
         194                 :    *                 times or false if they are end times.
         195                 :    */
         196                 :   void RemoveInstanceTimesForCreator(const nsSMILTimeValueSpec* aSpec,
         197                 :                                      bool aIsBegin);
         198                 :
         199                 :   /**
         200                 :    * Sets the object that will be called by this timed element each time it is
         201                 :    * sampled.
         202                 :    *
         203                 :    * In Schmitz's model it is possible to associate several time clients with
         204                 :    * a timed element but for now we only allow one.
         205                 :    *
         206                 :    * @param aClient   The time client to associate. Any previous time client
         207                 :    *                  will be disassociated and no longer sampled. Setting this
         208                 :    *                  to nsnull will simply disassociate the previous client, if
         209                 :    *                  any.
         210                 :    */
         211                 :   void SetTimeClient(nsSMILAnimationFunction* aClient);
         212                 :
         213                 :   /**
         214                 :    * Samples the object at the given container time. Timing intervals are
         215                 :    * updated and if this element is active at the given time the associated time
         216                 :    * client will be sampled with the appropriate simple time.
         217                 :    *
         218                 :    * @param aContainerTime The container time at which to sample.
         219                 :    */
         220                 :   void SampleAt(nsSMILTime aContainerTime);
         221                 :
         222                 :   /**
         223                 :    * Performs a special sample for the end of an interval. Such a sample should
         224                 :    * only advance the timed element (and any dependent elements) to the waiting
         225                 :    * or postactive state. It should not cause a transition to the active state.
         226                 :    * Transition to the active state is only performed on a regular SampleAt.
         227                 :    *
         228                 :    * This allows all interval ends at a given time to be processed first and
         229                 :    * hence the new interval can be established based on full information of the
         230                 :    * available instance times.
         231                 :    *
         232                 :    * @param aContainerTime The container time at which to sample.
         233                 :    */
         234                 :   void SampleEndAt(nsSMILTime aContainerTime);
         235                 :
         236                 :   /**
         237                 :    * Informs the timed element that its time container has changed time
         238                 :    * relative to document time. The timed element therefore needs to update its
         239                 :    * dependent elements (which may belong to a different time container) so they
         240                 :    * can re-resolve their times.
         241                 :    */
         242                 :   void HandleContainerTimeChange();
         243                 :
         244                 :   /**
         245                 :    * Resets this timed element's accumulated times and intervals back to start
         246                 :    * up state.
         247                 :    *
         248                 :    * This is used for backwards seeking where rather than accumulating
         249                 :    * historical timing state and winding it back, we reset the element and seek
         250                 :    * forwards.
         251                 :    */
         252                 :   void Rewind();
         253                 :
         254                 :   /**
         255                 :    * Attempts to set an attribute on this timed element.
         256                 :    *
         257                 :    * @param aAttribute  The name of the attribute to set. The namespace of this
         258                 :    *                    attribute is not specified as it is checked by the host
         259                 :    *                    element. Only attributes in the namespace defined for
         260                 :    *                    SMIL attributes in the host language are passed to the
         261                 :    *                    timed element.
         262                 :    * @param aValue      The attribute value.
         263                 :    * @param aResult     The nsAttrValue object that may be used for storing the
         264                 :    *                    parsed result.
         265                 :    * @param aContextNode The element to use for context when resolving
         266                 :    *                     references to other elements.
         267                 :    * @param[out] aParseResult The result of parsing the attribute. Will be set
         268                 :    *                          to NS_OK if parsing is successful.
         269                 :    *
         270                 :    * @return true if the given attribute is a timing attribute, false
         271                 :    * otherwise.
         272                 :    */
         273                 :   bool SetAttr(nsIAtom* aAttribute, const nsAString& aValue,
         274                 :                  nsAttrValue& aResult, Element* aContextNode,
         275                 :                  nsresult* aParseResult = nsnull);
         276                 :
         277                 :   /**
         278                 :    * Attempts to unset an attribute on this timed element.
         279                 :    *
         280                 :    * @param aAttribute  The name of the attribute to set. As with SetAttr the
         281                 :    *                    namespace of the attribute is not specified (see
         282                 :    *                    SetAttr).
         283                 :    *
         284                 :    * @return true if the given attribute is a timing attribute, false
         285                 :    * otherwise.
         286                 :    */
         287                 :   bool UnsetAttr(nsIAtom* aAttribute);
         288                 :
         289                 :   /**
         290                 :    * Adds a syncbase dependency to the list of dependents that will be notified
         291                 :    * when this timed element creates, deletes, or updates its current interval.
         292                 :    *
         293                 :    * @param aDependent  The nsSMILTimeValueSpec object to notify. A raw pointer
         294                 :    *                    to this object will be stored. Therefore it is necessary
         295                 :    *                    for the object to be explicitly unregistered (with
         296                 :    *                    RemoveDependent) when it is destroyed.
         297                 :    */
         298                 :   void AddDependent(nsSMILTimeValueSpec& aDependent);
         299                 :
         300                 :   /**
         301                 :    * Removes a syncbase dependency from the list of dependents that are notified
         302                 :    * when the current interval is modified.
         303                 :    *
         304                 :    * @param aDependent  The nsSMILTimeValueSpec object to unregister.
         305                 :    */
         306                 :   void RemoveDependent(nsSMILTimeValueSpec& aDependent);
         307                 :
         308                 :   /**
         309                 :    * Determines if this timed element is dependent on the given timed element's
         310                 :    * begin time for the interval currently in effect. Whilst the element is in
         311                 :    * the active state this is the current interval and in the postactive or
         312                 :    * waiting state this is the previous interval if one exists. In all other
         313                 :    * cases the element is not considered a time dependent of any other element.
         314                 :    *
         315                 :    * @param aOther    The potential syncbase element.
         316                 :    * @return true if this timed element's begin time for the currently
         317                 :    * effective interval is directly or indirectly derived from aOther, false
         318                 :    * otherwise.
         319                 :    */
         320                 :   bool IsTimeDependent(const nsSMILTimedElement& aOther) const;
         321                 :
         322                 :   /**
         323                 :    * Called when the timed element has been bound to the document so that
         324                 :    * references from this timed element to other elements can be resolved.
         325                 :    *
         326                 :    * @param aContextNode  The node which provides the necessary context for
         327                 :    *                      resolving references. This is typically the element in
         328                 :    *                      the host language that owns this timed element. Should
         329                 :    *                      not be null.
         330                 :    */
         331                 :   void BindToTree(nsIContent* aContextNode);
         332                 :
         333                 :   /**
         334                 :    * Called when the target of the animation has changed so that event
         335                 :    * registrations can be updated.
         336                 :    */
         337                 :   void HandleTargetElementChange(mozilla::dom::Element* aNewTarget);
         338                 :
         339                 :   /**
         340                 :    * Called when the timed element has been removed from a document so that
         341                 :    * references to other elements can be broken.
         342                 :    */
         343               0 :   void DissolveReferences() { Unlink(); }
         344                 :
         345                 :   // Cycle collection
         346                 :   void Traverse(nsCycleCollectionTraversalCallback* aCallback);
         347                 :   void Unlink();
         348                 :
         349                 :   typedef bool (*RemovalTestFunction)(nsSMILInstanceTime* aInstance);
         350                 :
         351                 : protected:
         352                 :   // Typedefs
         353                 :   typedef nsTArray<nsAutoPtr<nsSMILTimeValueSpec> > TimeValueSpecList;
         354                 :   typedef nsTArray<nsRefPtr<nsSMILInstanceTime> >   InstanceTimeList;
         355                 :   typedef nsTArray<nsAutoPtr<nsSMILInterval> >      IntervalList;
         356                 :   typedef nsPtrHashKey<nsSMILTimeValueSpec> TimeValueSpecPtrKey;
         357                 :   typedef nsTHashtable<TimeValueSpecPtrKey> TimeValueSpecHashSet;
         358                 :
         359                 :   // Helper classes
         360                 :   class InstanceTimeComparator {
         361                 :     public:
         362                 :       bool Equals(const nsSMILInstanceTime* aElem1,
         363                 :                     const nsSMILInstanceTime* aElem2) const;
         364                 :       bool LessThan(const nsSMILInstanceTime* aElem1,
         365                 :                       const nsSMILInstanceTime* aElem2) const;
         366                 :   };
         367                 :
         368                 :   struct NotifyTimeDependentsParams {
         369                 :     nsSMILTimedElement*  mTimedElement;
         370                 :     nsSMILTimeContainer* mTimeContainer;
         371                 :   };
         372                 :
         373                 :   // Templated helper functions
         374                 :   template <class TestFunctor>
         375                 :   void RemoveInstanceTimes(InstanceTimeList& aArray, TestFunctor& aTest);
         376                 :
         377                 :   //
         378                 :   // Implementation helpers
         379                 :   //
         380                 :
         381                 :   nsresult          SetBeginSpec(const nsAString& aBeginSpec,
         382                 :                                  Element* aContextNode,
         383                 :                                  RemovalTestFunction aRemove);
         384                 :   nsresult          SetEndSpec(const nsAString& aEndSpec,
         385                 :                                Element* aContextNode,
         386                 :                                RemovalTestFunction aRemove);
         387                 :   nsresult          SetSimpleDuration(const nsAString& aDurSpec);
         388                 :   nsresult          SetMin(const nsAString& aMinSpec);
         389                 :   nsresult          SetMax(const nsAString& aMaxSpec);
         390                 :   nsresult          SetRestart(const nsAString& aRestartSpec);
         391                 :   nsresult          SetRepeatCount(const nsAString& aRepeatCountSpec);
         392                 :   nsresult          SetRepeatDur(const nsAString& aRepeatDurSpec);
         393                 :   nsresult          SetFillMode(const nsAString& aFillModeSpec);
         394                 :
         395                 :   void              UnsetBeginSpec(RemovalTestFunction aRemove);
         396                 :   void              UnsetEndSpec(RemovalTestFunction aRemove);
         397                 :   void              UnsetSimpleDuration();
         398                 :   void              UnsetMin();
         399                 :   void              UnsetMax();
         400                 :   void              UnsetRestart();
         401                 :   void              UnsetRepeatCount();
         402                 :   void              UnsetRepeatDur();
         403                 :   void              UnsetFillMode();
         404                 :
         405                 :   nsresult          SetBeginOrEndSpec(const nsAString& aSpec,
         406                 :                                       Element* aContextNode,
         407                 :                                       bool aIsBegin,
         408                 :                                       RemovalTestFunction aRemove);
         409                 :   void              ClearSpecs(TimeValueSpecList& aSpecs,
         410                 :                                InstanceTimeList& aInstances,
         411                 :                                RemovalTestFunction aRemove);
         412                 :   void              ClearIntervals();
         413                 :   void              DoSampleAt(nsSMILTime aContainerTime, bool aEndOnly);
         414                 :
         415                 :   /**
         416                 :    * Helper function to check for an early end and, if necessary, update the
         417                 :    * current interval accordingly.
         418                 :    *
         419                 :    * See SMIL 3.0, section 5.4.5, Element life cycle, "Active Time - Playing an
         420                 :    * interval" for a description of ending early.
         421                 :    *
         422                 :    * @param aSampleTime The current sample time. Early ends should only be
         423                 :    *                    applied at the last possible moment (i.e. if they are at
         424                 :    *                    or before the current sample time) and only if the
         425                 :    *                    current interval is not already ending.
         426                 :    * @return true if the end time of the current interval was updated,
         427                 :    *         false otherwise.
         428                 :    */
         429                 :   bool ApplyEarlyEnd(const nsSMILTimeValue& aSampleTime);
         430                 :
         431                 :   /**
         432                 :    * Clears certain state in response to the element restarting.
         433                 :    *
         434                 :    * This state is described in SMIL 3.0, section 5.4.3, Resetting element state
         435                 :    */
         436                 :   void Reset();
         437                 :
         438                 :   /**
         439                 :    * Completes a seek operation by sending appropriate events and, in the case
         440                 :    * of a backwards seek, updating the state of timing information that was
         441                 :    * previously considered historical.
         442                 :    */
         443                 :   void DoPostSeek();
         444                 :
         445                 :   /**
         446                 :    * Unmarks instance times that were previously preserved because they were
         447                 :    * considered important historical milestones but are no longer such because
         448                 :    * a backwards seek has been performed.
         449                 :    */
         450                 :   void UnpreserveInstanceTimes(InstanceTimeList& aList);
         451                 :
         452                 :   /**
         453                 :    * Helper function to iterate through this element's accumulated timing
         454                 :    * information (specifically old nsSMILIntervals and nsSMILTimeInstanceTimes)
         455                 :    * and discard items that are no longer needed or exceed some threshold of
         456                 :    * accumulated state.
         457                 :    */
         458                 :   void FilterHistory();
         459                 :
         460                 :   // Helper functions for FilterHistory to clear old nsSMILIntervals and
         461                 :   // nsSMILInstanceTimes respectively.
         462                 :   void FilterIntervals();
         463                 :   void FilterInstanceTimes(InstanceTimeList& aList);
         464                 :
         465                 :   /**
         466                 :    * Calculates the next acceptable interval for this element after the
         467                 :    * specified interval, or, if no previous interval is specified, it will be
         468                 :    * the first interval with an end time after t=0.
         469                 :    *
         470                 :    * @see SMILANIM 3.6.8
         471                 :    *
         472                 :    * @param aPrevInterval   The previous interval used. If supplied, the first
         473                 :    *                        interval that begins after aPrevInterval will be
         474                 :    *                        returned. May be nsnull.
         475                 :    * @param aReplacedInterval The interval that is being updated (if any). This
         476                 :    *                        used to ensure we don't return interval endpoints
         477                 :    *                        that are dependent on themselves. May be nsnull.
         478                 :    * @param aFixedBeginTime The time to use for the start of the interval. This
         479                 :    *                        is used when only the endpoint of the interval
         480                 :    *                        should be updated such as when the animation is in
         481                 :    *                        the ACTIVE state. May be nsnull.
         482                 :    * @param[out] aResult    The next interval. Will be unchanged if no suitable
         483                 :    *                        interval was found (in which case false will be
         484                 :    *                        returned).
         485                 :    * @return  true if a suitable interval was found, false otherwise.
         486                 :    */
         487                 :   bool              GetNextInterval(const nsSMILInterval* aPrevInterval,
         488                 :                                     const nsSMILInterval* aReplacedInterval,
         489                 :                                     const nsSMILInstanceTime* aFixedBeginTime,
         490                 :                                     nsSMILInterval& aResult) const;
         491                 :   nsSMILInstanceTime* GetNextGreater(const InstanceTimeList& aList,
         492                 :                                      const nsSMILTimeValue& aBase,
         493                 :                                      PRInt32& aPosition) const;
         494                 :   nsSMILInstanceTime* GetNextGreaterOrEqual(const InstanceTimeList& aList,
         495                 :                                             const nsSMILTimeValue& aBase,
         496                 :                                             PRInt32& aPosition) const;
         497                 :   nsSMILTimeValue   CalcActiveEnd(const nsSMILTimeValue& aBegin,
         498                 :                                   const nsSMILTimeValue& aEnd) const;
         499                 :   nsSMILTimeValue   GetRepeatDuration() const;
         500                 :   nsSMILTimeValue   ApplyMinAndMax(const nsSMILTimeValue& aDuration) const;
         501                 :   nsSMILTime        ActiveTimeToSimpleTime(nsSMILTime aActiveTime,
         502                 :                                            PRUint32& aRepeatIteration);
         503                 :   nsSMILInstanceTime* CheckForEarlyEnd(
         504                 :                         const nsSMILTimeValue& aContainerTime) const;
         505                 :   void              UpdateCurrentInterval(bool aForceChangeNotice = false);
         506                 :   void              SampleSimpleTime(nsSMILTime aActiveTime);
         507                 :   void              SampleFillValue();
         508                 :   nsresult          AddInstanceTimeFromCurrentTime(nsSMILTime aCurrentTime,
         509                 :                         double aOffsetSeconds, bool aIsBegin);
         510                 :   void              RegisterMilestone();
         511                 :   bool              GetNextMilestone(nsSMILMilestone& aNextMilestone) const;
         512                 :
         513                 :   // Notification methods. Note that these notifications can result in nested
         514                 :   // calls to this same object. Therefore,
         515                 :   // (i)  we should not perform notification until this object is in
         516                 :   //      a consistent state to receive callbacks, and
         517                 :   // (ii) after calling these methods we must assume that the state of the
         518                 :   //      element may have changed.
         519                 :   void              NotifyNewInterval();
         520                 :   void              NotifyChangedInterval(nsSMILInterval* aInterval,
         521                 :                                           bool aBeginObjectChanged,
         522                 :                                           bool aEndObjectChanged);
         523                 :
         524                 :   void              FireTimeEventAsync(PRUint32 aMsg, PRInt32 aDetail);
         525                 :   const nsSMILInstanceTime* GetEffectiveBeginInstance() const;
         526                 :   const nsSMILInterval* GetPreviousInterval() const;
         527               0 :   bool              HasPlayed() const { return !mOldIntervals.IsEmpty(); }
         528                 :   bool              EndHasEventConditions() const;
         529                 :   bool              AreEndTimesDependentOn(
         530                 :                       const nsSMILInstanceTime* aBase) const;
         531                 :
         532                 :   // Reset the current interval by first passing ownership to a temporary
         533                 :   // variable so that if Unlink() results in us receiving a callback,
         534                 :   // mCurrentInterval will be nsnull and we will be in a consistent state.
         535               0 :   void ResetCurrentInterval()
         536                 :   {
         537               0 :     if (mCurrentInterval) {
         538                 :       // Transfer ownership to temp var. (This sets mCurrentInterval to null.)
         539               0 :       nsAutoPtr<nsSMILInterval> interval(mCurrentInterval);
         540               0 :       interval->Unlink();
         541                 :     }
         542               0 :   }
         543                 :
         544                 :   // Hashtable callback methods
         545                 :   PR_STATIC_CALLBACK(PLDHashOperator) NotifyNewIntervalCallback(
         546                 :       TimeValueSpecPtrKey* aKey, void* aData);
         547                 :
         548                 :   //
         549                 :   // Members
         550                 :   //
         551                 :   nsISMILAnimationElement*        mAnimationElement; // [weak] won't outlive
         552                 :                                                      // owner
         553                 :   TimeValueSpecList               mBeginSpecs; // [strong]
         554                 :   TimeValueSpecList               mEndSpecs; // [strong]
         555                 :
         556                 :   nsSMILTimeValue                 mSimpleDur;
         557                 :
         558                 :   nsSMILRepeatCount               mRepeatCount;
         559                 :   nsSMILTimeValue                 mRepeatDur;
         560                 :
         561                 :   nsSMILTimeValue                 mMin;
         562                 :   nsSMILTimeValue                 mMax;
         563                 :
         564                 :   enum nsSMILFillMode
         565                 :   {
         566                 :     FILL_REMOVE,
         567                 :     FILL_FREEZE
         568                 :   };
         569                 :   nsSMILFillMode                  mFillMode;
         570                 :   static nsAttrValue::EnumTable   sFillModeTable[];
         571                 :
         572                 :   enum nsSMILRestartMode
         573                 :   {
         574                 :     RESTART_ALWAYS,
         575                 :     RESTART_WHENNOTACTIVE,
         576                 :     RESTART_NEVER
         577                 :   };
         578                 :   nsSMILRestartMode               mRestartMode;
         579                 :   static nsAttrValue::EnumTable   sRestartModeTable[];
         580                 :
         581                 :   InstanceTimeList                mBeginInstances;
         582                 :   InstanceTimeList                mEndInstances;
         583                 :   PRUint32                        mInstanceSerialIndex;
         584                 :
         585                 :   nsSMILAnimationFunction*        mClient;
         586                 :   nsAutoPtr<nsSMILInterval>       mCurrentInterval;
         587                 :   IntervalList                    mOldIntervals;
         588                 :   PRUint32                        mCurrentRepeatIteration;
         589                 :   nsSMILMilestone                 mPrevRegisteredMilestone;
         590                 :   static const nsSMILMilestone    sMaxMilestone;
         591                 :   static const PRUint8            sMaxNumIntervals;
         592                 :   static const PRUint8            sMaxNumInstanceTimes;
         593                 :
         594                 :   // Set of dependent time value specs to be notified when establishing a new
         595                 :   // current interval. Change notifications and delete notifications are handled
         596                 :   // by the interval.
         597                 :   //
         598                 :   // [weak] The nsSMILTimeValueSpec objects register themselves and unregister
         599                 :   // on destruction. Likewise, we notify them when we are destroyed.
         600                 :   TimeValueSpecHashSet mTimeDependents;
         601                 :
         602                 :   /**
         603                 :    * The state of the element in its life-cycle. These states are based on the
         604                 :    * element life-cycle described in SMILANIM 3.6.8
         605                 :    */
         606                 :   enum nsSMILElementState
         607                 :   {
         608                 :     STATE_STARTUP,
         609                 :     STATE_WAITING,
         610                 :     STATE_ACTIVE,
         611                 :     STATE_POSTACTIVE
         612                 :   };
         613                 :   nsSMILElementState              mElementState;
         614                 :
         615                 :   enum nsSMILSeekState
         616                 :   {
         617                 :     SEEK_NOT_SEEKING,
         618                 :     SEEK_FORWARD_FROM_ACTIVE,
         619                 :     SEEK_FORWARD_FROM_INACTIVE,
         620                 :     SEEK_BACKWARD_FROM_ACTIVE,
         621                 :     SEEK_BACKWARD_FROM_INACTIVE
         622                 :   };
         623                 :   nsSMILSeekState                 mSeekState;
         624                 :
         625                 :   // Used to batch updates to the timing model
         626                 :   class AutoIntervalUpdateBatcher;
         627                 :   bool mDeferIntervalUpdates;
         628                 :   bool mDoDeferredUpdate; // Set if an update to the current interval was
         629                 :                           // requested while mDeferIntervalUpdates was set
         630                 :
         631                 :   // Recursion depth checking
         632                 :   PRUint8              mDeleteCount;
         633                 :   PRUint8              mUpdateIntervalRecursionDepth;
         634                 :   static const PRUint8 sMaxUpdateIntervalRecursionDepth;
         635                 : };
         636                 :
         637                 : #endif // NS_SMILTIMEDELEMENT_H_

Generated by: LCOV version 1.7