Bug 1340322 - Part 12: Add another variant of nsAnimationManager::UpdateAnimations for stylo. r=birtles
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 06 Mar 2017 09:54:06 +0900
changeset 375008 33d72dd744907cd6598a6d41058e1a6783eb36ab
parent 375007 6f6d0b68ef23d3647f5fa9ad053750f47625b090
child 375009 5233a7d951daa594edc37f5b5d3a7f4119822922
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1340322, 1341985
milestone54.0a1
Bug 1340322 - Part 12: Add another variant of nsAnimationManager::UpdateAnimations for stylo. r=birtles This function updates CSS Animations with servo's computed values. In bug 1341985, this function will be called with null servo's computed values in the case where the target element is in display:none subtree. MozReview-Commit-ID: GzOYy57hYho
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -1122,16 +1122,42 @@ nsAnimationManager::UpdateAnimations(nsS
 
   NonOwningAnimationTarget target(aElement, aStyleContext->GetPseudoType());
   GeckoCSSAnimationBuilder builder(aStyleContext, target);
 
   const nsStyleDisplay* disp = aStyleContext->StyleDisplay();
   DoUpdateAnimations(target, *disp, builder);
 }
 
+void
+nsAnimationManager::UpdateAnimations(
+  dom::Element* aElement,
+  nsIAtom* aPseudoTagOrNull,
+  const ServoComputedValues* aComputedValues,
+  const ServoComputedValues* aParentComputedValues)
+{
+  MOZ_ASSERT(mPresContext->IsDynamic(),
+             "Should not update animations for print or print preview");
+  MOZ_ASSERT(aElement->IsInComposedDoc(),
+             "Should not update animations that are not attached to the "
+             "document tree");
+
+  CSSPseudoElementType pseudoType =
+    nsCSSPseudoElements::GetPseudoType(aPseudoTagOrNull,
+                                       CSSEnabledState::eForAllContent);
+  NonOwningAnimationTarget target(aElement, pseudoType);
+  ServoCSSAnimationBuilder builder(aComputedValues, aParentComputedValues);
+
+  // Currently we don't seem to call this UpdateAnimations for elements in
+  // display:none subtree. We will call this function for such elements with
+  // null computed values in bug 1341985.
+  const nsStyleDisplay *disp = Servo_GetStyleDisplay(aComputedValues);
+  DoUpdateAnimations(target, *disp, builder);
+}
+
 template<class BuilderType>
 void
 nsAnimationManager::DoUpdateAnimations(
   const NonOwningAnimationTarget& aTarget,
   const nsStyleDisplay& aStyleDisplay,
   BuilderType& aBuilder)
 {
   // Everything that causes our animation data to change triggers a
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -11,16 +11,17 @@
 #include "AnimationCommon.h"
 #include "mozilla/dom/Animation.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 
 class nsIGlobalObject;
 class nsStyleContext;
 struct nsStyleDisplay;
+struct ServoComputedValues;
 
 namespace mozilla {
 namespace css {
 class Declaration;
 } /* namespace css */
 namespace dom {
 class KeyframeEffectReadOnly;
 class Promise;
@@ -318,16 +319,26 @@ public:
    *
    * aStyleContext may be a style context for aElement or for its
    * :before or :after pseudo-element.
    */
   void UpdateAnimations(nsStyleContext* aStyleContext,
                         mozilla::dom::Element* aElement);
 
   /**
+   * This function does the same thing as the above UpdateAnimations()
+   * but with servo's computed values.
+   */
+  void UpdateAnimations(
+    mozilla::dom::Element* aElement,
+    nsIAtom* aPseudoTagOrNull,
+    const ServoComputedValues* aComputedValues,
+    const ServoComputedValues* aParentComputedValus);
+
+  /**
    * Add a pending event.
    */
   void QueueEvent(mozilla::AnimationEventInfo&& aEventInfo)
   {
     mEventDispatcher.QueueEvent(
       mozilla::Forward<mozilla::AnimationEventInfo>(aEventInfo));
   }