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/. */
7 #include "AnimationUtils.h"
9 #include "mozilla/dom/Animation.h"
10 #include "mozilla/dom/Document.h"
11 #include "mozilla/dom/KeyframeEffect.h"
12 #include "mozilla/EffectSet.h"
13 #include "mozilla/dom/Animation.h"
16 #include "nsIContent.h"
17 #include "nsGlobalWindow.h"
19 #include "xpcpublic.h" // For xpc::NativeGlobal
21 using namespace mozilla::dom
;
26 void AnimationUtils::LogAsyncAnimationFailure(nsCString
& aMessage
,
27 const nsIContent
* aContent
) {
29 aMessage
.AppendLiteral(" [");
30 aMessage
.Append(nsAtomCString(aContent
->NodeInfo()->NameAtom()));
32 nsAtom
* id
= aContent
->GetID();
34 aMessage
.AppendLiteral(" with id '");
35 aMessage
.Append(nsAtomCString(aContent
->GetID()));
36 aMessage
.Append('\'');
40 aMessage
.Append('\n');
41 printf_stderr("%s", aMessage
.get());
45 Document
* AnimationUtils::GetCurrentRealmDocument(JSContext
* aCx
) {
46 nsGlobalWindowInner
* win
= xpc::CurrentWindowOrNull(aCx
);
54 Document
* AnimationUtils::GetDocumentFromGlobal(JSObject
* aGlobalObject
) {
55 nsGlobalWindowInner
* win
= xpc::WindowOrNull(aGlobalObject
);
63 bool AnimationUtils::FrameHasAnimatedScale(const nsIFrame
* aFrame
) {
64 EffectSet
* effectSet
= EffectSet::GetEffectSetForFrame(
65 aFrame
, nsCSSPropertyIDSet::TransformLikeProperties());
70 for (const dom::KeyframeEffect
* effect
: *effectSet
) {
71 if (effect
->ContainsAnimatedScale(aFrame
)) {
80 bool AnimationUtils::HasCurrentTransitions(const Element
* aElement
,
81 PseudoStyleType aPseudoType
) {
84 EffectSet
* effectSet
= EffectSet::GetEffectSet(aElement
, aPseudoType
);
89 for (const dom::KeyframeEffect
* effect
: *effectSet
) {
90 // If |effect| is current, it must have an associated Animation
91 // so we don't need to null-check the result of GetAnimation().
92 if (effect
->IsCurrent() && effect
->GetAnimation()->AsCSSTransition()) {
100 } // namespace mozilla