Bug 1343153 - Part 2: Use Servo css-parser for ParseEasing. r=birtles,emilio
☠☠ backed out by 09112a8f735c ☠ ☠
authorBoris Chiou <boris.chiou@gmail.com>
Tue, 21 Mar 2017 14:27:46 +0800
changeset 348601 9de875f312386db0aed5e9b24d40471398c91971
parent 348600 c5da825e8bd938750a32c2fd67f3c5594c51d9ce
child 348602 b2c7ea6392fc0581ae8998080ce39440b5e21c5d
push id31532
push userkwierso@gmail.com
push dateTue, 21 Mar 2017 22:32:51 +0000
treeherdermozilla-central@18bb0299dd9b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles, emilio
bugs1343153
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1343153 - Part 2: Use Servo css-parser for ParseEasing. r=birtles,emilio We use Servo css-parser to parse keyframe property-value pairs, so we should also use it to parse easing for Web Animations. MozReview-Commit-ID: FsfHQaNT2xO
dom/animation/TimingParams.cpp
layout/style/ServoBindingList.h
layout/style/ServoBindingTypes.h
--- a/dom/animation/TimingParams.cpp
+++ b/dom/animation/TimingParams.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/TimingParams.h"
 
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/dom/AnimatableBinding.h"
 #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
+#include "mozilla/ServoBindings.h"
 #include "nsCSSParser.h" // For nsCSSParser
 #include "nsIDocument.h"
 #include "nsRuleNode.h"
 
 namespace mozilla {
 
 template <class OptionsType>
 static const dom::AnimationEffectTimingProperties&
@@ -108,16 +109,36 @@ TimingParams::FromOptionsUnion(
 
 /* static */ Maybe<ComputedTimingFunction>
 TimingParams::ParseEasing(const nsAString& aEasing,
                           nsIDocument* aDocument,
                           ErrorResult& aRv)
 {
   MOZ_ASSERT(aDocument);
 
+  if (aDocument->IsStyledByServo()) {
+    nsTimingFunction timingFunction;
+    nsCString baseString;
+    // FIXME this is using the wrong base uri (bug 1343919)
+    GeckoParserExtraData data(aDocument->GetDocumentURI(),
+                              aDocument->GetDocumentURI(),
+                              aDocument->NodePrincipal());
+    aDocument->GetDocumentURI()->GetSpec(baseString);
+    if (!Servo_ParseEasing(&aEasing, &baseString, &data, &timingFunction)) {
+      aRv.ThrowTypeError<dom::MSG_INVALID_EASING_ERROR>(aEasing);
+      return Nothing();
+    }
+
+    if (timingFunction.mType == nsTimingFunction::Type::Linear) {
+      return Nothing();
+    }
+
+    return Some(ComputedTimingFunction(timingFunction));
+  }
+
   nsCSSValue value;
   nsCSSParser parser;
   parser.ParseLonghandProperty(eCSSProperty_animation_timing_function,
                                aEasing,
                                aDocument->GetDocumentURI(),
                                aDocument->GetDocumentURI(),
                                aDocument->NodePrincipal(),
                                value);
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -113,16 +113,21 @@ SERVO_BINDING_FUNC(Servo_NamespaceRule_G
                    RawServoNamespaceRuleBorrowed rule)
 
 // Animations API
 SERVO_BINDING_FUNC(Servo_ParseProperty,
                    RawServoDeclarationBlockStrong,
                    const nsACString* property, const nsACString* value,
                    const nsACString* base,
                    const GeckoParserExtraData* data)
+SERVO_BINDING_FUNC(Servo_ParseEasing, bool,
+                   const nsAString* easing,
+                   const nsACString* base,
+                   const GeckoParserExtraData* data,
+                   nsTimingFunctionBorrowedMut output)
 SERVO_BINDING_FUNC(Servo_GetComputedKeyframeValues, void,
                    RawGeckoKeyframeListBorrowed keyframes,
                    ServoComputedValuesBorrowed style,
                    ServoComputedValuesBorrowedOrNull parent_style,
                    RawServoStyleSetBorrowed set,
                    RawGeckoComputedKeyframeValuesListBorrowedMut result)
 SERVO_BINDING_FUNC(Servo_AnimationValueMap_Push, void,
                    RawServoAnimationValueMapBorrowed,
--- a/layout/style/ServoBindingTypes.h
+++ b/layout/style/ServoBindingTypes.h
@@ -30,16 +30,17 @@ struct Keyframe;
 struct PropertyStyleAnimationValuePair;
 using ComputedKeyframeValues = nsTArray<PropertyStyleAnimationValuePair>;
 } // namespace mozilla
 
 class nsCSSValue;
 class nsIDocument;
 class nsINode;
 class nsPresContext;
+struct nsTimingFunction;
 
 using mozilla::dom::StyleChildrenIterator;
 using mozilla::ServoElementSnapshot;
 
 typedef nsINode RawGeckoNode;
 typedef mozilla::dom::Element RawGeckoElement;
 typedef nsIDocument RawGeckoDocument;
 typedef nsPresContext RawGeckoPresContext;
@@ -116,16 +117,17 @@ DECL_BORROWED_REF_TYPE_FOR(nsCSSValue)
 DECL_BORROWED_MUT_REF_TYPE_FOR(nsCSSValue)
 DECL_OWNED_REF_TYPE_FOR(RawGeckoPresContext)
 DECL_BORROWED_REF_TYPE_FOR(RawGeckoPresContext)
 DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoAnimationValueList)
 DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoKeyframeList)
 DECL_BORROWED_REF_TYPE_FOR(RawGeckoKeyframeList)
 DECL_BORROWED_MUT_REF_TYPE_FOR(RawGeckoComputedKeyframeValuesList)
 DECL_BORROWED_REF_TYPE_FOR(RawGeckoStyleAnimationList)
+DECL_BORROWED_MUT_REF_TYPE_FOR(nsTimingFunction)
 
 #undef DECL_ARC_REF_TYPE_FOR
 #undef DECL_OWNED_REF_TYPE_FOR
 #undef DECL_NULLABLE_OWNED_REF_TYPE_FOR
 #undef DECL_BORROWED_REF_TYPE_FOR
 #undef DECL_NULLABLE_BORROWED_REF_TYPE_FOR
 #undef DECL_BORROWED_MUT_REF_TYPE_FOR
 #undef DECL_NULLABLE_BORROWED_MUT_REF_TYPE_FOR