зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1302973 - Store timelines on document; r=smaug
MozReview-Commit-ID: KHtAq0VgPZW --HG-- extra : rebase_source : 7daa2a4202f489308981e9cff02e2d7f3bf92c1e
This commit is contained in:
Родитель
4ee6a90bbb
Коммит
b813bcffe5
|
@ -21,6 +21,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(DocumentTimeline)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(DocumentTimeline,
|
||||
AnimationTimeline)
|
||||
tmp->UnregisterFromRefreshDriver();
|
||||
if (tmp->isInList()) {
|
||||
tmp->remove();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(DocumentTimeline,
|
||||
|
@ -134,6 +137,9 @@ DocumentTimeline::NotifyAnimationUpdated(Animation& aAnimation)
|
|||
if (!mIsObservingRefreshDriver) {
|
||||
nsRefreshDriver* refreshDriver = GetRefreshDriver();
|
||||
if (refreshDriver) {
|
||||
MOZ_ASSERT(isInList(),
|
||||
"We should not register with the refresh driver if we are not"
|
||||
" in the document's list of timelines");
|
||||
refreshDriver->AddRefreshObserver(this, Flush_Style);
|
||||
mIsObservingRefreshDriver = true;
|
||||
}
|
||||
|
@ -198,6 +204,9 @@ DocumentTimeline::NotifyRefreshDriverCreated(nsRefreshDriver* aDriver)
|
|||
" it is created");
|
||||
|
||||
if (!mAnimationOrder.isEmpty()) {
|
||||
MOZ_ASSERT(isInList(),
|
||||
"We should not register with the refresh driver if we are not"
|
||||
" in the document's list of timelines");
|
||||
aDriver->AddRefreshObserver(this, Flush_Style);
|
||||
mIsObservingRefreshDriver = true;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define mozilla_dom_DocumentTimeline_h
|
||||
|
||||
#include "mozilla/dom/DocumentTimelineBinding.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "AnimationTimeline.h"
|
||||
#include "nsIDocument.h"
|
||||
|
@ -28,6 +29,7 @@ namespace dom {
|
|||
class DocumentTimeline final
|
||||
: public AnimationTimeline
|
||||
, public nsARefreshObserver
|
||||
, public LinkedListElement<DocumentTimeline>
|
||||
{
|
||||
public:
|
||||
DocumentTimeline(nsIDocument* aDocument, const TimeDuration& aOriginTime)
|
||||
|
@ -36,6 +38,9 @@ public:
|
|||
, mIsObservingRefreshDriver(false)
|
||||
, mOriginTime(aOriginTime)
|
||||
{
|
||||
if (mDocument) {
|
||||
mDocument->Timelines().insertBack(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -43,6 +48,9 @@ protected:
|
|||
{
|
||||
MOZ_ASSERT(!mIsObservingRefreshDriver, "Timeline should have disassociated"
|
||||
" from the refresh driver before being destroyed");
|
||||
if (isInList()) {
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -1476,6 +1476,8 @@ nsDocument::~nsDocument()
|
|||
mAnimationController->Disconnect();
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mTimelines.isEmpty());
|
||||
|
||||
mParentDocument = nullptr;
|
||||
|
||||
// Kill the subdocument map, doing this will release its strong
|
||||
|
@ -1998,15 +2000,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.
|
||||
if (mDocumentTimeline) {
|
||||
nsRefreshDriver* rd = mPresShell && mPresShell->GetPresContext() ?
|
||||
mPresShell->GetPresContext()->RefreshDriver() :
|
||||
nullptr;
|
||||
if (rd) {
|
||||
mDocumentTimeline->NotifyRefreshDriverDestroying(rd);
|
||||
}
|
||||
mDocumentTimeline = nullptr;
|
||||
}
|
||||
mDocumentTimeline = nullptr;
|
||||
|
||||
nsCOMPtr<nsIPropertyBag2> bag = do_QueryInterface(aChannel);
|
||||
if (bag) {
|
||||
|
|
|
@ -606,6 +606,10 @@ public:
|
|||
virtual mozilla::dom::DocumentTimeline* Timeline() override;
|
||||
virtual void GetAnimations(
|
||||
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) override;
|
||||
mozilla::LinkedList<mozilla::dom::DocumentTimeline>& Timelines() override
|
||||
{
|
||||
return mTimelines;
|
||||
}
|
||||
|
||||
virtual nsresult SetSubDocumentFor(Element* aContent,
|
||||
nsIDocument* aSubDoc) override;
|
||||
|
@ -1597,6 +1601,7 @@ private:
|
|||
RefPtr<mozilla::dom::UndoManager> mUndoManager;
|
||||
|
||||
RefPtr<mozilla::dom::DocumentTimeline> mDocumentTimeline;
|
||||
mozilla::LinkedList<mozilla::dom::DocumentTimeline> mTimelines;
|
||||
|
||||
enum ViewportType {
|
||||
DisplayWidthHeight,
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "prclist.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/CORSMode.h"
|
||||
#include "mozilla/LinkedList.h"
|
||||
#include "mozilla/StyleBackendType.h"
|
||||
#include "mozilla/StyleSheet.h"
|
||||
#include <bitset> // for member
|
||||
|
@ -2325,6 +2326,7 @@ public:
|
|||
virtual already_AddRefed<mozilla::dom::UndoManager> GetUndoManager() = 0;
|
||||
|
||||
virtual mozilla::dom::DocumentTimeline* Timeline() = 0;
|
||||
virtual mozilla::LinkedList<mozilla::dom::DocumentTimeline>& Timelines() = 0;
|
||||
|
||||
virtual void GetAnimations(
|
||||
nsTArray<RefPtr<mozilla::dom::Animation>>& aAnimations) = 0;
|
||||
|
|
|
@ -975,8 +975,9 @@ PresShell::Init(nsIDocument* aDocument,
|
|||
animCtrl->NotifyRefreshDriverCreated(GetPresContext()->RefreshDriver());
|
||||
}
|
||||
|
||||
mDocument->Timeline()->NotifyRefreshDriverCreated(GetPresContext()->
|
||||
RefreshDriver());
|
||||
for (DocumentTimeline* timeline : mDocument->Timelines()) {
|
||||
timeline->NotifyRefreshDriverCreated(GetPresContext()->RefreshDriver());
|
||||
}
|
||||
|
||||
// Get our activeness from the docShell.
|
||||
QueryIsActive();
|
||||
|
@ -1276,8 +1277,9 @@ PresShell::Destroy()
|
|||
if (mDocument->HasAnimationController()) {
|
||||
mDocument->GetAnimationController()->NotifyRefreshDriverDestroying(rd);
|
||||
}
|
||||
|
||||
mDocument->Timeline()->NotifyRefreshDriverDestroying(rd);
|
||||
for (DocumentTimeline* timeline : mDocument->Timelines()) {
|
||||
timeline->NotifyRefreshDriverDestroying(rd);
|
||||
}
|
||||
}
|
||||
|
||||
if (mPresContext) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче