Bug 1347815 - part2: label LayerActivityTracker. draft
authorJeremy Chen <jeremychen@mozilla.com>
Sun, 09 Apr 2017 16:53:56 +0800
changeset 559238 37a58ea16d49df67e36325a71a7c6f60244a034e
parent 559237 0a0b12ce90fbf6189449a5325d5789f3f36c0671
child 559239 a2b844ae3f093ecd198512bd083e75855b9cf704
push id53025
push userjichen@mozilla.com
push dateSun, 09 Apr 2017 08:54:13 +0000
bugs1347815
milestone55.0a1
Bug 1347815 - part2: label LayerActivityTracker. LayerActivityTracker::NotifyExpired() will be invoked by nsExpirationTracker::TimerCallback() from an unlabeled runnable. We provide a SystemGroup EventTarget for the invocation of this callback since there's nothing within a page that would rely on the timer firing at a particular time (i.e., it doesn't matter when this timer's callback is scheduled, relative to other runnables dispatched for the page). MozReview-Commit-ID: FZHtqicwDG5
layout/painting/ActiveLayerTracker.cpp
--- a/layout/painting/ActiveLayerTracker.cpp
+++ b/layout/painting/ActiveLayerTracker.cpp
@@ -114,19 +114,20 @@ public:
   uint8_t mRestyleCounts[ACTIVITY_COUNT];
   bool mContentActive;
 };
 
 class LayerActivityTracker final : public nsExpirationTracker<LayerActivity,4> {
 public:
   // 75-100ms is a good timeout period. We use 4 generations of 25ms each.
   enum { GENERATION_MS = 100 };
-  LayerActivityTracker()
+  explicit LayerActivityTracker(nsIEventTarget* aEventTarget)
     : nsExpirationTracker<LayerActivity,4>(GENERATION_MS,
-                                           "LayerActivityTracker")
+                                           "LayerActivityTracker",
+                                           aEventTarget)
     , mDestroying(false)
   {}
   ~LayerActivityTracker() {
     mDestroying = true;
     AgeAllGenerations();
   }
 
   virtual void NotifyExpired(LayerActivity* aObject);
@@ -198,17 +199,18 @@ static LayerActivity*
 GetLayerActivityForUpdate(nsIFrame* aFrame)
 {
   FrameProperties properties = aFrame->Properties();
   LayerActivity* layerActivity = properties.Get(LayerActivityProperty());
   if (layerActivity) {
     gLayerActivityTracker->MarkUsed(layerActivity);
   } else {
     if (!gLayerActivityTracker) {
-      gLayerActivityTracker = new LayerActivityTracker();
+      gLayerActivityTracker = new LayerActivityTracker(
+        SystemGroup::EventTargetFor(TaskCategory::Other));
     }
     layerActivity = new LayerActivity(aFrame);
     gLayerActivityTracker->AddObject(layerActivity);
     aFrame->AddStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY);
     properties.Set(LayerActivityProperty(), layerActivity);
   }
   return layerActivity;
 }
@@ -506,17 +508,18 @@ ActiveLayerTracker::IsContentActive(nsIF
   LayerActivity* layerActivity = GetLayerActivity(aFrame);
   return layerActivity && layerActivity->mContentActive;
 }
 
 /* static */ void
 ActiveLayerTracker::SetCurrentScrollHandlerFrame(nsIFrame* aFrame)
 {
   if (!gLayerActivityTracker) {
-    gLayerActivityTracker = new LayerActivityTracker();
+    gLayerActivityTracker = new LayerActivityTracker(
+      SystemGroup::EventTargetFor(TaskCategory::Other));
   }
   gLayerActivityTracker->mCurrentScrollHandlerFrame = aFrame;
 }
 
 /* static */ void
 ActiveLayerTracker::Shutdown()
 {
   delete gLayerActivityTracker;