Bug 1463605 - Call MarkNeedsDisplayItemRebuild() for IB split siblings too. r?mattwoodrow draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 23 May 2018 18:15:12 +0900
changeset 798672 e1a3cb72c379c24b25ae5aacaa4ae97af6ea76a4
parent 798671 30afd4222e9be5138ed5ebb73f1158313ff760cf
child 798673 b2f1641c766de7fb167c8523b9b439e762376a50
push id110818
push userbmo:hikezoe@mozilla.com
push dateWed, 23 May 2018 09:17:42 +0000
reviewersmattwoodrow
bugs1463605
milestone62.0a1
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