Bug 1255276 part 1: Refactor existing SVGTransformableElement::GetAttributeChangeHint logic to use an "isAdditionOrRemoval" bool. r=longsonr
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 14 Mar 2016 17:37:32 -0700
changeset 288669 0b31695a67bfc56ef22390f531ee3d381cc42c57
parent 288668 3c4a045fe05f3e69e9454ab87199673da0b16dd9
child 288670 9483041fedeeb95464e6713a9b98ef947bf7d268
push id18174
push usercbook@mozilla.com
push dateTue, 15 Mar 2016 09:44:58 +0000
treeherderfx-team@dd0baa33759d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1255276
milestone48.0a1
Bug 1255276 part 1: Refactor existing SVGTransformableElement::GetAttributeChangeHint logic to use an "isAdditionOrRemoval" bool. r=longsonr
dom/svg/SVGTransformableElement.cpp
--- a/dom/svg/SVGTransformableElement.cpp
+++ b/dom/svg/SVGTransformableElement.cpp
@@ -58,25 +58,35 @@ SVGTransformableElement::GetAttributeCha
   if (aAttribute == nsGkAtoms::transform ||
       aAttribute == nsGkAtoms::mozAnimateMotionDummyAttr) {
     nsIFrame* frame =
       const_cast<SVGTransformableElement*>(this)->GetPrimaryFrame();
     NS_UpdateHint(retval, nsChangeHint_InvalidateRenderingObservers);
     if (!frame || (frame->GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
       return retval;
     }
+
+    bool isAdditionOrRemoval = false;
     if (aModType == nsIDOMMutationEvent::ADDITION ||
-        aModType == nsIDOMMutationEvent::REMOVAL ||
-        (aModType == nsIDOMMutationEvent::MODIFICATION &&
-         !(mTransforms && mTransforms->HasTransform()))) {
+        aModType == nsIDOMMutationEvent::REMOVAL) {
+      isAdditionOrRemoval = true;
+    } else {
+      MOZ_ASSERT(aModType == nsIDOMMutationEvent::MODIFICATION,
+                 "Unknown modification type.");
+      if (!mTransforms ||
+          !mTransforms->HasTransform()) {
+        // New value is empty -- this is effectively an attribute-removal.
+        isAdditionOrRemoval = true;
+      }
+    }
+
+    if (isAdditionOrRemoval) {
       // Reconstruct the frame tree to handle stacking context changes:
       NS_UpdateHint(retval, nsChangeHint_ReconstructFrame);
     } else {
-      MOZ_ASSERT(aModType == nsIDOMMutationEvent::MODIFICATION,
-                 "Unknown modification type.");
       // We just assume the old and new transforms are different.
       NS_UpdateHint(retval, NS_CombineHint(nsChangeHint_UpdatePostTransformOverflow,
                                            nsChangeHint_UpdateTransformLayer));
     }
   }
   return retval;
 }