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