2011-04-12 06:18:44 +00:00
|
|
|
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
2011-04-12 06:18:44 +00:00
|
|
|
|
2014-02-26 05:23:56 +00:00
|
|
|
#include "mozilla/dom/AnimationEvent.h"
|
2013-09-25 11:21:20 +00:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-02-26 05:23:56 +00:00
|
|
|
#include "prtime.h"
|
2011-04-12 06:18:44 +00:00
|
|
|
|
2014-02-26 05:23:56 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-27 06:20:54 +00:00
|
|
|
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent::AnimationEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalAnimationEvent* aEvent)
|
2014-03-05 00:37:43 +00:00
|
|
|
: Event(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent : new InternalAnimationEvent(false, 0))
|
2011-04-12 06:18:44 +00:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = false;
|
2011-04-12 06:18:44 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 14:59:28 +00:00
|
|
|
mEventIsInternal = true;
|
2011-04-12 06:18:44 +00:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-26 05:23:56 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(AnimationEvent)
|
2011-04-12 06:18:44 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMAnimationEvent)
|
2014-03-05 00:37:43 +00:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2011-04-12 06:18:44 +00:00
|
|
|
|
2014-03-05 00:37:43 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(AnimationEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(AnimationEvent, Event)
|
2011-04-12 06:18:44 +00:00
|
|
|
|
2013-05-05 13:22:29 +00:00
|
|
|
//static
|
2014-02-26 05:23:56 +00:00
|
|
|
already_AddRefed<AnimationEvent>
|
|
|
|
AnimationEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const AnimationEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
2013-05-05 13:22:29 +00:00
|
|
|
{
|
2014-02-26 05:23:56 +00:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
|
|
|
nsRefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
|
2013-05-05 13:22:29 +00:00
|
|
|
bool trusted = e->Init(t);
|
2013-05-08 20:45:35 +00:00
|
|
|
|
|
|
|
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
|
|
|
|
|
2013-10-18 06:10:22 +00:00
|
|
|
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
|
|
|
|
internalEvent->animationName = aParam.mAnimationName;
|
|
|
|
internalEvent->elapsedTime = aParam.mElapsedTime;
|
|
|
|
internalEvent->pseudoElement = aParam.mPseudoElement;
|
2013-05-08 20:45:35 +00:00
|
|
|
|
2013-05-05 13:22:29 +00:00
|
|
|
e->SetTrusted(trusted);
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2011-04-12 06:18:44 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent::GetAnimationName(nsAString& aAnimationName)
|
2011-04-12 06:18:44 +00:00
|
|
|
{
|
2013-10-18 06:10:22 +00:00
|
|
|
aAnimationName = mEvent->AsAnimationEvent()->animationName;
|
2011-04-12 06:18:44 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent::GetElapsedTime(float* aElapsedTime)
|
2011-04-12 06:18:44 +00:00
|
|
|
{
|
2013-03-14 21:16:03 +00:00
|
|
|
*aElapsedTime = ElapsedTime();
|
2011-04-12 06:18:44 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 06:10:22 +00:00
|
|
|
float
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent::ElapsedTime()
|
2013-10-18 06:10:22 +00:00
|
|
|
{
|
|
|
|
return mEvent->AsAnimationEvent()->elapsedTime;
|
|
|
|
}
|
|
|
|
|
2013-05-05 13:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
|
2013-05-05 13:22:29 +00:00
|
|
|
{
|
2013-10-18 06:10:22 +00:00
|
|
|
aPseudoElement = mEvent->AsAnimationEvent()->pseudoElement;
|
2013-05-05 13:22:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-26 05:23:56 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2011-04-12 06:18:44 +00:00
|
|
|
nsresult
|
2014-02-26 05:23:56 +00:00
|
|
|
NS_NewDOMAnimationEvent(nsIDOMEvent** aInstancePtrResult,
|
|
|
|
EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalAnimationEvent* aEvent)
|
2011-04-12 06:18:44 +00:00
|
|
|
{
|
2014-02-26 05:23:56 +00:00
|
|
|
AnimationEvent* it = new AnimationEvent(aOwner, aPresContext, aEvent);
|
2014-03-17 20:00:11 +00:00
|
|
|
NS_ADDREF(it);
|
|
|
|
*aInstancePtrResult = static_cast<Event*>(it);
|
|
|
|
return NS_OK;
|
2011-04-12 06:18:44 +00:00
|
|
|
}
|