Bug 1303229: Get the proper viewport size for animations. r?hiro,heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 11 Mar 2017 02:40:47 +0100
changeset 497108 770f35da922d4e2077fa7a0efc17fd9c941f4c84
parent 497107 7f621b6d1ca7ae5defe9beb1849099330049d03c
child 548794 c8c11814ae7f22aa2a19216f607766faac6821ea
push id48793
push userbmo:emilio+bugs@crisal.io
push dateSat, 11 Mar 2017 13:30:38 +0000
reviewershiro, heycam
bugs1303229
milestone55.0a1
Bug 1303229: Get the proper viewport size for animations. r?hiro,heycam While we're here, don't re-recompute the default computed values, just grab them from the device. MozReview-Commit-ID: GqqnPLIwN2F Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
dom/animation/KeyframeUtils.cpp
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/dom/animation/KeyframeUtils.cpp
+++ b/dom/animation/KeyframeUtils.cpp
@@ -593,32 +593,23 @@ KeyframeUtils::ApplyDistributeSpacing(ns
 
 /* static */ nsTArray<ComputedKeyframeValues>
 KeyframeUtils::GetComputedKeyframeValues(
   const nsTArray<Keyframe>& aKeyframes,
   dom::Element* aElement,
   const ServoComputedStyleValues& aServoValues)
 {
   MOZ_ASSERT(aElement);
-  MOZ_ASSERT(aElement->OwnerDoc()->IsStyledByServo());
+  MOZ_ASSERT(aElement->IsStyledByServo());
 
   nsPresContext* presContext = nsContentUtils::GetContextForContent(aElement);
   MOZ_ASSERT(presContext);
 
-  nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
-
-  // Construct each nsTArray<PropertyStyleAnimationValuePair> here.
-  result.AppendElements(aKeyframes.Length());
-
-  Servo_GetComputedKeyframeValues(&aKeyframes,
-                                  aServoValues.mCurrentStyle,
-                                  aServoValues.mParentStyle,
-                                  presContext,
-                                  &result);
-  return result;
+  return presContext->StyleSet()->AsServo()
+    ->GetComputedKeyframeValuesFor(aKeyframes, aElement, aServoValues);
 }
 
 /* static */ nsTArray<ComputedKeyframeValues>
 KeyframeUtils::GetComputedKeyframeValues(const nsTArray<Keyframe>& aKeyframes,
                                          dom::Element* aElement,
                                          nsStyleContext* aStyleContext)
 {
   MOZ_ASSERT(aStyleContext);
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -103,17 +103,17 @@ SERVO_BINDING_FUNC(Servo_ParseProperty,
                    RawServoDeclarationBlockStrong,
                    const nsACString* property, const nsACString* value,
                    const nsACString* base,
                    const GeckoParserExtraData* data)
 SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
                    RawGeckoKeyframeListBorrowed keyframes,
                    ServoComputedValuesBorrowed style,
                    ServoComputedValuesBorrowedOrNull parent_style,
-                   RawGeckoPresContextBorrowed pres_context,
+                   RawServoStyleSetBorrowed set,
                    RawGeckoComputedKeyframeValuesListBorrowedMut result)
 
 // AnimationValues handling
 SERVO_BINDING_FUNC(Servo_AnimationValues_Interpolate,
                    RawServoAnimationValueStrong,
                    RawServoAnimationValueBorrowed from,
                    RawServoAnimationValueBorrowed to,
                    double progress)
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -6,16 +6,17 @@
 
 #include "mozilla/ServoStyleSet.h"
 
 #include "mozilla/DocumentStyleRootIterator.h"
 #include "mozilla/ServoRestyleManager.h"
 #include "mozilla/dom/ChildIterator.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
+#include "mozilla/dom/KeyframeEffectReadOnly.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsCSSPseudoElements.h"
 #include "nsHTMLStyleSheet.h"
 #include "nsIDocumentInlines.h"
 #include "nsPrintfCString.h"
 #include "nsStyleContext.h"
 #include "nsStyleSet.h"
 
@@ -705,16 +706,34 @@ ServoStyleSet::FillKeyframesForName(cons
   NS_ConvertUTF16toUTF8 name(aName);
   return Servo_StyleSet_FillKeyframesForName(mRawSet.get(),
                                              &name,
                                              &aTimingFunction,
                                              aComputedValues,
                                              &aKeyframes);
 }
 
+nsTArray<ComputedKeyframeValues>
+ServoStyleSet::GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
+                                            dom::Element* aElement,
+                                            const ServoComputedStyleValues& aServoValues)
+{
+  nsTArray<ComputedKeyframeValues> result(aKeyframes.Length());
+
+  // Construct each nsTArray<PropertyStyleAnimationValuePair> here.
+  result.AppendElements(aKeyframes.Length());
+
+  Servo_GetComputedKeyframeValues(&aKeyframes,
+                                  aServoValues.mCurrentStyle,
+                                  aServoValues.mParentStyle,
+                                  mRawSet.get(),
+                                  &result);
+  return result;
+}
+
 void
 ServoStyleSet::RebuildData()
 {
   ClearNonInheritingStyleContexts();
   Servo_StyleSet_RebuildData(mRawSet.get());
 }
 
 already_AddRefed<ServoComputedValues>
@@ -723,17 +742,17 @@ ServoStyleSet::ResolveServoStyle(Element
   return Servo_ResolveStyle(aElement, mRawSet.get()).Consume();
 }
 
 void
 ServoStyleSet::ClearNonInheritingStyleContexts()
 {
   for (RefPtr<nsStyleContext>& ptr : mNonInheritingStyleContexts) {
     ptr = nullptr;
-  }  
+  }
 }
 
 already_AddRefed<ServoComputedValues>
 ServoStyleSet::ResolveStyleLazily(Element* aElement, nsIAtom* aPseudoTag)
 {
   mPresContext->EffectCompositor()->PreTraverse(aElement, aPseudoTag);
 
   MOZ_ASSERT(!sInServoTraversal);
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -23,16 +23,17 @@
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 class CSSStyleSheet;
 class ServoRestyleManager;
 class ServoStyleSheet;
 struct Keyframe;
+struct ServoComputedStyleValues;
 } // namespace mozilla
 class nsIDocument;
 class nsStyleContext;
 class nsPresContext;
 struct nsTimingFunction;
 struct TreeMatchContext;
 
 namespace mozilla {
@@ -236,16 +237,21 @@ public:
    */
   already_AddRefed<ServoComputedValues> ResolveServoStyle(dom::Element* aElement);
 
   bool FillKeyframesForName(const nsString& aName,
                             const nsTimingFunction& aTimingFunction,
                             const ServoComputedValues* aComputedValues,
                             nsTArray<Keyframe>& aKeyframes);
 
+  nsTArray<ComputedKeyframeValues>
+  GetComputedKeyframeValuesFor(const nsTArray<Keyframe>& aKeyframes,
+                               dom::Element* aElement,
+                               const ServoComputedStyleValues& aServoValues);
+
 private:
   already_AddRefed<nsStyleContext> GetContext(already_AddRefed<ServoComputedValues>,
                                               nsStyleContext* aParentContext,
                                               nsIAtom* aPseudoTag,
                                               CSSPseudoElementType aPseudoType,
                                               dom::Element* aElementForAnimation);
 
   already_AddRefed<nsStyleContext> GetContext(nsIContent* aContent,