2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 10:18:44 +04:00
|
|
|
|
2014-02-26 09:23:56 +04:00
|
|
|
#include "mozilla/dom/AnimationEvent.h"
|
2013-09-25 15:21:20 +04:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-02-26 09:23:56 +04:00
|
|
|
#include "prtime.h"
|
2011-04-12 10:18:44 +04:00
|
|
|
|
2014-02-26 09:23:56 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-27 10:20:54 +04:00
|
|
|
|
2014-02-26 09:23:56 +04:00
|
|
|
AnimationEvent::AnimationEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalAnimationEvent* aEvent)
|
2014-03-05 04:37:43 +04:00
|
|
|
: Event(aOwner, aPresContext,
|
2015-08-29 02:58:26 +03:00
|
|
|
aEvent ? aEvent : new InternalAnimationEvent(false, eVoidEvent))
|
2011-04-12 10:18:44 +04:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = false;
|
2011-04-12 10:18:44 +04:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 18:59:28 +04:00
|
|
|
mEventIsInternal = true;
|
2016-03-28 07:29:42 +03:00
|
|
|
mEvent->mTime = PR_Now();
|
2011-04-12 10:18:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-26 09:23:56 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(AnimationEvent)
|
2011-04-12 10:18:44 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMAnimationEvent)
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2011-04-12 10:18:44 +04:00
|
|
|
|
2014-03-05 04:37:43 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(AnimationEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(AnimationEvent, Event)
|
2011-04-12 10:18:44 +04:00
|
|
|
|
2013-05-05 17:22:29 +04:00
|
|
|
//static
|
2014-02-26 09:23:56 +04:00
|
|
|
already_AddRefed<AnimationEvent>
|
|
|
|
AnimationEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const AnimationEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
2013-05-05 17:22:29 +04:00
|
|
|
{
|
2014-02-26 09:23:56 +04:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
|
2013-05-05 17:22:29 +04:00
|
|
|
bool trusted = e->Init(t);
|
2013-05-09 00:45:35 +04:00
|
|
|
|
2015-11-13 03:09:42 +03:00
|
|
|
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
|
2013-05-09 00:45:35 +04:00
|
|
|
|
2013-10-18 10:10:22 +04:00
|
|
|
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
|
2016-03-26 07:37:19 +03:00
|
|
|
internalEvent->mAnimationName = aParam.mAnimationName;
|
2016-03-26 07:37:19 +03:00
|
|
|
internalEvent->mElapsedTime = aParam.mElapsedTime;
|
2016-03-26 07:37:20 +03:00
|
|
|
internalEvent->mPseudoElement = aParam.mPseudoElement;
|
2013-05-09 00:45:35 +04:00
|
|
|
|
2013-05-05 17:22:29 +04:00
|
|
|
e->SetTrusted(trusted);
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2011-04-12 10:18:44 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-26 09:23:56 +04:00
|
|
|
AnimationEvent::GetAnimationName(nsAString& aAnimationName)
|
2011-04-12 10:18:44 +04:00
|
|
|
{
|
2016-03-26 07:37:19 +03:00
|
|
|
aAnimationName = mEvent->AsAnimationEvent()->mAnimationName;
|
2011-04-12 10:18:44 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-26 09:23:56 +04:00
|
|
|
AnimationEvent::GetElapsedTime(float* aElapsedTime)
|
2011-04-12 10:18:44 +04:00
|
|
|
{
|
2013-03-15 01:16:03 +04:00
|
|
|
*aElapsedTime = ElapsedTime();
|
2011-04-12 10:18:44 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-18 10:10:22 +04:00
|
|
|
float
|
2014-02-26 09:23:56 +04:00
|
|
|
AnimationEvent::ElapsedTime()
|
2013-10-18 10:10:22 +04:00
|
|
|
{
|
2016-03-26 07:37:19 +03:00
|
|
|
return mEvent->AsAnimationEvent()->mElapsedTime;
|
2013-10-18 10:10:22 +04:00
|
|
|
}
|
|
|
|
|
2013-05-05 17:22:29 +04:00
|
|
|
NS_IMETHODIMP
|
2014-02-26 09:23:56 +04:00
|
|
|
AnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
|
2013-05-05 17:22:29 +04:00
|
|
|
{
|
2016-03-26 07:37:20 +03:00
|
|
|
aPseudoElement = mEvent->AsAnimationEvent()->mPseudoElement;
|
2013-05-05 17:22:29 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-26 09:23:56 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 14:39:31 +03:00
|
|
|
already_AddRefed<AnimationEvent>
|
|
|
|
NS_NewDOMAnimationEvent(EventTarget* aOwner,
|
2014-02-26 09:23:56 +04:00
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalAnimationEvent* aEvent)
|
2011-04-12 10:18:44 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AnimationEvent> it =
|
2015-08-12 14:39:31 +03:00
|
|
|
new AnimationEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2011-04-12 10:18:44 +04:00
|
|
|
}
|