Moved ns_observer_proc() to as close to the beginning of the file as possible to get rid of the static prototype that seemed to be confusing as and ld on FreeBSD 2.2. Okay'd by kipp and troy.

This commit is contained in:
briano%netscape.com 1999-04-30 01:58:44 +00:00
Родитель f4c399a6e8
Коммит ffc1865b04
2 изменённых файлов: 173 добавлений и 184 удалений

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

@ -33,10 +33,6 @@
static NS_DEFINE_IID(kIImageGroupIID, NS_IIMAGEGROUP_IID);
static void ns_observer_proc (XP_Observable aSource,
XP_ObservableMsg aMsg,
void* aMsgData,
void* aClosure);
class ImageGroupImpl : public nsIImageGroup
{
@ -116,6 +112,43 @@ ImageGroupImpl::~ImageGroupImpl()
NS_IMPL_ISUPPORTS(ImageGroupImpl, kIImageGroupIID)
static void ns_observer_proc (XP_Observable aSource,
XP_ObservableMsg aMsg,
void* aMsgData,
void* aClosure)
{
ImageGroupImpl *image_group = (ImageGroupImpl *)aClosure;
nsVoidArray *observer_list = image_group->GetObservers();
if (observer_list != nsnull) {
PRInt32 i, count = observer_list->Count();
nsIImageGroupObserver *observer;
for (i = 0; i < count; i++) {
observer = (nsIImageGroupObserver *)observer_list->ElementAt(i);
if (observer != nsnull) {
switch (aMsg) {
case IL_STARTED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kStartedLoading);
break;
case IL_ABORTED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kAbortedLoading);
case IL_FINISHED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kFinishedLoading);
case IL_STARTED_LOOPING:
observer->Notify(image_group,
nsImageGroupNotification_kStartedLooping);
case IL_FINISHED_LOOPING:
observer->Notify(image_group,
nsImageGroupNotification_kFinishedLooping);
}
}
}
}
}
static PRBool
ReconnectHack(void* arg, nsIStreamListener* aListener)
{
@ -310,42 +343,3 @@ NS_NewImageGroup(nsIImageGroup **aInstancePtrResult)
return group->QueryInterface(kIImageGroupIID, (void **) aInstancePtrResult);
}
static void ns_observer_proc (XP_Observable aSource,
XP_ObservableMsg aMsg,
void* aMsgData,
void* aClosure)
{
ImageGroupImpl *image_group = (ImageGroupImpl *)aClosure;
nsVoidArray *observer_list = image_group->GetObservers();
if (observer_list != nsnull) {
PRInt32 i, count = observer_list->Count();
nsIImageGroupObserver *observer;
for (i = 0; i < count; i++) {
observer = (nsIImageGroupObserver *)observer_list->ElementAt(i);
if (observer != nsnull) {
switch (aMsg) {
case IL_STARTED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kStartedLoading);
break;
case IL_ABORTED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kAbortedLoading);
case IL_FINISHED_LOADING:
observer->Notify(image_group,
nsImageGroupNotification_kFinishedLoading);
case IL_STARTED_LOOPING:
observer->Notify(image_group,
nsImageGroupNotification_kStartedLooping);
case IL_FINISHED_LOOPING:
observer->Notify(image_group,
nsImageGroupNotification_kFinishedLooping);
}
}
}
}
}

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

