зеркало из https://github.com/mozilla/pjs.git
Added implementation of BeginUpdateViewBatch() and
EndUpdateViewBatch() to nsIViewManager and nsViewManager.
This commit is contained in:
Родитель
e88000567d
Коммит
5548735176
|
@ -357,6 +357,22 @@ public:
|
|||
*/
|
||||
NS_IMETHOD EnableRefresh(void) = 0;
|
||||
|
||||
/**
|
||||
* prevents the view manager from refreshing. allows UpdateView()
|
||||
* to notify widgets of damaged regions that should be repainted
|
||||
* when the batch is ended.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD BeginUpdateViewBatch(void) = 0;
|
||||
|
||||
/**
|
||||
* allow the view manager to refresh any damaged areas accumulated
|
||||
* after the BeginUpdateViewBatch() call. this may cause a
|
||||
* synchronous paint to occur inside the call.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD EndUpdateViewBatch(void) = 0;
|
||||
|
||||
/**
|
||||
* set the view that is is considered to be the root scrollable
|
||||
* view for the document.
|
||||
|
|
|
@ -102,6 +102,7 @@ static NS_DEFINE_IID(knsViewManagerIID, NS_IVIEWMANAGER_IID);
|
|||
nsViewManager :: nsViewManager()
|
||||
{
|
||||
mVMCount++;
|
||||
mUpdateBatchCnt = 0;
|
||||
}
|
||||
|
||||
nsViewManager :: ~nsViewManager()
|
||||
|
@ -1478,7 +1479,7 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, nsIRegion *aRegion, PR
|
|||
NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aView, "null view");
|
||||
if (!mRefreshEnabled) {
|
||||
if (!mRefreshEnabled && 0 == mUpdateBatchCnt) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1519,7 +1520,7 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
|
|||
|
||||
if (nsnull != widgetView)
|
||||
{
|
||||
if (0 == mUpdateCnt)
|
||||
if (0 == mUpdateCnt && 0 == mUpdateBatchCnt)
|
||||
RestartTimer();
|
||||
|
||||
mUpdateCnt++;
|
||||
|
@ -1548,19 +1549,22 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
|
|||
|
||||
// See if we should do an immediate refresh or wait
|
||||
|
||||
if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE)
|
||||
if (0 == mUpdateBatchCnt)
|
||||
{
|
||||
Composite();
|
||||
}
|
||||
else if ((mTrueFrameRate > 0) && !(aUpdateFlags & NS_VMREFRESH_NO_SYNC))
|
||||
{
|
||||
// or if a sync paint is allowed and it's time for the compositor to
|
||||
// do a refresh
|
||||
|
||||
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
|
||||
|
||||
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
|
||||
if (aUpdateFlags & NS_VMREFRESH_IMMEDIATE)
|
||||
{
|
||||
Composite();
|
||||
}
|
||||
else if ((mTrueFrameRate > 0) && !(aUpdateFlags & NS_VMREFRESH_NO_SYNC))
|
||||
{
|
||||
// or if a sync paint is allowed and it's time for the compositor to
|
||||
// do a refresh
|
||||
|
||||
PRInt32 deltams = PR_IntervalToMilliseconds(PR_IntervalNow() - mLastRefresh);
|
||||
|
||||
if (deltams > (1000 / (PRInt32)mTrueFrameRate))
|
||||
Composite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2367,6 +2371,39 @@ NS_IMETHODIMP nsViewManager :: EnableRefresh(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager :: BeginUpdateViewBatch(void)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
if (mUpdateBatchCnt == 0)
|
||||
result = DisableRefresh();
|
||||
|
||||
if (NS_SUCCEEDED(result))
|
||||
++mUpdateBatchCnt;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager :: EndUpdateViewBatch(void)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
--mUpdateBatchCnt;
|
||||
|
||||
NS_ASSERTION(mUpdateBatchCnt >= 0, "Invalid batch count!");
|
||||
|
||||
if (mUpdateBatchCnt < 0)
|
||||
{
|
||||
mUpdateBatchCnt = 0;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mUpdateBatchCnt == 0)
|
||||
result = EnableRefresh();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsViewManager :: SetRootScrollableView(nsIScrollableView *aScrollable)
|
||||
{
|
||||
mRootScrollable = aScrollable;
|
||||
|
|
|
@ -108,6 +108,9 @@ public:
|
|||
NS_IMETHOD DisableRefresh(void);
|
||||
NS_IMETHOD EnableRefresh(void);
|
||||
|
||||
NS_IMETHOD BeginUpdateViewBatch(void);
|
||||
NS_IMETHOD EndUpdateViewBatch(void);
|
||||
|
||||
NS_IMETHOD SetRootScrollableView(nsIScrollableView *aScrollable);
|
||||
NS_IMETHOD GetRootScrollableView(nsIScrollableView **aScrollable);
|
||||
|
||||
|
@ -155,6 +158,7 @@ private:
|
|||
nsIView *mMouseGrabber;
|
||||
nsIView *mKeyGrabber;
|
||||
PRInt32 mUpdateCnt;
|
||||
PRInt32 mUpdateBatchCnt;
|
||||
nsVoidArray *mDisplayList;
|
||||
nsIScrollableView *mRootScrollable;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче