mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1152171 part 2 - Rename AnimationTimeline to DocumentTimeline; r=smaug
And then re-add AnimationTimeline as an abstract super-interface of DocumentTimeline. --HG-- rename : dom/animation/AnimationTimeline.cpp => dom/animation/DocumentTimeline.cpp rename : dom/animation/AnimationTimeline.h => dom/animation/DocumentTimeline.h rename : dom/animation/test/animation-timeline/test_animation-timeline.html => dom/animation/test/document-timeline/test_document-timeline.html rename : dom/animation/test/animation-timeline/test_request_animation_frame.html => dom/animation/test/document-timeline/test_request_animation_frame.html
This commit is contained in:
parent
41ae9d94b3
commit
6b5fcefb36
@ -180,7 +180,7 @@ AnimationPlayer::PlayState() const
|
||||
}
|
||||
|
||||
static inline already_AddRefed<Promise>
|
||||
CreatePromise(AnimationTimeline* aTimeline, ErrorResult& aRv)
|
||||
CreatePromise(DocumentTimeline* aTimeline, ErrorResult& aRv)
|
||||
{
|
||||
nsIGlobalObject* global = aTimeline->GetParentObject();
|
||||
if (global) {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp, TimeDuration
|
||||
#include "mozilla/dom/Animation.h" // for Animation
|
||||
#include "mozilla/dom/AnimationPlayerBinding.h" // for AnimationPlayState
|
||||
#include "mozilla/dom/AnimationTimeline.h" // for AnimationTimeline
|
||||
#include "mozilla/dom/DocumentTimeline.h" // for DocumentTimeline
|
||||
#include "mozilla/dom/Promise.h" // for Promise
|
||||
#include "nsCSSProperty.h" // for nsCSSProperty
|
||||
|
||||
@ -51,7 +51,7 @@ protected:
|
||||
virtual ~AnimationPlayer() {}
|
||||
|
||||
public:
|
||||
explicit AnimationPlayer(AnimationTimeline* aTimeline)
|
||||
explicit AnimationPlayer(DocumentTimeline* aTimeline)
|
||||
: mTimeline(aTimeline)
|
||||
, mPlaybackRate(1.0)
|
||||
, mPendingState(PendingState::NotPending)
|
||||
@ -65,8 +65,9 @@ public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationPlayer)
|
||||
|
||||
AnimationTimeline* GetParentObject() const { return mTimeline; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
DocumentTimeline* GetParentObject() const { return mTimeline; }
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
virtual CSSAnimationPlayer* AsCSSAnimationPlayer() { return nullptr; }
|
||||
virtual CSSTransitionPlayer* AsCSSTransitionPlayer() { return nullptr; }
|
||||
@ -80,7 +81,7 @@ public:
|
||||
|
||||
// AnimationPlayer methods
|
||||
Animation* GetSource() const { return mSource; }
|
||||
AnimationTimeline* Timeline() const { return mTimeline; }
|
||||
DocumentTimeline* Timeline() const { return mTimeline; }
|
||||
Nullable<TimeDuration> GetStartTime() const { return mStartTime; }
|
||||
void SetStartTime(const Nullable<TimeDuration>& aNewStartTime);
|
||||
Nullable<TimeDuration> GetCurrentTime() const;
|
||||
@ -301,7 +302,7 @@ protected:
|
||||
virtual css::CommonAnimationManager* GetAnimationManager() const = 0;
|
||||
AnimationPlayerCollection* GetCollection() const;
|
||||
|
||||
nsRefPtr<AnimationTimeline> mTimeline;
|
||||
nsRefPtr<DocumentTimeline> mTimeline;
|
||||
nsRefPtr<Animation> mSource;
|
||||
// The beginning of the delay period.
|
||||
Nullable<TimeDuration> mStartTime; // Timeline timescale
|
||||
|
@ -4,118 +4,19 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AnimationTimeline.h"
|
||||
#include "mozilla/dom/AnimationTimelineBinding.h"
|
||||
#include "AnimationUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationTimeline, mDocument, mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationTimeline, mWindow)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(AnimationTimeline, AddRef)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(AnimationTimeline, Release)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(AnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(AnimationTimeline)
|
||||
|
||||
JSObject*
|
||||
AnimationTimeline::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return AnimationTimelineBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
Nullable<TimeDuration>
|
||||
AnimationTimeline::GetCurrentTime() const
|
||||
{
|
||||
return ToTimelineTime(GetCurrentTimeStamp());
|
||||
}
|
||||
|
||||
Nullable<double>
|
||||
AnimationTimeline::GetCurrentTimeAsDouble() const
|
||||
{
|
||||
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
AnimationTimeline::GetCurrentTimeStamp() const
|
||||
{
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
TimeStamp refreshTime = refreshDriver
|
||||
? refreshDriver->MostRecentRefresh()
|
||||
: TimeStamp();
|
||||
|
||||
// Always return the same object to benefit from return-value optimization.
|
||||
TimeStamp result = !refreshTime.IsNull()
|
||||
? refreshTime
|
||||
: mLastRefreshDriverTime;
|
||||
|
||||
// If we don't have a refresh driver and we've never had one use the
|
||||
// timeline's zero time.
|
||||
if (result.IsNull()) {
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (timing) {
|
||||
result = timing->GetNavigationStartTimeStamp();
|
||||
// Also, let this time represent the current refresh time. This way
|
||||
// we'll save it as the last refresh time and skip looking up
|
||||
// navigation timing each time.
|
||||
refreshTime = result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!refreshTime.IsNull()) {
|
||||
mLastRefreshDriverTime = refreshTime;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Nullable<TimeDuration>
|
||||
AnimationTimeline::ToTimelineTime(const TimeStamp& aTimeStamp) const
|
||||
{
|
||||
Nullable<TimeDuration> result; // Initializes to null
|
||||
if (aTimeStamp.IsNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (MOZ_UNLIKELY(!timing)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.SetValue(aTimeStamp - timing->GetNavigationStartTimeStamp());
|
||||
return result;
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
AnimationTimeline::ToTimeStamp(const TimeDuration& aTimeDuration) const
|
||||
{
|
||||
TimeStamp result;
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (MOZ_UNLIKELY(!timing)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = timing->GetNavigationStartTimeStamp() + aTimeDuration;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsRefreshDriver*
|
||||
AnimationTimeline::GetRefreshDriver() const
|
||||
{
|
||||
nsIPresShell* presShell = mDocument->GetShell();
|
||||
if (MOZ_UNLIKELY(!presShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
if (MOZ_UNLIKELY(!presContext)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return presContext->RefreshDriver();
|
||||
}
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AnimationTimeline)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -6,26 +6,24 @@
|
||||
#ifndef mozilla_dom_AnimationTimeline_h
|
||||
#define mozilla_dom_AnimationTimeline_h
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/AnimationUtils.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class AnimationTimeline final : public nsWrapperCache
|
||||
class AnimationTimeline
|
||||
: public nsISupports
|
||||
, public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
explicit AnimationTimeline(nsIDocument* aDocument)
|
||||
: mDocument(aDocument)
|
||||
, mWindow(aDocument->GetParentObject())
|
||||
explicit AnimationTimeline(nsIGlobalObject* aWindow)
|
||||
: mWindow(aWindow)
|
||||
{
|
||||
MOZ_ASSERT(mWindow);
|
||||
}
|
||||
@ -34,56 +32,22 @@ protected:
|
||||
virtual ~AnimationTimeline() { }
|
||||
|
||||
public:
|
||||
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationTimeline)
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationTimeline)
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationTimeline)
|
||||
|
||||
nsIGlobalObject* GetParentObject() const
|
||||
{
|
||||
return mWindow;
|
||||
}
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||
nsIGlobalObject* GetParentObject() const { return mWindow; }
|
||||
|
||||
// AnimationTimeline methods
|
||||
Nullable<TimeDuration> GetCurrentTime() const;
|
||||
virtual Nullable<TimeDuration> GetCurrentTime() const = 0;
|
||||
|
||||
// Wrapper functions for AnimationTimeline DOM methods when called from
|
||||
// script.
|
||||
Nullable<double> GetCurrentTimeAsDouble() const;
|
||||
|
||||
// Converts a TimeStamp to the equivalent value in timeline time.
|
||||
// Note that when IsUnderTestControl() is true, there is no correspondence
|
||||
// between timeline time and wallclock time. In such a case, passing a
|
||||
// timestamp from TimeStamp::Now() to this method will not return a
|
||||
// meaningful result.
|
||||
Nullable<TimeDuration> ToTimelineTime(const TimeStamp& aTimeStamp) const;
|
||||
TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const;
|
||||
|
||||
nsRefreshDriver* GetRefreshDriver() const;
|
||||
// Returns true if this timeline is driven by a refresh driver that is
|
||||
// under test control. In such a case, there is no correspondence between
|
||||
// TimeStamp values returned by the refresh driver and wallclock time.
|
||||
// As a result, passing a value from TimeStamp::Now() to ToTimelineTime()
|
||||
// would not return a meaningful result.
|
||||
bool IsUnderTestControl() const
|
||||
{
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
return refreshDriver && refreshDriver->IsTestControllingRefreshesEnabled();
|
||||
Nullable<double> GetCurrentTimeAsDouble() const {
|
||||
return AnimationUtils::TimeDurationToDouble(GetCurrentTime());
|
||||
}
|
||||
|
||||
protected:
|
||||
TimeStamp GetCurrentTimeStamp() const;
|
||||
|
||||
// Sometimes documents can be given a new window, or windows can be given a
|
||||
// new document (e.g. document.open()). Since GetParentObject is required to
|
||||
// _always_ return the same object it can't get the window from our
|
||||
// mDocument, which is why we have pointers to both our document and window.
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIGlobalObject> mWindow;
|
||||
|
||||
// The most recently used refresh driver time. This is used in cases where
|
||||
// we don't have a refresh driver (e.g. because we are in a display:none
|
||||
// iframe).
|
||||
mutable TimeStamp mLastRefreshDriverTime;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
123
dom/animation/DocumentTimeline.cpp
Normal file
123
dom/animation/DocumentTimeline.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* 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 "DocumentTimeline.h"
|
||||
#include "mozilla/dom/DocumentTimelineBinding.h"
|
||||
#include "AnimationUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsPresContext.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(DocumentTimeline, AnimationTimeline,
|
||||
mDocument)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(DocumentTimeline,
|
||||
AnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DocumentTimeline)
|
||||
NS_INTERFACE_MAP_END_INHERITING(AnimationTimeline)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(DocumentTimeline, AnimationTimeline)
|
||||
NS_IMPL_RELEASE_INHERITED(DocumentTimeline, AnimationTimeline)
|
||||
|
||||
JSObject*
|
||||
DocumentTimeline::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
return DocumentTimelineBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
Nullable<TimeDuration>
|
||||
DocumentTimeline::GetCurrentTime() const
|
||||
{
|
||||
return ToTimelineTime(GetCurrentTimeStamp());
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
DocumentTimeline::GetCurrentTimeStamp() const
|
||||
{
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
TimeStamp refreshTime = refreshDriver
|
||||
? refreshDriver->MostRecentRefresh()
|
||||
: TimeStamp();
|
||||
|
||||
// Always return the same object to benefit from return-value optimization.
|
||||
TimeStamp result = !refreshTime.IsNull()
|
||||
? refreshTime
|
||||
: mLastRefreshDriverTime;
|
||||
|
||||
// If we don't have a refresh driver and we've never had one use the
|
||||
// timeline's zero time.
|
||||
if (result.IsNull()) {
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (timing) {
|
||||
result = timing->GetNavigationStartTimeStamp();
|
||||
// Also, let this time represent the current refresh time. This way
|
||||
// we'll save it as the last refresh time and skip looking up
|
||||
// navigation timing each time.
|
||||
refreshTime = result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!refreshTime.IsNull()) {
|
||||
mLastRefreshDriverTime = refreshTime;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Nullable<TimeDuration>
|
||||
DocumentTimeline::ToTimelineTime(const TimeStamp& aTimeStamp) const
|
||||
{
|
||||
Nullable<TimeDuration> result; // Initializes to null
|
||||
if (aTimeStamp.IsNull()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (MOZ_UNLIKELY(!timing)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.SetValue(aTimeStamp - timing->GetNavigationStartTimeStamp());
|
||||
return result;
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
DocumentTimeline::ToTimeStamp(const TimeDuration& aTimeDuration) const
|
||||
{
|
||||
TimeStamp result;
|
||||
nsRefPtr<nsDOMNavigationTiming> timing = mDocument->GetNavigationTiming();
|
||||
if (MOZ_UNLIKELY(!timing)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = timing->GetNavigationStartTimeStamp() + aTimeDuration;
|
||||
return result;
|
||||
}
|
||||
|
||||
nsRefreshDriver*
|
||||
DocumentTimeline::GetRefreshDriver() const
|
||||
{
|
||||
nsIPresShell* presShell = mDocument->GetShell();
|
||||
if (MOZ_UNLIKELY(!presShell)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsPresContext* presContext = presShell->GetPresContext();
|
||||
if (MOZ_UNLIKELY(!presContext)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return presContext->RefreshDriver();
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
76
dom/animation/DocumentTimeline.h
Normal file
76
dom/animation/DocumentTimeline.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_DocumentTimeline_h
|
||||
#define mozilla_dom_DocumentTimeline_h
|
||||
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "AnimationTimeline.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsRefreshDriver.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DocumentTimeline final : public AnimationTimeline
|
||||
{
|
||||
public:
|
||||
explicit DocumentTimeline(nsIDocument* aDocument)
|
||||
: AnimationTimeline(aDocument->GetParentObject())
|
||||
, mDocument(aDocument)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~DocumentTimeline() { }
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DocumentTimeline,
|
||||
AnimationTimeline)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
// DocumentTimeline methods
|
||||
virtual Nullable<TimeDuration> GetCurrentTime() const override;
|
||||
|
||||
// Converts a TimeStamp to the equivalent value in timeline time.
|
||||
// Note that when IsUnderTestControl() is true, there is no correspondence
|
||||
// between timeline time and wallclock time. In such a case, passing a
|
||||
// timestamp from TimeStamp::Now() to this method will not return a
|
||||
// meaningful result.
|
||||
Nullable<TimeDuration> ToTimelineTime(const TimeStamp& aTimeStamp) const;
|
||||
TimeStamp ToTimeStamp(const TimeDuration& aTimelineTime) const;
|
||||
|
||||
nsRefreshDriver* GetRefreshDriver() const;
|
||||
// Returns true if this timeline is driven by a refresh driver that is
|
||||
// under test control. In such a case, there is no correspondence between
|
||||
// TimeStamp values returned by the refresh driver and wallclock time.
|
||||
// As a result, passing a value from TimeStamp::Now() to ToTimelineTime()
|
||||
// would not return a meaningful result.
|
||||
bool IsUnderTestControl() const
|
||||
{
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
return refreshDriver && refreshDriver->IsTestControllingRefreshesEnabled();
|
||||
}
|
||||
|
||||
protected:
|
||||
TimeStamp GetCurrentTimeStamp() const;
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
|
||||
// The most recently used refresh driver time. This is used in cases where
|
||||
// we don't have a refresh driver (e.g. because we are in a display:none
|
||||
// iframe).
|
||||
mutable TimeStamp mLastRefreshDriverTime;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_DocumentTimeline_h
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "PendingPlayerTracker.h"
|
||||
|
||||
#include "mozilla/dom/AnimationTimeline.h"
|
||||
#include "mozilla/dom/DocumentTimeline.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
@ -52,7 +52,7 @@ TriggerPlayerAtTime(nsRefPtrHashKey<dom::AnimationPlayer>* aKey,
|
||||
void* aReadyTime)
|
||||
{
|
||||
dom::AnimationPlayer* player = aKey->GetKey();
|
||||
dom::AnimationTimeline* timeline = player->Timeline();
|
||||
dom::DocumentTimeline* timeline = player->Timeline();
|
||||
|
||||
// When the timeline's refresh driver is under test control, its values
|
||||
// have no correspondance to wallclock times so we shouldn't try to convert
|
||||
|
@ -12,9 +12,11 @@ EXPORTS.mozilla.dom += [
|
||||
'AnimationEffect.h',
|
||||
'AnimationPlayer.h',
|
||||
'AnimationTimeline.h',
|
||||
'DocumentTimeline.h',
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
'AnimationUtils.h',
|
||||
'PendingPlayerTracker.h',
|
||||
]
|
||||
|
||||
@ -23,6 +25,7 @@ UNIFIED_SOURCES += [
|
||||
'AnimationEffect.cpp',
|
||||
'AnimationPlayer.cpp',
|
||||
'AnimationTimeline.cpp',
|
||||
'DocumentTimeline.cpp',
|
||||
'PendingPlayerTracker.cpp',
|
||||
]
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Web Animations API: AnimationTimeline tests</title>
|
||||
<title>Web Animations API: DocumentTimeline tests</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
@ -2,9 +2,6 @@
|
||||
support-files =
|
||||
testcommon.js
|
||||
|
||||
[animation-timeline/test_animation-timeline.html]
|
||||
[animation-timeline/test_request_animation_frame.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[css-animations/test_animations-dynamic-changes.html]
|
||||
[css-animations/test_animation-effect-name.html]
|
||||
[css-animations/test_animation-pausing.html]
|
||||
@ -24,4 +21,7 @@ skip-if = buildapp == 'mulet'
|
||||
[css-transitions/test_animation-player-starttime.html]
|
||||
[css-transitions/test_element-get-animation-players.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[document-timeline/test_document-timeline.html]
|
||||
[document-timeline/test_request_animation_frame.html]
|
||||
skip-if = buildapp == 'mulet'
|
||||
[mozilla/test_deferred_start.html]
|
||||
|
@ -186,9 +186,9 @@
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "nsIAppsService.h"
|
||||
#include "mozilla/dom/AnonymousContent.h"
|
||||
#include "mozilla/dom/AnimationTimeline.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/DocumentFragment.h"
|
||||
#include "mozilla/dom/DocumentTimeline.h"
|
||||
#include "mozilla/dom/Event.h"
|
||||
#include "mozilla/dom/HTMLBodyElement.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
@ -2017,7 +2017,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCachedEncoder)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStateObjectCached)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mUndoManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocumentTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingPlayerTracker)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mTemplateContentsOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChildrenCollection)
|
||||
@ -2101,7 +2101,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAnimationTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentTimeline)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingPlayerTracker)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mTemplateContentsOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChildrenCollection)
|
||||
@ -2303,7 +2303,7 @@ nsDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
|
||||
// Note that, since mTiming does not change during a reset, the
|
||||
// navigationStart time remains unchanged and therefore any future new
|
||||
// timeline will have the same global clock time as the old one.
|
||||
mAnimationTimeline = nullptr;
|
||||
mDocumentTimeline = nullptr;
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel);
|
||||
if (bag) {
|
||||
@ -3322,14 +3322,14 @@ nsDocument::IsWebAnimationsEnabled(JSContext* /*unused*/, JSObject* /*unused*/)
|
||||
Preferences::GetBool("dom.animations-api.core.enabled");
|
||||
}
|
||||
|
||||
AnimationTimeline*
|
||||
DocumentTimeline*
|
||||
nsDocument::Timeline()
|
||||
{
|
||||
if (!mAnimationTimeline) {
|
||||
mAnimationTimeline = new AnimationTimeline(this);
|
||||
if (!mDocumentTimeline) {
|
||||
mDocumentTimeline = new DocumentTimeline(this);
|
||||
}
|
||||
|
||||
return mAnimationTimeline;
|
||||
return mDocumentTimeline;
|
||||
}
|
||||
|
||||
/* Return true if the document is in the focused top-level window, and is an
|
||||
|
@ -785,7 +785,7 @@ public:
|
||||
virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() override;
|
||||
|
||||
static bool IsWebAnimationsEnabled(JSContext* aCx, JSObject* aObject);
|
||||
virtual mozilla::dom::AnimationTimeline* Timeline() override;
|
||||
virtual mozilla::dom::DocumentTimeline* Timeline() override;
|
||||
|
||||
virtual nsresult SetSubDocumentFor(Element* aContent,
|
||||
nsIDocument* aSubDoc) override;
|
||||
@ -1805,7 +1805,7 @@ private:
|
||||
|
||||
nsRefPtr<mozilla::dom::UndoManager> mUndoManager;
|
||||
|
||||
nsRefPtr<mozilla::dom::AnimationTimeline> mAnimationTimeline;
|
||||
nsRefPtr<mozilla::dom::DocumentTimeline> mDocumentTimeline;
|
||||
|
||||
enum ViewportType {
|
||||
DisplayWidthHeight,
|
||||
|
@ -101,7 +101,6 @@ class VRHMDInfo;
|
||||
} // namespace gfx
|
||||
|
||||
namespace dom {
|
||||
class AnimationTimeline;
|
||||
class AnonymousContent;
|
||||
class Attr;
|
||||
class BoxObject;
|
||||
@ -109,6 +108,7 @@ class CDATASection;
|
||||
class Comment;
|
||||
struct CustomElementDefinition;
|
||||
class DocumentFragment;
|
||||
class DocumentTimeline;
|
||||
class DocumentType;
|
||||
class DOMImplementation;
|
||||
class DOMStringList;
|
||||
@ -2087,7 +2087,7 @@ public:
|
||||
|
||||
virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() = 0;
|
||||
|
||||
virtual mozilla::dom::AnimationTimeline* Timeline() = 0;
|
||||
virtual mozilla::dom::DocumentTimeline* Timeline() = 0;
|
||||
|
||||
typedef mozilla::dom::CallbackObjectHolder<
|
||||
mozilla::dom::FrameRequestCallback,
|
||||
|
@ -88,6 +88,10 @@ DOMInterfaces = {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'AnimationTimeline': {
|
||||
'concrete': False
|
||||
},
|
||||
|
||||
'AnonymousContent': {
|
||||
'wrapperCache': False
|
||||
},
|
||||
|
@ -352,6 +352,8 @@ var interfaceNamesInGlobalScope =
|
||||
"Document",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"DocumentFragment",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{name: "DocumentTimeline", pref: "dom.animations-api.core.enabled"},
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
"DocumentType",
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
|
@ -4,9 +4,9 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/web-animations/#the-animationtimeline-interface
|
||||
* https://w3c.github.io/web-animations/#animationtimeline
|
||||
*
|
||||
* Copyright © 2014 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
|
@ -292,10 +292,10 @@ partial interface Document {
|
||||
//(Not implemented)NodeList findAll(DOMString selectors, optional (Element or sequence<Node>)? refNodes);
|
||||
};
|
||||
|
||||
// http://dev.w3.org/fxtf/web-animations/#extensions-to-the-document-interface
|
||||
// http://w3c.github.io/web-animations/#extensions-to-the-document-interface
|
||||
partial interface Document {
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
readonly attribute AnimationTimeline timeline;
|
||||
readonly attribute DocumentTimeline timeline;
|
||||
};
|
||||
|
||||
// Mozilla extensions of various sorts
|
||||
|
17
dom/webidl/DocumentTimeline.webidl
Normal file
17
dom/webidl/DocumentTimeline.webidl
Normal file
@ -0,0 +1,17 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://w3c.github.io/web-animations/#documenttimeline
|
||||
*
|
||||
* Copyright © 2015 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
// Not yet implemented:
|
||||
// [Constructor (DOMHighResTimeStamp originTime)]
|
||||
[Func="nsDocument::IsWebAnimationsEnabled"]
|
||||
interface DocumentTimeline : AnimationTimeline {
|
||||
};
|
@ -108,6 +108,7 @@ WEBIDL_FILES = [
|
||||
'DisplayPortInputPort.webidl',
|
||||
'Document.webidl',
|
||||
'DocumentFragment.webidl',
|
||||
'DocumentTimeline.webidl',
|
||||
'DocumentType.webidl',
|
||||
'DOMCursor.webidl',
|
||||
'DOMError.webidl',
|
||||
|
@ -290,7 +290,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
|
||||
nsAutoAnimationMutationBatch mb(aElement);
|
||||
|
||||
// build the animations list
|
||||
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
||||
dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
||||
AnimationPlayerPtrArray newPlayers;
|
||||
if (!aStyleContext->IsInDisplayNoneSubtree()) {
|
||||
BuildAnimations(aStyleContext, aElement, timeline, newPlayers);
|
||||
@ -487,7 +487,7 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
|
||||
void
|
||||
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
|
||||
dom::Element* aTarget,
|
||||
dom::AnimationTimeline* aTimeline,
|
||||
dom::DocumentTimeline* aTimeline,
|
||||
AnimationPlayerPtrArray& aPlayers)
|
||||
{
|
||||
MOZ_ASSERT(aPlayers.IsEmpty(), "expect empty array");
|
||||
|
@ -55,7 +55,7 @@ typedef InfallibleTArray<AnimationEventInfo> EventArray;
|
||||
class CSSAnimationPlayer final : public dom::AnimationPlayer
|
||||
{
|
||||
public:
|
||||
explicit CSSAnimationPlayer(dom::AnimationTimeline* aTimeline)
|
||||
explicit CSSAnimationPlayer(dom::DocumentTimeline* aTimeline)
|
||||
: dom::AnimationPlayer(aTimeline)
|
||||
, mIsStylePaused(false)
|
||||
, mPauseShouldStick(false)
|
||||
@ -237,7 +237,7 @@ protected:
|
||||
private:
|
||||
void BuildAnimations(nsStyleContext* aStyleContext,
|
||||
mozilla::dom::Element* aTarget,
|
||||
mozilla::dom::AnimationTimeline* aTimeline,
|
||||
mozilla::dom::DocumentTimeline* aTimeline,
|
||||
mozilla::AnimationPlayerPtrArray& aAnimations);
|
||||
bool BuildSegment(InfallibleTArray<mozilla::AnimationPropertySegment>&
|
||||
aSegments,
|
||||
|
@ -398,7 +398,7 @@ nsTransitionManager::ConsiderStartingTransition(
|
||||
return;
|
||||
}
|
||||
|
||||
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
||||
dom::DocumentTimeline* timeline = aElement->OwnerDoc()->Timeline();
|
||||
|
||||
StyleAnimationValue startValue, endValue, dummyValue;
|
||||
bool haveValues =
|
||||
|
@ -68,7 +68,7 @@ struct ElementPropertyTransition : public dom::Animation
|
||||
class CSSTransitionPlayer final : public dom::AnimationPlayer
|
||||
{
|
||||
public:
|
||||
explicit CSSTransitionPlayer(dom::AnimationTimeline* aTimeline)
|
||||
explicit CSSTransitionPlayer(dom::DocumentTimeline* aTimeline)
|
||||
: dom::AnimationPlayer(aTimeline)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user