2015-05-03 12:32:37 -07: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 04:12:37 -07: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/. */
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
#include "mozilla/dom/TransitionEvent.h"
|
2013-09-25 04:21:20 -07:00
|
|
|
#include "mozilla/ContentEvents.h"
|
2014-02-28 06:58:42 -08:00
|
|
|
#include "prtime.h"
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
2013-09-26 23:20:55 -07:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
TransitionEvent::TransitionEvent(EventTarget* aOwner,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
InternalTransitionEvent* aEvent)
|
2014-03-04 16:37:43 -08:00
|
|
|
: Event(aOwner, aPresContext,
|
2015-08-28 16:58:26 -07:00
|
|
|
aEvent ? aEvent : new InternalTransitionEvent(false, eVoidEvent))
|
2009-12-23 11:10:31 -08:00
|
|
|
{
|
|
|
|
if (aEvent) {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = false;
|
2009-12-23 11:10:31 -08:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 07:59:28 -07:00
|
|
|
mEventIsInternal = true;
|
2009-12-23 11:10:31 -08:00
|
|
|
mEvent->time = PR_Now();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
NS_INTERFACE_MAP_BEGIN(TransitionEvent)
|
2009-12-23 11:10:31 -08:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent)
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(Event)
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2014-03-04 16:37:43 -08:00
|
|
|
NS_IMPL_ADDREF_INHERITED(TransitionEvent, Event)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(TransitionEvent, Event)
|
2009-12-23 11:10:31 -08:00
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
// static
|
|
|
|
already_AddRefed<TransitionEvent>
|
|
|
|
TransitionEvent::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aType,
|
|
|
|
const TransitionEventInit& aParam,
|
|
|
|
ErrorResult& aRv)
|
2013-05-04 07:41:20 -07:00
|
|
|
{
|
2014-02-28 06:58:42 -08:00
|
|
|
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr);
|
2013-05-04 07:41:20 -07:00
|
|
|
bool trusted = e->Init(t);
|
2013-05-08 13:45:35 -07:00
|
|
|
|
2015-11-12 16:09:42 -08:00
|
|
|
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
|
2013-05-08 13:45:35 -07:00
|
|
|
|
2013-10-17 23:10:22 -07:00
|
|
|
InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
|
|
|
|
internalEvent->propertyName = aParam.mPropertyName;
|
|
|
|
internalEvent->elapsedTime = aParam.mElapsedTime;
|
|
|
|
internalEvent->pseudoElement = aParam.mPseudoElement;
|
2013-05-08 13:45:35 -07:00
|
|
|
|
2013-05-04 07:41:20 -07:00
|
|
|
e->SetTrusted(trusted);
|
|
|
|
return e.forget();
|
|
|
|
}
|
|
|
|
|
2009-12-23 11:10:31 -08:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 06:58:42 -08:00
|
|
|
TransitionEvent::GetPropertyName(nsAString& aPropertyName)
|
2009-12-23 11:10:31 -08:00
|
|
|
{
|
2013-10-17 23:10:22 -07:00
|
|
|
aPropertyName = mEvent->AsTransitionEvent()->propertyName;
|
2009-12-23 11:10:31 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-02-28 06:58:42 -08:00
|
|
|
TransitionEvent::GetElapsedTime(float* aElapsedTime)
|
2009-12-23 11:10:31 -08:00
|
|
|
{
|
2013-03-14 14:16:13 -07:00
|
|
|
*aElapsedTime = ElapsedTime();
|
2009-12-23 11:10:31 -08:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-10-17 23:10:22 -07:00
|
|
|
float
|
2014-02-28 06:58:42 -08:00
|
|
|
TransitionEvent::ElapsedTime()
|
2013-10-17 23:10:22 -07:00
|
|
|
{
|
|
|
|
return mEvent->AsTransitionEvent()->elapsedTime;
|
|
|
|
}
|
|
|
|
|
2013-05-04 07:41:20 -07:00
|
|
|
NS_IMETHODIMP
|
2014-02-28 06:58:42 -08:00
|
|
|
TransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
|
2013-05-04 07:41:20 -07:00
|
|
|
{
|
2013-10-17 23:10:22 -07:00
|
|
|
aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement;
|
2013-05-04 07:41:20 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-28 06:58:42 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2015-08-12 04:39:31 -07:00
|
|
|
already_AddRefed<TransitionEvent>
|
|
|
|
NS_NewDOMTransitionEvent(EventTarget* aOwner,
|
2014-02-28 06:58:42 -08:00
|
|
|
nsPresContext* aPresContext,
|
2013-09-26 23:20:55 -07:00
|
|
|
InternalTransitionEvent* aEvent)
|
2009-12-23 11:10:31 -08:00
|
|
|
{
|
2015-10-17 22:24:48 -07:00
|
|
|
RefPtr<TransitionEvent> it =
|
2015-08-12 04:39:31 -07:00
|
|
|
new TransitionEvent(aOwner, aPresContext, aEvent);
|
|
|
|
return it.forget();
|
2009-12-23 11:10:31 -08:00
|
|
|
}
|