Bug 1618536 - Introduce nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD representing preload of font, mapping to TYPE_FONT externally, r=baku

Depends on D69628

Differential Revision: https://phabricator.services.mozilla.com/D72118
This commit is contained in:
Honza Bambas 2020-05-11 14:13:16 +00:00
parent 9e027ce534
commit ef0d4e6dd1
9 changed files with 18 additions and 3 deletions

View File

@ -141,6 +141,7 @@ inline const char* NS_CP_ContentTypeName(uint32_t contentType) {
CASE_RETURN(TYPE_INTERNAL_FORCE_ALLOWED_DTD);
CASE_RETURN(TYPE_INTERNAL_AUDIOWORKLET);
CASE_RETURN(TYPE_INTERNAL_PAINTWORKLET);
CASE_RETURN(TYPE_INTERNAL_FONT_PRELOAD);
default:
return "<Unknown Type>";
}

View File

@ -7990,7 +7990,8 @@ bool nsContentUtils::IsPreloadType(nsContentPolicyType aType) {
return (aType == nsIContentPolicy::TYPE_INTERNAL_SCRIPT_PRELOAD ||
aType == nsIContentPolicy::TYPE_INTERNAL_MODULE_PRELOAD ||
aType == nsIContentPolicy::TYPE_INTERNAL_IMAGE_PRELOAD ||
aType == nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD);
aType == nsIContentPolicy::TYPE_INTERNAL_STYLESHEET_PRELOAD ||
aType == nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD);
}
/* static */

View File

@ -3411,6 +3411,9 @@ nsContentUtils::InternalContentPolicyTypeToExternal(nsContentPolicyType aType) {
case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD:
return nsIContentPolicy::TYPE_DTD;
case nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD:
return nsIContentPolicy::TYPE_FONT;
default:
return aType;
}

View File

@ -394,6 +394,12 @@ interface nsIContentPolicy : nsISupports
*/
const nsContentPolicyType TYPE_INTERNAL_PAINTWORKLET = 50;
/**
* Same as TYPE_FONT but indicates this is a <link rel=preload as=font>
* preload initiated load.
*/
const nsContentPolicyType TYPE_INTERNAL_FONT_PRELOAD = 51;
/* When adding new content types, please update
* NS_CP_ContentTypeName, nsCSPContext, CSP_ContentTypeToDirective,
* DoContentSecurityChecks, all nsIContentPolicy implementations, the

View File

@ -336,7 +336,8 @@ static_assert(nsIContentPolicy::TYPE_INVALID == 0 &&
nsIContentPolicy::TYPE_INTERNAL_DTD == 47 &&
nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD == 48 &&
nsIContentPolicy::TYPE_INTERNAL_AUDIOWORKLET == 49 &&
nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET == 50,
nsIContentPolicy::TYPE_INTERNAL_PAINTWORKLET == 50 &&
nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD == 51,
"nsContentPolicyType values are as expected");
namespace {

View File

@ -293,6 +293,7 @@ RequestDestination InternalRequest::MapContentPolicyTypeToRequestDestination(
destination = RequestDestination::_empty;
break;
case nsIContentPolicy::TYPE_FONT:
case nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD:
destination = RequestDestination::Font;
break;
case nsIContentPolicy::TYPE_MEDIA:

View File

@ -42,7 +42,7 @@ namespace dom {
* audioworklet | TYPE_INTERNAL_AUDIOWORKLET
* document | TYPE_DOCUMENT, TYPE_INTERNAL_IFRAME, TYPE_SUBDOCUMENT
* embed | TYPE_INTERNAL_EMBED
* font | TYPE_FONT
* font | TYPE_FONT, TYPE_INTERNAL_FONT_PRELOAD
* image | TYPE_INTERNAL_IMAGE, TYPE_INTERNAL_IMAGE_PRELOAD,
* | TYPE_IMAGE, TYPE_INTERNAL_IMAGE_FAVICON, TYPE_IMAGESET
* manifest | TYPE_WEB_MANIFEST

View File

@ -75,6 +75,7 @@ nsCString MapInternalContentPolicyTypeToDest(nsContentPolicyType aType) {
case nsIContentPolicy::TYPE_INTERNAL_FORCE_ALLOWED_DTD:
return NS_LITERAL_CSTRING("empty");
case nsIContentPolicy::TYPE_FONT:
case nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD:
return NS_LITERAL_CSTRING("font");
case nsIContentPolicy::TYPE_MEDIA:
return NS_LITERAL_CSTRING("empty");

View File

@ -271,6 +271,7 @@ CSPDirective CSP_ContentTypeToDirective(nsContentPolicyType aType) {
return nsIContentSecurityPolicy::STYLE_SRC_DIRECTIVE;
case nsIContentPolicy::TYPE_FONT:
case nsIContentPolicy::TYPE_INTERNAL_FONT_PRELOAD:
return nsIContentSecurityPolicy::FONT_SRC_DIRECTIVE;
case nsIContentPolicy::TYPE_MEDIA: