Bug 1340958 - Drop AnimationRule and ServoAnimationRule. r?boris draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Fri, 17 Mar 2017 13:24:42 +0900
changeset 500414 6facc8359e3b6561903b60ecac99da9dcc8e7921
parent 500413 d1252f6b56cc3faff6029fddb61d806011929bc5
child 500415 7f18f0287ac59e9d3f3f74fbcc439338fa291ae6
push id49724
push userhikezoe@mozilla.com
push dateFri, 17 Mar 2017 06:26:10 +0000
reviewersboris
bugs1340958
milestone55.0a1
Bug 1340958 - Drop AnimationRule and ServoAnimationRule. r?boris MozReview-Commit-ID: ClnvyShHpsN
dom/animation/Animation.cpp
dom/animation/AnimationRule.h
dom/animation/EffectCompositor.cpp
dom/animation/EffectCompositor.h
dom/animation/EffectSet.h
dom/animation/KeyframeEffectReadOnly.cpp
dom/animation/ServoAnimationRule.cpp
dom/animation/ServoAnimationRule.h
dom/animation/moz.build
layout/style/ServoBindings.cpp
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -8,17 +8,16 @@
 #include "AnimationUtils.h"
 #include "mozilla/dom/AnimationBinding.h"
 #include "mozilla/dom/AnimationPlaybackEvent.h"
 #include "mozilla/dom/DocumentTimeline.h"
 #include "mozilla/AnimationTarget.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/AsyncEventDispatcher.h" // For AsyncEventDispatcher
 #include "mozilla/Maybe.h" // For Maybe
-#include "mozilla/AnimationRule.h" // For AnimationRule
 #include "mozilla/TypeTraits.h" // For Forward<>
 #include "nsAnimationManager.h" // For CSSAnimation
 #include "nsDOMMutationObserver.h" // For nsAutoAnimationMutationBatch
 #include "nsIDocument.h" // For nsIDocument
 #include "nsIPresShell.h" // For nsIPresShell
 #include "nsThreadUtils.h" // For nsRunnableMethod and nsRevocableEventPtr
 #include "nsTransitionManager.h" // For CSSTransition
 #include "PendingAnimationTracker.h" // For PendingAnimationTracker
