Bug 1264769 - Patch 2: Dispatch loadstart event for image loading, r=hsivonen

--HG--
extra : rebase_source : 8d10beb495f631364a95c4247e31cae2b04c6f63
This commit is contained in:
Ben Tian 2016-10-05 10:06:27 +08:00
Родитель 50934d0360
Коммит e2f03e4b07
2 изменённых файлов: 15 добавлений и 4 удалений

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

@ -660,7 +660,7 @@ nsImageLoadingContent::ForceReload(const mozilla::dom::Optional<bool>& aNotify,
ImageLoadType loadType = \
(mCurrentRequestFlags & REQUEST_IS_IMAGESET) ? eImageLoadType_Imageset
: eImageLoadType_Normal;
nsresult rv = LoadImage(currentURI, true, notify, loadType, nullptr,
nsresult rv = LoadImage(currentURI, true, notify, loadType, true, nullptr,
nsIRequest::VALIDATE_ALWAYS);
if (NS_FAILED(rv)) {
aError.Throw(rv);
@ -751,7 +751,10 @@ nsImageLoadingContent::LoadImage(const nsAString& aNewURI,
return NS_OK;
}
// Second, parse the URI string to get image URI
// Fire loadstart event
FireEvent(NS_LITERAL_STRING("loadstart"));
// Parse the URI string to get image URI
nsCOMPtr<nsIURI> imageURI;
nsresult rv = StringToURI(aNewURI, doc, getter_AddRefs(imageURI));
if (NS_FAILED(rv)) {
@ -764,7 +767,7 @@ nsImageLoadingContent::LoadImage(const nsAString& aNewURI,
NS_TryToSetImmutable(imageURI);
return LoadImage(imageURI, aForce, aNotify, aImageLoadType, doc);
return LoadImage(imageURI, aForce, aNotify, aImageLoadType, false, doc);
}
nsresult
@ -772,9 +775,15 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI,
bool aForce,
bool aNotify,
ImageLoadType aImageLoadType,
bool aLoadStart,
nsIDocument* aDocument,
nsLoadFlags aLoadFlags)
{
// Fire loadstart event if required
if (aLoadStart) {
FireEvent(NS_LITERAL_STRING("loadstart"));
}
if (!mLoadingEnabled) {
// XXX Why fire an error here? seems like the callers to SetLoadingEnabled
// don't want/need it.

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

@ -126,13 +126,15 @@ protected:
* @param aNotify If true, nsIDocumentObserver state change notifications
* will be sent as needed.
* @param aImageLoadType The ImageLoadType for this request
* @param aLoadStart If true, dispatch "loadstart" event.
* @param aDocument Optional parameter giving the document this node is in.
* This is purely a performance optimization.
* @param aLoadFlags Optional parameter specifying load flags to use for
* the image load
*/
nsresult LoadImage(nsIURI* aNewURI, bool aForce, bool aNotify,
ImageLoadType aImageLoadType, nsIDocument* aDocument = nullptr,
ImageLoadType aImageLoadType, bool aLoadStart = true,
nsIDocument* aDocument = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL);
/**