Bug 1302888 - Replace GetPresContext() with nsContentUtils::GetContextForContent() to obtain nsPresContext* in dom/animation draft
authorBharatR123 <bharatraghunthan9767@gmail.com>
Mon, 13 Mar 2017 20:39:49 +0530
changeset 497949 d67563a086342e1ce68ff62f0503a73773e1074c
parent 497206 f9362554866b327700c7f9b18050d7b7eb3d2b23
child 549046 7515808a6702f8ab3e9a51a3744b76d6d6090976
push id49070
push userbmo:bharatraghunthan9767@gmail.com
push dateTue, 14 Mar 2017 03:32:55 +0000
bugs1302888
milestone55.0a1
Bug 1302888 - Replace GetPresContext() with nsContentUtils::GetContextForContent() to obtain nsPresContext* in dom/animation Edited all function calls in KeyFrameEffectReadOnly.cpp and one function call in EffectCompositor.cpp MozReview-Commit-ID: BzSHLZna4xX
dom/animation/EffectCompositor.cpp
dom/animation/KeyframeEffectReadOnly.cpp
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -15,16 +15,17 @@
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/LayerAnimationInfo.h"
 #include "mozilla/RestyleManager.h"
 #include "mozilla/RestyleManagerInlines.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "nsComputedDOMStyle.h" // nsComputedDOMStyle::GetPresShellForContent
+#include "nsContentUtils.h"
 #include "nsCSSPseudoElements.h"
 #include "nsCSSPropertyIDSet.h"
 #include "nsCSSProps.h"
 #include "nsIAtom.h"
 #include "nsIPresShell.h"
 #include "nsIPresShellInlines.h"
 #include "nsLayoutUtils.h"
 #include "nsRuleNode.h" // For nsRuleNode::ComputePropertiesOverridingAnimation
@@ -891,17 +892,17 @@ EffectCompositor::UpdateCascadeResults(E
           cascadeLevel == EffectCompositor::CascadeLevel::Transitions) {
         hasCompositorPropertiesForTransition = true;
       }
     }
   }
 
   aEffectSet.MarkCascadeUpdated();
 
-  nsPresContext* presContext = GetPresContext(aElement);
+  nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
   if (!presContext) {
     return;
   }
 
   // If properties for compositor are newly overridden by !important rules, or
   // released from being overridden by !important rules, we need to update
   // layers for animations level because it's a trigger to send animations to
   // the compositor or pull animations back from the compositor.
@@ -920,27 +921,16 @@ EffectCompositor::UpdateCascadeResults(E
         compositorPropertiesInSet(propertiesForAnimationsLevel)) {
     presContext->EffectCompositor()->
       RequestRestyle(aElement, aPseudoType,
                      EffectCompositor::RestyleType::Layer,
                      EffectCompositor::CascadeLevel::Transitions);
   }
 }
 
-/* static */ nsPresContext*
-EffectCompositor::GetPresContext(Element* aElement)
-{
-  MOZ_ASSERT(aElement);
-  nsIPresShell* shell = nsComputedDOMStyle::GetPresShellForContent(aElement);
-  if (!shell) {
-    return nullptr;
-  }
-  return shell->GetPresContext();
-}
-
 /* static */ void
 EffectCompositor::SetPerformanceWarning(
   const nsIFrame *aFrame,
   nsCSSPropertyID aProperty,
   const AnimationPerformanceWarning& aWarning)
 {
   EffectSet* effects = EffectSet::GetEffectSet(aFrame);
   if (!effects) {
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -990,18 +990,21 @@ KeyframeEffectReadOnly::UnregisterTarget
     }
   }
 }
 
 void
 KeyframeEffectReadOnly::RequestRestyle(
   EffectCompositor::RestyleType aRestyleType)
 {
-  nsPresContext* presContext = GetPresContext();
-  if (presContext && mTarget && mAnimation) {
+   if (!mTarget) {
+    return;
+  }
+  nsPresContext* presContext = nsContentUtils::GetContextForContent(mTarget->mElement);
+  if (presContext && mAnimation) {
     presContext->EffectCompositor()->
       RequestRestyle(mTarget->mElement, mTarget->mPseudoType,
                      aRestyleType, mAnimation->CascadeLevel());
   }
 }
 
 already_AddRefed<nsStyleContext>
 KeyframeEffectReadOnly::GetTargetStyleContext()