Bug 1442817 - Add another variant of nsDocument::FlushPendingNotifications which are able to skip to flushing throttled animations. r=birtles,emilio

MozReview-Commit-ID: BZ9yAoAmWBB

--HG--
extra : rebase_source : 4f240b042992b3f13f296ce932c0d9795407932f
This commit is contained in:
Hiroyuki Ikezoe 2018-03-09 06:41:30 +09:00
Родитель 771de40179
Коммит 78ac3dcdb4
2 изменённых файлов: 27 добавлений и 9 удалений

Просмотреть файл

@ -7579,6 +7579,15 @@ nsIDocument::CreateEvent(const nsAString& aEventType, CallerType aCallerType,
void
nsIDocument::FlushPendingNotifications(FlushType aType)
{
mozilla::ChangesToFlush flush(aType, aType >= FlushType::Style);
FlushPendingNotifications(flush);
}
void
nsIDocument::FlushPendingNotifications(mozilla::ChangesToFlush aFlush)
{
FlushType flushType = aFlush.mFlushType;
nsDocumentOnStack dos(this);
// We need to flush the sink for non-HTML documents (because the XML
@ -7588,7 +7597,7 @@ nsIDocument::FlushPendingNotifications(FlushType aType)
// part if we have no presshell or if it's already done an initial
// reflow.
if ((!IsHTMLDocument() ||
(aType > FlushType::ContentAndNotify && mPresShell &&
(flushType > FlushType::ContentAndNotify && mPresShell &&
!mPresShell->DidInitialize())) &&
(mParser || mWeakSink)) {
nsCOMPtr<nsIContentSink> sink;
@ -7602,14 +7611,14 @@ nsIDocument::FlushPendingNotifications(FlushType aType)
}
// Determine if it is safe to flush the sink notifications
// by determining if it safe to flush all the presshells.
if (sink && (aType == FlushType::Content || IsSafeToFlush())) {
sink->FlushPendingNotifications(aType);
if (sink && (flushType == FlushType::Content || IsSafeToFlush())) {
sink->FlushPendingNotifications(flushType);
}
}
// Should we be flushing pending binding constructors in here?
if (aType <= FlushType::ContentAndNotify) {
if (flushType <= FlushType::ContentAndNotify) {
// Nothing to do here
return;
}
@ -7624,14 +7633,15 @@ nsIDocument::FlushPendingNotifications(FlushType aType)
// layout flush on our parent, since we need our container to be the
// correct size to determine the correct style.
if (mParentDocument && IsSafeToFlush()) {
FlushType parentType = aType;
if (aType >= FlushType::Style)
parentType = std::max(FlushType::Layout, aType);
mParentDocument->FlushPendingNotifications(parentType);
mozilla::ChangesToFlush parentFlush = aFlush;
if (flushType >= FlushType::Style) {
parentFlush.mFlushType = std::max(FlushType::Layout, flushType);
}
mParentDocument->FlushPendingNotifications(parentFlush);
}
if (nsIPresShell* shell = GetShell()) {
shell->FlushPendingNotifications(aType);
shell->FlushPendingNotifications(aFlush);
}
}

Просмотреть файл

@ -1737,6 +1737,14 @@ public:
*/
void FlushPendingNotifications(mozilla::FlushType aType);
/**
* Another variant of the above FlushPendingNotifications. This function
* takes a ChangesToFlush to specify whether throttled animations are flushed
* or not.
* If in doublt, use the above FlushPendingNotifications.
*/
void FlushPendingNotifications(mozilla::ChangesToFlush aFlush);
/**
* Calls FlushPendingNotifications on any external resources this document
* has. If this document has no external resources or is an external resource