Bug 911889. Part 5. Add API to detect whether an nsRefreshDriver is in the middle of a refresh. r=dbaron

--HG--
extra : rebase_source : 3cb0dccfe176b5f6d79fd0898ddf6e5a8bed2e39
This commit is contained in:
Robert O'Callahan 2013-09-04 23:47:21 +12:00
parent 7cd28ca766
commit 5bd9a4ff2a
2 changed files with 11 additions and 2 deletions

View File

@ -26,7 +26,7 @@
#endif
#include "mozilla/Util.h"
#include "mozilla/AutoRestore.h"
#include "nsRefreshDriver.h"
#include "nsITimer.h"
#include "nsLayoutUtils.h"
@ -685,7 +685,8 @@ nsRefreshDriver::nsRefreshDriver(nsPresContext* aPresContext)
mThrottled(false),
mTestControllingRefreshes(false),
mViewManagerFlushIsPending(false),
mRequestedHighPrecision(false)
mRequestedHighPrecision(false),
mInRefresh(false)
{
mMostRecentRefreshEpochTime = JS_Now();
mMostRecentRefresh = TimeStamp::Now();
@ -1061,6 +1062,9 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
profiler_tracing("Paint", "RD", TRACING_INTERVAL_START);
AutoRestore<bool> restoreInRefresh(mInRefresh);
mInRefresh = true;
/*
* The timer holds a reference to |this| while calling |Notify|.
* However, implementations of |WillRefresh| are permitted to destroy
@ -1220,6 +1224,8 @@ nsRefreshDriver::Tick(int64_t aNowEpoch, TimeStamp aNowTime)
mPostRefreshObservers[i]->DidRefresh();
}
profiler_tracing("Paint", "RD", TRACING_INTERVAL_END);
NS_ASSERTION(mInRefresh, "Still in refresh");
}
/* static */ PLDHashOperator

View File

@ -249,6 +249,8 @@ public:
*/
static int32_t DefaultInterval();
bool IsInRefresh() { return mInRefresh; }
private:
typedef nsTObserverArray<nsARefreshObserver*> ObserverArray;
typedef nsTHashtable<nsISupportsHashKey> RequestTable;
@ -302,6 +304,7 @@ private:
bool mTestControllingRefreshes;
bool mViewManagerFlushIsPending;
bool mRequestedHighPrecision;
bool mInRefresh;
int64_t mMostRecentRefreshEpochTime;
mozilla::TimeStamp mMostRecentRefresh;