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