Bug 1526850 - Part 4: Add nsCSSPropertyIDSet::IsSubsetOf() for checking the restrictions of some arguments. r=hiro
authorBoris Chiou <boris.chiou@gmail.com>
Fri, 01 Mar 2019 21:13:07 +0000
changeset 519916 653f907add4ebbcd782d08ed7777d39667fbc6bf
parent 519915 c05471f233f32996e77e8aa4476afb02630cd9c0
child 519917 17423f4f1520acef481e4644b29e2e4adbfba330
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1526850
milestone67.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 1526850 - Part 4: Add nsCSSPropertyIDSet::IsSubsetOf() for checking the restrictions of some arguments. r=hiro We restrict the argument (i.e. `nsCSSPropertyIDSet`) of some functions is the subset of other property set (e.g. transform-like properties), so add this function for better readability. Depends on D19629 Differential Revision: https://phabricator.services.mozilla.com/D21598
dom/animation/EffectCompositor.cpp
layout/painting/ActiveLayerTracker.cpp
layout/style/nsCSSPropertyIDSet.h
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -102,26 +102,25 @@ bool EffectCompositor::AllowCompositorAn
 // GetAnimationsForCompositor and HasAnimationsForCompositor.
 //
 // Takes an optional array to fill with eligible animations.
 //
 // Returns true if there are eligible animations, false otherwise.
 bool FindAnimationsForCompositor(
     const nsIFrame* aFrame, const nsCSSPropertyIDSet& aPropertySet,
     nsTArray<RefPtr<dom::Animation>>* aMatches /*out*/) {
-  MOZ_ASSERT(aPropertySet
-                     .Intersect(LayerAnimationInfo::GetCSSPropertiesFor(
-                         DisplayItemType::TYPE_TRANSFORM))
-                     .Equals(aPropertySet) ||
-                 aPropertySet.Equals(LayerAnimationInfo::GetCSSPropertiesFor(
-                     DisplayItemType::TYPE_OPACITY)) ||
-                 aPropertySet.Equals(LayerAnimationInfo::GetCSSPropertiesFor(
-                     DisplayItemType::TYPE_BACKGROUND_COLOR)),
-             "Should be the subset of transform-like properties, or opacity, "
-             "or background color");
+  MOZ_ASSERT(
+      aPropertySet.IsSubsetOf(LayerAnimationInfo::GetCSSPropertiesFor(
+          DisplayItemType::TYPE_TRANSFORM)) ||
+          aPropertySet.IsSubsetOf(LayerAnimationInfo::GetCSSPropertiesFor(
+              DisplayItemType::TYPE_OPACITY)) ||
+          aPropertySet.IsSubsetOf(LayerAnimationInfo::GetCSSPropertiesFor(
+              DisplayItemType::TYPE_BACKGROUND_COLOR)),
+      "Should be the subset of transform-like properties, or opacity, "
+      "or background color");
 
   MOZ_ASSERT(!aMatches || aMatches->IsEmpty(),
              "Matches array, if provided, should be empty");
 
   EffectSet* effects = EffectSet::GetEffectSet(aFrame);
   if (!effects || effects->IsEmpty()) {
     return false;
   }
--- a/layout/painting/ActiveLayerTracker.cpp
+++ b/layout/painting/ActiveLayerTracker.cpp
@@ -95,22 +95,22 @@ class LayerActivity {
       default:
         MOZ_ASSERT(false);
         return ACTIVITY_OPACITY;
     }
   }
 
   static ActivityIndex GetActivityIndexForPropertySet(
       const nsCSSPropertyIDSet& aPropertySet) {
-    if (aPropertySet.Intersect(nsCSSPropertyIDSet::TransformLikeProperties())
-            .Equals(aPropertySet)) {
+    if (aPropertySet.IsSubsetOf(
+            nsCSSPropertyIDSet::TransformLikeProperties())) {
       return ACTIVITY_TRANSFORM;
     }
-    MOZ_ASSERT(aPropertySet.Intersect(nsCSSPropertyIDSet::OpacityProperties())
-                   .Equals(aPropertySet));
+    MOZ_ASSERT(
+        aPropertySet.IsSubsetOf(nsCSSPropertyIDSet::OpacityProperties()));
     return ACTIVITY_OPACITY;
   }
 
   // While tracked, exactly one of mFrame or mContent is non-null, depending
   // on whether this property is stored on a frame or on a content node.
   // When this property is expired by the layer activity tracker, both mFrame
   // and mContent are nulled-out and the property is deleted.
   nsIFrame* mFrame;
@@ -467,20 +467,18 @@ bool ActiveLayerTracker::IsTransformMayb
                          nsCSSPropertyIDSet::TransformLikeProperties());
 }
 
 /* static */
 bool ActiveLayerTracker::IsStyleAnimated(
     nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
     const nsCSSPropertyIDSet& aPropertySet) {
   MOZ_ASSERT(
-      aPropertySet.Intersect(nsCSSPropertyIDSet::TransformLikeProperties())
-              .Equals(aPropertySet) ||
-          aPropertySet.Intersect(nsCSSPropertyIDSet::OpacityProperties())
-              .Equals(aPropertySet),
+      aPropertySet.IsSubsetOf(nsCSSPropertyIDSet::TransformLikeProperties()) ||
+          aPropertySet.IsSubsetOf(nsCSSPropertyIDSet::OpacityProperties()),
       "Only subset of opacity or transform-like properties set calls this");
 
   const nsCSSPropertyIDSet transformSet =
       nsCSSPropertyIDSet::TransformLikeProperties();
   if ((aFrame->StyleDisplay()->mWillChangeBitField &
        NS_STYLE_WILL_CHANGE_TRANSFORM) &&
       aPropertySet.Intersects(transformSet) &&
       (!aBuilder ||
--- a/layout/style/nsCSSPropertyIDSet.h
+++ b/layout/style/nsCSSPropertyIDSet.h
@@ -110,16 +110,20 @@ class nsCSSPropertyIDSet {
     for (size_t i = 0; i < mozilla::ArrayLength(mProperties); ++i) {
       if (mProperties[i] != 0) {
         return false;
       }
     }
     return true;
   }
 
+  bool IsSubsetOf(const nsCSSPropertyIDSet& aOther) const {
+    return this->Intersect(aOther).Equals(*this);
+  }
+
   // Return a new nsCSSPropertyIDSet which is the inverse of this set.
   nsCSSPropertyIDSet Inverse() const {
     nsCSSPropertyIDSet result;
     for (size_t i = 0; i < mozilla::ArrayLength(mProperties); ++i) {
       result.mProperties[i] = ~mProperties[i];
     }
     return result;
   }