Bug 1463605 - Call MarkNeedsDisplayItemRebuild() for IB split siblings too. r=mattwoodrow
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 23 May 2018 18:15:12 +0900
changeset 419647 abf79f352837374a27211f78c1b934bb898ee9c9
parent 419646 9dacb05350d80c4e5591de4d7f10c766b969103e
child 419648 fb535bef1dd0b9bbf704354a364293d051d5e9d6
push id64375
push userhikezoe@mozilla.com
push dateThu, 24 May 2018 04:45:24 +0000
treeherderautoland@c411ccb6bb4a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1463605
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1463605 - Call MarkNeedsDisplayItemRebuild() for IB split siblings too. r=mattwoodrow MozReview-Commit-ID: 4vN69YLUbIy
dom/animation/KeyframeEffect.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -746,16 +746,27 @@ KeyframeEffect::BuildProperties(const Co
              "Apart from the computed offset members, the keyframes array"
              " should not be modified");
 #endif
 
   mKeyframes.SwapElements(keyframesCopy);
   return result;
 }
 
+template<typename FrameEnumFunc>
+static void
+EnumerateContinuationsOrIBSplitSiblings(nsIFrame* aFrame,
+                                        FrameEnumFunc&& aFunc)
+{
+  while (aFrame) {
+    aFunc(aFrame);
+    aFrame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(aFrame);
+  }
+}
+
 void
 KeyframeEffect::UpdateTargetRegistration()
 {
   if (!mTarget) {
     return;
   }
 
   bool isRelevant = mAnimation && mAnimation->IsRelevant();
@@ -768,21 +779,22 @@ KeyframeEffect::UpdateTargetRegistration
              "Out of date Animation::IsRelevant value");
 
   if (isRelevant && !mInEffectSet) {
     EffectSet* effectSet =
       EffectSet::GetOrCreateEffectSet(mTarget->mElement, mTarget->mPseudoType);
     effectSet->AddEffect(*this);
     mInEffectSet = true;
     UpdateEffectSet(effectSet);
-    nsIFrame* f = GetPrimaryFrame();
-    while (f) {
-      f->MarkNeedsDisplayItemRebuild();
-      f = f->GetNextContinuation();
-    }
+    nsIFrame* frame = GetPrimaryFrame();
+    EnumerateContinuationsOrIBSplitSiblings(frame,
+      [](nsIFrame* aFrame) {
+        aFrame->MarkNeedsDisplayItemRebuild();
+      }
+    );
   } else if (!isRelevant && mInEffectSet) {
     UnregisterTarget();
   }
 }
 
 void
 KeyframeEffect::UnregisterTarget()
 {
@@ -797,21 +809,22 @@ KeyframeEffect::UnregisterTarget()
   mInEffectSet = false;
   if (effectSet) {
     effectSet->RemoveEffect(*this);
 
     if (effectSet->IsEmpty()) {
       EffectSet::DestroyEffectSet(mTarget->mElement, mTarget->mPseudoType);
     }
   }
-  nsIFrame* f = GetPrimaryFrame();
-  while (f) {
-    f->MarkNeedsDisplayItemRebuild();
-    f = f->GetNextContinuation();
-  }
+  nsIFrame* frame = GetPrimaryFrame();
+  EnumerateContinuationsOrIBSplitSiblings(frame,
+    [](nsIFrame* aFrame) {
+      aFrame->MarkNeedsDisplayItemRebuild();
+    }
+  );
 }
 
 void
 KeyframeEffect::RequestRestyle(EffectCompositor::RestyleType aRestyleType)
 {
    if (!mTarget) {
     return;
   }
@@ -1780,24 +1793,26 @@ KeyframeEffect::UpdateEffectSet(EffectSe
                                          mTarget->mPseudoType);
   if (!effectSet) {
     return;
   }
 
   nsIFrame* frame = GetStyleFrame();
   if (HasAnimationOfProperty(eCSSProperty_opacity)) {
     effectSet->SetMayHaveOpacityAnimation();
-    while (frame) {
-      frame->SetMayHaveOpacityAnimation();
-      frame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(frame);
-    }
+    EnumerateContinuationsOrIBSplitSiblings(frame,
+      [](nsIFrame* aFrame) {
+        aFrame->SetMayHaveOpacityAnimation();
+      }
+    );
   }
   if (HasAnimationOfProperty(eCSSProperty_transform)) {
     effectSet->SetMayHaveTransformAnimation();
-    while (frame) {
-      frame->SetMayHaveTransformAnimation();
-      frame = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(frame);
-    }
+    EnumerateContinuationsOrIBSplitSiblings(frame,
+      [](nsIFrame* aFrame) {
+        aFrame->SetMayHaveTransformAnimation();
+      }
+    );
   }
 }
 
 } // namespace dom
 } // namespace mozilla