@ -29,7 +29,142 @@ static NS_DEFINE_IID(kIImageRequestIID, NS_IIMAGEREQUEST_IID);
static void ns_observer_proc (XP_Observable aSource,
XP_ObservableMsg aMsg,
void* aMsgData,
void* aClosure);
void* aClosure)
{
ImageRequestImpl *image_request = (ImageRequestImpl *)aClosure;
IL_MessageData *message_data = (IL_MessageData *)aMsgData;
nsVoidArray *observer_list = image_request->GetObservers();
nsIImage *image = nsnull;
// IL_ImageReq *il_image_req = image_request->GetImageRequest();
IL_ImageReq *il_image_req = (IL_ImageReq *)aSource;
if (il_image_req != nsnull) {
IL_Pixmap *pixmap = IL_GetImagePixmap(il_image_req);
if (pixmap != nsnull) {
image = (nsIImage *)pixmap->client_data;
}
}
if (observer_list != nsnull) {
PRInt32 i, count = observer_list->Count();
nsIImageRequestObserver *observer;
for (i = 0; i < count; i++) {
observer = (nsIImageRequestObserver *)observer_list->ElementAt(i);
if (observer != nsnull) {
switch (aMsg) {
case IL_START_URL:
observer->Notify(image_request,
image, nsImageNotification_kStartURL, 0, 0,
nsnull);
break;
case IL_DESCRIPTION:
observer->Notify(image_request,
image, nsImageNotification_kDescription, 0, 0,
message_data->description);
break;
case IL_DIMENSIONS:
observer->Notify(image_request,
image, nsImageNotification_kDimensions,
(PRInt32)message_data->width,
(PRInt32)message_data->height,
nsnull);
break;
case IL_IS_TRANSPARENT:
observer->Notify(image_request,
image, nsImageNotification_kIsTransparent, 0, 0,
nsnull);
break;
case IL_PIXMAP_UPDATE:
{
nsRect rect(message_data->update_rect.x_origin,
message_data->update_rect.y_origin,
message_data->update_rect.width,
message_data->update_rect.height);
observer->Notify(image_request,
image, nsImageNotification_kPixmapUpdate, 0, 0,
&rect);
}
break;
case IL_FRAME_COMPLETE:
observer->Notify(image_request,
image, nsImageNotification_kFrameComplete, 0, 0,
nsnull);
break;
case IL_PROGRESS:
observer->Notify(image_request,
image, nsImageNotification_kProgress,
message_data->percent_progress, 0,
nsnull);
break;
case IL_IMAGE_COMPLETE:
observer->Notify(image_request,
image, nsImageNotification_kImageComplete, 0, 0,
nsnull);
break;
case IL_STOP_URL:
observer->Notify(image_request,
image, nsImageNotification_kStopURL, 0, 0,
nsnull);
break;
case IL_IMAGE_DESTROYED:
image_request->SetImageRequest(nsnull);
observer->Notify(image_request,
image, nsImageNotification_kImageDestroyed, 0, 0,
nsnull);
break;
case IL_ABORTED:
observer->Notify(image_request,
image, nsImageNotification_kAborted, 0, 0,
nsnull);
break;
case IL_INTERNAL_IMAGE:
observer->Notify(image_request,
image, nsImageNotification_kInternalImage, 0, 0,
nsnull);
break;
case IL_NOT_IN_CACHE:
observer->NotifyError(image_request,
nsImageError_kNotInCache);
break;
case IL_ERROR_NO_DATA:
observer->NotifyError(image_request,
nsImageError_kNoData);
break;
case IL_ERROR_IMAGE_DATA_CORRUPT:
observer->NotifyError(image_request,
nsImageError_kImageDataCorrupt);
break;
case IL_ERROR_IMAGE_DATA_TRUNCATED:
observer->NotifyError(image_request,
nsImageError_kImageDataTruncated);
break;
case IL_ERROR_IMAGE_DATA_ILLEGAL:
observer->NotifyError(image_request,
nsImageError_kImageDataIllegal);
break;
case IL_ERROR_INTERNAL:
observer->NotifyError(image_request,
nsImageError_kInternalError);
break;
}
}
}
}
/*
* If the IL_ImageReq is being destroyed, clear the reference held by
* the nsImageRequestImpl...
*
* This will prevent a dangling reference in cases where the image group
* is destroyed before the image request...
*/
if ((IL_IMAGE_DESTROYED == aMsg) && (nsnull != image_request)) {
image_request->SetImageRequest(nsnull);
image_request->ImageDestroyed();
}
}
ImageRequestImpl::ImageRequestImpl()
{
@ -212,146 +347,6 @@ ImageRequestImpl::Interrupt()
}
static void ns_observer_proc (XP_Observable aSource,
XP_ObservableMsg aMsg,
void* aMsgData,
void* aClosure)
{
ImageRequestImpl *image_request = (ImageRequestImpl *)aClosure;
IL_MessageData *message_data = (IL_MessageData *)aMsgData;
nsVoidArray *observer_list = image_request->GetObservers();
nsIImage *image = nsnull;
// IL_ImageReq *il_image_req = image_request->GetImageRequest();
IL_ImageReq *il_image_req = (IL_ImageReq *)aSource;
if (il_image_req != nsnull) {
IL_Pixmap *pixmap = IL_GetImagePixmap(il_image_req);
if (pixmap != nsnull) {
image = (nsIImage *)pixmap->client_data;
}
}
if (observer_list != nsnull) {
PRInt32 i, count = observer_list->Count();
nsIImageRequestObserver *observer;
for (i = 0; i < count; i++) {
observer = (nsIImageRequestObserver *)observer_list->ElementAt(i);
if (observer != nsnull) {
switch (aMsg) {
case IL_START_URL:
observer->Notify(image_request,
image, nsImageNotification_kStartURL, 0, 0,
nsnull);
break;
case IL_DESCRIPTION:
observer->Notify(image_request,
image, nsImageNotification_kDescription, 0, 0,
message_data->description);
break;
case IL_DIMENSIONS:
observer->Notify(image_request,
image, nsImageNotification_kDimensions,
(PRInt32)message_data->width,
(PRInt32)message_data->height,
nsnull);
break;
case IL_IS_TRANSPARENT:
observer->Notify(image_request,
image, nsImageNotification_kIsTransparent, 0, 0,
nsnull);
break;
case IL_PIXMAP_UPDATE:
{
nsRect rect(message_data->update_rect.x_origin,
message_data->update_rect.y_origin,
message_data->update_rect.width,
message_data->update_rect.height);
observer->Notify(image_request,
image, nsImageNotification_kPixmapUpdate, 0, 0,
&rect);
}
break;
case IL_FRAME_COMPLETE:
observer->Notify(image_request,
image, nsImageNotification_kFrameComplete, 0, 0,
nsnull);
break;
case IL_PROGRESS:
observer->Notify(image_request,
image, nsImageNotification_kProgress,
message_data->percent_progress, 0,
nsnull);
break;
case IL_IMAGE_COMPLETE:
observer->Notify(image_request,
image, nsImageNotification_kImageComplete, 0, 0,
nsnull);
break;
case IL_STOP_URL:
observer->Notify(image_request,
image, nsImageNotification_kStopURL, 0, 0,
nsnull);
break;
case IL_IMAGE_DESTROYED:
image_request->SetImageRequest(nsnull);
observer->Notify(image_request,
image, nsImageNotification_kImageDestroyed, 0, 0,
nsnull);
break;
case IL_ABORTED:
observer->Notify(image_request,
image, nsImageNotification_kAborted, 0, 0,
nsnull);
break;
case IL_INTERNAL_IMAGE:
observer->Notify(image_request,
image, nsImageNotification_kInternalImage, 0, 0,
nsnull);
break;
case IL_NOT_IN_CACHE:
observer->NotifyError(image_request,
nsImageError_kNotInCache);
break;
case IL_ERROR_NO_DATA:
observer->NotifyError(image_request,
nsImageError_kNoData);
break;
case IL_ERROR_IMAGE_DATA_CORRUPT:
observer->NotifyError(image_request,
nsImageError_kImageDataCorrupt);
break;
case IL_ERROR_IMAGE_DATA_TRUNCATED:
observer->NotifyError(image_request,
nsImageError_kImageDataTruncated);
break;
case IL_ERROR_IMAGE_DATA_ILLEGAL:
observer->NotifyError(image_request,
nsImageError_kImageDataIllegal);
break;
case IL_ERROR_INTERNAL:
observer->NotifyError(image_request,
nsImageError_kInternalError);
break;
}
}
}
}
/*
* If the IL_ImageReq is being destroyed, clear the reference held by
* the nsImageRequestImpl...
*
* This will prevent a dangling reference in cases where the image group
* is destroyed before the image request...
*/
if ((IL_IMAGE_DESTROYED == aMsg) && (nsnull != image_request)) {
image_request->SetImageRequest(nsnull);
image_request->ImageDestroyed();
}
}
void
ImageRequestImpl::ImageDestroyed()
{