mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 913247: Don't call imgIContainer::RequestRefresh during hashtable enumeration. r=jwatt
This commit is contained in:
parent
e3ec693723
commit
c122699022
@ -1157,7 +1157,18 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
mStartTable.EnumerateRead(nsRefreshDriver::StartTableRefresh, &parms);
|
||||
|
||||
if (mRequests.Count()) {
|
||||
mRequests.EnumerateEntries(nsRefreshDriver::ImageRequestEnumerator, &parms);
|
||||
// RequestRefresh may run scripts, so it's not safe to directly call it
|
||||
// while using a hashtable enumerator to enumerate mRequests in case
|
||||
// script modifies the hashtable. Instead, we build a (local) array of
|
||||
// images to refresh, and then we refresh each image in that array.
|
||||
nsCOMArray<imgIContainer> imagesToRefresh(mRequests.Count());
|
||||
mRequests.EnumerateEntries(nsRefreshDriver::ImageRequestEnumerator,
|
||||
&imagesToRefresh);
|
||||
|
||||
for (uint32_t i = 0; i < imagesToRefresh.Length(); i++) {
|
||||
imagesToRefresh[i]->RequestRefresh(aNowTime);
|
||||
}
|
||||
imagesToRefresh.Clear();
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < mPresShellsToInvalidateIfHidden.Length(); i++) {
|
||||
@ -1194,14 +1205,13 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
|
||||
nsRefreshDriver::ImageRequestEnumerator(nsISupportsHashKey* aEntry,
|
||||
void* aUserArg)
|
||||
{
|
||||
ImageRequestParameters* parms =
|
||||
static_cast<ImageRequestParameters*> (aUserArg);
|
||||
mozilla::TimeStamp mostRecentRefresh = parms->mCurrent;
|
||||
nsCOMArray<imgIContainer>* imagesToRefresh =
|
||||
static_cast<nsCOMArray<imgIContainer>*> (aUserArg);
|
||||
imgIRequest* req = static_cast<imgIRequest*>(aEntry->GetKey());
|
||||
NS_ABORT_IF_FALSE(req, "Unable to retrieve the image request");
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
if (NS_SUCCEEDED(req->GetImage(getter_AddRefs(image)))) {
|
||||
image->RequestRefresh(mostRecentRefresh);
|
||||
imagesToRefresh->AppendElement(image);
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
|
Loading…
Reference in New Issue
Block a user