From 6449b7514bd6f0d32b6fd396fcdfcf12ab5dd6ba Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 15 Mar 2025 20:20:23 +0100 Subject: [PATCH 1/6] No issue - Fix some deprot --- dom/base/Link.h | 1 + dom/html/HTMLSlotElement.cpp | 1 + dom/html/TextTrackManager.cpp | 1 + dom/html/nsHTMLDNSPrefetch.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/dom/base/Link.h b/dom/base/Link.h index 0974d6108c..99a5735110 100644 --- a/dom/base/Link.h +++ b/dom/base/Link.h @@ -13,6 +13,7 @@ #include "mozilla/IHistory.h" #include "mozilla/MemoryReporting.h" #include "nsIContent.h" // for nsLinkState +#include "nsIContentPolicyBase.h" // for nsContentPolicyType namespace mozilla { diff --git a/dom/html/HTMLSlotElement.cpp b/dom/html/HTMLSlotElement.cpp index 9286ff9591..eb5b48c22a 100644 --- a/dom/html/HTMLSlotElement.cpp +++ b/dom/html/HTMLSlotElement.cpp @@ -10,6 +10,7 @@ #include "mozilla/dom/ShadowRoot.h" #include "nsGkAtoms.h" #include "nsDocument.h" +#include "nsLayoutUtils.h" nsGenericHTMLElement* NS_NewHTMLSlotElement(already_AddRefed&& aNodeInfo, diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp index 1809478f2d..4b69675a0d 100644 --- a/dom/html/TextTrackManager.cpp +++ b/dom/html/TextTrackManager.cpp @@ -11,6 +11,7 @@ #include "mozilla/dom/TextTrackCue.h" #include "mozilla/dom/Event.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/CycleCollectedJSContext.h" #include "nsComponentManagerUtils.h" #include "nsVariant.h" #include "nsVideoFrame.h" diff --git a/dom/html/nsHTMLDNSPrefetch.cpp b/dom/html/nsHTMLDNSPrefetch.cpp index 1b91d8041d..2f55f9672b 100644 --- a/dom/html/nsHTMLDNSPrefetch.cpp +++ b/dom/html/nsHTMLDNSPrefetch.cpp @@ -15,6 +15,7 @@ #include "nsNetUtil.h" #include "nsNetCID.h" #include "nsIProtocolHandler.h" +#include "nsContentUtils.h" #include "nsIDNSListener.h" #include "nsIWebProgressListener.h" From 6411abd43c5c2de2ac43826cdc197a68e1bcc336 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 21 Mar 2025 15:30:47 +0100 Subject: [PATCH 2/6] Issue #2711 - Apply pattern transforms when using text-rendering on canvas. Resolves #2711 --- dom/canvas/CanvasRenderingContext2D.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index d134cfade1..32241e7c98 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -4171,7 +4171,7 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess already_AddRefed GetPatternFor(Style aStyle) { const CanvasPattern* pat = mCtx->CurrentState().patternStyles[aStyle]; - RefPtr pattern = new gfxPattern(pat->mSurface, Matrix()); + RefPtr pattern = new gfxPattern(pat->mSurface, pat->mTransform); pattern->SetExtend(CvtCanvasRepeatToGfxRepeat(pat->mRepeat)); return pattern.forget(); } From d678f508de4296df4fb29ffb892e158003d849d4 Mon Sep 17 00:00:00 2001 From: Shadow Date: Fri, 14 Mar 2025 13:39:08 +0000 Subject: [PATCH 3/6] Issue #2703 - Part 1: micro-optimize purging expired preflight cache entries. The entries in mMethods and mHeaders aren't sorted in any special way, so we can remove expired entries using UnorderedRemoveElementAt, which is faster than RemoveElementAt. --- netwerk/protocol/http/nsCORSListenerProxy.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index add904092a..a5f5fab43b 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -215,15 +215,18 @@ static bool EnsurePreflightCache() void nsPreflightCache::CacheEntry::PurgeExpired(TimeStamp now) { - uint32_t i; - for (i = 0; i < mMethods.Length(); ++i) { + for (uint32_t i = 0, len = mMethods.Length(); i < len; ++i) { if (now >= mMethods[i].expirationTime) { - mMethods.RemoveElementAt(i--); + mMethods.UnorderedRemoveElementAt(i); + --i; // Examine the element again, if necessary. + --len; } } - for (i = 0; i < mHeaders.Length(); ++i) { + for (uint32_t i = 0, len = mHeaders.Length(); i < len; ++i) { if (now >= mHeaders[i].expirationTime) { - mHeaders.RemoveElementAt(i--); + mHeaders.UnorderedRemoveElementAt(i); + --i; // Examine the element again, if necessary. + --len; } } } From 7854198085ce1d2622fab52744b504ab1fbee0ae Mon Sep 17 00:00:00 2001 From: Shadow Date: Fri, 14 Mar 2025 13:47:55 +0000 Subject: [PATCH 4/6] Issue #2703 - Part 2: Don't repeatedly construct comparators when checking cache entries. nsCaseInsensitiveCStringComparator ought to be cheap to construct, but the object actually has a vtable to install and whatnot. So it's beneficial to pull the construction of it outside of the headers loop. --- netwerk/protocol/http/nsCORSListenerProxy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index a5f5fab43b..a1e6089523 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -250,9 +250,9 @@ nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod, for (uint32_t i = 0; i < aHeaders.Length(); ++i) { uint32_t j; + const auto& comparator = nsCaseInsensitiveCStringComparator(); for (j = 0; j < mHeaders.Length(); ++j) { - if (aHeaders[i].Equals(mHeaders[j].token, - nsCaseInsensitiveCStringComparator())) { + if (aHeaders[i].Equals(mHeaders[j].token, comparator)) { break; } } @@ -1385,8 +1385,8 @@ nsCORSPreflightListener::CheckPreflightRequestApproved(nsIRequest* aRequest) ) { continue; } - if (!headers.Contains(mPreflightHeaders[i], - nsCaseInsensitiveCStringArrayComparator())) { + const auto& comparator = nsCaseInsensitiveCStringArrayComparator(); + if (!headers.Contains(mPreflightHeaders[i], comparator)) { LogBlockedRequest(aRequest, "CORSMissingAllowHeaderFromPreflight", NS_ConvertUTF8toUTF16(mPreflightHeaders[i]).get()); return NS_ERROR_DOM_BAD_URI; From fdfe81fe5430065910173fbd9238c33cc0e7a2e1 Mon Sep 17 00:00:00 2001 From: Shadow Date: Fri, 14 Mar 2025 14:26:29 +0000 Subject: [PATCH 5/6] Issue #2703 - Part 3: Make cache entry request checking more readable. --- netwerk/protocol/http/nsCORSListenerProxy.cpp | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index a1e6089523..7f0c06d04f 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -238,25 +238,26 @@ nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod, PurgeExpired(TimeStamp::NowLoRes()); if (!aMethod.EqualsLiteral("GET") && !aMethod.EqualsLiteral("POST")) { - uint32_t i; - for (i = 0; i < mMethods.Length(); ++i) { - if (aMethod.Equals(mMethods[i].token)) - break; - } - if (i == mMethods.Length()) { + struct CheckToken { + bool Equals(const TokenTime& e, const nsCString& method) const { + return e.token.Equals(method); + } + }; + + if (!mMethods.Contains(aMethod, CheckToken())) { return false; } } - for (uint32_t i = 0; i < aHeaders.Length(); ++i) { - uint32_t j; - const auto& comparator = nsCaseInsensitiveCStringComparator(); - for (j = 0; j < mHeaders.Length(); ++j) { - if (aHeaders[i].Equals(mHeaders[j].token, comparator)) { - break; - } + const struct CheckHeaderToken { + bool Equals(const TokenTime& e, const nsCString& header) const { + return e.token.Equals(header, comparator); } - if (j == mHeaders.Length()) { + + const nsCaseInsensitiveCStringComparator comparator; + } checker; + for (uint32_t i = 0; i < aHeaders.Length(); ++i) { + if (!mHeaders.Contains(aHeaders[i], checker)) { return false; } } From 8f2f4d8d3d377b5c68a39bcfc11fe778e2025ff0 Mon Sep 17 00:00:00 2001 From: Shadow Date: Fri, 14 Mar 2025 14:40:41 +0000 Subject: [PATCH 6/6] Issue #2703 - Part 4: Fix incorrect clang warning in nsCORSListenerProxy. See BZ Bug 1444472 Resolves #2703 --- netwerk/protocol/http/nsCORSListenerProxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index 7f0c06d04f..fdb6bb97e5 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -249,7 +249,7 @@ nsPreflightCache::CacheEntry::CheckRequest(const nsCString& aMethod, } } - const struct CheckHeaderToken { + struct CheckHeaderToken { bool Equals(const TokenTime& e, const nsCString& header) const { return e.token.Equals(header, comparator); }