Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / events / TransitionEvent.cpp
blob696f54ce496dbbfbaaefdf212a95891d3559b303
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "mozilla/dom/TransitionEvent.h"
8 #include "mozilla/ContentEvents.h"
9 #include "prtime.h"
11 namespace mozilla::dom {
13 TransitionEvent::TransitionEvent(EventTarget* aOwner,
14 nsPresContext* aPresContext,
15 InternalTransitionEvent* aEvent)
16 : Event(aOwner, aPresContext,
17 aEvent ? aEvent : new InternalTransitionEvent(false, eVoidEvent)) {
18 if (aEvent) {
19 mEventIsInternal = false;
20 } else {
21 mEventIsInternal = true;
25 // static
26 already_AddRefed<TransitionEvent> TransitionEvent::Constructor(
27 const GlobalObject& aGlobal, const nsAString& aType,
28 const TransitionEventInit& aParam) {
29 nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
30 RefPtr<TransitionEvent> e = new TransitionEvent(t, nullptr, nullptr);
31 bool trusted = e->Init(t);
33 e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
35 InternalTransitionEvent* internalEvent = e->mEvent->AsTransitionEvent();
36 internalEvent->mPropertyName = aParam.mPropertyName;
37 internalEvent->mElapsedTime = aParam.mElapsedTime;
38 internalEvent->mPseudoElement = aParam.mPseudoElement;
40 e->SetTrusted(trusted);
41 e->SetComposed(aParam.mComposed);
42 return e.forget();
45 void TransitionEvent::GetPropertyName(nsAString& aPropertyName) const {
46 aPropertyName = mEvent->AsTransitionEvent()->mPropertyName;
49 float TransitionEvent::ElapsedTime() {
50 return mEvent->AsTransitionEvent()->mElapsedTime;
53 void TransitionEvent::GetPseudoElement(nsAString& aPseudoElement) const {
54 aPseudoElement = mEvent->AsTransitionEvent()->mPseudoElement;
57 } // namespace mozilla::dom
59 using namespace mozilla;
60 using namespace mozilla::dom;
62 already_AddRefed<TransitionEvent> NS_NewDOMTransitionEvent(
63 EventTarget* aOwner, nsPresContext* aPresContext,
64 InternalTransitionEvent* aEvent) {
65 RefPtr<TransitionEvent> it =
66 new TransitionEvent(aOwner, aPresContext, aEvent);
67 return it.forget();