Bug 1335321 - stylo: Do CachedBorderImageData::PurgeCachedImages work on the main thread. r=bholley

MozReview-Commit-ID: 82vKTooB2fh

--HG--
extra : rebase_source : 7a4cfc44987a499738f6d8f79cf107393c3fca0c
This commit is contained in:
Cameron McCormack 2017-02-20 20:39:05 +08:00
parent 7f072468f4
commit 8856103bc6

View File

@ -2054,10 +2054,29 @@ CachedBorderImageData::GetCachedSVGViewportSize()
return mCachedSVGViewportSize;
}
struct PurgeCachedImagesTask : mozilla::Runnable
{
NS_IMETHOD Run() final
{
mSubImages.Clear();
return NS_OK;
}
nsCOMArray<imgIContainer> mSubImages;
};
void
CachedBorderImageData::PurgeCachedImages()
{
mSubImages.Clear();
if (ServoStyleSet::IsInServoTraversal()) {
RefPtr<PurgeCachedImagesTask> task = new PurgeCachedImagesTask();
task->mSubImages.SwapElements(mSubImages);
// This will run the task immediately if we're already on the main thread,
// but that is fine.
NS_DispatchToMainThread(task.forget());
} else {
mSubImages.Clear();
}
}
void