LCOV - code coverage report
Current view: top level - dom/animation - AnimationPerformanceWarning.h (source / functions) Hit Total Coverage
Test: output.info Lines: 3 13 23.1 %
Date: 2017-07-14 16:53:18 Functions: 2 8 25.0 %
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_dom_AnimationPerformanceWarning_h
       8             : #define mozilla_dom_AnimationPerformanceWarning_h
       9             : 
      10             : #include <initializer_list>
      11             : 
      12             : #include "mozilla/Maybe.h"
      13             : #include "nsTArray.h"
      14             : 
      15             : class nsXPIDLString;
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : // Represents the reason why we can't run the CSS property on the compositor.
      20          24 : struct AnimationPerformanceWarning
      21             : {
      22             :   enum class Type : uint8_t {
      23             :     ContentTooLarge,
      24             :     ContentTooLargeArea,
      25             :     TransformBackfaceVisibilityHidden,
      26             :     TransformPreserve3D,
      27             :     TransformSVG,
      28             :     TransformWithGeometricProperties,
      29             :     TransformWithSyncGeometricAnimations,
      30             :     TransformFrameInactive,
      31             :     OpacityFrameInactive,
      32             :     HasRenderingObserver,
      33             :   };
      34             : 
      35          24 :   explicit AnimationPerformanceWarning(Type aType)
      36          24 :     : mType(aType) { }
      37             : 
      38           0 :   AnimationPerformanceWarning(Type aType,
      39             :                               std::initializer_list<int32_t> aParams)
      40           0 :     : mType(aType)
      41             :   {
      42             :     // FIXME:  Once std::initializer_list::size() become a constexpr function,
      43             :     // we should use static_assert here.
      44           0 :     MOZ_ASSERT(aParams.size() <= kMaxParamsForLocalization,
      45             :       "The length of parameters should be less than "
      46             :       "kMaxParamsForLocalization");
      47           0 :     mParams.emplace(aParams);
      48           0 :   }
      49             : 
      50             :   // Maximum number of parameters passed to
      51             :   // nsContentUtils::FormatLocalizedString to localize warning messages.
      52             :   //
      53             :   // NOTE: This constexpr can't be forward declared, so if you want to use
      54             :   // this variable, please include this header file directly.
      55             :   // This value is the same as the limit of nsStringBundle::FormatString.
      56             :   // See the implementation of nsStringBundle::FormatString.
      57             :   static constexpr uint8_t kMaxParamsForLocalization = 10;
      58             : 
      59             :   // Indicates why this property could not be animated on the compositor.
      60             :   Type mType;
      61             : 
      62             :   // Optional parameters that may be used for localization.
      63             :   Maybe<nsTArray<int32_t>> mParams;
      64             : 
      65             :   bool ToLocalizedString(nsXPIDLString& aLocalizedString) const;
      66             :   template<uint32_t N>
      67             :   nsresult ToLocalizedStringWithIntParams(
      68             :     const char* aKey, nsXPIDLString& aLocalizedString) const;
      69             : 
      70           0 :   bool operator==(const AnimationPerformanceWarning& aOther) const
      71             :   {
      72           0 :     return mType == aOther.mType &&
      73           0 :            mParams == aOther.mParams;
      74             :   }
      75           0 :   bool operator!=(const AnimationPerformanceWarning& aOther) const
      76             :   {
      77           0 :     return !(*this == aOther);
      78             :   }
      79             : };
      80             : 
      81             : } // namespace mozilla
      82             : 
      83             : #endif // mozilla_dom_AnimationPerformanceWarning_h

Generated by: LCOV version 1.13