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:
Jeff Muizelaar
2012-07-04 11:42:29 -04:00
parent b69cbd104c
commit 5f70f009a4
5 changed files with 29 additions and 0 deletions

View File

@@ -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;
};