LCOV - code coverage report
Current view: directory - content/smil - nsSMILTimeValueSpec.h (source / functions) Found Hit Coverage
Test: app.info Lines: 16 0 0.0 %
Date: 2012-06-02 Functions: 7 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_SMILTIMEVALUESPEC_H_
      39                 : #define NS_SMILTIMEVALUESPEC_H_
      40                 : 
      41                 : #include "nsSMILTimeValueSpecParams.h"
      42                 : #include "nsReferencedElement.h"
      43                 : #include "nsAutoPtr.h"
      44                 : #include "nsIDOMEventListener.h"
      45                 : 
      46                 : class nsAString;
      47                 : class nsSMILTimeValue;
      48                 : class nsSMILTimedElement;
      49                 : class nsSMILTimeContainer;
      50                 : class nsSMILInstanceTime;
      51                 : class nsSMILInterval;
      52                 : 
      53                 : //----------------------------------------------------------------------
      54                 : // nsSMILTimeValueSpec class
      55                 : //
      56                 : // An individual element of a 'begin' or 'end' attribute, e.g. '5s', 'a.end'.
      57                 : // This class handles the parsing of such specifications and performs the
      58                 : // necessary event handling (for event, repeat, and accesskey specifications)
      59                 : // and synchronisation (for syncbase specifications).
      60                 : //
      61                 : // For an overview of how this class is related to other SMIL time classes see
      62                 : // the documentation in nsSMILTimeValue.h
      63                 : 
      64                 : class nsSMILTimeValueSpec
      65                 : {
      66                 : public:
      67                 :   typedef mozilla::dom::Element Element;
      68                 : 
      69                 :   nsSMILTimeValueSpec(nsSMILTimedElement& aOwner, bool aIsBegin);
      70                 :   ~nsSMILTimeValueSpec();
      71                 : 
      72                 :   nsresult SetSpec(const nsAString& aStringSpec, Element* aContextNode);
      73                 :   void     ResolveReferences(nsIContent* aContextNode);
      74                 :   bool     IsEventBased() const;
      75                 : 
      76                 :   void     HandleNewInterval(nsSMILInterval& aInterval,
      77                 :                              const nsSMILTimeContainer* aSrcContainer);
      78                 :   void     HandleTargetElementChange(Element* aNewTarget);
      79                 : 
      80                 :   // For created nsSMILInstanceTime objects
      81                 :   bool     DependsOnBegin() const;
      82                 :   void     HandleChangedInstanceTime(const nsSMILInstanceTime& aBaseTime,
      83                 :                                      const nsSMILTimeContainer* aSrcContainer,
      84                 :                                      nsSMILInstanceTime& aInstanceTimeToUpdate,
      85                 :                                      bool aObjectChanged);
      86                 :   void     HandleDeletedInstanceTime(nsSMILInstanceTime& aInstanceTime);
      87                 : 
      88                 :   // Cycle-collection support
      89                 :   void Traverse(nsCycleCollectionTraversalCallback* aCallback);
      90                 :   void Unlink();
      91                 : 
      92                 : protected:
      93                 :   void UpdateReferencedElement(Element* aFrom, Element* aTo);
      94                 :   void UnregisterFromReferencedElement(Element* aElement);
      95                 :   nsSMILTimedElement* GetTimedElement(Element* aElement);
      96                 :   bool IsWhitelistedEvent();
      97                 :   void RegisterEventListener(Element* aElement);
      98                 :   void UnregisterEventListener(Element* aElement);
      99                 :   nsEventListenerManager* GetEventListenerManager(Element* aElement);
     100                 :   void HandleEvent(nsIDOMEvent* aEvent);
     101                 :   bool CheckEventDetail(nsIDOMEvent* aEvent);
     102                 :   bool CheckRepeatEventDetail(nsIDOMEvent* aEvent);
     103                 :   bool CheckAccessKeyEventDetail(nsIDOMEvent* aEvent);
     104                 :   nsSMILTimeValue ConvertBetweenTimeContainers(const nsSMILTimeValue& aSrcTime,
     105                 :                                       const nsSMILTimeContainer* aSrcContainer);
     106                 :   bool ApplyOffset(nsSMILTimeValue& aTime) const;
     107                 : 
     108                 :   nsSMILTimedElement*           mOwner;
     109                 :   bool                          mIsBegin; // Indicates if *we* are a begin spec,
     110                 :                                           // not to be confused with
     111                 :                                           // mParams.mSyncBegin which indicates
     112                 :                                           // if we're synced with the begin of
     113                 :                                           // the target.
     114                 :   nsSMILTimeValueSpecParams     mParams;
     115                 : 
     116                 :   class TimeReferenceElement : public nsReferencedElement
     117               0 :   {
     118                 :   public:
     119               0 :     TimeReferenceElement(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
     120               0 :     void ResetWithElement(Element* aTo) {
     121               0 :       nsRefPtr<Element> from = get();
     122               0 :       Unlink();
     123               0 :       ElementChanged(from, aTo);
     124               0 :     }
     125                 : 
     126                 :   protected:
     127               0 :     virtual void ElementChanged(Element* aFrom, Element* aTo)
     128                 :     {
     129               0 :       nsReferencedElement::ElementChanged(aFrom, aTo);
     130               0 :       mSpec->UpdateReferencedElement(aFrom, aTo);
     131               0 :     }
     132               0 :     virtual bool IsPersistent() { return true; }
     133                 :   private:
     134                 :     nsSMILTimeValueSpec* mSpec;
     135                 :   };
     136                 : 
     137                 :   TimeReferenceElement mReferencedElement;
     138                 : 
     139                 :   class EventListener MOZ_FINAL : public nsIDOMEventListener
     140                 :   {
     141                 :   public:
     142               0 :     EventListener(nsSMILTimeValueSpec* aOwner) : mSpec(aOwner) { }
     143               0 :     void Disconnect()
     144                 :     {
     145               0 :       mSpec = nsnull;
     146               0 :     }
     147                 : 
     148                 :     NS_DECL_ISUPPORTS
     149                 :     NS_DECL_NSIDOMEVENTLISTENER
     150                 : 
     151                 :   private:
     152                 :     nsSMILTimeValueSpec* mSpec;
     153                 :   };
     154                 :   nsCOMPtr<EventListener> mEventListener;
     155                 : };
     156                 : 
     157                 : #endif // NS_SMILTIMEVALUESPEC_H_

Generated by: LCOV version 1.7