зеркало из https://github.com/mozilla/gecko-dev.git
adding animation restart capibilities
This commit is contained in:
Родитель
964bf51e3f
Коммит
43e705186c
|
@ -38,6 +38,26 @@ public:
|
|||
mFrom, mFunc.get()));
|
||||
}
|
||||
|
||||
LogScope(void *from, const nsAReadableCString &fn,
|
||||
const nsLiteralCString ¶mName, const char *paramValue) :
|
||||
mFrom(from), mFunc(fn)
|
||||
{
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG, ("[this=%p] %s (%s=\"%s\") {ENTER}\n",
|
||||
mFrom, mFunc.get(),
|
||||
paramName.get(),
|
||||
paramValue));
|
||||
}
|
||||
|
||||
LogScope(void *from, const nsAReadableCString &fn,
|
||||
const nsLiteralCString ¶mName, void *paramValue) :
|
||||
mFrom(from), mFunc(fn)
|
||||
{
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG, ("[this=%p] %s (%s=%p) {ENTER}\n",
|
||||
mFrom, mFunc.get(),
|
||||
paramName.get(),
|
||||
paramValue));
|
||||
}
|
||||
|
||||
~LogScope() {
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG, ("[this=%p] %s {EXIT}\n",
|
||||
mFrom, mFunc.get()));
|
||||
|
@ -53,7 +73,19 @@ private:
|
|||
LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (NS_STATIC_CAST(void *, this), \
|
||||
NS_LITERAL_CSTRING(s))
|
||||
|
||||
#define LOG_SCOPE_STRING_PARAM(s, pn, pv) \
|
||||
LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (NS_STATIC_CAST(void *, this), \
|
||||
NS_LITERAL_CSTRING(s), \
|
||||
NS_LITERAL_CSTRING(pn), pv)
|
||||
|
||||
#define LOG_SCOPE_PTR_PARAM(s, pn, pv) \
|
||||
LogScope LOG_SCOPE_TMP_VAR ##__LINE__ (NS_STATIC_CAST(void *, this), \
|
||||
NS_LITERAL_CSTRING(s), \
|
||||
NS_LITERAL_CSTRING(pn), \
|
||||
NS_STATIC_CAST(void*, pv))
|
||||
|
||||
#else
|
||||
#define LOG_SCOPE(s)
|
||||
#define LOG_SCOPE_STRING_PARAM(s, pn, pv)
|
||||
#define gImgLog
|
||||
#endif
|
||||
|
|
|
@ -73,26 +73,18 @@ imgLoader::~imgLoader()
|
|||
PR_DestroyLock(mLock);
|
||||
#endif
|
||||
}
|
||||
#include "nsString.h"
|
||||
#include "nsAReadableString.h"
|
||||
|
||||
PRLogModuleInfo *testLog = PR_NewLogModule("test123");
|
||||
|
||||
/* imgIRequest loadImage (in nsIURI uri, in imgIDecoderObserver aObserver, in nsISupports cx); */
|
||||
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
|
||||
{
|
||||
LOG_SCOPE("imgLoader::LoadImage");
|
||||
|
||||
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
nsXPIDLCString spec;
|
||||
aURI->GetSpec(getter_Copies(spec));
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgLoader::LoadImage (aURI=%s) {ENTER}\n",
|
||||
this, spec.get()));
|
||||
LOG_SCOPE_STRING_PARAM("imgLoader::LoadImage", "aURI", spec.get());
|
||||
#endif
|
||||
|
||||
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
|
||||
|
||||
imgRequest *request = nsnull;
|
||||
|
||||
ImageCache::Get(aURI, &request); // addrefs
|
||||
|
|
|
@ -81,8 +81,7 @@ nsresult imgRequest::Init(nsIChannel *aChannel)
|
|||
|
||||
nsresult imgRequest::AddObserver(imgIDecoderObserver *observer)
|
||||
{
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::AddObserver (observer=%p)\n", this, observer));
|
||||
LOG_SCOPE_PTR_PARAM("imgRequest::AddObserver", "observer", observer);
|
||||
|
||||
mObservers.AppendElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
|
@ -98,24 +97,45 @@ nsresult imgRequest::AddObserver(imgIDecoderObserver *observer)
|
|||
if (mState & onStopDecode)
|
||||
observer->OnStopDecode(nsnull, nsnull, NS_OK, nsnull);
|
||||
|
||||
if (mObservers.Count() == 1) {
|
||||
PRUint32 nframes;
|
||||
mImage->GetNumFrames(&nframes);
|
||||
if (nframes > 0) {
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::AddObserver -- starting animation\n", this));
|
||||
|
||||
mImage->StartAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult imgRequest::RemoveObserver(imgIDecoderObserver *observer, nsresult status)
|
||||
{
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::RemoveObserver (observer=%p) {ENTER}\n",
|
||||
this, observer));
|
||||
LOG_SCOPE_PTR_PARAM("imgRequest::RemoveObserver", "observer", observer);
|
||||
|
||||
mObservers.RemoveElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
if ((mObservers.Count() == 0) && mChannel && mProcessing) {
|
||||
this->Cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
if (mObservers.Count() == 0) {
|
||||
if (mImage) {
|
||||
PRUint32 nframes;
|
||||
mImage->GetNumFrames(&nframes);
|
||||
if (nframes > 0) {
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::RemoveObserver -- stopping animation\n", this));
|
||||
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::RemoveObserver {EXIT}\n",
|
||||
this));
|
||||
mImage->StopAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
if (mChannel && mProcessing) {
|
||||
PR_LOG(gImgLog, PR_LOG_DEBUG,
|
||||
("[this=%p] imgRequest::RemoveObserver -- load in progress. canceling\n", this));
|
||||
|
||||
this->Cancel(NS_BINDING_ABORTED);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче