Bug 1166500 - Part 7: Throttle paint-only animations if the presShell is not active. r=dbaron

This commit is contained in:
Hiroyuki Ikezoe 2016-05-24 12:57:43 +09:00
Родитель f4e8a9f94a
Коммит b2888c83cd
2 изменённых файлов: 19 добавлений и 6 удалений

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

@ -19,6 +19,7 @@
#include "nsCSSProps.h" // For nsCSSProps::PropHasFlags
#include "nsCSSPseudoElements.h" // For CSSPseudoElementType
#include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
#include "nsIPresShell.h" // For nsIPresShell
namespace mozilla {
@ -1066,9 +1067,13 @@ KeyframeEffectReadOnly::CanThrottle() const
}
// We can throttle the animation if the animation is paint only and
// the target frame is out of view.
if (CanIgnoreIfNotVisible() && frame->IsScrolledOutOfView()) {
return true;
// the target frame is out of view or the document is in background tabs.
if (CanIgnoreIfNotVisible()) {
nsIPresShell* presShell = GetPresShell();
if ((presShell && !presShell->IsActive()) ||
frame->IsScrolledOutOfView()) {
return true;
}
}
// First we need to check layer generation and transform overflow
@ -1201,14 +1206,20 @@ KeyframeEffectReadOnly::GetRenderedDocument() const
return mTarget->mElement->GetComposedDoc();
}
nsPresContext*
KeyframeEffectReadOnly::GetPresContext() const
nsIPresShell*
KeyframeEffectReadOnly::GetPresShell() const
{
nsIDocument* doc = GetRenderedDocument();
if (!doc) {
return nullptr;
}
nsIPresShell* shell = doc->GetShell();
return doc->GetShell();
}
nsPresContext*
KeyframeEffectReadOnly::GetPresContext() const
{
nsIPresShell* shell = GetPresShell();
if (!shell) {
return nullptr;
}

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

@ -37,6 +37,7 @@ class nsCSSPropertySet;
class nsIContent;
class nsIDocument;
class nsIFrame;
class nsIPresShell;
class nsPresContext;
namespace mozilla {
@ -332,6 +333,7 @@ public:
nsIDocument* GetRenderedDocument() const;
nsPresContext* GetPresContext() const;
nsIPresShell* GetPresShell() const;
// Associates a warning with the animated property on the specified frame
// indicating why, for example, the property could not be animated on the