Bug 1209405 - Part 2: High CPU load on Kickstarter, even without JS, CSS and images. r=birtles
MozReview-Commit-ID: 91q0F9u2T4t
--- a/dom/smil/nsSMILCompositor.cpp
+++ b/dom/smil/nsSMILCompositor.cpp
@@ -135,34 +135,44 @@ nsSMILCompositor::CreateSMILAttr()
mKey.mAttributeName);
}
return nullptr;
}
uint32_t
nsSMILCompositor::GetFirstFuncToAffectSandwich()
{
+ // canThrottle is true when attributeName is not 'display' and
+ // the element or subtree is display:none
+ RefPtr<nsStyleContext> styleContext =
+ nsComputedDOMStyle::GetStyleContextForElementNoFlush(mKey.mElement,
+ nullptr, nullptr);
+ bool canThrottle = mKey.mAttributeName != nsGkAtoms::display &&
+ styleContext &&
+ styleContext->IsInDisplayNoneSubtree();
+
uint32_t i;
for (i = mAnimationFunctions.Length(); i > 0; --i) {
nsSMILAnimationFunction* curAnimFunc = mAnimationFunctions[i-1];
// In the following, the lack of short-circuit behavior of |= means that we
// will ALWAYS run UpdateCachedTarget (even if mForceCompositing is true)
// but only call HasChanged and WasSkippedInPrevSample if necessary. This
// is important since we need UpdateCachedTarget to run in order to detect
// changes to the target in subsequent samples.
mForceCompositing |=
curAnimFunc->UpdateCachedTarget(mKey) ||
- curAnimFunc->HasChanged() ||
+ (curAnimFunc->HasChanged() && !canThrottle) ||
curAnimFunc->WasSkippedInPrevSample();
if (curAnimFunc->WillReplace()) {
--i;
break;
}
}
+
// Mark remaining animation functions as having been skipped so if we later
// use them we'll know to force compositing.
// Note that we only really need to do this if something has changed
// (otherwise we would have set the flag on a previous sample) and if
// something has changed mForceCompositing will be true.
if (mForceCompositing) {
for (uint32_t j = i; j > 0; --j) {
mAnimationFunctions[j-1]->SetWasSkipped();