/src/mozilla-central/dom/events/AnimationEvent.cpp
Line | Count | Source (jump to first uncovered line) |
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 "mozilla/dom/AnimationEvent.h" |
8 | | #include "mozilla/ContentEvents.h" |
9 | | #include "prtime.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace dom { |
13 | | |
14 | | AnimationEvent::AnimationEvent(EventTarget* aOwner, |
15 | | nsPresContext* aPresContext, |
16 | | InternalAnimationEvent* aEvent) |
17 | | : Event(aOwner, aPresContext, |
18 | | aEvent ? aEvent : new InternalAnimationEvent(false, eVoidEvent)) |
19 | 0 | { |
20 | 0 | if (aEvent) { |
21 | 0 | mEventIsInternal = false; |
22 | 0 | } |
23 | 0 | else { |
24 | 0 | mEventIsInternal = true; |
25 | 0 | mEvent->mTime = PR_Now(); |
26 | 0 | } |
27 | 0 | } |
28 | | |
29 | | //static |
30 | | already_AddRefed<AnimationEvent> |
31 | | AnimationEvent::Constructor(const GlobalObject& aGlobal, |
32 | | const nsAString& aType, |
33 | | const AnimationEventInit& aParam, |
34 | | ErrorResult& aRv) |
35 | 0 | { |
36 | 0 | nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); |
37 | 0 | RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr); |
38 | 0 | bool trusted = e->Init(t); |
39 | 0 |
|
40 | 0 | e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable); |
41 | 0 |
|
42 | 0 | InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent(); |
43 | 0 | internalEvent->mAnimationName = aParam.mAnimationName; |
44 | 0 | internalEvent->mElapsedTime = aParam.mElapsedTime; |
45 | 0 | internalEvent->mPseudoElement = aParam.mPseudoElement; |
46 | 0 |
|
47 | 0 | e->SetTrusted(trusted); |
48 | 0 | e->SetComposed(aParam.mComposed); |
49 | 0 | return e.forget(); |
50 | 0 | } |
51 | | |
52 | | void |
53 | | AnimationEvent::GetAnimationName(nsAString& aAnimationName) |
54 | 0 | { |
55 | 0 | aAnimationName = mEvent->AsAnimationEvent()->mAnimationName; |
56 | 0 | } |
57 | | |
58 | | |
59 | | float |
60 | | AnimationEvent::ElapsedTime() |
61 | 0 | { |
62 | 0 | return mEvent->AsAnimationEvent()->mElapsedTime; |
63 | 0 | } |
64 | | |
65 | | void |
66 | | AnimationEvent::GetPseudoElement(nsAString& aPseudoElement) |
67 | 0 | { |
68 | 0 | aPseudoElement = mEvent->AsAnimationEvent()->mPseudoElement; |
69 | 0 | } |
70 | | |
71 | | } // namespace dom |
72 | | } // namespace mozilla |
73 | | |
74 | | using namespace mozilla; |
75 | | using namespace mozilla::dom; |
76 | | |
77 | | already_AddRefed<AnimationEvent> |
78 | | NS_NewDOMAnimationEvent(EventTarget* aOwner, |
79 | | nsPresContext* aPresContext, |
80 | | InternalAnimationEvent* aEvent) |
81 | 0 | { |
82 | 0 | RefPtr<AnimationEvent> it = |
83 | 0 | new AnimationEvent(aOwner, aPresContext, aEvent); |
84 | 0 | return it.forget(); |
85 | 0 | } |