2015-12-04 02:32:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "AnimationUtils.h"
|
|
|
|
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIContent.h"
|
2016-03-11 11:20:17 +03:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsGlobalWindow.h"
|
2015-12-04 02:32:53 +03:00
|
|
|
#include "nsString.h"
|
2016-03-11 11:21:03 +03:00
|
|
|
#include "xpcpublic.h" // For xpc::NativeGlobal
|
2016-05-24 06:57:43 +03:00
|
|
|
#include "mozilla/Preferences.h"
|
2015-12-04 02:32:53 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
AnimationUtils::LogAsyncAnimationFailure(nsCString& aMessage,
|
|
|
|
const nsIContent* aContent)
|
|
|
|
{
|
|
|
|
if (aContent) {
|
|
|
|
aMessage.AppendLiteral(" [");
|
|
|
|
aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom()));
|
|
|
|
|
|
|
|
nsIAtom* id = aContent->GetID();
|
|
|
|
if (id) {
|
|
|
|
aMessage.AppendLiteral(" with id '");
|
|
|
|
aMessage.Append(nsAtomCString(aContent->GetID()));
|
|
|
|
aMessage.Append('\'');
|
|
|
|
}
|
|
|
|
aMessage.Append(']');
|
|
|
|
}
|
|
|
|
aMessage.Append('\n');
|
|
|
|
printf_stderr("%s", aMessage.get());
|
|
|
|
}
|
|
|
|
|
2016-03-11 11:20:17 +03:00
|
|
|
/* static */ nsIDocument*
|
|
|
|
AnimationUtils::GetCurrentRealmDocument(JSContext* aCx)
|
|
|
|
{
|
|
|
|
nsGlobalWindow* win = xpc::CurrentWindowOrNull(aCx);
|
|
|
|
if (!win) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return win->GetDoc();
|
|
|
|
}
|
|
|
|
|
2016-05-24 06:57:43 +03:00
|
|
|
/* static */ bool
|
|
|
|
AnimationUtils::IsOffscreenThrottlingEnabled()
|
|
|
|
{
|
|
|
|
static bool sOffscreenThrottlingEnabled;
|
|
|
|
static bool sPrefCached = false;
|
|
|
|
|
|
|
|
if (!sPrefCached) {
|
|
|
|
sPrefCached = true;
|
|
|
|
Preferences::AddBoolVarCache(&sOffscreenThrottlingEnabled,
|
|
|
|
"dom.animations.offscreen-throttling");
|
|
|
|
}
|
|
|
|
|
|
|
|
return sOffscreenThrottlingEnabled;
|
|
|
|
}
|
|
|
|
|
2016-08-10 12:58:49 +03:00
|
|
|
/* static */ bool
|
2016-12-04 02:07:40 +03:00
|
|
|
AnimationUtils::IsCoreAPIEnabled()
|
2016-08-10 12:58:49 +03:00
|
|
|
{
|
|
|
|
static bool sCoreAPIEnabled;
|
|
|
|
static bool sPrefCached = false;
|
|
|
|
|
|
|
|
if (!sPrefCached) {
|
|
|
|
sPrefCached = true;
|
|
|
|
Preferences::AddBoolVarCache(&sCoreAPIEnabled,
|
|
|
|
"dom.animations-api.core.enabled");
|
|
|
|
}
|
|
|
|
|
2016-12-04 02:07:40 +03:00
|
|
|
return sCoreAPIEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ bool
|
2016-12-07 12:47:23 +03:00
|
|
|
AnimationUtils::IsCoreAPIEnabledForCaller(dom::CallerType aCallerType)
|
2016-12-04 02:07:40 +03:00
|
|
|
{
|
2016-12-07 12:47:23 +03:00
|
|
|
return IsCoreAPIEnabled() || aCallerType == dom::CallerType::System;
|
2016-08-10 12:58:49 +03:00
|
|
|
}
|
|
|
|
|
2015-12-04 02:32:53 +03:00
|
|
|
} // namespace mozilla
|