Bug 1342863 - (Part 2) DocGroup labeling for runnables dispatched by NS_DispatchTo(Main|Current)Thread in nsPresContext. r?dholbert draft
authorKuoE0 <kuoe0.tw@gmail.com>
Wed, 15 Mar 2017 10:53:59 +0800
changeset 503441 1acb644c045b3cc828356b608eab810c3d0153b9
parent 503440 41449c452d687b1131c897eb08d04a4ad4f671e8
child 503442 b37dca0f5fe08f8a0ef507ec9ff515eddd783a5d
push id50578
push userbmo:kuoe0@mozilla.com
push dateThu, 23 Mar 2017 06:29:55 +0000
reviewersdholbert
bugs1342863
milestone55.0a1
Bug 1342863 - (Part 2) DocGroup labeling for runnables dispatched by NS_DispatchTo(Main|Current)Thread in nsPresContext. r?dholbert MozReview-Commit-ID: COWvfXRhPj7
layout/base/nsPresContext.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1086,17 +1086,19 @@ nsPresContext::UpdateCharSet(const nsCSt
 NS_IMETHODIMP
 nsPresContext::Observe(nsISupports* aSubject,
                         const char* aTopic,
                         const char16_t* aData)
 {
   if (!nsCRT::strcmp(aTopic, "charset")) {
     RefPtr<CharSetChangingRunnable> runnable =
       new CharSetChangingRunnable(this, NS_LossyConvertUTF16toASCII(aData));
-    return NS_DispatchToCurrentThread(runnable);
+    return Document()->Dispatch("CharSetChangingRunnable",
+                                TaskCategory::Other,
+                                runnable.forget());
   }
 
   NS_WARNING("unrecognized topic in nsPresContext::Observe");
   return NS_ERROR_FAILURE;
 }
 
 nsPresContext*
 nsPresContext::GetParentPresContext()
@@ -1743,17 +1745,20 @@ void
 nsPresContext::ThemeChanged()
 {
   if (!mPendingThemeChanged) {
     sLookAndFeelChanged = true;
     sThemeChanged = true;
 
     nsCOMPtr<nsIRunnable> ev =
       NewRunnableMethod(this, &nsPresContext::ThemeChangedInternal);
-    if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
+    nsresult rv = Document()->Dispatch("nsPresContext::ThemeChangedInternal",
+                                       TaskCategory::Other,
+                                       ev.forget());
+    if (NS_SUCCEEDED(rv)) {
       mPendingThemeChanged = true;
     }
   }
 }
 
 static bool
 NotifyThemeChanged(TabParent* aTabParent, void* aArg)
 {
@@ -1803,17 +1808,20 @@ nsPresContext::ThemeChangedInternal()
 
 void
 nsPresContext::SysColorChanged()
 {
   if (!mPendingSysColorChanged) {
     sLookAndFeelChanged = true;
     nsCOMPtr<nsIRunnable> ev =
       NewRunnableMethod(this, &nsPresContext::SysColorChangedInternal);
-    if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
+    nsresult rv = Document()->Dispatch("nsPresContext::SysColorChangedInternal",
+                                       TaskCategory::Other,
+                                       ev.forget());
+    if (NS_SUCCEEDED(rv)) {
       mPendingSysColorChanged = true;
     }
   }
 }
 
 void
 nsPresContext::SysColorChangedInternal()
 {
@@ -1835,17 +1843,21 @@ nsPresContext::SysColorChangedInternal()
 }
 
 void
 nsPresContext::UIResolutionChanged()
 {
   if (!mPendingUIResolutionChanged) {
     nsCOMPtr<nsIRunnable> ev =
       NewRunnableMethod(this, &nsPresContext::UIResolutionChangedInternal);
-    if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
+    nsresult rv =
+      Document()->Dispatch("nsPresContext::UIResolutionChangedInternal",
+                           TaskCategory::Other,
+                           ev.forget());
+    if (NS_SUCCEEDED(rv)) {
       mPendingUIResolutionChanged = true;
     }
   }
 }
 
 void
 nsPresContext::UIResolutionChangedSync()
 {
@@ -2091,17 +2103,21 @@ nsPresContext::PostMediaFeatureValuesCha
 {
   // FIXME: We should probably replace this event with use of
   // nsRefreshDriver::AddStyleFlushObserver (except the pres shell would
   // need to track whether it's been added).
   if (!mPendingMediaFeatureValuesChanged && mShell) {
     nsCOMPtr<nsIRunnable> ev =
       NewRunnableMethod("nsPresContext::HandleMediaFeatureValuesChangedEvent",
                         this, &nsPresContext::HandleMediaFeatureValuesChangedEvent);
-    if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
+    nsresult rv =
+      Document()->Dispatch("nsPresContext::HandleMediaFeatureValuesChangedEvent",
+                           TaskCategory::Other,
+                           ev.forget());
+    if (NS_SUCCEEDED(rv)) {
       mPendingMediaFeatureValuesChanged = true;
       mShell->SetNeedStyleFlush();
     }
   }
 }
 
 void
 nsPresContext::HandleMediaFeatureValuesChangedEvent()
@@ -2284,17 +2300,21 @@ nsPresContext::RebuildCounterStyles()
   mCounterStylesDirty = true;
   if (mShell) {
     mShell->SetNeedStyleFlush();
   }
   if (!mPostedFlushCounterStyles) {
     nsCOMPtr<nsIRunnable> ev =
       NewRunnableMethod("nsPresContext::HandleRebuildCounterStyles",
                         this, &nsPresContext::HandleRebuildCounterStyles);
-    if (NS_SUCCEEDED(NS_DispatchToCurrentThread(ev))) {
+    nsresult rv =
+      Document()->Dispatch("nsPresContext::HandleRebuildCounterStyles",
+                           TaskCategory::Other,
+                           ev.forget());
+    if (NS_SUCCEEDED(rv)) {
       mPostedFlushCounterStyles = true;
     }
   }
 }
 
 void
 nsPresContext::NotifyMissingFonts()
 {
@@ -3313,17 +3333,19 @@ nsRootPresContext::CancelAllDidPaintTime
   mNotifyDidPaintTimers.Clear();
 }
 
 void
 nsRootPresContext::AddWillPaintObserver(nsIRunnable* aRunnable)
 {
   if (!mWillPaintFallbackEvent.IsPending()) {
     mWillPaintFallbackEvent = new RunWillPaintObservers(this);
-    NS_DispatchToMainThread(mWillPaintFallbackEvent.get());
+    Document()->Dispatch("RunWillPaintObservers",
+                         TaskCategory::Other,
+                         do_AddRef(mWillPaintFallbackEvent.get()));
   }
   mWillPaintObservers.AppendElement(aRunnable);
 }
 
 /**
  * Run all runnables that need to get called before the next paint.
  */
 void