Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / events / AnimationEvent.cpp
blob62a4c5196cb95829169074e8eebe5493507f76aa
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 "mozilla/dom/AnimationEvent.h"
8 #include "mozilla/ContentEvents.h"
9 #include "prtime.h"
11 namespace mozilla::dom {
13 AnimationEvent::AnimationEvent(EventTarget* aOwner, nsPresContext* aPresContext,
14 InternalAnimationEvent* aEvent)
15 : Event(aOwner, aPresContext,
16 aEvent ? aEvent : new InternalAnimationEvent(false, eVoidEvent)) {
17 if (aEvent) {
18 mEventIsInternal = false;
19 } else {
20 mEventIsInternal = true;
24 // static
25 already_AddRefed<AnimationEvent> AnimationEvent::Constructor(
26 const GlobalObject& aGlobal, const nsAString& aType,
27 const AnimationEventInit& aParam) {
28 nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
29 RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
30 bool trusted = e->Init(t);
32 e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
34 InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
35 internalEvent->mAnimationName = aParam.mAnimationName;
36 internalEvent->mElapsedTime = aParam.mElapsedTime;
37 internalEvent->mPseudoElement = aParam.mPseudoElement;
39 e->SetTrusted(trusted);
40 e->SetComposed(aParam.mComposed);
41 return e.forget();
44 void AnimationEvent::GetAnimationName(nsAString& aAnimationName) {
45 aAnimationName = mEvent->AsAnimationEvent()->mAnimationName;
48 float AnimationEvent::ElapsedTime() {
49 return mEvent->AsAnimationEvent()->mElapsedTime;
52 void AnimationEvent::GetPseudoElement(nsAString& aPseudoElement) {
53 aPseudoElement = mEvent->AsAnimationEvent()->mPseudoElement;
56 } // namespace mozilla::dom
58 using namespace mozilla;
59 using namespace mozilla::dom;
61 already_AddRefed<AnimationEvent> NS_NewDOMAnimationEvent(
62 EventTarget* aOwner, nsPresContext* aPresContext,
63 InternalAnimationEvent* aEvent) {
64 RefPtr<AnimationEvent> it = new AnimationEvent(aOwner, aPresContext, aEvent);
65 return it.forget();