LCOV - code coverage report
Current view: top level - dom/animation - AnimationUtils.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 5 35 14.3 %
Date: 2017-07-14 16:53:18 Functions: 1 6 16.7 %
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             : #include "AnimationUtils.h"
       8             : 
       9             : #include "nsDebug.h"
      10             : #include "nsIAtom.h"
      11             : #include "nsIContent.h"
      12             : #include "nsIDocument.h"
      13             : #include "nsGlobalWindow.h"
      14             : #include "nsString.h"
      15             : #include "xpcpublic.h" // For xpc::NativeGlobal
      16             : #include "mozilla/EffectSet.h"
      17             : #include "mozilla/dom/KeyframeEffectReadOnly.h"
      18             : #include "mozilla/Preferences.h"
      19             : 
      20             : namespace mozilla {
      21             : 
      22             : /* static */ void
      23           0 : AnimationUtils::LogAsyncAnimationFailure(nsCString& aMessage,
      24             :                                          const nsIContent* aContent)
      25             : {
      26           0 :   if (aContent) {
      27           0 :     aMessage.AppendLiteral(" [");
      28           0 :     aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom()));
      29             : 
      30           0 :     nsIAtom* id = aContent->GetID();
      31           0 :     if (id) {
      32           0 :       aMessage.AppendLiteral(" with id '");
      33           0 :       aMessage.Append(nsAtomCString(aContent->GetID()));
      34           0 :       aMessage.Append('\'');
      35             :     }
      36           0 :     aMessage.Append(']');
      37             :   }
      38           0 :   aMessage.Append('\n');
      39           0 :   printf_stderr("%s", aMessage.get());
      40           0 : }
      41             : 
      42             : /* static */ nsIDocument*
      43           0 : AnimationUtils::GetCurrentRealmDocument(JSContext* aCx)
      44             : {
      45           0 :   nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
      46           0 :   if (!win) {
      47           0 :     return nullptr;
      48             :   }
      49           0 :   return win->GetDoc();
      50             : }
      51             : 
      52             : /* static */ bool
      53           4 : AnimationUtils::IsOffscreenThrottlingEnabled()
      54             : {
      55             :   static bool sOffscreenThrottlingEnabled;
      56             :   static bool sPrefCached = false;
      57             : 
      58           4 :   if (!sPrefCached) {
      59           1 :     sPrefCached = true;
      60             :     Preferences::AddBoolVarCache(&sOffscreenThrottlingEnabled,
      61           1 :                                  "dom.animations.offscreen-throttling");
      62             :   }
      63             : 
      64           4 :   return sOffscreenThrottlingEnabled;
      65             : }
      66             : 
      67             : /* static */ bool
      68           0 : AnimationUtils::IsCoreAPIEnabled()
      69             : {
      70             :   static bool sCoreAPIEnabled;
      71             :   static bool sPrefCached = false;
      72             : 
      73           0 :   if (!sPrefCached) {
      74           0 :     sPrefCached = true;
      75             :     Preferences::AddBoolVarCache(&sCoreAPIEnabled,
      76           0 :                                  "dom.animations-api.core.enabled");
      77             :   }
      78             : 
      79           0 :   return sCoreAPIEnabled;
      80             : }
      81             : 
      82             : /* static */ bool
      83           0 : AnimationUtils::IsCoreAPIEnabledForCaller(dom::CallerType aCallerType)
      84             : {
      85           0 :   return IsCoreAPIEnabled() || aCallerType == dom::CallerType::System;
      86             : }
      87             : 
      88             : /* static */ bool
      89           0 : AnimationUtils::EffectSetContainsAnimatedScale(EffectSet& aEffects,
      90             :                                                const nsIFrame* aFrame)
      91             : {
      92           0 :   for (const dom::KeyframeEffectReadOnly* effect : aEffects) {
      93           0 :     if (effect->ContainsAnimatedScale(aFrame)) {
      94           0 :       return true;
      95             :     }
      96             :   }
      97             : 
      98           0 :   return false;
      99             : }
     100             : 
     101             : } // namespace mozilla

Generated by: LCOV version 1.13