Bug 563327 part 1. Expose an nsIPresShell API for refresh observers. r=roc

This commit is contained in:
Boris Zbarsky 2010-06-14 16:06:49 -04:00
Родитель 44545d494f
Коммит 075d271004
3 изменённых файлов: 64 добавлений и 4 удалений

Просмотреть файл

@ -11835,8 +11835,7 @@ nsCSSFrameConstructor::PostRestyleEventInternal(PRBool aForLazyConstruction)
// add ourselves as a refresh observer until then.
PRBool inRefresh = aForLazyConstruction ? mInLazyFCRefresh : mInStyleRefresh;
if (!mObservingRefreshDriver && !inRefresh) {
mObservingRefreshDriver = mPresShell->GetPresContext()->
RefreshDriver()->AddRefreshObserver(this, Flush_Style);
mObservingRefreshDriver = mPresShell->AddRefreshObserver(this, Flush_Style);
}
}
@ -11848,8 +11847,7 @@ nsCSSFrameConstructor::WillRefresh(mozilla::TimeStamp aTime)
// a refresh so we don't restart due to animation-triggered
// restyles. The actual work of processing our restyles will get
// done when the refresh driver flushes styles.
mPresShell->GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(this, Flush_Style);
mPresShell->RemoveRefreshObserver(this, Flush_Style);
mObservingRefreshDriver = PR_FALSE;
mInLazyFCRefresh = PR_TRUE;
mInStyleRefresh = PR_TRUE;

Просмотреть файл

@ -67,6 +67,7 @@
#include "mozFlushType.h"
#include "nsWeakReference.h"
#include <stdio.h> // for FILE definition
#include "nsRefreshDriver.h"
class nsIContent;
class nsIDocument;
@ -999,6 +1000,37 @@ public:
PRUint64 GetPaintCount() { return mPaintCount; }
void IncrementPaintCount() { ++mPaintCount; }
/**
* Refresh observer management.
*/
protected:
virtual PRBool AddRefreshObserverExternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType);
PRBool AddRefreshObserverInternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType);
virtual PRBool RemoveRefreshObserverExternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType);
PRBool RemoveRefreshObserverInternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType);
public:
PRBool AddRefreshObserver(nsARefreshObserver* aObserver,
mozFlushType aFlushType) {
#ifdef _IMPL_NS_LAYOUT
return AddRefreshObserverInternal(aObserver, aFlushType);
#else
return AddRefreshObserverExternal(aObserver, aFlushType);
#endif
}
PRBool RemoveRefreshObserver(nsARefreshObserver* aObserver,
mozFlushType aFlushType) {
#ifdef _IMPL_NS_LAYOUT
return RemoveRefreshObserverInternal(aObserver, aFlushType);
#else
return RemoveRefreshObserverExternal(aObserver, aFlushType);
#endif
}
/**
* Initialize and shut down static variables.
*/

Просмотреть файл

@ -7761,6 +7761,36 @@ PresShell::Observe(nsISupports* aSubject,
return NS_ERROR_FAILURE;
}
PRBool
nsIPresShell::AddRefreshObserverInternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType)
{
return GetPresContext()->RefreshDriver()->
AddRefreshObserver(aObserver, aFlushType);
}
/* virtual */ PRBool
nsIPresShell::AddRefreshObserverExternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType)
{
return AddRefreshObserverInternal(aObserver, aFlushType);
}
PRBool
nsIPresShell::RemoveRefreshObserverInternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType)
{
return GetPresContext()->RefreshDriver()->
RemoveRefreshObserver(aObserver, aFlushType);
}
/* virtual */ PRBool
nsIPresShell::RemoveRefreshObserverExternal(nsARefreshObserver* aObserver,
mozFlushType aFlushType)
{
return RemoveRefreshObserverInternal(aObserver, aFlushType);
}
//------------------------------------------------------
// End of protected and private methods on the PresShell
//------------------------------------------------------