Bug 1626570 - Improve handling of copying arrays in layout/base/. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D72354
This commit is contained in:
Simon Giesecke 2020-05-05 10:40:24 +00:00
parent 40a765717d
commit 37c0751e92
2 changed files with 4 additions and 7 deletions

View File

@ -341,8 +341,7 @@ class RefreshDriverTimer {
return;
}
nsTArray<RefPtr<nsRefreshDriver>> drivers(aDrivers);
for (nsRefreshDriver* driver : drivers) {
for (nsRefreshDriver* driver : aDrivers.Clone()) {
// don't poke this driver if it's in test mode
if (driver->IsTestControllingRefreshesEnabled()) {
continue;
@ -979,7 +978,7 @@ class InactiveRefreshDriverTimer final
mLastFireTime = now;
nsTArray<RefPtr<nsRefreshDriver>> drivers(mContentRefreshDrivers);
nsTArray<RefPtr<nsRefreshDriver>> drivers(mContentRefreshDrivers.Clone());
drivers.AppendElements(mRootRefreshDrivers);
size_t index = mNextDriverIndex;

View File

@ -155,8 +155,7 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI* aSheetURI,
rv = LoadAndRegisterSheetInternal(aSheetURI, aSheetType);
if (NS_SUCCEEDED(rv)) {
// Hold on to a copy of the registered PresShells.
nsTArray<RefPtr<PresShell>> toNotify(mPresShells);
for (PresShell* presShell : toNotify) {
for (PresShell* presShell : mPresShells.Clone()) {
StyleSheet* sheet = mSheets[aSheetType].LastElement();
presShell->NotifyStyleSheetServiceSheetAdded(sheet, aSheetType);
}
@ -307,8 +306,7 @@ nsStyleSheetService::UnregisterSheet(nsIURI* aSheetURI, uint32_t aSheetType) {
}
// Hold on to a copy of the registered PresShells.
nsTArray<RefPtr<PresShell>> toNotify(mPresShells);
for (PresShell* presShell : toNotify) {
for (PresShell* presShell : mPresShells.Clone()) {
if (presShell->StyleSet()) {
if (sheet) {
presShell->NotifyStyleSheetServiceSheetRemoved(sheet, aSheetType);