Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-10-31 21:48:26 +08:00
commit 4397f384a7
6 changed files with 83 additions and 16 deletions

View file

@ -225,19 +225,13 @@ void VideoFrameContainer::SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicS
nsTArray<ImageContainer::OwningImage> oldImages;
mImageContainer->GetCurrentImages(&oldImages);
ImageContainer::FrameID lastFrameIDForOldPrincipalHandle =
mFrameIDForPendingPrincipalHandle - 1;
if (mPendingPrincipalHandle != PRINCIPAL_HANDLE_NONE &&
((!oldImages.IsEmpty() &&
oldImages.LastElement().mFrameID >= lastFrameIDForOldPrincipalHandle) ||
(!aImages.IsEmpty() &&
aImages[0].mFrameID > lastFrameIDForOldPrincipalHandle))) {
// We are releasing the last FrameID prior to `lastFrameIDForOldPrincipalHandle`
// OR
// there are no FrameIDs prior to `lastFrameIDForOldPrincipalHandle` in the new
// set of images.
// This means that the old principal handle has been flushed out and we can
// notify our video element about this change.
(aImages.IsEmpty() ||
aImages[0].mFrameID >= mFrameIDForPendingPrincipalHandle)) {
// There are no FrameIDs prior to `mFrameIDForPendingPrincipalHandle`
// in the new set of images.
// This means that the old principal handle has been flushed out and we
// can notify our video element about this change.
RefPtr<VideoFrameContainer> self = this;
PrincipalHandle principalHandle = mPendingPrincipalHandle;
mLastPrincipalHandle = mPendingPrincipalHandle;

View file

@ -191,14 +191,23 @@ public:
FLAG_FORMAT_WOFF = 1 << 6,
FLAG_FORMAT_WOFF2 = 1 << 7,
FLAG_FORMAT_OPENTYPE_VARIATIONS = 1 << 8,
FLAG_FORMAT_TRUETYPE_VARIATIONS = 1 << 9,
FLAG_FORMAT_WOFF_VARIATIONS = 1 << 10,
FLAG_FORMAT_WOFF2_VARIATIONS = 1 << 11,
// the common formats that we support everywhere
FLAG_FORMATS_COMMON = FLAG_FORMAT_OPENTYPE |
FLAG_FORMAT_TRUETYPE |
FLAG_FORMAT_WOFF |
FLAG_FORMAT_WOFF2,
FLAG_FORMAT_WOFF2 |
FLAG_FORMAT_OPENTYPE_VARIATIONS |
FLAG_FORMAT_TRUETYPE_VARIATIONS |
FLAG_FORMAT_WOFF_VARIATIONS |
FLAG_FORMAT_WOFF2_VARIATIONS,
// mask of all unused bits, update when adding new formats
FLAG_FORMAT_NOT_USED = ~((1 << 8)-1)
FLAG_FORMAT_NOT_USED = ~((1 << 12)-1)
};

View file

@ -178,6 +178,18 @@ nsFontFace::GetFormat(nsAString & aFormat)
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2) {
AppendToFormat(aFormat, "woff2");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS) {
AppendToFormat(aFormat, "opentype-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS) {
AppendToFormat(aFormat, "truetype-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS) {
AppendToFormat(aFormat, "woff-variations");
}
if (formatFlags & gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS) {
AppendToFormat(aFormat, "woff2-variations");
}
}
return NS_OK;
}

View file

@ -1132,6 +1132,15 @@ FontFaceSet::FindOrCreateUserFontEntryFromFontFace(const nsAString& aFamilyName,
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_EOT;
} else if (valueString.LowerCaseEqualsASCII("svg")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_SVG;
} else if (valueString.LowerCaseEqualsASCII("woff-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF_VARIATIONS;
} else if (Preferences::GetBool(GFX_PREF_WOFF2_ENABLED) &&
valueString.LowerCaseEqualsASCII("woff2-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_WOFF2_VARIATIONS;
} else if (valueString.LowerCaseEqualsASCII("opentype-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_OPENTYPE_VARIATIONS;
} else if (valueString.LowerCaseEqualsASCII("truetype-variations")) {
face->mFormatFlags |= gfxUserFontSet::FLAG_FORMAT_TRUETYPE_VARIATIONS;
} else {
// unknown format specified, mark to distinguish from the
// case where no format hints are specified

View file

@ -644,6 +644,7 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context,
mContentType.Truncate();
mContentLength = UINT64_MAX;
mContentDisposition.Truncate();
mContentSecurityPolicy.Truncate();
mIsByteRangeRequest = false;
mByteRangeStart = 0;
mByteRangeEnd = 0;
@ -715,6 +716,18 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) {
if (NS_FAILED(rv)) {
return rv;
}
nsCString csp;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-security-policy"),
csp);
if (NS_SUCCEEDED(rv)) {
mRootContentSecurityPolicy = csp;
}
nsCString contentDisposition;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"),
contentDisposition);
if (NS_SUCCEEDED(rv)) {
mRootContentDisposition = contentDisposition;
}
} else {
// try asking the channel directly
rv = channel->GetContentType(delimiter);
@ -875,7 +888,12 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
rv = mPartChannel->SetContentLength(mContentLength);
if (NS_FAILED(rv)) return rv;
mPartChannel->SetContentDisposition(mContentDisposition);
// Adopt content-disposition from the root doc, if present.
if (!mRootContentDisposition.IsEmpty()) {
mPartChannel->SetContentDisposition(mRootContentDisposition);
} else {
mPartChannel->SetContentDisposition(mContentDisposition);
}
nsLoadFlags loadFlags = 0;
mPartChannel->GetLoadFlags(&loadFlags);
@ -1062,6 +1080,28 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
mIsByteRangeRequest = true;
if (mContentLength == UINT64_MAX)
mContentLength = uint64_t(mByteRangeEnd - mByteRangeStart + 1);
} else if (headerStr.LowerCaseEqualsLiteral("content-security-policy")) {
mContentSecurityPolicy = headerVal;
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aChannel);
if (httpChannel) {
nsCString resultCSP = mRootContentSecurityPolicy;
if (!mContentSecurityPolicy.IsEmpty()) {
// We are updating the root channel CSP header respectively for
// each part as: CSP-root + CSP-partN, where N is the part number.
// Here we append current part's CSP to root CSP and reset CSP
// header for each part.
if (!resultCSP.IsEmpty()) {
resultCSP.Append(";");
}
resultCSP.Append(mContentSecurityPolicy);
}
nsresult rv = httpChannel->SetResponseHeader(
NS_LITERAL_CSTRING("Content-Security-Policy"),
resultCSP, false);
if (NS_FAILED(rv)) {
return NS_ERROR_CORRUPTED_CONTENT;
}
}
}
}
*newLine = tmpChar;

View file

@ -96,7 +96,7 @@ protected:
// main stream and sending them off the destination stream listener, than doing any real
// stream parsing/converting.
//
// WARNING: This converter requires that it's destination stream listener be able to handle
// WARNING: This converter requires that its destination stream listener be able to handle
// multiple OnStartRequest(), OnDataAvailable(), and OnStopRequest() call combinations.
// Each series represents the beginning, data production, and ending phase of each sub-
// part of the original stream.
@ -156,6 +156,9 @@ protected:
nsCOMPtr<nsISupports> mContext;
nsCString mContentType;
nsCString mContentDisposition;
nsCString mContentSecurityPolicy;
nsCString mRootContentSecurityPolicy;
nsCString mRootContentDisposition;
uint64_t mContentLength;
char *mBuffer;