mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
c64d600a96
The difference between nsDocument::IsWebAnimationsEnabled and nsContentUtils::AnimationsAPICoreEnabled is that the former checks the caller type and treats the preference as set for system callers which is particularly needed for enabling things like the getProperties() API for DevTools etc. Generally in API-facing call sites we have a JS context / CallerType and so we want to distinguish between system callers and non-system callers. However, for a few internal uses--specifically filling-in missing keyframes--we don't care about the caller type and always follow the pref setting. That may or not be quite what we want, but this patch doesn't change that except for one call site: KeyframeUtils::GetKeyframesFromObject. This patch changes GetKeyframesFromObject from *not* checking the caller type to checking the caller type. That seems to be the correct behavior here since this is called from KeyframeEffectReadOnly::SetKeyframes(JSContext*, JS::Handle<JSObject*>, ErrorResult&) (i.e. a JS API-facing call site) where we *should* enable the full API when the caller is chrome code. MozReview-Commit-ID: FQJBk3zytwd --HG-- extra : rebase_source : 577bca1e551e39fecfab309f64c993eba110337f
81 lines
2.1 KiB
C++
81 lines
2.1 KiB
C++
/* -*- 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 "nsAtom.h"
|
|
#include "nsIContent.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsGlobalWindow.h"
|
|
#include "nsString.h"
|
|
#include "xpcpublic.h" // For xpc::NativeGlobal
|
|
#include "mozilla/EffectSet.h"
|
|
#include "mozilla/dom/KeyframeEffectReadOnly.h"
|
|
#include "mozilla/Preferences.h"
|
|
|
|
namespace mozilla {
|
|
|
|
/* static */ void
|
|
AnimationUtils::LogAsyncAnimationFailure(nsCString& aMessage,
|
|
const nsIContent* aContent)
|
|
{
|
|
if (aContent) {
|
|
aMessage.AppendLiteral(" [");
|
|
aMessage.Append(nsAtomCString(aContent->NodeInfo()->NameAtom()));
|
|
|
|
nsAtom* 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());
|
|
}
|
|
|
|
/* static */ nsIDocument*
|
|
AnimationUtils::GetCurrentRealmDocument(JSContext* aCx)
|
|
{
|
|
nsGlobalWindowInner* win = xpc::CurrentWindowOrNull(aCx);
|
|
if (!win) {
|
|
return nullptr;
|
|
}
|
|
return win->GetDoc();
|
|
}
|
|
|
|
/* static */ bool
|
|
AnimationUtils::IsOffscreenThrottlingEnabled()
|
|
{
|
|
static bool sOffscreenThrottlingEnabled;
|
|
static bool sPrefCached = false;
|
|
|
|
if (!sPrefCached) {
|
|
sPrefCached = true;
|
|
Preferences::AddBoolVarCache(&sOffscreenThrottlingEnabled,
|
|
"dom.animations.offscreen-throttling");
|
|
}
|
|
|
|
return sOffscreenThrottlingEnabled;
|
|
}
|
|
|
|
/* static */ bool
|
|
AnimationUtils::EffectSetContainsAnimatedScale(EffectSet& aEffects,
|
|
const nsIFrame* aFrame)
|
|
{
|
|
for (const dom::KeyframeEffectReadOnly* effect : aEffects) {
|
|
if (effect->ContainsAnimatedScale(aFrame)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
} // namespace mozilla
|