зеркало из https://github.com/mozilla/pjs.git
Make nsRefreshDriver hold a reference to its observers while notifying them. (Bug 531585) r=bzbarsky
This commit is contained in:
Родитель
7c795c0147
Коммит
fd03d03437
|
@ -44,6 +44,7 @@
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "prlog.h"
|
#include "prlog.h"
|
||||||
|
#include "nsAutoPtr.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO:
|
* TODO:
|
||||||
|
@ -194,10 +195,22 @@ nsRefreshDriver::Notify(nsITimer *aTimer)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The timer holds a reference to |this| while calling |Notify|.
|
||||||
|
* However, implementations of |WillRefresh| are permitted to destroy
|
||||||
|
* the pres context, which will cause our |mPresContext| to become
|
||||||
|
* null. If this happens, we must stop notifying observers.
|
||||||
|
*/
|
||||||
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(mObservers); ++i) {
|
for (PRUint32 i = 0; i < NS_ARRAY_LENGTH(mObservers); ++i) {
|
||||||
ObserverArray::EndLimitedIterator etor(mObservers[i]);
|
ObserverArray::EndLimitedIterator etor(mObservers[i]);
|
||||||
while (etor.HasMore()) {
|
while (etor.HasMore()) {
|
||||||
etor.GetNext()->WillRefresh(mMostRecentRefresh);
|
nsRefPtr<nsARefreshObserver> obs = etor.GetNext();
|
||||||
|
obs->WillRefresh(mMostRecentRefresh);
|
||||||
|
|
||||||
|
if (!mPresContext || !mPresContext->GetPresShell()) {
|
||||||
|
StopTimer();
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
// This is the Flush_Style case.
|
// This is the Flush_Style case.
|
||||||
|
|
|
@ -58,6 +58,15 @@ class nsPresContext;
|
||||||
*/
|
*/
|
||||||
class nsARefreshObserver {
|
class nsARefreshObserver {
|
||||||
public:
|
public:
|
||||||
|
// AddRef and Release signatures that match nsISupports. Implementors
|
||||||
|
// must implement reference counting, and those that do implement
|
||||||
|
// nsISupports will already have methods with the correct signature.
|
||||||
|
//
|
||||||
|
// The refresh driver does NOT hold references to refresh observers
|
||||||
|
// except while it is notifying them.
|
||||||
|
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
|
||||||
|
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
|
||||||
|
|
||||||
virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
|
virtual void WillRefresh(mozilla::TimeStamp aTime) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -93,6 +102,9 @@ public:
|
||||||
* painting, and, correspondingly, which get notified when there
|
* painting, and, correspondingly, which get notified when there
|
||||||
* is a flush during such suppression
|
* is a flush during such suppression
|
||||||
* and it must be either Flush_Style, Flush_Layout, or Flush_Display.
|
* and it must be either Flush_Style, Flush_Layout, or Flush_Display.
|
||||||
|
*
|
||||||
|
* The refresh driver does NOT own a reference to these observers;
|
||||||
|
* they must remove themselves before they are destroyed.
|
||||||
*/
|
*/
|
||||||
PRBool AddRefreshObserver(nsARefreshObserver *aObserver,
|
PRBool AddRefreshObserver(nsARefreshObserver *aObserver,
|
||||||
mozFlushType aFlushType);
|
mozFlushType aFlushType);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче