diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index e153edb5a69e..7bcb0427b828 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -185,6 +185,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext, NS_IF_RELEASE(baseURL); mInitialLoadCompleted = PR_FALSE; + mCanSendLoadEvent = PR_TRUE; return rv; } @@ -237,6 +238,13 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus, void* // or both failed to load, then notify the PresShell if (imageFailedToLoad) { if (presShell) { + // Also send error event + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_IMAGE_ERROR; + presShell->HandleEventWithTarget(&event,this,mContent,&status); + nsAutoString usemap; mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap); // We failed to load the image. Notify the pres shell if we aren't an image map @@ -254,6 +262,20 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus, void* } } + if (mCanSendLoadEvent && + !imageFailedToLoad && + (NS_IMAGE_LOAD_STATUS_IMAGE_READY & aStatus) && + presShell) { + // Send load event + mCanSendLoadEvent = PR_FALSE; + + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_IMAGE_LOAD; + presShell->HandleEventWithTarget(&event,this,mContent,&status); + } + #if 0 // ifdef'ing out the deleting of the lowsrc image // if the "src" image was change via script to an iage that // didn't exist, the the author would expect the lowsrc to be displayed. @@ -1030,6 +1052,8 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext, // Stop the earlier image load mImageLoader.StopLoadImage(aPresContext); + mCanSendLoadEvent = PR_TRUE; + // Update the URL and start the new image load mImageLoader.UpdateURLSpec(aPresContext, newSRC); } diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 618d87a5acc2..aeeeb4979efa 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -132,6 +132,7 @@ protected: nsImageMap* mImageMap; PRPackedBool mSizeFrozen; PRPackedBool mInitialLoadCompleted; + PRPackedBool mCanSendLoadEvent; nsMargin mBorderPadding; }; diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index e153edb5a69e..7bcb0427b828 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -185,6 +185,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext, NS_IF_RELEASE(baseURL); mInitialLoadCompleted = PR_FALSE; + mCanSendLoadEvent = PR_TRUE; return rv; } @@ -237,6 +238,13 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus, void* // or both failed to load, then notify the PresShell if (imageFailedToLoad) { if (presShell) { + // Also send error event + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_IMAGE_ERROR; + presShell->HandleEventWithTarget(&event,this,mContent,&status); + nsAutoString usemap; mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap); // We failed to load the image. Notify the pres shell if we aren't an image map @@ -254,6 +262,20 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus, void* } } + if (mCanSendLoadEvent && + !imageFailedToLoad && + (NS_IMAGE_LOAD_STATUS_IMAGE_READY & aStatus) && + presShell) { + // Send load event + mCanSendLoadEvent = PR_FALSE; + + nsEventStatus status = nsEventStatus_eIgnore; + nsEvent event; + event.eventStructType = NS_EVENT; + event.message = NS_IMAGE_LOAD; + presShell->HandleEventWithTarget(&event,this,mContent,&status); + } + #if 0 // ifdef'ing out the deleting of the lowsrc image // if the "src" image was change via script to an iage that // didn't exist, the the author would expect the lowsrc to be displayed. @@ -1030,6 +1052,8 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext, // Stop the earlier image load mImageLoader.StopLoadImage(aPresContext); + mCanSendLoadEvent = PR_TRUE; + // Update the URL and start the new image load mImageLoader.UpdateURLSpec(aPresContext, newSRC); } diff --git a/layout/html/base/src/nsImageFrame.h b/layout/html/base/src/nsImageFrame.h index 618d87a5acc2..aeeeb4979efa 100644 --- a/layout/html/base/src/nsImageFrame.h +++ b/layout/html/base/src/nsImageFrame.h @@ -132,6 +132,7 @@ protected: nsImageMap* mImageMap; PRPackedBool mSizeFrozen; PRPackedBool mInitialLoadCompleted; + PRPackedBool mCanSendLoadEvent; nsMargin mBorderPadding; }; diff --git a/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/layout/html/forms/src/nsGfxTextControlFrame2.cpp index b65c015b24f2..b99ba0243d9e 100644 --- a/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -321,11 +321,9 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelectio mFrame->GetFormContent(*getter_AddRefs(content)); if (content) { nsEventStatus status = nsEventStatus_eIgnore; - nsGUIEvent event; - event.eventStructType = NS_GUI_EVENT; - event.widget = nsnull; + nsEvent event; + event.eventStructType = NS_EVENT; event.message = NS_FORM_SELECTED; - event.flags = NS_EVENT_FLAG_INIT; nsCOMPtr doc; if (NS_SUCCEEDED(content->GetDocument(*getter_AddRefs(doc)))) {