Bug 1196114 - Part 1: Add SetPerformanceWarning. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Fri, 12 Feb 2016 10:46:01 +0900
changeset 330605 99279e691ab49797426762ee405a5cae8395676c
parent 330604 f0a26e267ebf3a403e30c4bbcc0cc6a64d275b1c
child 330606 2b21e2fcd7100cb69753225a924bd2eeac85373e
push id10780
push userhiikezoe@mozilla-japan.org
push dateFri, 12 Feb 2016 01:46:53 +0000
reviewersbirtles
bugs1196114
milestone47.0a1
Bug 1196114 - Part 1: Add SetPerformanceWarning. r?birtles MozReview-Commit-ID: DittatwWlng
dom/animation/EffectCompositor.cpp
dom/animation/EffectCompositor.h
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -707,16 +707,31 @@ EffectCompositor::GetPresContext(Element
   MOZ_ASSERT(aElement);
   nsIPresShell* shell = nsComputedDOMStyle::GetPresShellForContent(aElement);
   if (!shell) {
     return nullptr;
   }
   return shell->GetPresContext();
 }
 
+/* static */ void
+EffectCompositor::SetPerformanceWarning(const nsIFrame *aFrame,
+                                        nsCSSProperty aProperty,
+                                        nsAString& aMessage)
+{
+  EffectSet* effects = EffectSet::GetEffectSet(aFrame);
+  if (!effects) {
+    return;
+  }
+
+  for (KeyframeEffectReadOnly* effect : *effects) {
+    effect->SetPerformanceWarning(aProperty, aMessage);
+  }
+}
+
 // ---------------------------------------------------------
 //
 // Nested class: AnimationStyleRuleProcessor
 //
 // ---------------------------------------------------------
 
 NS_IMPL_ISUPPORTS(EffectCompositor::AnimationStyleRuleProcessor,
                   nsIStyleRuleProcessor)
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -182,16 +182,19 @@ public:
   // AnimationCollection), *not* the generated content.
   //
   // Returns an empty result when a suitable element cannot be found including
   // when the frame represents a pseudo-element on which we do not support
   // animations.
   static Maybe<Pair<dom::Element*, nsCSSPseudoElements::Type>>
   GetAnimationElementAndPseudoForFrame(const nsIFrame* aFrame);
 
+  static void SetPerformanceWarning(const nsIFrame* aFrame,
+                                    nsCSSProperty aProperty,
+                                    nsAString& aMessage);
 private:
   ~EffectCompositor() = default;
 
   // Rebuilds the animation rule corresponding to |aCascadeLevel| on the
   // EffectSet associated with the specified (pseudo-)element.
   static void ComposeAnimationRule(dom::Element* aElement,
                                    nsCSSPseudoElements::Type aPseudoType,
                                    CascadeLevel aCascadeLevel,
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -572,16 +572,19 @@ KeyframeEffectReadOnly::SetIsRunningOnCo
 {
   MOZ_ASSERT(nsCSSProps::PropHasFlags(aProperty,
                                       CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR),
              "Property being animated on compositor is a recognized "
              "compositor-animatable property");
   for (AnimationProperty& property : mProperties) {
     if (property.mProperty == aProperty) {
       property.mIsRunningOnCompositor = aIsRunning;
+      if (aIsRunning) {
+        property.mWarningMessage.Truncate();
+      }
       return;
     }
   }
 }
 
 KeyframeEffectReadOnly::~KeyframeEffectReadOnly()
 {
 }
@@ -2077,10 +2080,21 @@ KeyframeEffectReadOnly::ShouldBlockCompo
         return true;
       }
     }
   }
 
   return false;
 }
 
+void
+KeyframeEffectReadOnly::SetPerformanceWarning(nsCSSProperty aProperty,
+                                              nsAString &aMessage)
+{
+  for (AnimationProperty& property : mProperties) {
+    if (property.mProperty == aProperty) {
+      property.mWarningMessage = aMessage;
+      return;
+    }
+  }
+}
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -136,16 +136,18 @@ struct AnimationProperty
   // between calling RequestRestyle on its AnimationCollection and when the
   // restyle is performed, this member may temporarily become false even if
   // the animation remains on the layer after the restyle.
   //
   // **NOTE**: This member is not included when comparing AnimationProperty
   // objects for equality.
   bool mIsRunningOnCompositor = false;
 
+  nsString mWarningMessage;
+
   InfallibleTArray<AnimationPropertySegment> mSegments;
 
   // NOTE: This operator does *not* compare the mWinsInCascade member *or* the
   // mIsRunningOnCompositor member.
   // This is because AnimationProperty objects are compared when recreating
   // CSS animations to determine if mutation observer change records need to
   // be created or not. However, at the point when these objects are compared
   // neither the mWinsInCascade nor the mIsRunningOnCompositor will have been
@@ -322,16 +324,19 @@ public:
   // it be ok to do 'opacity' animations on the compositor in either case?
   bool ShouldBlockCompositorAnimations(const nsIFrame* aFrame) const;
 
   nsIDocument* GetRenderedDocument() const;
   nsPresContext* GetPresContext() const;
 
   inline AnimationCollection* GetCollection() const;
 
+  void SetPerformanceWarning(nsCSSProperty aProperty,
+                             nsAString& aMessage);
+
 protected:
   virtual ~KeyframeEffectReadOnly();
   void ResetIsRunningOnCompositor();
 
   // This effect is registered with its target element so long as:
   //
   // (a) It has a target element, and
   // (b) It is "relevant" (i.e. yet to finish but not idle, or finished but