LCOV - code coverage report
Current view: directory - layout/style - AnimationCommon.h (source / functions) Found Hit Coverage
Test: app.info Lines: 25 0 0.0 %
Date: 2012-06-02 Functions: 11 0 0.0 %

       1                 : /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
       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 AnimationCommon, common animation code for transitions
      16                 :  * and animations.
      17                 :  *
      18                 :  * The Initial Developer of the Original Code is the Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2011
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef mozilla_css_AnimationCommon_h
      40                 : #define mozilla_css_AnimationCommon_h
      41                 : 
      42                 : #include "nsIStyleRuleProcessor.h"
      43                 : #include "nsIStyleRule.h"
      44                 : #include "nsRefreshDriver.h"
      45                 : #include "prclist.h"
      46                 : #include "nsStyleAnimation.h"
      47                 : #include "nsCSSProperty.h"
      48                 : #include "mozilla/dom/Element.h"
      49                 : #include "nsSMILKeySpline.h"
      50                 : #include "nsStyleStruct.h"
      51                 : 
      52                 : class nsPresContext;
      53                 : 
      54                 : namespace mozilla {
      55                 : namespace css {
      56                 : 
      57                 : struct CommonElementAnimationData;
      58                 : 
      59                 : class CommonAnimationManager : public nsIStyleRuleProcessor,
      60                 :                                public nsARefreshObserver {
      61                 : public:
      62                 :   CommonAnimationManager(nsPresContext *aPresContext);
      63                 :   virtual ~CommonAnimationManager();
      64                 : 
      65                 :   // nsISupports
      66                 :   NS_DECL_ISUPPORTS
      67                 : 
      68                 :   // nsIStyleRuleProcessor (parts)
      69                 :   virtual nsRestyleHint HasStateDependentStyle(StateRuleProcessorData* aData);
      70                 :   virtual bool HasDocumentStateDependentStyle(StateRuleProcessorData* aData);
      71                 :   virtual nsRestyleHint
      72                 :     HasAttributeDependentStyle(AttributeRuleProcessorData* aData);
      73                 :   virtual bool MediumFeaturesChanged(nsPresContext* aPresContext);
      74                 :   virtual NS_MUST_OVERRIDE size_t
      75                 :     SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE;
      76                 :   virtual NS_MUST_OVERRIDE size_t
      77                 :     SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE;
      78                 : 
      79                 :   /**
      80                 :    * Notify the manager that the pres context is going away.
      81                 :    */
      82                 :   void Disconnect();
      83                 : 
      84                 :   static bool ExtractComputedValueForTransition(
      85                 :                   nsCSSProperty aProperty,
      86                 :                   nsStyleContext* aStyleContext,
      87                 :                   nsStyleAnimation::Value& aComputedValue);
      88                 : protected:
      89                 :   friend struct CommonElementAnimationData; // for ElementDataRemoved
      90                 : 
      91                 :   void AddElementData(CommonElementAnimationData* aData);
      92                 :   void ElementDataRemoved();
      93                 :   void RemoveAllElementData();
      94                 : 
      95                 :   PRCList mElementData;
      96                 :   nsPresContext *mPresContext; // weak (non-null from ctor to Disconnect)
      97                 : };
      98                 : 
      99                 : /**
     100                 :  * A style rule that maps property-nsStyleAnimation::Value pairs.
     101                 :  */
     102                 : class AnimValuesStyleRule : public nsIStyleRule
     103               0 : {
     104                 : public:
     105                 :   // nsISupports implementation
     106                 :   NS_DECL_ISUPPORTS
     107                 : 
     108                 :   // nsIStyleRule implementation
     109                 :   virtual void MapRuleInfoInto(nsRuleData* aRuleData);
     110                 : #ifdef DEBUG
     111                 :   virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
     112                 : #endif
     113                 : 
     114               0 :   void AddValue(nsCSSProperty aProperty, nsStyleAnimation::Value &aStartValue)
     115                 :   {
     116               0 :     PropertyValuePair v = { aProperty, aStartValue };
     117               0 :     mPropertyValuePairs.AppendElement(v);
     118               0 :   }
     119                 : 
     120                 :   // Caller must fill in returned value.
     121               0 :   nsStyleAnimation::Value* AddEmptyValue(nsCSSProperty aProperty)
     122                 :   {
     123               0 :     PropertyValuePair *p = mPropertyValuePairs.AppendElement();
     124               0 :     p->mProperty = aProperty;
     125               0 :     return &p->mValue;
     126                 :   }
     127                 : 
     128               0 :   struct PropertyValuePair {
     129                 :     nsCSSProperty mProperty;
     130                 :     nsStyleAnimation::Value mValue;
     131                 :   };
     132                 : 
     133                 : private:
     134                 :   InfallibleTArray<PropertyValuePair> mPropertyValuePairs;
     135                 : };
     136                 : 
     137               0 : class ComputedTimingFunction {
     138                 : public:
     139                 :   typedef nsTimingFunction::Type Type;
     140                 :   void Init(const nsTimingFunction &aFunction);
     141                 :   double GetValue(double aPortion) const;
     142                 : private:
     143                 :   Type mType;
     144                 :   nsSMILKeySpline mTimingFunction;
     145                 :   PRUint32 mSteps;
     146                 : };
     147                 : 
     148                 : struct CommonElementAnimationData : public PRCList
     149                 : {
     150               0 :   CommonElementAnimationData(dom::Element *aElement, nsIAtom *aElementProperty,
     151                 :                              CommonAnimationManager *aManager)
     152                 :     : mElement(aElement)
     153                 :     , mElementProperty(aElementProperty)
     154                 :     , mManager(aManager)
     155                 : #ifdef DEBUG
     156               0 :     , mCalledPropertyDtor(false)
     157                 : #endif
     158                 :   {
     159               0 :     MOZ_COUNT_CTOR(CommonElementAnimationData);
     160               0 :     PR_INIT_CLIST(this);
     161               0 :   }
     162               0 :   ~CommonElementAnimationData()
     163                 :   {
     164               0 :     NS_ABORT_IF_FALSE(mCalledPropertyDtor,
     165                 :                       "must call destructor through element property dtor");
     166               0 :     MOZ_COUNT_DTOR(CommonElementAnimationData);
     167               0 :     PR_REMOVE_LINK(this);
     168               0 :     mManager->ElementDataRemoved();
     169               0 :   }
     170                 : 
     171               0 :   void Destroy()
     172                 :   {
     173                 :     // This will call our destructor.
     174               0 :     mElement->DeleteProperty(mElementProperty);
     175               0 :   }
     176                 : 
     177                 :   dom::Element *mElement;
     178                 : 
     179                 :   // the atom we use in mElement's prop table (must be a static atom,
     180                 :   // i.e., in an atom list)
     181                 :   nsIAtom *mElementProperty;
     182                 : 
     183                 :   CommonAnimationManager *mManager;
     184                 : 
     185                 : #ifdef DEBUG
     186                 :   bool mCalledPropertyDtor;
     187                 : #endif
     188                 : };
     189                 : 
     190                 : }
     191                 : }
     192                 : 
     193                 : #endif /* !defined(mozilla_css_AnimationCommon_h) */

Generated by: LCOV version 1.7