Bug 1302637 - Animation::PostUpdate() calls KeyframeEffectReadonly::RequestRestyle() draft
authorBharatR123 <bharatraghunthan9767@gmail.com>
Tue, 14 Mar 2017 22:03:22 +0530
changeset 499738 34e6303663e7acc66bb34e01d1e473ae0ce58321
parent 498360 2baef2ffbaedb7354286726660ebd36e84b432f0
child 549440 280b2aee75e09c69bbe0f51631cb718e23ee2711
push id49504
push userbmo:bharatraghunthan9767@gmail.com
push dateThu, 16 Mar 2017 05:41:04 +0000
bugs1302637
milestone55.0a1
Bug 1302637 - Animation::PostUpdate() calls KeyframeEffectReadonly::RequestRestyle() Also removed the function GetPresContext() in KeyframeEffectReadOnly.cpp and KeyframeEffectReadOnly.h MozReview-Commit-ID: AJCgxQ05yVQ
dom/animation/Animation.cpp
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/KeyframeEffectReadOnly.h
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -1313,32 +1313,17 @@ Animation::PostUpdate()
   if (!mEffect) {
     return;
   }
 
   KeyframeEffectReadOnly* keyframeEffect = mEffect->AsKeyframeEffect();
   if (!keyframeEffect) {
     return;
   }
-
-  Maybe<NonOwningAnimationTarget> target = keyframeEffect->GetTarget();
-  if (!target) {
-    return;
-  }
-
-  nsPresContext* presContext = keyframeEffect->GetPresContext();
-  if (!presContext) {
-    return;
-  }
-
-  presContext->EffectCompositor()
-             ->RequestRestyle(target->mElement,
-                              target->mPseudoType,
-                              EffectCompositor::RestyleType::Layer,
-                              CascadeLevel());
+  keyframeEffect->RequestRestyle(EffectCompositor::RestyleType::Layer);
 }
 
 void
 Animation::CancelPendingTasks()
 {
   if (mPendingState == PendingState::NotPending) {
     return;
   }
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -1447,26 +1447,16 @@ KeyframeEffectReadOnly::GetPresShell() c
 {
   nsIDocument* doc = GetRenderedDocument();
   if (!doc) {
     return nullptr;
   }
   return doc->GetShell();
 }
 
-nsPresContext*
-KeyframeEffectReadOnly::GetPresContext() const
-{
-  nsIPresShell* shell = GetPresShell();
-  if (!shell) {
-    return nullptr;
-  }
-  return shell->GetPresContext();
-}
-
 /* static */ bool
 KeyframeEffectReadOnly::IsGeometricProperty(
   const nsCSSPropertyID aProperty)
 {
   MOZ_ASSERT(!nsCSSProps::IsShorthand(aProperty),
              "Property should be a longhand property");
 
   switch (aProperty) {
--- a/dom/animation/KeyframeEffectReadOnly.h
+++ b/dom/animation/KeyframeEffectReadOnly.h
@@ -29,17 +29,16 @@
 #include "mozilla/dom/Element.h"
 
 struct JSContext;
 class JSObject;
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
 class nsIPresShell;
-class nsPresContext;
 
 namespace mozilla {
 
 class AnimValuesStyleRule;
 enum class CSSPseudoElementType : uint8_t;
 class ErrorResult;
 struct AnimationRule;
 struct TimingParams;
@@ -206,21 +205,19 @@ public:
                      ErrorResult& aRv) const;
 
   IterationCompositeOperation IterationComposite() const;
   CompositeOperation Composite() const;
   void GetSpacing(nsString& aRetVal) const
   {
     mEffectOptions.GetSpacingAsString(aRetVal);
   }
-
   void NotifyAnimationTimingUpdated();
-
+  void RequestRestyle(EffectCompositor::RestyleType aRestyleType);
   void SetAnimation(Animation* aAnimation) override;
-
   void SetKeyframes(JSContext* aContext, JS::Handle<JSObject*> aKeyframes,
                     ErrorResult& aRv);
   void SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
                     nsStyleContext* aStyleContext);
   void SetKeyframes(nsTArray<Keyframe>&& aKeyframes,
                     const ServoComputedStyleValues& aServoValues);
 
   // Returns true if the effect includes |aProperty| regardless of whether the
@@ -292,17 +289,16 @@ public:
     AnimationPerformanceWarning::Type& aPerformanceWarning) const;
   bool HasGeometricProperties() const;
   bool AffectsGeometry() const override
   {
     return GetTarget() && HasGeometricProperties();
   }
 
   nsIDocument* GetRenderedDocument() const;
-  nsPresContext* GetPresContext() const;
   nsIPresShell* GetPresShell() const;
 
   // Associates a warning with the animated property on the specified frame
   // indicating why, for example, the property could not be animated on the
   // compositor. |aParams| and |aParamsLength| are optional parameters which
   // will be used to generate a localized message for devtools.
   void SetPerformanceWarning(
     nsCSSPropertyID aProperty,
@@ -374,18 +370,16 @@ protected:
   // As a result, we need to make sure this gets called whenever anything
   // changes with regards to this effects's timing including changes to the
   // owning Animation's timing.
   void UpdateTargetRegistration();
 
   // Remove the current effect target from its EffectSet.
   void UnregisterTarget();
 
-  void RequestRestyle(EffectCompositor::RestyleType aRestyleType);
-
   // Update the associated frame state bits so that, if necessary, a stacking
   // context will be created and the effect sent to the compositor.  We
   // typically need to do this when the properties referenced by the keyframe
   // have changed, or when the target frame might have changed.
   void MaybeUpdateFrameForCompositor();
 
   // Looks up the style context associated with the target element, if any.
   // We need to be careful to *not* call this when we are updating the style