From 8bbcb50b626c9555b53987c31b422f4dea0ea552 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 28 Oct 2024 14:51:10 +0100 Subject: [PATCH 1/5] Revert "Issue #2645 - Fix type confusion for `ResumeKind`" This reverts commit 12e9db2481d2b542e4f32f9b5ba63a4c72b874d5. --- js/src/vm/Interpreter.cpp | 7 +------ js/src/vm/Opcodes.h | 2 +- js/src/vm/TypeInference.cpp | 4 +++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index db5e01803b..ad52234a31 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -1960,13 +1960,8 @@ CASE(JSOP_RETRVAL) /* Resume execution in the calling frame. */ if (MOZ_LIKELY(interpReturnOK)) { - - if (JSOp(*REGS.pc) == JSOP_RESUME) { - ADVANCE_AND_DISPATCH(JSOP_RESUME_LENGTH); - } - TypeScript::Monitor(cx, script, REGS.pc, REGS.sp[-1]); - MOZ_ASSERT(CodeSpec[*REGS.pc].length == JSOP_CALL_LENGTH); + ADVANCE_AND_DISPATCH(JSOP_CALL_LENGTH); } diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h index c5be5f6bef..ad140ff7bc 100644 --- a/js/src/vm/Opcodes.h +++ b/js/src/vm/Opcodes.h @@ -2106,7 +2106,7 @@ * Operands: resume kind (GeneratorObject::ResumeKind) * Stack: gen, val => rval */ \ - macro(JSOP_RESUME, 205,"resume", NULL, 2, 2, 1, JOF_UINT16|JOF_INVOKE) \ + macro(JSOP_RESUME, 205,"resume", NULL, 3, 2, 1, JOF_UINT8|JOF_INVOKE) \ /* * Pops the top two values on the stack as 'obj' and 'v', pushes 'v' to * 'obj'. diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index 8ed6e885f8..a36926eb94 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -3335,7 +3335,9 @@ js::TypeMonitorResult(JSContext* cx, JSScript* script, jsbytecode* pc, TypeSet:: void js::TypeMonitorResult(JSContext* cx, JSScript* script, jsbytecode* pc, const js::Value& rval) { - MOZ_ASSERT(CodeSpec[*pc].format & JOF_TYPESET); + /* Allow the non-TYPESET scenario to simplify stubs used in compound opcodes. */ + if (!(CodeSpec[*pc].format & JOF_TYPESET)) + return; if (!script->hasBaselineScript()) return; From 8d536c0cc76ee3d783d26b1f27da7b916797eab4 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 29 Oct 2024 11:16:30 +0100 Subject: [PATCH 2/5] Issue #2646 - Parse "variations" keywords. Resolves #2646 --- gfx/thebes/gfxUserFontSet.h | 13 +++++++++++-- layout/inspector/nsFontFace.cpp | 12 ++++++++++++ layout/style/FontFaceSet.cpp | 9 +++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gfx/thebes/gfxUserFontSet.h b/gfx/thebes/gfxUserFontSet.h index 3a13573ac2..2570bd7119 100644 --- a/gfx/thebes/gfxUserFontSet.h +++ b/gfx/thebes/gfxUserFontSet.h @@ -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) }; diff --git a/layout/inspector/nsFontFace.cpp b/layout/inspector/nsFontFace.cpp index abf9f6439c..03ac0d583f 100644 --- a/layout/inspector/nsFontFace.cpp +++ b/layout/inspector/nsFontFace.cpp @@ -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; } diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 81e6250ec7..54dc570a91 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -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 From 6fe326c7bb74c39a713b8d33f7462e2b5fe3ffb6 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 30 Oct 2024 09:06:43 +0100 Subject: [PATCH 3/5] Issue #2648 - Apply CSP to documents sent through multipart/x-mixed-replace --- .../converters/nsMultiMixedConv.cpp | 29 +++++++++++++++++++ .../streamconv/converters/nsMultiMixedConv.h | 4 ++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index 44a0dfd705..af21747ce6 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -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,12 @@ 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; + } } else { // try asking the channel directly rv = channel->GetContentType(delimiter); @@ -1062,6 +1069,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 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; diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index fa058b0720..c96cb55b88 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -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,8 @@ protected: nsCOMPtr mContext; nsCString mContentType; nsCString mContentDisposition; + nsCString mContentSecurityPolicy; + nsCString mRootContentSecurityPolicy; uint64_t mContentLength; char *mBuffer; From 5c0c0c02d9c28142a0f30d844482b158061c31ef Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 30 Oct 2024 09:50:08 +0100 Subject: [PATCH 4/5] Issue #2648 - Inherit the content disposition of the multipart response --- netwerk/streamconv/converters/nsMultiMixedConv.cpp | 13 ++++++++++++- netwerk/streamconv/converters/nsMultiMixedConv.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index af21747ce6..797f19029a 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -722,6 +722,12 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) { 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); @@ -882,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); diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index c96cb55b88..6944f957ad 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -158,6 +158,7 @@ protected: nsCString mContentDisposition; nsCString mContentSecurityPolicy; nsCString mRootContentSecurityPolicy; + nsCString mRootContentDisposition; uint64_t mContentLength; char *mBuffer; From 9ba1057e54a0e894ae26b2bb605c03dffe9ccf4a Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Wed, 30 Oct 2024 13:21:33 +0100 Subject: [PATCH 5/5] Bug 1920800 - Remove oldImages from check for flushed old principal handle The logic should be equivalent when frame IDs on aImages are contiguously increasing from IDs on previously set frames. There are currently no callers passing empty aImages, but the logic in this case would now be as described in the documentation of UpdatePrincipalHandleForFrameID(): > We will notify mElement that aPrincipalHandle has been applied when all > FrameIDs prior to aFrameID have been flushed out. --- dom/media/VideoFrameContainer.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/dom/media/VideoFrameContainer.cpp b/dom/media/VideoFrameContainer.cpp index 9b4237512f..e482c50bb3 100644 --- a/dom/media/VideoFrameContainer.cpp +++ b/dom/media/VideoFrameContainer.cpp @@ -225,19 +225,13 @@ void VideoFrameContainer::SetCurrentFramesLocked(const gfx::IntSize& aIntrinsicS nsTArray 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 self = this; PrincipalHandle principalHandle = mPendingPrincipalHandle; mLastPrincipalHandle = mPendingPrincipalHandle;