michael@0: /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "mozilla/dom/TransitionEvent.h" michael@0: #include "mozilla/ContentEvents.h" michael@0: #include "prtime.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: TransitionEvent::TransitionEvent(EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: InternalTransitionEvent* aEvent) michael@0: : Event(aOwner, aPresContext, michael@0: aEvent ? aEvent : new InternalTransitionEvent(false, 0)) michael@0: { michael@0: if (aEvent) { michael@0: mEventIsInternal = false; michael@0: } michael@0: else { michael@0: mEventIsInternal = true; michael@0: mEvent->time = PR_Now(); michael@0: } michael@0: } michael@0: michael@0: NS_INTERFACE_MAP_BEGIN(TransitionEvent) michael@0: NS_INTERFACE_MAP_ENTRY(nsIDOMTransitionEvent) michael@0: NS_INTERFACE_MAP_END_INHERITING(Event) michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(TransitionEvent, Event) michael@0: NS_IMPL_RELEASE_INHERITED(TransitionEvent, Event) michael@0: michael@0: // static michael@0: already_AddRefed michael@0: TransitionEvent::Constructor(const GlobalObject& aGlobal, michael@0: const nsAString& aType, michael@0: const TransitionEventInit& aParam, michael@0: ErrorResult& aRv) michael@0: { michael@0: nsCOMPtr t = do_QueryInterface(aGlobal.GetAsSupports()); michael@0: nsRefPtr e = new TransitionEvent(t, nullptr, nullptr); michael@0: bool trusted = e->Init(t); michael@0: michael@0: aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable); michael@0: michael@0: InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent(); michael@0: internalEvent->propertyName = aParam.mPropertyName; michael@0: internalEvent->elapsedTime = aParam.mElapsedTime; michael@0: internalEvent->pseudoElement = aParam.mPseudoElement; michael@0: michael@0: e->SetTrusted(trusted); michael@0: return e.forget(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TransitionEvent::GetPropertyName(nsAString& aPropertyName) michael@0: { michael@0: aPropertyName = mEvent->AsTransitionEvent()->propertyName; michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TransitionEvent::GetElapsedTime(float* aElapsedTime) michael@0: { michael@0: *aElapsedTime = ElapsedTime(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: float michael@0: TransitionEvent::ElapsedTime() michael@0: { michael@0: return mEvent->AsTransitionEvent()->elapsedTime; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: TransitionEvent::GetPseudoElement(nsAString& aPseudoElement) michael@0: { michael@0: aPseudoElement = mEvent->AsTransitionEvent()->pseudoElement; michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: using namespace mozilla; michael@0: using namespace mozilla::dom; michael@0: michael@0: nsresult michael@0: NS_NewDOMTransitionEvent(nsIDOMEvent** aInstancePtrResult, michael@0: EventTarget* aOwner, michael@0: nsPresContext* aPresContext, michael@0: InternalTransitionEvent* aEvent) michael@0: { michael@0: TransitionEvent *it = new TransitionEvent(aOwner, aPresContext, aEvent); michael@0: NS_ADDREF(it); michael@0: *aInstancePtrResult = static_cast(it); michael@0: return NS_OK; michael@0: }