mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Bug 1264769 - Part 1: Dispatch loadend event for image loading. r=hsivonen
--HG-- extra : rebase_source : 8843a2a3c56c74dc1838f2da3c8251783e20f295
This commit is contained in:
parent
bafa8ffb78
commit
7d5abfc007
@ -230,8 +230,15 @@ nsImageLoadingContent::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus)
|
||||
// Fire the appropriate DOM event.
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
FireEvent(NS_LITERAL_STRING("load"));
|
||||
|
||||
// Do not fire loadend event for multipart/x-mixed-replace image streams.
|
||||
bool isMultipart;
|
||||
if (NS_FAILED(aRequest->GetMultipart(&isMultipart)) || !isMultipart) {
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
}
|
||||
} else {
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
}
|
||||
|
||||
nsCOMPtr<nsINode> thisNode = do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
|
||||
@ -628,7 +635,9 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
||||
// know what we tried (and failed) to load.
|
||||
if (!mCurrentRequest)
|
||||
aChannel->GetURI(getter_AddRefs(mCurrentURI));
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
aError.Throw(rv);
|
||||
}
|
||||
return listener.forget();
|
||||
@ -752,9 +761,10 @@ nsImageLoadingContent::LoadImage(const nsAString& aNewURI,
|
||||
nsCOMPtr<nsIURI> imageURI;
|
||||
nsresult rv = StringToURI(aNewURI, doc, getter_AddRefs(imageURI));
|
||||
if (NS_FAILED(rv)) {
|
||||
// Cancel image requests and fire error event per spec
|
||||
// Cancel image requests and then fire error and loadend events per spec
|
||||
CancelImageRequests(aNotify);
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -793,6 +803,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
||||
// XXX Why fire an error here? seems like the callers to SetLoadingEnabled
|
||||
// don't want/need it.
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -849,6 +860,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
||||
policyType);
|
||||
if (!NS_CP_ACCEPTED(cpDecision)) {
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
SetBlockedRequest(aNewURI, cpDecision);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -921,7 +933,9 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
|
||||
// know what we tried (and failed) to load.
|
||||
if (!mCurrentRequest)
|
||||
mCurrentURI = aNewURI;
|
||||
|
||||
FireEvent(NS_LITERAL_STRING("error"));
|
||||
FireEvent(NS_LITERAL_STRING("loadend"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,8 @@ private:
|
||||
/**
|
||||
* Method to fire an event once we know what's going on with the image load.
|
||||
*
|
||||
* @param aEventType "load" or "error" depending on how things went
|
||||
* @param aEventType "loadstart", "loadend", "load", or "error" depending on
|
||||
* how things went
|
||||
*/
|
||||
nsresult FireEvent(const nsAString& aEventType);
|
||||
|
||||
@ -318,7 +319,7 @@ protected:
|
||||
|
||||
/**
|
||||
* Cancels and nulls-out the "current" and "pending" requests if they exist.
|
||||
*
|
||||
*
|
||||
* @param aNonvisibleAction An action to take if the image is no longer
|
||||
* visible as a result; see |UntrackImage|.
|
||||
*/
|
||||
|
@ -286,6 +286,10 @@ EVENT(loadedmetadata,
|
||||
eLoadedMetaData,
|
||||
EventNameType_HTML,
|
||||
eBasicEventClass)
|
||||
EVENT(loadend,
|
||||
eLoadEnd,
|
||||
EventNameType_HTML,
|
||||
eBasicEventClass)
|
||||
EVENT(loadstart,
|
||||
eLoadStart,
|
||||
EventNameType_HTML,
|
||||
@ -705,7 +709,7 @@ NON_IDL_EVENT(DOMFocusOut,
|
||||
eLegacyDOMFocusOut,
|
||||
EventNameType_HTMLXUL,
|
||||
eUIEventClass)
|
||||
|
||||
|
||||
NON_IDL_EVENT(DOMMouseScroll,
|
||||
eLegacyMouseLineOrPageScroll,
|
||||
EventNameType_HTMLXUL,
|
||||
@ -714,7 +718,7 @@ NON_IDL_EVENT(MozMousePixelScroll,
|
||||
eLegacyMousePixelScroll,
|
||||
EventNameType_HTMLXUL,
|
||||
eMouseScrollEventClass)
|
||||
|
||||
|
||||
NON_IDL_EVENT(open,
|
||||
eOpen,
|
||||
EventNameType_None,
|
||||
|
@ -60,6 +60,7 @@ interface GlobalEventHandlers {
|
||||
attribute EventHandler onload;
|
||||
attribute EventHandler onloadeddata;
|
||||
attribute EventHandler onloadedmetadata;
|
||||
attribute EventHandler onloadend;
|
||||
attribute EventHandler onloadstart;
|
||||
attribute EventHandler onmousedown;
|
||||
[LenientThis] attribute EventHandler onmouseenter;
|
||||
|
@ -1,6 +0,0 @@
|
||||
[invalid-src.html]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[Loading a non-parsing URL as an image should silently fail; triggering appropriate events]
|
||||
expected: TIMEOUT
|
||||
|
@ -113,11 +113,12 @@ NS_EVENT_MESSAGE(eUnload)
|
||||
NS_EVENT_MESSAGE(eHashChange)
|
||||
NS_EVENT_MESSAGE(eImageAbort)
|
||||
NS_EVENT_MESSAGE(eLoadError)
|
||||
NS_EVENT_MESSAGE(eLoadEnd)
|
||||
NS_EVENT_MESSAGE(ePopState)
|
||||
NS_EVENT_MESSAGE(eStorage)
|
||||
NS_EVENT_MESSAGE(eBeforeUnload)
|
||||
NS_EVENT_MESSAGE(eReadyStateChange)
|
||||
|
||||
|
||||
NS_EVENT_MESSAGE(eFormSubmit)
|
||||
NS_EVENT_MESSAGE(eFormReset)
|
||||
NS_EVENT_MESSAGE(eFormChange)
|
||||
@ -164,7 +165,7 @@ NS_EVENT_MESSAGE_FIRST_LAST(eLegacyMutationEvent,
|
||||
eLegacySubtreeModified, eLegacyCharacterDataModified)
|
||||
|
||||
NS_EVENT_MESSAGE(eUnidentifiedEvent)
|
||||
|
||||
|
||||
// composition events
|
||||
NS_EVENT_MESSAGE(eCompositionStart)
|
||||
// eCompositionEnd is the message for DOM compositionend event.
|
||||
|
Loading…
x
Reference in New Issue
Block a user