LCOV - code coverage report
Current view: directory - layout/style - nsAnimationManager.h (source / functions) Found Hit Coverage
Test: app.info Lines: 19 0 0.0 %
Date: 2012-06-02 Functions: 8 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 nsAnimationManager, an implementation of part
      16                 :  * of css3-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                 : #ifndef nsAnimationManager_h_
      39                 : #define nsAnimationManager_h_
      40                 : 
      41                 : #include "AnimationCommon.h"
      42                 : #include "nsCSSPseudoElements.h"
      43                 : #include "nsStyleContext.h"
      44                 : #include "nsDataHashtable.h"
      45                 : #include "nsGUIEvent.h"
      46                 : #include "mozilla/TimeStamp.h"
      47                 : #include "nsThreadUtils.h"
      48                 : 
      49                 : class nsCSSKeyframesRule;
      50                 : struct AnimationPropertySegment;
      51                 : struct ElementAnimation;
      52                 : struct ElementAnimations;
      53                 : 
      54                 : namespace mozilla {
      55                 : namespace css {
      56                 : class Declaration;
      57                 : }
      58                 : }
      59                 : 
      60                 : class nsAnimationManager : public mozilla::css::CommonAnimationManager
      61               0 : {
      62                 : public:
      63               0 :   nsAnimationManager(nsPresContext *aPresContext)
      64                 :     : mozilla::css::CommonAnimationManager(aPresContext),
      65               0 :       mKeyframesListIsDirty(true)
      66                 :   {
      67               0 :     mKeyframesRules.Init(16); // FIXME: make infallible!
      68               0 :   }
      69                 : 
      70               0 :   struct AnimationEventInfo {
      71                 :     nsRefPtr<mozilla::dom::Element> mElement;
      72                 :     nsAnimationEvent mEvent;
      73                 : 
      74               0 :     AnimationEventInfo(mozilla::dom::Element *aElement,
      75                 :                        const nsString& aAnimationName,
      76                 :                        PRUint32 aMessage, mozilla::TimeDuration aElapsedTime)
      77                 :       : mElement(aElement),
      78               0 :         mEvent(true, aMessage, aAnimationName, aElapsedTime.ToSeconds())
      79                 :     {
      80               0 :     }
      81                 : 
      82                 :     // nsAnimationEvent doesn't support copy-construction, so we need
      83                 :     // to ourselves in order to work with nsTArray
      84               0 :     AnimationEventInfo(const AnimationEventInfo &aOther)
      85                 :       : mElement(aOther.mElement),
      86                 :         mEvent(true, aOther.mEvent.message,
      87               0 :                aOther.mEvent.animationName, aOther.mEvent.elapsedTime)
      88                 :     {
      89               0 :     }
      90                 :   };
      91                 : 
      92                 :   // nsIStyleRuleProcessor (parts)
      93                 :   virtual void RulesMatching(ElementRuleProcessorData* aData);
      94                 :   virtual void RulesMatching(PseudoElementRuleProcessorData* aData);
      95                 :   virtual void RulesMatching(AnonBoxRuleProcessorData* aData);
      96                 : #ifdef MOZ_XUL
      97                 :   virtual void RulesMatching(XULTreeRuleProcessorData* aData);
      98                 : #endif
      99                 :   virtual NS_MUST_OVERRIDE size_t
     100                 :     SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE;
     101                 :   virtual NS_MUST_OVERRIDE size_t
     102                 :     SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf) const MOZ_OVERRIDE;
     103                 : 
     104                 :   // nsARefreshObserver
     105                 :   virtual void WillRefresh(mozilla::TimeStamp aTime);
     106                 : 
     107                 :   /**
     108                 :    * Return the style rule that RulesMatching should add for
     109                 :    * aStyleContext.  This might be different from what RulesMatching
     110                 :    * actually added during aStyleContext's construction because the
     111                 :    * element's animation-name may have changed.  (However, this does
     112                 :    * return null during the non-animation restyling phase, as
     113                 :    * RulesMatching does.)
     114                 :    *
     115                 :    * aStyleContext may be a style context for aElement or for its
     116                 :    * :before or :after pseudo-element.
     117                 :    */
     118                 :   nsIStyleRule* CheckAnimationRule(nsStyleContext* aStyleContext,
     119                 :                                    mozilla::dom::Element* aElement);
     120                 : 
     121               0 :   void KeyframesListIsDirty() {
     122               0 :     mKeyframesListIsDirty = true;
     123               0 :   }
     124                 : 
     125                 :   typedef InfallibleTArray<AnimationEventInfo> EventArray;
     126                 : 
     127                 :   /**
     128                 :    * Dispatch any pending events.  We accumulate animationend and
     129                 :    * animationiteration events only during refresh driver notifications
     130                 :    * (and dispatch them at the end of such notifications), but we
     131                 :    * accumulate animationstart events at other points when style
     132                 :    * contexts are created.
     133                 :    */
     134               0 :   void DispatchEvents() {
     135                 :     // Fast-path the common case: no events
     136               0 :     if (!mPendingEvents.IsEmpty()) {
     137               0 :       DoDispatchEvents();
     138                 :     }
     139               0 :   }
     140                 : 
     141                 : private:
     142                 :   ElementAnimations* GetElementAnimations(mozilla::dom::Element *aElement,
     143                 :                                           nsCSSPseudoElements::Type aPseudoType,
     144                 :                                           bool aCreateIfNeeded);
     145                 :   void BuildAnimations(nsStyleContext* aStyleContext,
     146                 :                        InfallibleTArray<ElementAnimation>& aAnimations);
     147                 :   bool BuildSegment(InfallibleTArray<AnimationPropertySegment>& aSegments,
     148                 :                     nsCSSProperty aProperty, const nsAnimation& aAnimation,
     149                 :                     float aFromKey, nsStyleContext* aFromContext,
     150                 :                     mozilla::css::Declaration* aFromDeclaration,
     151                 :                     float aToKey, nsStyleContext* aToContext);
     152                 :   nsIStyleRule* GetAnimationRule(mozilla::dom::Element* aElement,
     153                 :                                  nsCSSPseudoElements::Type aPseudoType);
     154                 : 
     155                 :   nsCSSKeyframesRule* KeyframesRuleFor(const nsSubstring& aName);
     156                 : 
     157                 :   // The guts of DispatchEvents
     158                 :   void DoDispatchEvents();
     159                 : 
     160                 :   bool mKeyframesListIsDirty;
     161                 :   nsDataHashtable<nsStringHashKey, nsCSSKeyframesRule*> mKeyframesRules;
     162                 : 
     163                 :   EventArray mPendingEvents;
     164                 : };
     165                 : 
     166                 : #endif /* !defined(nsAnimationManager_h_) */

Generated by: LCOV version 1.7