зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1911605 - Make decode() checks for "will we replace the current request" cheaper. r=smaug
No behavior change but this is cheaper and more straight-forward (doesn't depend on the innards of PrepareNextRequest). Differential Revision: https://phabricator.services.mozilla.com/D218543
This commit is contained in:
Родитель
83c38a9417
Коммит
e6fc1a88bb
|
@ -951,20 +951,13 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
|
|||
// Shouldn't that be done before the start of the load?
|
||||
// XXX what about shouldProcess?
|
||||
|
||||
// If we have a current request without a size, we know we will replace it
|
||||
// with the PrepareNextRequest below. If the new current request is for a
|
||||
// different URI, then we need to reject any outstanding promises.
|
||||
if (mCurrentRequest && !HaveSize(mCurrentRequest)) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
MaybeAgeRequestGeneration(uri);
|
||||
}
|
||||
|
||||
// Our state might change. Watch it.
|
||||
AutoStateChanger changer(this, true);
|
||||
|
||||
// Do the load.
|
||||
RefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
RefPtr<imgRequestProxy>& req = PrepareNextRequest(eImageLoadType_Normal, uri);
|
||||
nsresult rv = loader->LoadImageWithChannel(aChannel, this, doc, aListener,
|
||||
getter_AddRefs(req));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
|
@ -1105,13 +1098,6 @@ nsresult nsImageLoadingContent::LoadImage(nsIURI* aNewURI, bool aForce,
|
|||
}
|
||||
}
|
||||
|
||||
// If we have a current request without a size, we know we will replace it
|
||||
// with the PrepareNextRequest below. If the new current request is for a
|
||||
// different URI, then we need to reject any outstanding promises.
|
||||
if (mCurrentRequest && !HaveSize(mCurrentRequest)) {
|
||||
MaybeAgeRequestGeneration(aNewURI);
|
||||
}
|
||||
|
||||
// From this point on, our image state could change. Watch it.
|
||||
AutoStateChanger changer(this, aNotify);
|
||||
|
||||
|
@ -1126,7 +1112,8 @@ nsresult nsImageLoadingContent::LoadImage(nsIURI* aNewURI, bool aForce,
|
|||
nsLoadFlags loadFlags =
|
||||
aLoadFlags | nsContentUtils::CORSModeToLoadImageFlags(GetCORSMode());
|
||||
|
||||
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType);
|
||||
RefPtr<imgRequestProxy>& req = PrepareNextRequest(aImageLoadType, aNewURI);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal;
|
||||
bool result = nsContentUtils::QueryTriggeringPrincipal(
|
||||
element, aTriggeringPrincipal, getter_AddRefs(triggeringPrincipal));
|
||||
|
@ -1464,19 +1451,23 @@ void nsImageLoadingContent::CancelPendingEvent() {
|
|||
}
|
||||
|
||||
RefPtr<imgRequestProxy>& nsImageLoadingContent::PrepareNextRequest(
|
||||
ImageLoadType aImageLoadType) {
|
||||
ImageLoadType aImageLoadType, nsIURI* aNewURI) {
|
||||
MaybeForceSyncDecoding(/* aPrepareNextRequest */ true);
|
||||
|
||||
// We only want to cancel the existing current request if size is not
|
||||
// available. bz says the web depends on this behavior.
|
||||
// Otherwise, we get rid of any half-baked request that might be sitting there
|
||||
// and make this one current.
|
||||
return HaveSize(mCurrentRequest) ? PreparePendingRequest(aImageLoadType)
|
||||
: PrepareCurrentRequest(aImageLoadType);
|
||||
return HaveSize(mCurrentRequest)
|
||||
? PreparePendingRequest(aImageLoadType)
|
||||
: PrepareCurrentRequest(aImageLoadType, aNewURI);
|
||||
}
|
||||
|
||||
RefPtr<imgRequestProxy>& nsImageLoadingContent::PrepareCurrentRequest(
|
||||
ImageLoadType aImageLoadType) {
|
||||
ImageLoadType aImageLoadType, nsIURI* aNewURI) {
|
||||
if (mCurrentRequest) {
|
||||
MaybeAgeRequestGeneration(aNewURI);
|
||||
}
|
||||
// Get rid of anything that was there previously.
|
||||
ClearCurrentRequest(NS_BINDING_ABORTED, Some(OnNonvisible::DiscardImages));
|
||||
|
||||
|
@ -1531,7 +1522,6 @@ void nsImageLoadingContent::MakePendingRequestCurrent() {
|
|||
// URI, then we need to reject any outstanding promises.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mPendingRequest->GetURI(getter_AddRefs(uri));
|
||||
MaybeAgeRequestGeneration(uri);
|
||||
|
||||
// Lock mCurrentRequest for the duration of this method. We do this because
|
||||
// PrepareCurrentRequest() might unlock mCurrentRequest. If mCurrentRequest
|
||||
|
@ -1544,7 +1534,7 @@ void nsImageLoadingContent::MakePendingRequestCurrent() {
|
|||
? eImageLoadType_Imageset
|
||||
: eImageLoadType_Normal;
|
||||
|
||||
PrepareCurrentRequest(loadType) = mPendingRequest;
|
||||
PrepareCurrentRequest(loadType, uri) = mPendingRequest;
|
||||
MakePendingScriptedRequestsCurrent();
|
||||
mPendingRequest = nullptr;
|
||||
mCurrentRequestFlags = mPendingRequestFlags;
|
||||
|
|
|
@ -391,8 +391,9 @@ class nsImageLoadingContent : public nsIImageLoadingContent {
|
|||
* request.
|
||||
*
|
||||
* @param aImageLoadType The ImageLoadType for this request
|
||||
* @param aNewURI The uri that we're going to load
|
||||
*/
|
||||
RefPtr<imgRequestProxy>& PrepareNextRequest(ImageLoadType aImageLoadType);
|
||||
RefPtr<imgRequestProxy>& PrepareNextRequest(ImageLoadType, nsIURI* aNewURI);
|
||||
|
||||
/**
|
||||
* Returns a COMPtr reference to the current/pending image requests, cleaning
|
||||
|
@ -401,9 +402,11 @@ class nsImageLoadingContent : public nsIImageLoadingContent {
|
|||
* Clear*Request(NS_BINDING_ABORTED) instead.
|
||||
*
|
||||
* @param aImageLoadType The ImageLoadType for this request
|
||||
* @param aNewURI The uri that we're going to load
|
||||
*/
|
||||
RefPtr<imgRequestProxy>& PrepareCurrentRequest(ImageLoadType aImageLoadType);
|
||||
RefPtr<imgRequestProxy>& PreparePendingRequest(ImageLoadType aImageLoadType);
|
||||
RefPtr<imgRequestProxy>& PrepareCurrentRequest(ImageLoadType,
|
||||
nsIURI* aNewURI);
|
||||
RefPtr<imgRequestProxy>& PreparePendingRequest(ImageLoadType);
|
||||
|
||||
/**
|
||||
* Switch our pending request to be our current request.
|
||||
|
|
Загрузка…
Ссылка в новой задаче