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
|
|
|
|
|
|
|
#include "nsDOMAnimationEvent.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsDOMClassInfoID.h"
|
|
|
|
#include "nsIClassInfo.h"
|
|
|
|
#include "nsIXPCScriptable.h"
|
|
|
|
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMAnimationEvent::nsDOMAnimationEvent(mozilla::dom::EventTarget* aOwner,
|
|
|
|
nsPresContext *aPresContext,
|
2011-04-12 06:18:44 +00:00
|
|
|
nsAnimationEvent *aEvent)
|
2013-03-09 11:34:29 +00:00
|
|
|
: nsDOMEvent(aOwner, aPresContext,
|
|
|
|
aEvent ? aEvent : new nsAnimationEvent(false, 0,
|
|
|
|
EmptyString(),
|
|
|
|
0.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();
|
|
|
|
}
|
2013-03-14 21:16:03 +00:00
|
|
|
SetIsDOMBinding();
|
2011-04-12 06:18:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsDOMAnimationEvent::~nsDOMAnimationEvent()
|
|
|
|
{
|
|
|
|
if (mEventIsInternal) {
|
|
|
|
delete AnimationEvent();
|
2012-07-30 14:20:58 +00:00
|
|
|
mEvent = nullptr;
|
2011-04-12 06:18:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DOMCI_DATA(AnimationEvent, nsDOMAnimationEvent)
|
|
|
|
|
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMAnimationEvent)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMAnimationEvent)
|
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(AnimationEvent)
|
|
|
|
NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsDOMAnimationEvent, nsDOMEvent)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsDOMAnimationEvent, nsDOMEvent)
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAnimationEvent::GetAnimationName(nsAString & aAnimationName)
|
|
|
|
{
|
|
|
|
aAnimationName = AnimationEvent()->animationName;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAnimationEvent::GetElapsedTime(float *aElapsedTime)
|
|
|
|
{
|
2013-03-14 21:16:03 +00:00
|
|
|
*aElapsedTime = ElapsedTime();
|
2011-04-12 06:18:44 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDOMAnimationEvent::InitAnimationEvent(const nsAString & typeArg,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool canBubbleArg,
|
|
|
|
bool cancelableArg,
|
2011-04-12 06:18:44 +00:00
|
|
|
const nsAString & animationNameArg,
|
|
|
|
float elapsedTimeArg)
|
|
|
|
{
|
|
|
|
nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
AnimationEvent()->animationName = animationNameArg;
|
|
|
|
AnimationEvent()->elapsedTime = elapsedTimeArg;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewDOMAnimationEvent(nsIDOMEvent **aInstancePtrResult,
|
2013-03-09 11:34:29 +00:00
|
|
|
mozilla::dom::EventTarget* aOwner,
|
2011-04-12 06:18:44 +00:00
|
|
|
nsPresContext *aPresContext,
|
|
|
|
nsAnimationEvent *aEvent)
|
|
|
|
{
|
2013-03-09 11:34:29 +00:00
|
|
|
nsDOMAnimationEvent* it =
|
|
|
|
new nsDOMAnimationEvent(aOwner, aPresContext, aEvent);
|
2011-04-12 06:18:44 +00:00
|
|
|
return CallQueryInterface(it, aInstancePtrResult);
|
|
|
|
}
|