mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 764188 - Expose a global frame tree generation number. r=dbaron
This generation number will be incremented every time that the frame tree for a presshell changes. Callers need to deal with the case where this value overflows. We use this to avoid a bunch of Android screenshotting.
This commit is contained in:
parent
4d76ce67d0
commit
6d2bb0d368
@ -8265,6 +8265,7 @@ nsCSSFrameConstructor::BeginUpdate() {
|
||||
rootPresContext->IncrementDOMGeneration();
|
||||
}
|
||||
|
||||
++sGlobalGenerationNumber;
|
||||
++mUpdateCount;
|
||||
}
|
||||
|
||||
|
@ -1993,3 +1993,5 @@ nsFrameManagerBase::UndisplayedMap::Clear(void)
|
||||
mLastLookup = nsnull;
|
||||
PL_HashTableEnumerateEntries(mTable, RemoveUndisplayedEntry, 0);
|
||||
}
|
||||
|
||||
PRUint32 nsFrameManagerBase::sGlobalGenerationNumber;
|
||||
|
@ -53,6 +53,8 @@ public:
|
||||
mRootFrame = aRootFrame;
|
||||
}
|
||||
|
||||
static PRUint32 GetGlobalGenerationNumber() { return sGlobalGenerationNumber; }
|
||||
|
||||
protected:
|
||||
class UndisplayedMap;
|
||||
|
||||
@ -64,6 +66,16 @@ protected:
|
||||
PLDHashTable mPlaceholderMap;
|
||||
UndisplayedMap* mUndisplayedMap;
|
||||
bool mIsDestroyingFrames; // The frame manager is destroying some frame(s).
|
||||
|
||||
// The frame tree generation number
|
||||
// We use this to avoid unnecessary screenshotting
|
||||
// on Android. Unfortunately, this is static to match
|
||||
// the single consumer which is also static. Keeping
|
||||
// this the same greatly simplifies lifetime issues and
|
||||
// makes sure we always using the correct number.
|
||||
// A per PresContext generation number is available
|
||||
// via nsPresContext::GetDOMGeneration
|
||||
static PRUint32 sGlobalGenerationNumber;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1350,6 +1350,9 @@ public:
|
||||
|
||||
/**
|
||||
* Get the current DOM generation counter.
|
||||
*
|
||||
* See nsFrameManagerBase::GetGlobalGenerationNumber() for a
|
||||
* global generation number.
|
||||
*/
|
||||
PRUint32 GetDOMGeneration() { return mDOMGeneration; }
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsIDOMClientRect.h"
|
||||
#include "nsIDOMWakeLockListener.h"
|
||||
#include "nsIPowerManagerService.h"
|
||||
#include "nsFrameManager.h"
|
||||
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
@ -117,6 +118,15 @@ class AfterPaintListener : public nsIDOMEventListener {
|
||||
}
|
||||
|
||||
virtual nsresult HandleEvent(nsIDOMEvent* aEvent) {
|
||||
PRUint32 generation = nsFrameManager::GetGlobalGenerationNumber();
|
||||
if (mLastGeneration == generation) {
|
||||
// the frame tree has not changed since our last AfterPaint
|
||||
// so we can drop this event.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mLastGeneration = generation;
|
||||
|
||||
nsCOMPtr<nsIDOMNotifyPaintEvent> paintEvent = do_QueryInterface(aEvent);
|
||||
if (!paintEvent)
|
||||
return NS_OK;
|
||||
@ -139,6 +149,7 @@ class AfterPaintListener : public nsIDOMEventListener {
|
||||
}
|
||||
|
||||
private:
|
||||
PRUint32 mLastGeneration;
|
||||
nsCOMPtr<nsIDOMEventTarget> mEventTarget;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user