deleted file mode 100644
--- a/dom/animation/AnimationRule.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_AnimationRule_h
-#define mozilla_AnimationRule_h
-
-#include "AnimValuesStyleRule.h"
-#include "ServoAnimationRule.h"
-
-namespace mozilla {
-
-// A wrapper for animation rules.
-struct AnimationRule
-{
-  RefPtr<AnimValuesStyleRule> mGecko;
-  RefPtr<ServoAnimationRule> mServo;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_AnimationRule_h
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -447,17 +447,17 @@ EffectCompositor::GetAnimationRule(dom::
   }
 #endif
 
   EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
   if (!effectSet) {
     return nullptr;
   }
 
-  return effectSet->AnimationRule(aCascadeLevel).mGecko;
+  return effectSet->AnimationRule(aCascadeLevel);
 }
 
 namespace {
   class EffectCompositeOrderComparator {
   public:
     bool Equals(const KeyframeEffectReadOnly* a,
                 const KeyframeEffectReadOnly* b) const
     {
@@ -766,29 +766,29 @@ EffectCompositor::ComposeAnimationRule(d
 
   // Get a list of effects sorted by composite order.
   nsTArray<KeyframeEffectReadOnly*> sortedEffectList(effects->Count());
   for (KeyframeEffectReadOnly* effect : *effects) {
     sortedEffectList.AppendElement(effect);
   }
   sortedEffectList.Sort(EffectCompositeOrderComparator());
 
-  AnimationRule& animRule = effects->AnimationRule(aCascadeLevel);
-  animRule.mGecko = nullptr;
+  RefPtr<AnimValuesStyleRule>& animRule = effects->AnimationRule(aCascadeLevel);
+  animRule = nullptr;
 
   // If multiple animations affect the same property, animations with higher
   // composite order (priority) override or add or animations with lower
   // priority except properties in propertiesToSkip.
   const nsCSSPropertyIDSet& propertiesToSkip =
     aCascadeLevel == CascadeLevel::Animations
     ? effects->PropertiesForAnimationsLevel().Inverse()
     : effects->PropertiesForAnimationsLevel();
   for (KeyframeEffectReadOnly* effect : sortedEffectList) {
     effect->GetAnimation()->WillComposeStyle();
-    effect->GetAnimation()->ComposeStyle(animRule.mGecko, propertiesToSkip);
+    effect->GetAnimation()->ComposeStyle(animRule, propertiesToSkip);
   }
 
   MOZ_ASSERT(effects == EffectSet::GetEffectSet(aElement, aPseudoType),
              "EffectSet should not change while composing style");
 }
 
 /* static */ void
 EffectCompositor::GetOverriddenProperties(nsStyleContext* aStyleContext,
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -27,17 +27,16 @@ class nsStyleContext;
 struct RawServoAnimationValueMap;
 typedef RawServoAnimationValueMap const* RawServoAnimationValueMapBorrowed;
 
 namespace mozilla {
 
 class EffectSet;
 class RestyleTracker;
 class StyleAnimationValue;
-class ServoAnimationRule;
 struct AnimationPerformanceWarning;
 struct AnimationProperty;
 struct NonOwningAnimationTarget;
 
 namespace dom {
 class Animation;
 class Element;
 }
--- a/dom/animation/EffectSet.h
+++ b/dom/animation/EffectSet.h
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_EffectSet_h
 #define mozilla_EffectSet_h
 
-#include "mozilla/AnimationRule.h" // For AnimationRule
+#include "mozilla/AnimValuesStyleRule.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 #include "nsHashKeys.h" // For nsPtrHashKey
 #include "nsTHashtable.h" // For nsTHashtable
 
@@ -158,17 +158,17 @@ public:
 #ifdef DEBUG
   bool IsBeingEnumerated() const { return mActiveIterators != 0; }
 #endif
 
   bool IsEmpty() const { return mEffects.IsEmpty(); }
 
   size_t Count() const { return mEffects.Count(); }
 
-  struct AnimationRule&
+  RefPtr<AnimValuesStyleRule>&
   AnimationRule(EffectCompositor::CascadeLevel aCascadeLevel)
   {
     return mAnimationRule[aCascadeLevel];
   }
 
   const TimeStamp& LastTransformSyncTime() const
   {
     return mLastTransformSyncTime;
@@ -208,17 +208,17 @@ private:
   // These style rules contain the style data for currently animating
   // values.  They only match when styling with animation.  When we
   // style without animation, we need to not use them so that we can
   // detect any new changes; if necessary we restyle immediately
   // afterwards with animation.
   EnumeratedArray<EffectCompositor::CascadeLevel,
                   EffectCompositor::CascadeLevel(
                     EffectCompositor::kCascadeLevelCount),
-                  mozilla::AnimationRule> mAnimationRule;
+                  RefPtr<AnimValuesStyleRule>> mAnimationRule;
 
   // Refresh driver timestamp from the moment when transform animations in this
   // effect set were last updated and sent to the compositor. This is used for
   // transform animations that run on the compositor but need to be updated on
   // the main thread periodically (e.g. so scrollbars can be updated).
   TimeStamp mLastTransformSyncTime;
 
   // Dirty flag to represent when the mPropertiesWithImportantRules and
--- a/dom/animation/KeyframeEffectReadOnly.cpp
+++ b/dom/animation/KeyframeEffectReadOnly.cpp
@@ -5,17 +5,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/KeyframeEffectReadOnly.h"
 
 #include "mozilla/dom/KeyframeAnimationOptionsBinding.h"
   // For UnrestrictedDoubleOrKeyframeAnimationOptions;
 #include "mozilla/dom/CSSPseudoElement.h"
 #include "mozilla/dom/KeyframeEffectBinding.h"
-#include "mozilla/AnimationRule.h"
+#include "mozilla/AnimValuesStyleRule.h"
 #include "mozilla/AnimationUtils.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/FloatingPoint.h" // For IsFinite
 #include "mozilla/LookAndFeel.h" // For LookAndFeel::GetInt
 #include "mozilla/KeyframeUtils.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/TypeTraits.h"
deleted file mode 100644
--- a/dom/animation/ServoAnimationRule.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "ServoAnimationRule.h"
-
-namespace mozilla {
-
-void
-ServoAnimationRule::AddValue(nsCSSPropertyID aProperty,
-                             RawServoAnimationValue* aValue)
-{
-  MOZ_ASSERT(aProperty != eCSSProperty_UNKNOWN,
-             "Unexpected css property");
-  mAnimationValues.Put(aProperty, aValue);
-}
-
-RawServoDeclarationBlockStrong
-ServoAnimationRule::GetValues() const
-{
-  // FIXME: Pass the hash table into the FFI directly.
-  nsTArray<const RawServoAnimationValue*> values(mAnimationValues.Count());
-  auto iter = mAnimationValues.ConstIter();
-  for (; !iter.Done(); iter.Next()) {
-    values.AppendElement(iter.Data());
-  }
-  return Servo_AnimationValues_Uncompute(&values);
-}
-
-} // namespace mozilla
deleted file mode 100644
--- a/dom/animation/ServoAnimationRule.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_ServoAnimationRule_h
-#define mozilla_ServoAnimationRule_h
-
-#include "nsCSSPropertyID.h"
-#include "nsHashKeys.h" // For nsUint32HashKey
-#include "nsRefPtrHashtable.h"
-#include "ServoBindings.h"
-
-namespace mozilla {
-
-/**
- * A rule for Stylo Animation Rule.
- */
-class ServoAnimationRule
-{
-public:
-  ServoAnimationRule() = default;
-
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ServoAnimationRule)
-
-  void AddValue(nsCSSPropertyID aProperty,
-                RawServoAnimationValue* aValue);
-  MOZ_MUST_USE RawServoDeclarationBlockStrong GetValues() const;
-
-private:
-  ~ServoAnimationRule() = default;
-
-  nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue> mAnimationValues;
-};
-
-} // namespace mozilla
-
-#endif // mozilla_ServoAnimationRule_h
--- a/dom/animation/moz.build
+++ b/dom/animation/moz.build
@@ -20,30 +20,28 @@ EXPORTS.mozilla.dom += [
     'DocumentTimeline.h',
     'KeyframeEffect.h',
     'KeyframeEffectReadOnly.h',
 ]
 
 EXPORTS.mozilla += [
     'AnimationComparator.h',
     'AnimationPerformanceWarning.h',
-    'AnimationRule.h',
     'AnimationTarget.h',
     'AnimationUtils.h',
     'AnimValuesStyleRule.h',
     'ComputedTiming.h',
     'ComputedTimingFunction.h',
     'EffectCompositor.h',
     'EffectSet.h',
     'Keyframe.h',
     'KeyframeEffectParams.h',
     'KeyframeUtils.h',
     'PendingAnimationTracker.h',
     'PseudoElementHashEntry.h',
-    'ServoAnimationRule.h',
     'TimingParams.h',
 ]
 
 UNIFIED_SOURCES += [
     'Animation.cpp',
     'AnimationEffectReadOnly.cpp',
     'AnimationEffectTiming.cpp',
     'AnimationEffectTimingReadOnly.cpp',
@@ -56,17 +54,16 @@ UNIFIED_SOURCES += [
     'DocumentTimeline.cpp',
     'EffectCompositor.cpp',
     'EffectSet.cpp',
     'KeyframeEffect.cpp',
     'KeyframeEffectParams.cpp',
     'KeyframeEffectReadOnly.cpp',
     'KeyframeUtils.cpp',
     'PendingAnimationTracker.cpp',
-    'ServoAnimationRule.cpp',
     'TimingParams.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
     '/layout/base',
     '/layout/style',
 ]
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -33,17 +33,16 @@
 #include "nsString.h"
 #include "nsStyleStruct.h"
 #include "nsStyleUtil.h"
 #include "nsTArray.h"
 
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/Keyframe.h"
-#include "mozilla/ServoAnimationRule.h"
 #include "mozilla/ServoElementSnapshot.h"
 #include "mozilla/ServoRestyleManager.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/DeclarationBlockInlines.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ElementInlines.h"
 #include "mozilla/LookAndFeel.h"