mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1338086 - Remove useless else blocks in order to reduce complexity image/ r=dholbert
MozReview-Commit-ID: 8qUQk8w0QSk --HG-- extra : rebase_source : c7451383027a14144490d2a8d2639f73cead1a5c
This commit is contained in:
parent
345833852a
commit
a54302b9d6
@ -179,13 +179,12 @@ GetIconSize(nsIMozIconURI* aIconURI)
|
||||
mozilla::DebugOnly<nsresult> rv = aIconURI->GetImageSize(&size);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "GetImageSize failed");
|
||||
return size;
|
||||
} else {
|
||||
int size;
|
||||
|
||||
GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
|
||||
gtk_icon_size_lookup(icon_size, &size, nullptr);
|
||||
return size;
|
||||
}
|
||||
int size;
|
||||
|
||||
GtkIconSize icon_size = moz_gtk_icon_size(iconSizeString.get());
|
||||
gtk_icon_size_lookup(icon_size, &size, nullptr);
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Scale icon buffer to preferred size */
|
||||
|
@ -645,8 +645,9 @@ ValidateSecurityInfo(imgRequest* request, bool forcePrincipalCheck,
|
||||
// document principal isn't the same, we can't use this request.
|
||||
if (request->GetCORSMode() != corsmode) {
|
||||
return false;
|
||||
} else if (request->GetCORSMode() != imgIRequest::CORS_NONE ||
|
||||
forcePrincipalCheck) {
|
||||
}
|
||||
if (request->GetCORSMode() != imgIRequest::CORS_NONE ||
|
||||
forcePrincipalCheck) {
|
||||
nsCOMPtr<nsIPrincipal> otherprincipal = request->GetLoadingPrincipal();
|
||||
|
||||
// If we previously had a principal, but we don't now, we can't use this
|
||||
@ -1338,9 +1339,9 @@ imgLoader::ClearCache(bool chrome)
|
||||
|
||||
if (chrome) {
|
||||
return ClearChromeImageCache();
|
||||
} else {
|
||||
return ClearImageCache();
|
||||
}
|
||||
return ClearImageCache();
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1633,80 +1634,79 @@ imgLoader::ValidateRequestWithNewChannel(imgRequest* request,
|
||||
|
||||
return NS_SUCCEEDED(rv);
|
||||
|
||||
} else {
|
||||
// We will rely on Necko to cache this request when it's possible, and to
|
||||
// tell imgCacheValidator::OnStartRequest whether the request came from its
|
||||
// cache.
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
bool forcePrincipalCheck;
|
||||
rv = NewImageChannel(getter_AddRefs(newChannel),
|
||||
&forcePrincipalCheck,
|
||||
aURI,
|
||||
aInitialDocumentURI,
|
||||
aCORSMode,
|
||||
aReferrerURI,
|
||||
aReferrerPolicy,
|
||||
aLoadGroup,
|
||||
mAcceptHeader,
|
||||
aLoadFlags,
|
||||
aLoadPolicyType,
|
||||
aLoadingPrincipal,
|
||||
aCX,
|
||||
mRespectPrivacy);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<imgRequestProxy> req;
|
||||
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
|
||||
aLoadFlags, getter_AddRefs(req));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure that OnStatus/OnProgress calls have the right request set...
|
||||
RefPtr<nsProgressNotificationProxy> progressproxy =
|
||||
new nsProgressNotificationProxy(newChannel, req);
|
||||
if (!progressproxy) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<imgCacheValidator> hvc =
|
||||
new imgCacheValidator(progressproxy, this, request, aCX,
|
||||
forcePrincipalCheck);
|
||||
|
||||
// Casting needed here to get past multiple inheritance.
|
||||
nsCOMPtr<nsIStreamListener> listener =
|
||||
do_QueryInterface(static_cast<nsIThreadRetargetableStreamListener*>(hvc));
|
||||
NS_ENSURE_TRUE(listener, false);
|
||||
|
||||
// We must set the notification callbacks before setting up the
|
||||
// CORS listener, because that's also interested inthe
|
||||
// notification callbacks.
|
||||
newChannel->SetNotificationCallbacks(hvc);
|
||||
|
||||
request->SetValidator(hvc);
|
||||
|
||||
// We will send notifications from imgCacheValidator::OnStartRequest().
|
||||
// In the mean time, we must defer notifications because we are added to
|
||||
// the imgRequest's proxy list, and we can get extra notifications
|
||||
// resulting from methods such as StartDecoding(). See bug 579122.
|
||||
req->SetNotificationsDeferred(true);
|
||||
|
||||
// Add the proxy without notifying
|
||||
hvc->AddProxy(req);
|
||||
|
||||
mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
|
||||
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
|
||||
|
||||
rv = newChannel->AsyncOpen2(listener);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
req.forget(aProxyRequest);
|
||||
return true;
|
||||
}
|
||||
// We will rely on Necko to cache this request when it's possible, and to
|
||||
// tell imgCacheValidator::OnStartRequest whether the request came from its
|
||||
// cache.
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
bool forcePrincipalCheck;
|
||||
rv = NewImageChannel(getter_AddRefs(newChannel),
|
||||
&forcePrincipalCheck,
|
||||
aURI,
|
||||
aInitialDocumentURI,
|
||||
aCORSMode,
|
||||
aReferrerURI,
|
||||
aReferrerPolicy,
|
||||
aLoadGroup,
|
||||
mAcceptHeader,
|
||||
aLoadFlags,
|
||||
aLoadPolicyType,
|
||||
aLoadingPrincipal,
|
||||
aCX,
|
||||
mRespectPrivacy);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<imgRequestProxy> req;
|
||||
rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver,
|
||||
aLoadFlags, getter_AddRefs(req));
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make sure that OnStatus/OnProgress calls have the right request set...
|
||||
RefPtr<nsProgressNotificationProxy> progressproxy =
|
||||
new nsProgressNotificationProxy(newChannel, req);
|
||||
if (!progressproxy) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RefPtr<imgCacheValidator> hvc =
|
||||
new imgCacheValidator(progressproxy, this, request, aCX,
|
||||
forcePrincipalCheck);
|
||||
|
||||
// Casting needed here to get past multiple inheritance.
|
||||
nsCOMPtr<nsIStreamListener> listener =
|
||||
do_QueryInterface(static_cast<nsIThreadRetargetableStreamListener*>(hvc));
|
||||
NS_ENSURE_TRUE(listener, false);
|
||||
|
||||
// We must set the notification callbacks before setting up the
|
||||
// CORS listener, because that's also interested inthe
|
||||
// notification callbacks.
|
||||
newChannel->SetNotificationCallbacks(hvc);
|
||||
|
||||
request->SetValidator(hvc);
|
||||
|
||||
// We will send notifications from imgCacheValidator::OnStartRequest().
|
||||
// In the mean time, we must defer notifications because we are added to
|
||||
// the imgRequest's proxy list, and we can get extra notifications
|
||||
// resulting from methods such as StartDecoding(). See bug 579122.
|
||||
req->SetNotificationsDeferred(true);
|
||||
|
||||
// Add the proxy without notifying
|
||||
hvc->AddProxy(req);
|
||||
|
||||
mozilla::net::PredictorLearn(aURI, aInitialDocumentURI,
|
||||
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, aLoadGroup);
|
||||
|
||||
rv = newChannel->AsyncOpen2(listener);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
req.forget(aProxyRequest);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -1876,10 +1876,8 @@ imgLoader::RemoveFromCache(const ImageCacheKey& aKey)
|
||||
AddToUncachedImages(request);
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -178,16 +178,16 @@ imgRequest::GetProgressTracker() const
|
||||
MOZ_ASSERT(!mProgressTracker,
|
||||
"Should have given mProgressTracker to mImage");
|
||||
return mImage->GetProgressTracker();
|
||||
} else {
|
||||
MOZ_ASSERT(mProgressTracker,
|
||||
"Should have mProgressTracker until we create mImage");
|
||||
RefPtr<ProgressTracker> progressTracker = mProgressTracker;
|
||||
MOZ_ASSERT(progressTracker);
|
||||
return progressTracker.forget();
|
||||
}
|
||||
MOZ_ASSERT(mProgressTracker,
|
||||
"Should have mProgressTracker until we create mImage");
|
||||
RefPtr<ProgressTracker> progressTracker = mProgressTracker;
|
||||
MOZ_ASSERT(progressTracker);
|
||||
return progressTracker.forget();
|
||||
}
|
||||
|
||||
void imgRequest::SetCacheEntry(imgCacheEntry* entry)
|
||||
void
|
||||
imgRequest::SetCacheEntry(imgCacheEntry* entry)
|
||||
{
|
||||
mCacheEntry = entry;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user