Files
palemoon27/dom/events/AnimationEvent.cpp
T
roytam1 8ace8dfc05 import changes from `dev' branch of rmottola/Arctic-Fox:
- let->var (7417185de3)
- Bug 1200194 - Expose nsCaret::GetFrameAndOffset for reuse. r=roc This function can be reused by AccessibleCaret. (4506d97981)
- Bug 1200194 - Fix AccessibleCaret is out of scrollport in cursor mode. r=roc (3c80be5af1)
- Bug 1175171 - Deallocate GTK's KeymapWrapper on shutdown. r=karlt (e5e5468d71)
- Bug 895274 part.6 Rename NS_EVENT_ALL to eAllEvents r=smaug (cc76e8ecc8)
- Bug 895274 part.7 Rename NS_WINDOW_START to eWindowEventFirst r=smaug (c7414fa347)
- Bug 895274 part.8 Rename NS_XUL_CLOSE to eWindowClose r=smaug (30e8142328)
- Bug 895274 part.5 Rename NS_EVENT_NULL to eVoidEvent r=smaug (1950fb6c82)
- Bug 895274 part.4 Clean up the macro names of EventNameList.h r=smaug (46a0c74362)
- Bug 895274 part.9 Rename NS_KEY_PRESS to eKeyPress r=smaug (fb863b578a)
- Bug 895274 part.10 Rename NS_KEY_UP to eKeyUp r=smaug (67a2e3c03a)
- fix (f3a9ad8088)
- Bug 1137557 - Part 1: Allow callee of TIP.keydown() to figure out preventDefault() of keydown and keypress event. r=masayuki, r+sr=smaug (c1d9bca9d0)
- Bug 1119133 Implement TextEventDispatcher::EndInputTransaction() for ensuring TextEventDispatcher forgets the link with TextInputProcessor r=smaug (fffdced45e)
2022-03-31 09:57:52 +08:00

100 lines
2.7 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "mozilla/dom/AnimationEvent.h"
#include "mozilla/ContentEvents.h"
#include "prtime.h"
namespace mozilla {
namespace dom {
AnimationEvent::AnimationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalAnimationEvent* aEvent)
: Event(aOwner, aPresContext,
aEvent ? aEvent : new InternalAnimationEvent(false, eVoidEvent))
{
if (aEvent) {
mEventIsInternal = false;
}
else {
mEventIsInternal = true;
mEvent->time = PR_Now();
}
}
NS_INTERFACE_MAP_BEGIN(AnimationEvent)
NS_INTERFACE_MAP_ENTRY(nsIDOMAnimationEvent)
NS_INTERFACE_MAP_END_INHERITING(Event)
NS_IMPL_ADDREF_INHERITED(AnimationEvent, Event)
NS_IMPL_RELEASE_INHERITED(AnimationEvent, Event)
//static
already_AddRefed<AnimationEvent>
AnimationEvent::Constructor(const GlobalObject& aGlobal,
const nsAString& aType,
const AnimationEventInit& aParam,
ErrorResult& aRv)
{
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
nsRefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
internalEvent->animationName = aParam.mAnimationName;
internalEvent->elapsedTime = aParam.mElapsedTime;
internalEvent->pseudoElement = aParam.mPseudoElement;
e->SetTrusted(trusted);
return e.forget();
}
NS_IMETHODIMP
AnimationEvent::GetAnimationName(nsAString& aAnimationName)
{
aAnimationName = mEvent->AsAnimationEvent()->animationName;
return NS_OK;
}
NS_IMETHODIMP
AnimationEvent::GetElapsedTime(float* aElapsedTime)
{
*aElapsedTime = ElapsedTime();
return NS_OK;
}
float
AnimationEvent::ElapsedTime()
{
return mEvent->AsAnimationEvent()->elapsedTime;
}
NS_IMETHODIMP
AnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
{
aPseudoElement = mEvent->AsAnimationEvent()->pseudoElement;
return NS_OK;
}
} // namespace dom
} // namespace mozilla
using namespace mozilla;
using namespace mozilla::dom;
already_AddRefed<AnimationEvent>
NS_NewDOMAnimationEvent(EventTarget* aOwner,
nsPresContext* aPresContext,
InternalAnimationEvent* aEvent)
{
nsRefPtr<AnimationEvent> it =
new AnimationEvent(aOwner, aPresContext, aEvent);
return it.forget();
}