зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 621c8480cd35 (bug 1872657) for causing FetchPriority related bp-nu bustages in IconLoader.cpp. CLOSED TREE
This commit is contained in:
Родитель
98851e0029
Коммит
b54de79827
|
@ -12394,8 +12394,7 @@ already_AddRefed<nsIURI> Document::ResolvePreloadImage(
|
|||
|
||||
void Document::PreLoadImage(nsIURI* aUri, const nsAString& aCrossOriginAttr,
|
||||
ReferrerPolicyEnum aReferrerPolicy, bool aIsImgSet,
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority) {
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId) {
|
||||
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL |
|
||||
nsContentUtils::CORSModeToLoadImageFlags(
|
||||
Element::StringToCORSMode(aCrossOriginAttr));
|
||||
|
@ -12416,8 +12415,7 @@ void Document::PreLoadImage(nsIURI* aUri, const nsAString& aCrossOriginAttr,
|
|||
nsresult rv = nsContentUtils::LoadImage(
|
||||
aUri, static_cast<nsINode*>(this), this, NodePrincipal(), 0, referrerInfo,
|
||||
nullptr /* no observer */, loadFlags, initiator, getter_AddRefs(request),
|
||||
policyType, false /* urgent */, aLinkPreload, aEarlyHintPreloaderId,
|
||||
nsGenericHTMLElement::ToFetchPriority(aFetchPriority));
|
||||
policyType, false /* urgent */, aLinkPreload, aEarlyHintPreloaderId);
|
||||
|
||||
// Pin image-reference to avoid evicting it from the img-cache before
|
||||
// the "real" load occurs. Unpinned in DispatchContentLoadedEvents and
|
||||
|
@ -12430,8 +12428,7 @@ void Document::PreLoadImage(nsIURI* aUri, const nsAString& aCrossOriginAttr,
|
|||
void Document::MaybePreLoadImage(nsIURI* aUri,
|
||||
const nsAString& aCrossOriginAttr,
|
||||
ReferrerPolicyEnum aReferrerPolicy,
|
||||
bool aIsImgSet, bool aLinkPreload,
|
||||
const nsAString& aFetchPriority) {
|
||||
bool aIsImgSet, bool aLinkPreload) {
|
||||
const CORSMode corsMode = dom::Element::StringToCORSMode(aCrossOriginAttr);
|
||||
if (aLinkPreload) {
|
||||
// Check if the image was already preloaded in this document to avoid
|
||||
|
@ -12440,7 +12437,7 @@ void Document::MaybePreLoadImage(nsIURI* aUri,
|
|||
PreloadHashKey::CreateAsImage(aUri, NodePrincipal(), corsMode);
|
||||
if (!mPreloadService.PreloadExists(key)) {
|
||||
PreLoadImage(aUri, aCrossOriginAttr, aReferrerPolicy, aIsImgSet,
|
||||
aLinkPreload, 0, aFetchPriority);
|
||||
aLinkPreload, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -12454,7 +12451,7 @@ void Document::MaybePreLoadImage(nsIURI* aUri,
|
|||
|
||||
// Image not in cache - trigger preload
|
||||
PreLoadImage(aUri, aCrossOriginAttr, aReferrerPolicy, aIsImgSet, aLinkPreload,
|
||||
0, aFetchPriority);
|
||||
0);
|
||||
}
|
||||
|
||||
void Document::MaybePreconnect(nsIURI* aOrigURI, mozilla::CORSMode aCORSMode) {
|
||||
|
|
|
@ -2930,11 +2930,10 @@ class Document : public nsINode,
|
|||
*/
|
||||
void MaybePreLoadImage(nsIURI* uri, const nsAString& aCrossOriginAttr,
|
||||
ReferrerPolicyEnum aReferrerPolicy, bool aIsImgSet,
|
||||
bool aLinkPreload, const nsAString& aFetchPriority);
|
||||
bool aLinkPreload);
|
||||
void PreLoadImage(nsIURI* uri, const nsAString& aCrossOriginAttr,
|
||||
ReferrerPolicyEnum aReferrerPolicy, bool aIsImgSet,
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
/**
|
||||
* Called by images to forget an image preload when they start doing
|
||||
|
|
|
@ -4004,8 +4004,7 @@ nsresult nsContentUtils::LoadImage(
|
|||
int32_t aLoadFlags, const nsAString& initiatorType,
|
||||
imgRequestProxy** aRequest, nsContentPolicyType aContentPolicyType,
|
||||
bool aUseUrgentStartForChannel, bool aLinkPreload,
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
mozilla::dom::FetchPriority aFetchPriority) {
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
MOZ_ASSERT(aURI, "Must have a URI");
|
||||
MOZ_ASSERT(aContext, "Must have a context");
|
||||
MOZ_ASSERT(aLoadingDocument, "Must have a document");
|
||||
|
@ -4042,7 +4041,7 @@ nsresult nsContentUtils::LoadImage(
|
|||
initiatorType, /* the load initiator */
|
||||
aUseUrgentStartForChannel, /* urgent-start flag */
|
||||
aLinkPreload, /* <link preload> initiator */
|
||||
aEarlyHintPreloaderId, aFetchPriority, aRequest);
|
||||
aEarlyHintPreloaderId, aRequest);
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/FromParser.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/fallible.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -1027,9 +1026,7 @@ class nsContentUtils {
|
|||
nsContentPolicyType aContentPolicyType =
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE,
|
||||
bool aUseUrgentStartForChannel = false, bool aLinkPreload = false,
|
||||
uint64_t aEarlyHintPreloaderId = 0,
|
||||
mozilla::dom::FetchPriority aFetchPriority =
|
||||
mozilla::dom::FetchPriority::Auto);
|
||||
uint64_t aEarlyHintPreloaderId = 0);
|
||||
|
||||
/**
|
||||
* Obtain an image loader that respects the given document/channel's privacy
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "mozilla/StaticPrefs_network.h"
|
||||
#include "mozilla/StoragePrincipalHelper.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/nsMixedContentBlocker.h"
|
||||
#include "mozilla/image/ImageMemoryReporter.h"
|
||||
#include "mozilla/layers/CompositorManagerChild.h"
|
||||
|
@ -816,28 +815,6 @@ static bool ValidateSecurityInfo(imgRequest* aRequest,
|
|||
/* aSendCSPViolationReports */ false);
|
||||
}
|
||||
|
||||
static void AdjustPriorityForImages(nsIChannel* aChannel,
|
||||
nsLoadFlags aLoadFlags,
|
||||
FetchPriority aFetchPriority) {
|
||||
// Image channels are loaded by default with reduced priority.
|
||||
if (nsCOMPtr<nsISupportsPriority> supportsPriority =
|
||||
do_QueryInterface(aChannel)) {
|
||||
int32_t priority = nsISupportsPriority::PRIORITY_LOW;
|
||||
|
||||
// Adjust priority according to fetchpriorty attribute.
|
||||
if (StaticPrefs::network_fetchpriority_enabled()) {
|
||||
priority += FETCH_PRIORITY_ADJUSTMENT_FOR(images, aFetchPriority);
|
||||
}
|
||||
|
||||
// Further reduce priority for background loads
|
||||
if (aLoadFlags & nsIRequest::LOAD_BACKGROUND) {
|
||||
++priority;
|
||||
}
|
||||
|
||||
supportsPriority->AdjustPriority(priority);
|
||||
}
|
||||
}
|
||||
|
||||
static nsresult NewImageChannel(
|
||||
nsIChannel** aResult,
|
||||
// If aForcePrincipalCheckForCacheEntry is true, then we will
|
||||
|
@ -851,8 +828,7 @@ static nsresult NewImageChannel(
|
|||
nsIReferrerInfo* aReferrerInfo, nsILoadGroup* aLoadGroup,
|
||||
nsLoadFlags aLoadFlags, nsContentPolicyType aPolicyType,
|
||||
nsIPrincipal* aTriggeringPrincipal, nsINode* aRequestingNode,
|
||||
bool aRespectPrivacy, uint64_t aEarlyHintPreloaderId,
|
||||
FetchPriority aFetchPriority) {
|
||||
bool aRespectPrivacy, uint64_t aEarlyHintPreloaderId) {
|
||||
MOZ_ASSERT(aResult);
|
||||
|
||||
nsresult rv;
|
||||
|
@ -972,7 +948,17 @@ static nsresult NewImageChannel(
|
|||
}
|
||||
}
|
||||
|
||||
AdjustPriorityForImages(*aResult, aLoadFlags, aFetchPriority);
|
||||
// Image channels are loaded by default with reduced priority.
|
||||
nsCOMPtr<nsISupportsPriority> p = do_QueryInterface(*aResult);
|
||||
if (p) {
|
||||
uint32_t priority = nsISupportsPriority::PRIORITY_LOW;
|
||||
|
||||
if (aLoadFlags & nsIRequest::LOAD_BACKGROUND) {
|
||||
++priority; // further reduce priority for background loads
|
||||
}
|
||||
|
||||
p->AdjustPriority(priority);
|
||||
}
|
||||
|
||||
// Create a new loadgroup for this new channel, using the old group as
|
||||
// the parent. The indirection keeps the channel insulated from cancels,
|
||||
|
@ -1729,8 +1715,7 @@ bool imgLoader::ValidateRequestWithNewChannel(
|
|||
uint64_t aInnerWindowId, nsLoadFlags aLoadFlags,
|
||||
nsContentPolicyType aLoadPolicyType, imgRequestProxy** aProxyRequest,
|
||||
nsIPrincipal* aTriggeringPrincipal, CORSMode aCORSMode, bool aLinkPreload,
|
||||
uint64_t aEarlyHintPreloaderId, FetchPriority aFetchPriority,
|
||||
bool* aNewChannelCreated) {
|
||||
uint64_t aEarlyHintPreloaderId, bool* aNewChannelCreated) {
|
||||
// now we need to insert a new channel request object in between the real
|
||||
// request and the proxy that basically delays loading the image until it
|
||||
// gets a 304 or figures out that this needs to be a new request
|
||||
|
@ -1773,11 +1758,11 @@ bool imgLoader::ValidateRequestWithNewChannel(
|
|||
// cache.
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
bool forcePrincipalCheck;
|
||||
rv = NewImageChannel(getter_AddRefs(newChannel), &forcePrincipalCheck, aURI,
|
||||
aInitialDocumentURI, aCORSMode, aReferrerInfo,
|
||||
aLoadGroup, aLoadFlags, aLoadPolicyType,
|
||||
aTriggeringPrincipal, aLoadingDocument, mRespectPrivacy,
|
||||
aEarlyHintPreloaderId, aFetchPriority);
|
||||
rv =
|
||||
NewImageChannel(getter_AddRefs(newChannel), &forcePrincipalCheck, aURI,
|
||||
aInitialDocumentURI, aCORSMode, aReferrerInfo, aLoadGroup,
|
||||
aLoadFlags, aLoadPolicyType, aTriggeringPrincipal,
|
||||
aLoadingDocument, mRespectPrivacy, aEarlyHintPreloaderId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1856,7 +1841,7 @@ void imgLoader::NotifyObserversForCachedImage(
|
|||
imgCacheEntry* aEntry, imgRequest* request, nsIURI* aURI,
|
||||
nsIReferrerInfo* aReferrerInfo, Document* aLoadingDocument,
|
||||
nsIPrincipal* aTriggeringPrincipal, CORSMode aCORSMode,
|
||||
uint64_t aEarlyHintPreloaderId, FetchPriority aFetchPriority) {
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
if (aEntry->HasNotified()) {
|
||||
return;
|
||||
}
|
||||
|
@ -1875,7 +1860,7 @@ void imgLoader::NotifyObserversForCachedImage(
|
|||
getter_AddRefs(newChannel), &forcePrincipalCheck, aURI, nullptr,
|
||||
aCORSMode, aReferrerInfo, nullptr, 0,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE, aTriggeringPrincipal,
|
||||
aLoadingDocument, mRespectPrivacy, aEarlyHintPreloaderId, aFetchPriority);
|
||||
aLoadingDocument, mRespectPrivacy, aEarlyHintPreloaderId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1900,8 +1885,7 @@ bool imgLoader::ValidateEntry(
|
|||
nsLoadFlags aLoadFlags, nsContentPolicyType aLoadPolicyType,
|
||||
bool aCanMakeNewChannel, bool* aNewChannelCreated,
|
||||
imgRequestProxy** aProxyRequest, nsIPrincipal* aTriggeringPrincipal,
|
||||
CORSMode aCORSMode, bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
FetchPriority aFetchPriority) {
|
||||
CORSMode aCORSMode, bool aLinkPreload, uint64_t aEarlyHintPreloaderId) {
|
||||
LOG_SCOPE(gImgLog, "imgLoader::ValidateEntry");
|
||||
|
||||
// If the expiration time is zero, then the request has not gotten far enough
|
||||
|
@ -2029,13 +2013,13 @@ bool imgLoader::ValidateEntry(
|
|||
request, aURI, aInitialDocumentURI, aReferrerInfo, aLoadGroup,
|
||||
aObserver, aLoadingDocument, innerWindowID, aLoadFlags, aLoadPolicyType,
|
||||
aProxyRequest, aTriggeringPrincipal, aCORSMode, aLinkPreload,
|
||||
aEarlyHintPreloaderId, aFetchPriority, aNewChannelCreated);
|
||||
aEarlyHintPreloaderId, aNewChannelCreated);
|
||||
}
|
||||
|
||||
if (!validateRequest) {
|
||||
NotifyObserversForCachedImage(
|
||||
aEntry, request, aURI, aReferrerInfo, aLoadingDocument,
|
||||
aTriggeringPrincipal, aCORSMode, aEarlyHintPreloaderId, aFetchPriority);
|
||||
NotifyObserversForCachedImage(aEntry, request, aURI, aReferrerInfo,
|
||||
aLoadingDocument, aTriggeringPrincipal,
|
||||
aCORSMode, aEarlyHintPreloaderId);
|
||||
}
|
||||
|
||||
return !validateRequest;
|
||||
|
@ -2190,7 +2174,7 @@ imgLoader::LoadImageXPCOM(
|
|||
0, aLoadGroup, aObserver, aLoadingDocument, aLoadingDocument,
|
||||
aLoadFlags, aCacheKey, aContentPolicyType, u""_ns,
|
||||
/* aUseUrgentStartForChannel */ false, /* aListPreload */ false,
|
||||
0, FetchPriority::Auto, &proxy);
|
||||
0, &proxy);
|
||||
*_retval = proxy;
|
||||
return rv;
|
||||
}
|
||||
|
@ -2249,7 +2233,7 @@ nsresult imgLoader::LoadImage(
|
|||
nsISupports* aCacheKey, nsContentPolicyType aContentPolicyType,
|
||||
const nsAString& initiatorType, bool aUseUrgentStartForChannel,
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
FetchPriority aFetchPriority, imgRequestProxy** _retval) {
|
||||
imgRequestProxy** _retval) {
|
||||
VerifyCacheSizes();
|
||||
|
||||
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
|
||||
|
@ -2402,7 +2386,7 @@ nsresult imgLoader::LoadImage(
|
|||
aLoadGroup, aObserver, aLoadingDocument, requestFlags,
|
||||
aContentPolicyType, true, &newChannelCreated, _retval,
|
||||
aTriggeringPrincipal, corsmode, aLinkPreload,
|
||||
aEarlyHintPreloaderId, aFetchPriority)) {
|
||||
aEarlyHintPreloaderId)) {
|
||||
request = entry->GetRequest();
|
||||
|
||||
// If this entry has no proxies, its request has no reference to the
|
||||
|
@ -2452,7 +2436,7 @@ nsresult imgLoader::LoadImage(
|
|||
aInitialDocumentURI, corsmode, aReferrerInfo,
|
||||
aLoadGroup, requestFlags, aContentPolicyType,
|
||||
aTriggeringPrincipal, aContext, mRespectPrivacy,
|
||||
aEarlyHintPreloaderId, aFetchPriority);
|
||||
aEarlyHintPreloaderId);
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -2666,8 +2650,7 @@ nsresult imgLoader::LoadImageWithChannel(nsIChannel* channel,
|
|||
|
||||
if (ValidateEntry(entry, uri, nullptr, nullptr, nullptr, aObserver,
|
||||
aLoadingDocument, requestFlags, policyType, false,
|
||||
nullptr, nullptr, nullptr, corsMode, false, 0,
|
||||
FetchPriority::Auto)) {
|
||||
nullptr, nullptr, nullptr, corsMode, false, 0)) {
|
||||
request = entry->GetRequest();
|
||||
} else {
|
||||
nsCOMPtr<nsICacheInfoChannel> cacheChan(do_QueryInterface(channel));
|
||||
|
|
|
@ -37,7 +37,6 @@ class imgMemoryReporter;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Document;
|
||||
enum class FetchPriority : uint8_t;
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -239,8 +238,7 @@ class imgLoader final : public imgILoader,
|
|||
nsLoadFlags aLoadFlags, nsISupports* aCacheKey,
|
||||
nsContentPolicyType aContentPolicyType, const nsAString& initiatorType,
|
||||
bool aUseUrgentStartForChannel, bool aLinkPreload,
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
mozilla::dom::FetchPriority aFetchPriority, imgRequestProxy** _retval);
|
||||
uint64_t aEarlyHintPreloaderId, imgRequestProxy** _retval);
|
||||
|
||||
[[nodiscard]] nsresult LoadImageWithChannel(
|
||||
nsIChannel* channel, imgINotificationObserver* aObserver,
|
||||
|
@ -351,8 +349,7 @@ class imgLoader final : public imgILoader,
|
|||
bool aCanMakeNewChannel, bool* aNewChannelCreated,
|
||||
imgRequestProxy** aProxyRequest,
|
||||
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode,
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
mozilla::dom::FetchPriority aFetchPriority);
|
||||
bool aLinkPreload, uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
bool ValidateRequestWithNewChannel(
|
||||
imgRequest* request, nsIURI* aURI, nsIURI* aInitialDocumentURI,
|
||||
|
@ -362,14 +359,15 @@ class imgLoader final : public imgILoader,
|
|||
nsLoadFlags aLoadFlags, nsContentPolicyType aContentPolicyType,
|
||||
imgRequestProxy** aProxyRequest, nsIPrincipal* aLoadingPrincipal,
|
||||
mozilla::CORSMode, bool aLinkPreload, uint64_t aEarlyHintPreloaderId,
|
||||
mozilla::dom::FetchPriority aFetchPriority, bool* aNewChannelCreated);
|
||||
bool* aNewChannelCreated);
|
||||
|
||||
void NotifyObserversForCachedImage(
|
||||
imgCacheEntry* aEntry, imgRequest* request, nsIURI* aURI,
|
||||
nsIReferrerInfo* aReferrerInfo, mozilla::dom::Document* aLoadingDocument,
|
||||
nsIPrincipal* aTriggeringPrincipal, mozilla::CORSMode,
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
mozilla::dom::FetchPriority aFetchPriority);
|
||||
void NotifyObserversForCachedImage(imgCacheEntry* aEntry, imgRequest* request,
|
||||
nsIURI* aURI,
|
||||
nsIReferrerInfo* aReferrerInfo,
|
||||
mozilla::dom::Document* aLoadingDocument,
|
||||
nsIPrincipal* aLoadingPrincipal,
|
||||
mozilla::CORSMode,
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
// aURI may be different from imgRequest's URI in the case of blob URIs, as we
|
||||
// can share requests with different URIs.
|
||||
nsresult CreateNewProxyForRequest(imgRequest* aRequest, nsIURI* aURI,
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "mozilla/DebugOnly.h"
|
||||
#include "mozilla/Encoding.h"
|
||||
#include "mozilla/HTMLEditor.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "mozilla/dom/ImageTracker.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Helpers.h"
|
||||
|
@ -269,7 +268,7 @@ BrokenImageIcon::BrokenImageIcon(const nsImageFrame& aFrame) {
|
|||
loadFlags, nullptr, contentPolicyType, u""_ns,
|
||||
false, /* aUseUrgentStartForChannel */
|
||||
false, /* aLinkPreload */
|
||||
0, FetchPriority::Auto, getter_AddRefs(mImage));
|
||||
0, getter_AddRefs(mImage));
|
||||
Unused << NS_WARN_IF(NS_FAILED(rv));
|
||||
}
|
||||
|
||||
|
|
|
@ -12004,26 +12004,6 @@
|
|||
value: 0
|
||||
mirror: always
|
||||
|
||||
# Adjustments to apply to the internal priority of <link rel=preload as=images
|
||||
# fetchpriority=low/high/auto> and <img fetchpriority=low/high/auto> with
|
||||
# respect to the case when network.fetchpriority is disabled.
|
||||
# - When the flag is disabled, Gecko currently sets priority to LOW.
|
||||
# - When the flag is enabled, it respectively maps to LOW/LOW/HIGH.
|
||||
# The image code can currently further adjust the priority for image load, see
|
||||
# imgRequest::BoostPriority and AdjustPriorityForImages.
|
||||
- name: network.fetchpriority.adjustments.images.low
|
||||
type: int32_t
|
||||
value: 0
|
||||
mirror: always
|
||||
- name: network.fetchpriority.adjustments.images.high
|
||||
type: int32_t
|
||||
value: -20
|
||||
mirror: always
|
||||
- name: network.fetchpriority.adjustments.images.auto
|
||||
type: int32_t
|
||||
value: 0
|
||||
mirror: always
|
||||
|
||||
# Enables `<link rel="preconnect">` tag and `Link: rel=preconnect` response header
|
||||
# handling.
|
||||
- name: network.preconnect
|
||||
|
|
|
@ -45,7 +45,7 @@ void nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor) {
|
|||
aExecutor->PreloadImage(
|
||||
mUrlOrSizes, mCrossOrigin, mMedia, mCharsetOrSrcset,
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity,
|
||||
mReferrerPolicyOrIntegrity, mIsLinkPreload, mFetchPriority);
|
||||
mReferrerPolicyOrIntegrity, mIsLinkPreload);
|
||||
break;
|
||||
case eSpeculativeLoadOpenPicture:
|
||||
aExecutor->PreloadOpenPicture();
|
||||
|
|
|
@ -75,7 +75,7 @@ class nsHtml5SpeculativeLoad {
|
|||
inline void InitImage(nsHtml5String aUrl, nsHtml5String aCrossOrigin,
|
||||
nsHtml5String aMedia, nsHtml5String aReferrerPolicy,
|
||||
nsHtml5String aSrcset, nsHtml5String aSizes,
|
||||
bool aLinkPreload, nsHtml5String aFetchPriority) {
|
||||
bool aLinkPreload) {
|
||||
MOZ_ASSERT(mOpCode == eSpeculativeLoadUninitialized,
|
||||
"Trying to reinitialize a speculative load!");
|
||||
mOpCode = eSpeculativeLoadImage;
|
||||
|
@ -92,7 +92,6 @@ class nsHtml5SpeculativeLoad {
|
|||
aSizes.ToString(
|
||||
mTypeOrCharsetSourceOrDocumentModeOrMetaCSPOrSizesOrIntegrity);
|
||||
mIsLinkPreload = aLinkPreload;
|
||||
aFetchPriority.ToString(mFetchPriority);
|
||||
}
|
||||
|
||||
inline void InitFont(nsHtml5String aUrl, nsHtml5String aCrossOrigin,
|
||||
|
|
|
@ -215,16 +215,9 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
nsHtml5AttributeName::ATTR_REFERRERPOLICY);
|
||||
nsHtml5String sizes =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES);
|
||||
|
||||
// TODO: support the fetchpriority attribute in bug 1839313.
|
||||
// Meanwhile the empty string is used since it's mapped to the
|
||||
// auto state
|
||||
// (https://html.spec.whatwg.org/#fetch-priority-attribute).
|
||||
auto fetchPriority = nsHtml5String::EmptyString();
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitImage(
|
||||
url, crossOrigin, /* aMedia = */ nullptr, referrerPolicy,
|
||||
srcset, sizes, false, fetchPriority);
|
||||
srcset, sizes, false);
|
||||
}
|
||||
} else if (nsGkAtoms::source == aName) {
|
||||
nsHtml5String srcset =
|
||||
|
@ -442,7 +435,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
nsHtml5AttributeName::ATTR_IMAGESIZES);
|
||||
mSpeculativeLoadQueue.AppendElement()->InitImage(
|
||||
url, crossOrigin, media, referrerPolicy, srcset, sizes,
|
||||
true, fetchPriority);
|
||||
true);
|
||||
} else if (as.LowerCaseEqualsASCII("font")) {
|
||||
mSpeculativeLoadQueue.AppendElement()->InitFont(
|
||||
url, crossOrigin, media, referrerPolicy, fetchPriority);
|
||||
|
@ -494,14 +487,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
nsHtml5String url =
|
||||
aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER);
|
||||
if (url) {
|
||||
// Fetch priority is not supported for video. Nullptr will map to
|
||||
// the auto state
|
||||
// (https://html.spec.whatwg.org/#fetch-priority-attribute).
|
||||
auto fetchPriority = nullptr;
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitImage(
|
||||
url, nullptr, nullptr, nullptr, nullptr, nullptr, false,
|
||||
fetchPriority);
|
||||
url, nullptr, nullptr, nullptr, nullptr, nullptr, false);
|
||||
}
|
||||
} else if (nsGkAtoms::style == aName) {
|
||||
mImportScanner.Start();
|
||||
|
@ -556,15 +543,8 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
|
|||
url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF);
|
||||
}
|
||||
if (url) {
|
||||
// Currently SVG's `<image>` element lacks support for
|
||||
// `fetchpriority`, see bug 1847712. Hence passing nullptr which
|
||||
// maps to the auto state
|
||||
// (https://html.spec.whatwg.org/#fetch-priority-attribute).
|
||||
auto fetchPriority = nullptr;
|
||||
|
||||
mSpeculativeLoadQueue.AppendElement()->InitImage(
|
||||
url, nullptr, nullptr, nullptr, nullptr, nullptr, false,
|
||||
fetchPriority);
|
||||
url, nullptr, nullptr, nullptr, nullptr, nullptr, false);
|
||||
}
|
||||
} else if (nsGkAtoms::script == aName) {
|
||||
nsHtml5TreeOperation* treeOp =
|
||||
|
|
|
@ -1261,8 +1261,7 @@ void nsHtml5TreeOpExecutor::PreloadStyle(
|
|||
void nsHtml5TreeOpExecutor::PreloadImage(
|
||||
const nsAString& aURL, const nsAString& aCrossOrigin,
|
||||
const nsAString& aMedia, const nsAString& aSrcset, const nsAString& aSizes,
|
||||
const nsAString& aImageReferrerPolicy, bool aLinkPreload,
|
||||
const nsAString& aFetchPriority) {
|
||||
const nsAString& aImageReferrerPolicy, bool aLinkPreload) {
|
||||
nsCOMPtr<nsIURI> baseURI = BaseURIForPreload();
|
||||
bool isImgSet = false;
|
||||
nsCOMPtr<nsIURI> uri =
|
||||
|
@ -1271,7 +1270,7 @@ void nsHtml5TreeOpExecutor::PreloadImage(
|
|||
// use document wide referrer policy
|
||||
mDocument->MaybePreLoadImage(uri, aCrossOrigin,
|
||||
GetPreloadReferrerPolicy(aImageReferrerPolicy),
|
||||
isImgSet, aLinkPreload, aFetchPriority);
|
||||
isImgSet, aLinkPreload);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -260,8 +260,7 @@ class nsHtml5TreeOpExecutor final
|
|||
void PreloadImage(const nsAString& aURL, const nsAString& aCrossOrigin,
|
||||
const nsAString& aMedia, const nsAString& aSrcset,
|
||||
const nsAString& aSizes,
|
||||
const nsAString& aImageReferrerPolicy, bool aLinkPreload,
|
||||
const nsAString& aFetchPriority);
|
||||
const nsAString& aImageReferrerPolicy, bool aLinkPreload);
|
||||
|
||||
void PreloadOpenPicture();
|
||||
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
[fetchpriority.h2.html]
|
||||
lsan-allowed: [mozilla::net::AddStaticElement, InitializeStaticHeaders, mozilla::net::nvFIFO::nvFIFO, mozilla::net::Http2BaseCompressor::Http2BaseCompressor] # https://bugzilla.mozilla.org/show_bug.cgi?id=1759310
|
||||
prefs: [network.fetchpriority.enabled:true]
|
||||
[link-initial-preload-image.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-dynamic-preload-image.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[link-header.h2.html?pipe=|header(Link,<dummy.image?1>; rel=preload; as=image; fetchpriority=low,True)|header(Link,<dummy.image?2>; rel=preload; as=image; fetchpriority=high,True)|header(Link,<dummy.image?3>; rel=preload; as=image; fetchpriority=auto,True)|header(Link,<dummy.image?4>; rel=preload; as=image,True): test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
[image-dynamic-load.h2.html: test different 'fetchpriority' values]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
"link-preload-style": SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGHEST,
|
||||
"non-deferred-style": SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL,
|
||||
"global-fetch-api": SpecialPowers.Ci.nsISupportsPriority.PRIORITY_NORMAL,
|
||||
"images": SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW,
|
||||
};
|
||||
for (const name in prioritiesWhenFetchpriorityDisabled) {
|
||||
let adjustments = {};
|
||||
|
|
|
@ -113,16 +113,16 @@ const kExpectedRequestsOfLinkPreloadFontDisabled = [
|
|||
|
||||
const kExpectedRequestsOfLinkPreloadImage = [
|
||||
{ fileNameAndSuffix: "dummy.image?1",
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW + 1
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
|
||||
},
|
||||
{ fileNameAndSuffix: "dummy.image?2",
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH + 1
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_HIGH
|
||||
},
|
||||
{ fileNameAndSuffix: "dummy.image?3",
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW + 1
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
|
||||
},
|
||||
{ fileNameAndSuffix: "dummy.image?4",
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW + 1
|
||||
internalPriority: SpecialPowers.Ci.nsISupportsPriority.PRIORITY_LOW
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -226,8 +226,7 @@ PreloadService::PreloadOrCoalesceResult PreloadService::PreloadOrCoalesce(
|
|||
break;
|
||||
}
|
||||
} else if (aAs.LowerCaseEqualsASCII("image")) {
|
||||
PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId,
|
||||
aFetchPriority);
|
||||
PreloadImage(uri, aCORS, aReferrerPolicy, isImgSet, aEarlyHintPreloaderId);
|
||||
} else if (aAs.LowerCaseEqualsASCII("font")) {
|
||||
PreloadFont(uri, aCORS, aReferrerPolicy, aEarlyHintPreloaderId,
|
||||
aFetchPriority);
|
||||
|
@ -259,11 +258,10 @@ void PreloadService::PreloadScript(
|
|||
void PreloadService::PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
|
||||
const nsAString& aImageReferrerPolicy,
|
||||
bool aIsImgSet,
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority) {
|
||||
mDocument->PreLoadImage(
|
||||
aURI, aCrossOrigin, PreloadReferrerPolicy(aImageReferrerPolicy),
|
||||
aIsImgSet, true, aEarlyHintPreloaderId, aFetchPriority);
|
||||
uint64_t aEarlyHintPreloaderId) {
|
||||
mDocument->PreLoadImage(aURI, aCrossOrigin,
|
||||
PreloadReferrerPolicy(aImageReferrerPolicy),
|
||||
aIsImgSet, true, aEarlyHintPreloaderId);
|
||||
}
|
||||
|
||||
void PreloadService::PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
|
||||
|
|
|
@ -90,8 +90,7 @@ class PreloadService {
|
|||
|
||||
void PreloadImage(nsIURI* aURI, const nsAString& aCrossOrigin,
|
||||
const nsAString& aImageReferrerPolicy, bool aIsImgSet,
|
||||
uint64_t aEarlyHintPreloaderId,
|
||||
const nsAString& aFetchPriority);
|
||||
uint64_t aEarlyHintPreloaderId);
|
||||
|
||||
void PreloadFont(nsIURI* aURI, const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "imgLoader.h"
|
||||
#include "imgRequestProxy.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "mozilla/dom/FetchPriority.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
|
@ -64,17 +63,16 @@ nsresult IconLoader::LoadIcon(nsIURI* aIconURI, nsINode* aNode,
|
|||
nullptr, nsIRequest::LOAD_NORMAL, nullptr,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE, u""_ns,
|
||||
/* aUseUrgentStartForChannel */ false, /* aLinkPreload */ false, 0,
|
||||
FetchPriority::Auto, getter_AddRefs(mIconRequest));
|
||||
getter_AddRefs(mIconRequest));
|
||||
} else {
|
||||
// TODO: nsIContentPolicy::TYPE_INTERNAL_IMAGE may not be the correct
|
||||
// policy. See bug 1691868 for more details.
|
||||
rv = loader->LoadImage(aIconURI, nullptr, nullptr, aNode->NodePrincipal(),
|
||||
0, loadGroup, this, aNode, document,
|
||||
nsIRequest::LOAD_NORMAL, nullptr,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE, u""_ns,
|
||||
/* aUseUrgentStartForChannel */ false,
|
||||
/* aLinkPreload */ false, 0, FetchPriority::Auto,
|
||||
getter_AddRefs(mIconRequest));
|
||||
rv = loader->LoadImage(
|
||||
aIconURI, nullptr, nullptr, aNode->NodePrincipal(), 0, loadGroup, this,
|
||||
aNode, document, nsIRequest::LOAD_NORMAL, nullptr,
|
||||
nsIContentPolicy::TYPE_INTERNAL_IMAGE, u""_ns,
|
||||
/* aUseUrgentStartForChannel */ false,
|
||||
/* aLinkPreload */ false, 0, getter_AddRefs(mIconRequest));
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче