gecko/content/events/src/nsDOMAnimationEvent.cpp
Olli Pettay be6e8cf113 Bug 847589 - Paris binding for AnimationEvent, r=Ms2ger
--HG--
extra : rebase_source : 5987a31b2700481c17b0f430cd66c6e1bb7881e5
2013-03-14 23:16:03 +02:00

88 lines
2.7 KiB
C++

/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
/* 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/. */
#include "nsDOMAnimationEvent.h"
#include "nsGUIEvent.h"
#include "nsDOMClassInfoID.h"
#include "nsIClassInfo.h"
#include "nsIXPCScriptable.h"
nsDOMAnimationEvent::nsDOMAnimationEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
nsAnimationEvent *aEvent)
: nsDOMEvent(aOwner, aPresContext,
aEvent ? aEvent : new nsAnimationEvent(false, 0,
EmptyString(),
0.0))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
SetIsDOMBinding();
}
nsDOMAnimationEvent::~nsDOMAnimationEvent()
{
if (mEventIsInternal) {
delete AnimationEvent();
mEvent = nullptr;
}
}
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)
{
*aElapsedTime = ElapsedTime();
return NS_OK;
}
NS_IMETHODIMP
nsDOMAnimationEvent::InitAnimationEvent(const nsAString & typeArg,
bool canBubbleArg,
bool cancelableArg,
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,
mozilla::dom::EventTarget* aOwner,
nsPresContext *aPresContext,
nsAnimationEvent *aEvent)
{
nsDOMAnimationEvent* it =
new nsDOMAnimationEvent(aOwner, aPresContext, aEvent);
return CallQueryInterface(it, aInstancePtrResult);
}