Bug 1175245: Convert nsRefreshDriver.cpp to use range-based "for" loops. r=tn

This commit is contained in:
Daniel Holbert
2015-06-17 14:36:40 -07:00
parent 486f638aef
commit dd68a06e04

View File

@@ -137,9 +137,9 @@ public:
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
for (size_t i = 0; i < mRefreshDrivers.Length(); i++) { for (nsRefreshDriver* driver : mRefreshDrivers) {
aNewTimer->AddRefreshDriver(mRefreshDrivers[i]); aNewTimer->AddRefreshDriver(driver);
mRefreshDrivers[i]->mActiveTimer = aNewTimer; driver->mActiveTimer = aNewTimer;
} }
mRefreshDrivers.Clear(); mRefreshDrivers.Clear();
@@ -177,13 +177,13 @@ protected:
nsTArray<nsRefPtr<nsRefreshDriver> > drivers(mRefreshDrivers); nsTArray<nsRefPtr<nsRefreshDriver> > drivers(mRefreshDrivers);
// RD is short for RefreshDriver // RD is short for RefreshDriver
profiler_tracing("Paint", "RD", TRACING_INTERVAL_START); profiler_tracing("Paint", "RD", TRACING_INTERVAL_START);
for (size_t i = 0; i < drivers.Length(); ++i) { for (nsRefreshDriver* driver : drivers) {
// don't poke this driver if it's in test mode // don't poke this driver if it's in test mode
if (drivers[i]->IsTestControllingRefreshesEnabled()) { if (driver->IsTestControllingRefreshesEnabled()) {
continue; continue;
} }
TickDriver(drivers[i], jsnow, now); TickDriver(driver, jsnow, now);
} }
profiler_tracing("Paint", "RD", TRACING_INTERVAL_END); profiler_tracing("Paint", "RD", TRACING_INTERVAL_END);
LOG("[%p] done.", this); LOG("[%p] done.", this);
@@ -1055,8 +1055,8 @@ nsRefreshDriver::~nsRefreshDriver()
mRootRefresh->RemoveRefreshObserver(this, Flush_Style); mRootRefresh->RemoveRefreshObserver(this, Flush_Style);
mRootRefresh = nullptr; mRootRefresh = nullptr;
} }
for (uint32_t i = 0; i < mPresShellsToInvalidateIfHidden.Length(); i++) { for (nsIPresShell* shell : mPresShellsToInvalidateIfHidden) {
mPresShellsToInvalidateIfHidden[i]->InvalidatePresShellIfHidden(); shell->InvalidatePresShellIfHidden();
} }
mPresShellsToInvalidateIfHidden.Clear(); mPresShellsToInvalidateIfHidden.Clear();
@@ -1540,8 +1540,7 @@ nsRefreshDriver::RunFrameRequestCallbacks(int64_t aNowEpoch, TimeStamp aNowTime)
if (!frameRequestCallbacks.IsEmpty()) { if (!frameRequestCallbacks.IsEmpty()) {
profiler_tracing("Paint", "Scripts", TRACING_INTERVAL_START); profiler_tracing("Paint", "Scripts", TRACING_INTERVAL_START);
int64_t eventTime = aNowEpoch / PR_USEC_PER_MSEC; int64_t eventTime = aNowEpoch / PR_USEC_PER_MSEC;
for (uint32_t i = 0; i < frameRequestCallbacks.Length(); ++i) { for (const DocumentFrameCallbacks& docCallbacks : frameRequestCallbacks) {
const DocumentFrameCallbacks& docCallbacks = frameRequestCallbacks[i];
// XXXbz Bug 863140: GetInnerWindow can return the outer // XXXbz Bug 863140: GetInnerWindow can return the outer
// window in some cases. // window in some cases.
nsPIDOMWindow* innerWindow = docCallbacks.mDocument->GetInnerWindow(); nsPIDOMWindow* innerWindow = docCallbacks.mDocument->GetInnerWindow();
@@ -1553,9 +1552,8 @@ nsRefreshDriver::RunFrameRequestCallbacks(int64_t aNowEpoch, TimeStamp aNowTime)
} }
// else window is partially torn down already // else window is partially torn down already
} }
for (uint32_t j = 0; j < docCallbacks.mCallbacks.Length(); ++j) { for (const nsIDocument::FrameRequestCallbackHolder& holder :
const nsIDocument::FrameRequestCallbackHolder& holder = docCallbacks.mCallbacks) {
docCallbacks.mCallbacks[j];
nsAutoMicroTask mt; nsAutoMicroTask mt;
if (holder.HasWebIDLCallback()) { if (holder.HasWebIDLCallback()) {
ErrorResult ignored; ErrorResult ignored;
@@ -1783,19 +1781,18 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
} }
} }
for (uint32_t i = 0; i < mPresShellsToInvalidateIfHidden.Length(); i++) { for (nsIPresShell* shell : mPresShellsToInvalidateIfHidden) {
mPresShellsToInvalidateIfHidden[i]->InvalidatePresShellIfHidden(); shell->InvalidatePresShellIfHidden();
} }
mPresShellsToInvalidateIfHidden.Clear(); mPresShellsToInvalidateIfHidden.Clear();
if (mViewManagerFlushIsPending) { if (mViewManagerFlushIsPending) {
nsTArray<nsDocShell*> profilingDocShells; nsTArray<nsDocShell*> profilingDocShells;
GetProfileTimelineSubDocShells(GetDocShell(mPresContext), profilingDocShells); GetProfileTimelineSubDocShells(GetDocShell(mPresContext), profilingDocShells);
for (uint32_t i = 0; i < profilingDocShells.Length(); i ++) { for (nsDocShell* docShell : profilingDocShells) {
// For the sake of the profile timeline's simplicity, this is flagged as // For the sake of the profile timeline's simplicity, this is flagged as
// paint even if it includes creating display lists // paint even if it includes creating display lists
profilingDocShells[i]->AddProfileTimelineMarker("Paint", docShell->AddProfileTimelineMarker("Paint", TRACING_INTERVAL_START);
TRACING_INTERVAL_START);
} }
#ifdef MOZ_DUMP_PAINTING #ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@@ -1811,9 +1808,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
printf_stderr("Ending ProcessPendingUpdates\n"); printf_stderr("Ending ProcessPendingUpdates\n");
} }
#endif #endif
for (uint32_t i = 0; i < profilingDocShells.Length(); i ++) { for (nsDocShell* docShell : profilingDocShells) {
profilingDocShells[i]->AddProfileTimelineMarker("Paint", docShell->AddProfileTimelineMarker("Paint", TRACING_INTERVAL_END);
TRACING_INTERVAL_END);
} }
if (nsContentUtils::XPConnect()) { if (nsContentUtils::XPConnect()) {
@@ -1826,8 +1822,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mozilla::Telemetry::AccumulateTimeDelta(mozilla::Telemetry::REFRESH_DRIVER_TICK, mTickStart); mozilla::Telemetry::AccumulateTimeDelta(mozilla::Telemetry::REFRESH_DRIVER_TICK, mTickStart);
#endif #endif
for (uint32_t i = 0; i < mPostRefreshObservers.Length(); ++i) { for (nsAPostRefreshObserver* postRefreshObserver: mPostRefreshObservers) {
mPostRefreshObservers[i]->DidRefresh(); postRefreshObserver->DidRefresh();
} }
NS_ASSERTION(mInRefresh, "Still in refresh"); NS_ASSERTION(mInRefresh, "Still in refresh");