Bug 1347815 - part1.2: label ScrollFrameActivityTracker. draft
authorJeremy Chen <jeremychen@mozilla.com>
Sun, 09 Apr 2017 16:53:56 +0800
changeset 559237 0a0b12ce90fbf6189449a5325d5789f3f36c0671
parent 559236 da77d5396248c8a21ad54536fc7e3867c038f251
child 559238 37a58ea16d49df67e36325a71a7c6f60244a034e
push id53025
push userjichen@mozilla.com
push dateSun, 09 Apr 2017 08:54:13 +0000
bugs1347815
milestone55.0a1
Bug 1347815 - part1.2: label ScrollFrameActivityTracker. ScrollFrameActivityTracker::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: 9QEjxCtFhve
layout/generic/nsGfxScrollFrame.cpp
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -1975,19 +1975,20 @@ ScrollFrameHelper::IsSmoothScrollingEnab
   return Preferences::GetBool(SMOOTH_SCROLL_PREF_NAME, false);
 }
 
 class ScrollFrameActivityTracker final : public nsExpirationTracker<ScrollFrameHelper,4> {
 public:
   // Wait for 3-4s between scrolls before we remove our layers.
   // That's 4 generations of 1s each.
   enum { TIMEOUT_MS = 1000 };
-  ScrollFrameActivityTracker()
+  explicit ScrollFrameActivityTracker(nsIEventTarget* aEventTarget)
     : nsExpirationTracker<ScrollFrameHelper,4>(TIMEOUT_MS,
-                                               "ScrollFrameActivityTracker")
+                                               "ScrollFrameActivityTracker",
+                                               aEventTarget)
   {}
   ~ScrollFrameActivityTracker() {
     AgeAllGenerations();
   }
 
   virtual void NotifyExpired(ScrollFrameHelper *aObject) {
     RemoveObject(aObject);
     aObject->MarkNotRecentlyScrolled();
@@ -2534,17 +2535,18 @@ void ScrollFrameHelper::MarkRecentlyScro
   if (IsAlwaysActive()) {
     return;
   }
 
   if (mActivityExpirationState.IsTracked()) {
     gScrollFrameActivityTracker->MarkUsed(this);
   } else {
     if (!gScrollFrameActivityTracker) {
-      gScrollFrameActivityTracker = new ScrollFrameActivityTracker();
+      gScrollFrameActivityTracker = new ScrollFrameActivityTracker(
+        SystemGroup::EventTargetFor(TaskCategory::Other));
     }
     gScrollFrameActivityTracker->AddObject(this);
   }
 
   // If we just scrolled and there's a displayport expiry timer in place,
   // reset the timer.
   ResetDisplayPortExpiryTimer();
 }