Bug 666446, Part 6/18 - Change nsBulletFrame to utilize refresh driver-based animations for performance improvements. [r=roc]

This commit is contained in:
Scott Johnson 2011-10-03 13:39:05 -07:00
Родитель 1b3c2d715f
Коммит f3191051d8
2 изменённых файлов: 49 добавлений и 3 удалений

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

@ -78,6 +78,7 @@ public:
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, imgIContainer *aImage);
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, bool aCurrentFrame,
const nsIntRect *aRect);
NS_IMETHOD OnStartDecode(imgIRequest *aRequest);
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult status,
const PRUnichar *statusArg);
// imgIContainerObserver (override nsStubImageDecoderObserver)
@ -101,6 +102,10 @@ nsBulletFrame::DestroyFrom(nsIFrame* aDestructRoot)
{
// Stop image loading first
if (mImageRequest) {
// Deregister our image request from the refresh driver
nsLayoutUtils::DeregisterImageRequest(PresContext(),
mImageRequest,
&mRequestRegistered);
mImageRequest->CancelAndForgetObserver(NS_ERROR_FAILURE);
mImageRequest = nsnull;
}
@ -170,6 +175,8 @@ nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (same) {
needNewRequest = PR_FALSE;
} else {
nsLayoutUtils::DeregisterImageRequest(PresContext(), mImageRequest,
&mRequestRegistered);
mImageRequest->Cancel(NS_ERROR_FAILURE);
mImageRequest = nsnull;
}
@ -178,10 +185,15 @@ nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
if (needNewRequest) {
newRequest->Clone(mListener, getter_AddRefs(mImageRequest));
nsLayoutUtils::RegisterImageRequest(PresContext(), mImageRequest,
&mRequestRegistered);
}
} else {
// No image request on the new style context
if (mImageRequest) {
nsLayoutUtils::DeregisterImageRequest(PresContext(), mImageRequest,
&mRequestRegistered);
mImageRequest->Cancel(NS_ERROR_FAILURE);
mImageRequest = nsnull;
}
@ -1521,6 +1533,17 @@ NS_IMETHODIMP nsBulletFrame::OnDataAvailable(imgIRequest *aRequest,
return NS_OK;
}
NS_IMETHODIMP nsBulletFrame::OnStartDecode(imgIRequest* aRequest)
{
// Register the image request with the refresh driver.
if (aRequest == mImageRequest) {
nsLayoutUtils::RegisterImageRequest(PresContext(), mImageRequest,
&mRequestRegistered);
}
return NS_OK;
}
NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
const PRUnichar *aStatusArg)
@ -1537,6 +1560,14 @@ NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest,
}
#endif
// Deregister the imgIRequest with the refresh driver if the
// image is not animated.
if (aRequest == mImageRequest) {
nsLayoutUtils::DeregisterImageRequestIfNotAnimated(PresContext(),
mImageRequest,
&mRequestRegistered);
}
return NS_OK;
}
@ -1634,17 +1665,25 @@ NS_IMETHODIMP nsBulletListener::OnDataAvailable(imgIRequest *aRequest,
const nsIntRect *aRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return NS_OK;
return mFrame->OnDataAvailable(aRequest, aCurrentFrame, aRect);
}
NS_IMETHODIMP nsBulletListener::OnStartDecode(imgIRequest *aRequest)
{
if (!mFrame)
return NS_OK;
return mFrame->OnStartDecode(aRequest);
}
NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest,
nsresult status,
const PRUnichar *statusArg)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return NS_OK;
return mFrame->OnStopDecode(aRequest, status, statusArg);
}
@ -1653,7 +1692,7 @@ NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer,
const nsIntRect *aDirtyRect)
{
if (!mFrame)
return NS_ERROR_FAILURE;
return NS_OK;
return mFrame->FrameChanged(aContainer, aDirtyRect);
}

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

@ -84,6 +84,7 @@ public:
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest,
bool aCurrentFrame,
const nsIntRect *aRect);
NS_IMETHOD OnStartDecode(imgIRequest *aRequest);
NS_IMETHOD OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
const PRUnichar *aStatusArg);
@ -121,6 +122,12 @@ protected:
nsSize mComputedSize;
PRInt32 mOrdinal;
bool mTextIsRTL;
private:
// This is a boolean flag indicating whether or not the current image request
// has been registered with the refresh driver.
bool mRequestRegistered;
};
#endif /* nsBulletFrame_h___ */