зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1158557 - Don't throttle rAF for documents with live static clones. r=smaug
--HG-- extra : rebase_source : a772e11a221489c1085ad62572e23cfbbf080353
This commit is contained in:
Родитель
f80640ea50
Коммит
0cc5f87a8d
|
@ -1636,6 +1636,8 @@ nsIDocument::~nsIDocument()
|
||||||
if (mNodeInfoManager) {
|
if (mNodeInfoManager) {
|
||||||
mNodeInfoManager->DropDocumentReference();
|
mNodeInfoManager->DropDocumentReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnlinkOriginalDocumentIfStatic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2093,13 +2095,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
|
||||||
}
|
}
|
||||||
tmp->mFirstChild = nullptr;
|
tmp->mFirstChild = nullptr;
|
||||||
|
|
||||||
|
tmp->UnlinkOriginalDocumentIfStatic();
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mXPathEvaluator)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mXPathEvaluator)
|
||||||
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
|
tmp->mCachedRootElement = nullptr; // Avoid a dangling pointer
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDisplayDocument)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFirstBaseNodeWithHref)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDOMImplementation)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mImageMaps)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOriginalDocument)
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCachedEncoder)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mUndoManager)
|
||||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentTimeline)
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocumentTimeline)
|
||||||
|
@ -3925,6 +3928,11 @@ nsIDocument::TakeFrameRequestCallbacks(FrameRequestCallbackList& aCallbacks)
|
||||||
bool
|
bool
|
||||||
nsIDocument::ShouldThrottleFrameRequests()
|
nsIDocument::ShouldThrottleFrameRequests()
|
||||||
{
|
{
|
||||||
|
if (mStaticCloneCount > 0) {
|
||||||
|
// Even if we're not visible, a static clone may be, so run at full speed.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mIsShowing) {
|
if (!mIsShowing) {
|
||||||
// We're not showing (probably in a background tab or the bf cache).
|
// We're not showing (probably in a background tab or the bf cache).
|
||||||
return true;
|
return true;
|
||||||
|
@ -10280,6 +10288,9 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||||
} else {
|
} else {
|
||||||
clonedDoc->mOriginalDocument = this;
|
clonedDoc->mOriginalDocument = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clonedDoc->mOriginalDocument->mStaticCloneCount++;
|
||||||
|
|
||||||
int32_t sheetsCount = GetNumberOfStyleSheets();
|
int32_t sheetsCount = GetNumberOfStyleSheets();
|
||||||
for (int32_t i = 0; i < sheetsCount; ++i) {
|
for (int32_t i = 0; i < sheetsCount; ++i) {
|
||||||
nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
|
nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(GetStyleSheetAt(i));
|
||||||
|
@ -10317,6 +10328,17 @@ nsIDocument::CreateStaticClone(nsIDocShell* aCloneContainer)
|
||||||
return clonedDoc.forget();
|
return clonedDoc.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsIDocument::UnlinkOriginalDocumentIfStatic()
|
||||||
|
{
|
||||||
|
if (IsStaticDocument() && mOriginalDocument) {
|
||||||
|
MOZ_ASSERT(mOriginalDocument->mStaticCloneCount > 0);
|
||||||
|
mOriginalDocument->mStaticCloneCount--;
|
||||||
|
mOriginalDocument = nullptr;
|
||||||
|
}
|
||||||
|
MOZ_ASSERT(!mOriginalDocument);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsIDocument::ScheduleFrameRequestCallback(const FrameRequestCallbackHolder& aCallback,
|
nsIDocument::ScheduleFrameRequestCallback(const FrameRequestCallbackHolder& aCallback,
|
||||||
int32_t *aHandle)
|
int32_t *aHandle)
|
||||||
|
|
|
@ -1937,6 +1937,12 @@ public:
|
||||||
return mOriginalDocument;
|
return mOriginalDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this document is a static clone, let the original document know that
|
||||||
|
* we're going away and then release our reference to it.
|
||||||
|
*/
|
||||||
|
void UnlinkOriginalDocumentIfStatic();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are called by the parser as it encounters <picture> tags, the end of
|
* These are called by the parser as it encounters <picture> tags, the end of
|
||||||
* said tags, and possible picture <source srcset> sources respectively. These
|
* said tags, and possible picture <source srcset> sources respectively. These
|
||||||
|
@ -2861,6 +2867,9 @@ protected:
|
||||||
*/
|
*/
|
||||||
int32_t mFrameRequestCallbackCounter;
|
int32_t mFrameRequestCallbackCounter;
|
||||||
|
|
||||||
|
// Count of live static clones of this document.
|
||||||
|
uint32_t mStaticCloneCount;
|
||||||
|
|
||||||
// Array of nodes that have been blocked to prevent user tracking.
|
// Array of nodes that have been blocked to prevent user tracking.
|
||||||
// They most likely have had their nsIChannel canceled by the URL
|
// They most likely have had their nsIChannel canceled by the URL
|
||||||
// classifier. (Safebrowsing)
|
// classifier. (Safebrowsing)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче