Files
palemoon27/dom/events/AnimationEvent.cpp
T
roytam1 a916628ef3 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1261552 - Add FFI hooks to construct, copy, and destroy gecko style structs from servo. r=heycam (a6d8cc9314)
- Bug 1263962 - Expand on the StyleAnimationValue::ExtractComputedValue documentation. r=dholbert (eeda5d725b)
- Bug 1244585 - Remove unused Declaration::HasVariableDeclaration method. r=xidorn (1cb256b3ab)
- Bug 1264238 - Part 1: Remove unused CSS_PROP_STUB_NOT_CSS macro. r=dholbert (2c329bde2b)
- Bug 1254000 - [css-grid] Enable Grid container properties in UA sheets to avoid warnings in the console. r=dholbert (a38272ace3)
- bit of bug 686281 (815a9f0825)
- Bug 1264238 - Part 2: Sort nsCSSPropList.h entries. r=dholbert (ab964e33b2)
- Bug 1266250 part 1 - [css-grid] Resurrect the 'grid-template' shorthand (backs out bug 1253529). r=dholbert (9eb605f1e5)
- Bug 1266250 part 2 - [css-grid] Resurrect the 'grid-template' shorthand (backs out bug 1253529). (717016e9e3)
- Bug 1250767 - Unified build bustage fixups. (a29448cf4b)
- Bug 1259676 - part1: rename from 'InternalAnimationEvent.animationName' to 'InternalAnimationEvent.mAnimationName'. r=masayuki (b388767ea8)
- Bug 1259676 - part2: rename from 'InternalAnimationEvent.elapsedTime' to 'InternalAnimationEvent.mElapsedTime'. r=masayuki (02cd3ba10f)
- Bug 1259676 - part3: rename from 'InternalAnimationEvent.pseudoElement' to 'InternalAnimationEvent.mPseudoElement'. r=masayuki (440a7fb6f4)
- Bug 1259676 - part4: reorder InternalAnimationEvent's members. r=masayuki (1d37fbc627)
2024-06-12 15:09:41 +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->mTime = 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());
RefPtr<AnimationEvent> e = new AnimationEvent(t, nullptr, nullptr);
bool trusted = e->Init(t);
e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
InternalAnimationEvent* internalEvent = e->mEvent->AsAnimationEvent();
internalEvent->mAnimationName = aParam.mAnimationName;
internalEvent->mElapsedTime = aParam.mElapsedTime;
internalEvent->mPseudoElement = aParam.mPseudoElement;
e->SetTrusted(trusted);
return e.forget();
}
NS_IMETHODIMP
AnimationEvent::GetAnimationName(nsAString& aAnimationName)
{
aAnimationName = mEvent->AsAnimationEvent()->mAnimationName;
return NS_OK;
}
NS_IMETHODIMP
AnimationEvent::GetElapsedTime(float* aElapsedTime)
{
*aElapsedTime = ElapsedTime();
return NS_OK;
}
float
AnimationEvent::ElapsedTime()
{
return mEvent->AsAnimationEvent()->mElapsedTime;
}
NS_IMETHODIMP
AnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
{
aPseudoElement = mEvent->AsAnimationEvent()->mPseudoElement;
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)
{
RefPtr<AnimationEvent> it =
new AnimationEvent(aOwner, aPresContext, aEvent);
return it.forget();
}