Bug 1342863 - (Part 2) DocGroup labeling for runnables dispatched by NS_DispatchTo(Main|Current)Thread in nsPresContext. r?dholbert
MozReview-Commit-ID: COWvfXRhPj7
--- 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