tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AnimationEvent.cpp (2227B)


      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/. */
      6 
      7 #include "mozilla/dom/AnimationEvent.h"
      8 
      9 #include "mozilla/ContentEvents.h"
     10 #include "prtime.h"
     11 
     12 namespace mozilla::dom {
     13 
     14 AnimationEvent::AnimationEvent(EventTarget* aOwner, nsPresContext* aPresContext,
     15                               InternalAnimationEvent* aEvent)
     16    : Event(aOwner, aPresContext,
     17            aEvent ? aEvent : new InternalAnimationEvent(false, eVoidEvent)) {
     18  if (aEvent) {
     19    mEventIsInternal = false;
     20  } else {
     21    mEventIsInternal = true;
     22  }
     23 }
     24 
     25 // static
     26 already_AddRefed<AnimationEvent> AnimationEvent::Constructor(
     27    const GlobalObject& aGlobal, const nsAString& aType,
     28    const AnimationEventInit& aParam) {
     29  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
     30  RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
     31  bool trusted = e->Init(t);
     32 
     33  e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
     34 
     35  InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
     36  internalEvent->mAnimationName = aParam.mAnimationName;
     37  internalEvent->mElapsedTime = aParam.mElapsedTime;
     38  internalEvent->mPseudoElement = aParam.mPseudoElement;
     39 
     40  e->SetTrusted(trusted);
     41  e->SetComposed(aParam.mComposed);
     42  return e.forget();
     43 }
     44 
     45 void AnimationEvent::GetAnimationName(nsAString& aAnimationName) {
     46  aAnimationName = mEvent->AsAnimationEvent()->mAnimationName;
     47 }
     48 
     49 float AnimationEvent::ElapsedTime() {
     50  return mEvent->AsAnimationEvent()->mElapsedTime;
     51 }
     52 
     53 void AnimationEvent::GetPseudoElement(nsAString& aPseudoElement) {
     54  aPseudoElement = mEvent->AsAnimationEvent()->mPseudoElement;
     55 }
     56 
     57 }  // namespace mozilla::dom
     58 
     59 using namespace mozilla;
     60 using namespace mozilla::dom;
     61 
     62 already_AddRefed<AnimationEvent> NS_NewDOMAnimationEvent(
     63    EventTarget* aOwner, nsPresContext* aPresContext,
     64    InternalAnimationEvent* aEvent) {
     65  RefPtr<AnimationEvent> it = new AnimationEvent(aOwner, aPresContext, aEvent);
     66  return it.forget();
     67 }