LCOV - code coverage report
Current view: top level - dom/animation - AnimationTarget.h (source / functions) Hit Total Coverage
Test: output.info Lines: 11 24 45.8 %
Date: 2017-07-14 16:53:18 Functions: 7 12 58.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_AnimationTarget_h
       8             : #define mozilla_AnimationTarget_h
       9             : 
      10             : #include "mozilla/Attributes.h"   // For MOZ_NON_OWNING_REF
      11             : #include "mozilla/Maybe.h"
      12             : #include "mozilla/RefPtr.h"
      13             : #include "nsCSSPseudoElements.h"
      14             : 
      15             : namespace mozilla {
      16             : 
      17             : namespace dom {
      18             : class Element;
      19             : } // namespace dom
      20             : 
      21           4 : struct OwningAnimationTarget
      22             : {
      23           2 :   OwningAnimationTarget(dom::Element* aElement, CSSPseudoElementType aType)
      24           2 :     : mElement(aElement), mPseudoType(aType) { }
      25             : 
      26           0 :   explicit OwningAnimationTarget(dom::Element* aElement)
      27           0 :     : mElement(aElement) { }
      28             : 
      29           0 :   bool operator==(const OwningAnimationTarget& aOther) const
      30             :   {
      31           0 :      return mElement == aOther.mElement &&
      32           0 :             mPseudoType == aOther.mPseudoType;
      33             :   }
      34             : 
      35             :   // mElement represents the parent element of a pseudo-element, not the
      36             :   // generated content element.
      37             :   RefPtr<dom::Element> mElement;
      38             :   CSSPseudoElementType mPseudoType = CSSPseudoElementType::NotPseudo;
      39             : };
      40             : 
      41             : struct NonOwningAnimationTarget
      42             : {
      43           2 :   NonOwningAnimationTarget() = default;
      44             : 
      45       31486 :   NonOwningAnimationTarget(dom::Element* aElement, CSSPseudoElementType aType)
      46       31486 :     : mElement(aElement), mPseudoType(aType) { }
      47             : 
      48           8 :   explicit NonOwningAnimationTarget(const OwningAnimationTarget& aOther)
      49           8 :     : mElement(aOther.mElement), mPseudoType(aOther.mPseudoType) { }
      50             : 
      51           3 :   bool operator==(const NonOwningAnimationTarget& aOther) const
      52             :   {
      53           3 :     return mElement == aOther.mElement &&
      54           3 :            mPseudoType == aOther.mPseudoType;
      55             :   }
      56             : 
      57             :   // mElement represents the parent element of a pseudo-element, not the
      58             :   // generated content element.
      59             :   dom::Element* MOZ_NON_OWNING_REF mElement = nullptr;
      60             :   CSSPseudoElementType mPseudoType = CSSPseudoElementType::NotPseudo;
      61             : };
      62             : 
      63             : 
      64             : // Helper functions for cycle-collecting Maybe<OwningAnimationTarget>
      65             : inline void
      66           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
      67             :                             Maybe<OwningAnimationTarget>& aTarget,
      68             :                             const char* aName,
      69             :                             uint32_t aFlags = 0)
      70             : {
      71           0 :   if (aTarget) {
      72           0 :     ImplCycleCollectionTraverse(aCallback, aTarget->mElement, aName, aFlags);
      73             :   }
      74           0 : }
      75             : 
      76             : inline void
      77           0 : ImplCycleCollectionUnlink(Maybe<OwningAnimationTarget>& aTarget)
      78             : {
      79           0 :   if (aTarget) {
      80           0 :     ImplCycleCollectionUnlink(aTarget->mElement);
      81             :   }
      82           0 : }
      83             : 
      84             : } // namespace mozilla
      85             : 
      86             : #endif // mozilla_AnimationTarget_h

Generated by: LCOV version 1.13