From 37753e32a8885844a1a3ca599ee5b5786590d856 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 22 Apr 2022 21:50:17 +0800 Subject: [PATCH 1/4] Issue #1881 - Interpret empty or whitespace root margin string as zero length This attempts to get the first non-whitespace token, which if exists, continues with previous behavior of parsing the margin string. Otherwise, if the specified margin string is empty or consists only of whitespace characters, is interpreted as zero length. IntersectionObserver is the only consumer of the `ParseMarginString` method, as far as I can tell, so this should not affect anything else. Note: For some reason, Firefox and Chrome treat the unitless zero length as invalid, while with this change, we do not change existing behavior in that regard and continue to accept that value. --- layout/style/nsCSSParser.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index bfdf6ee6e5..4331e454dc 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -2304,8 +2304,20 @@ CSSParserImpl::ParseMarginString(const nsSubstring& aBuffer, nsAutoSuppressErrors suppressErrors(this, aSuppressErrors); - // Parse a margin, and check that there's nothing else after it. - bool marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && !GetToken(true); + bool marginParsed = false; + + // Treat margin as zero length if there are no tokens, i.e., the specified + // margin string is empty or consists only of whitespace characters. + if (!GetToken(true)) { + nsCSSRect& zeroRootMargin = aValue.SetRectValue(); + zeroRootMargin.SetAllSidesTo(nsCSSValue(0.0f, eCSSUnit_Pixel)); + marginParsed = true; + } else { + UngetToken(); + // Parse a margin, and check that there's nothing else after it. + marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && + !GetToken(true); + } if (aSuppressErrors) { CLEAR_ERROR(); From 3f9cd2050f534abae25983039a1da34faeb56bc0 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 24 Apr 2022 15:52:33 +0000 Subject: [PATCH 2/4] Issue #1879 - Revert changes to cryptox.h The error when removing this code was an #if vs #elif. But since we're planning to restore MacOSX anyway, may as well rever the entire file here :) --- modules/libmar/verify/cryptox.h | 49 ++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/modules/libmar/verify/cryptox.h b/modules/libmar/verify/cryptox.h index d6dceb366c..2296b815f4 100644 --- a/modules/libmar/verify/cryptox.h +++ b/modules/libmar/verify/cryptox.h @@ -57,7 +57,54 @@ CryptoX_Result NSS_VerifySignature(VFYContext * const *ctx , #define CryptoX_FreeCertificate(cert) \ CERT_DestroyCertificate(*cert) -#if defined(XP_WIN) +#elif XP_MACOSX + +#define CryptoX_InvalidHandleValue NULL +#define CryptoX_ProviderHandle void* +#define CryptoX_SignatureHandle void* +#define CryptoX_PublicKey void* +#define CryptoX_Certificate void* + +// Forward-declare Objective-C functions implemented in MacVerifyCrypto.mm. +#ifdef __cplusplus +extern "C" { +#endif +CryptoX_Result CryptoMac_InitCryptoProvider(); +CryptoX_Result CryptoMac_VerifyBegin(CryptoX_SignatureHandle* aInputData); +CryptoX_Result CryptoMac_VerifyUpdate(CryptoX_SignatureHandle* aInputData, + void* aBuf, unsigned int aLen); +CryptoX_Result CryptoMac_LoadPublicKey(const unsigned char* aCertData, + unsigned int aDataSize, + CryptoX_PublicKey* aPublicKey); +CryptoX_Result CryptoMac_VerifySignature(CryptoX_SignatureHandle* aInputData, + CryptoX_PublicKey* aPublicKey, + const unsigned char* aSignature, + unsigned int aSignatureLen); +void CryptoMac_FreeSignatureHandle(CryptoX_SignatureHandle* aInputData); +void CryptoMac_FreePublicKey(CryptoX_PublicKey* aPublicKey); +#ifdef __cplusplus +} // extern "C" +#endif + +#define CryptoX_InitCryptoProvider(aProviderHandle) \ + CryptoMac_InitCryptoProvider() +#define CryptoX_VerifyBegin(aCryptoHandle, aInputData, aPublicKey) \ + CryptoMac_VerifyBegin(aInputData) +#define CryptoX_VerifyUpdate(aInputData, aBuf, aLen) \ + CryptoMac_VerifyUpdate(aInputData, aBuf, aLen) +#define CryptoX_LoadPublicKey(aProviderHandle, aCertData, aDataSize, \ + aPublicKey) \ + CryptoMac_LoadPublicKey(aCertData, aDataSize, aPublicKey) +#define CryptoX_VerifySignature(aInputData, aPublicKey, aSignature, \ + aSignatureLen) \ + CryptoMac_VerifySignature(aInputData, aPublicKey, aSignature, aSignatureLen) +#define CryptoX_FreeSignatureHandle(aInputData) \ + CryptoMac_FreeSignatureHandle(aInputData) +#define CryptoX_FreePublicKey(aPublicKey) \ + CryptoMac_FreePublicKey(aPublicKey) +#define CryptoX_FreeCertificate(aCertificate) + +#elif defined(XP_WIN) #include #include From 7c9304728325428ec47821bd5d983570f495d97a Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 24 Apr 2022 17:00:46 +0000 Subject: [PATCH 3/4] Issue #1885 - Allow unitless rootMargin entries for IntersectionObserver. I could have done this through a CSSLoader to allow all CSS unit quirks but I wasn't planning to start passing around document and element references everywhere, so instead just did it manually by accepting numbers/floats in addition to pixel and percent. --- dom/base/DOMIntersectionObserver.cpp | 6 +++++- layout/style/nsCSSParser.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp index bc8f030d0f..fb6315cc42 100644 --- a/dom/base/DOMIntersectionObserver.cpp +++ b/dom/base/DOMIntersectionObserver.cpp @@ -126,7 +126,9 @@ DOMIntersectionObserver::SetRootMargin(const nsAString& aString) for (uint32_t i = 0; i < ArrayLength(nsCSSRect::sides); ++i) { nsCSSValue value = mRootMargin.*nsCSSRect::sides[i]; - if (!(value.IsPixelLengthUnit() || value.IsPercentLengthUnit())) { + if (!(value.IsPixelLengthUnit() || + value.IsPercentLengthUnit() || + value.IsFloatUnit(value.GetUnit()))) { return false; } } @@ -327,6 +329,8 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time nsStyleCoord coord; if (value.IsPixelLengthUnit()) { coord.SetCoordValue(value.GetPixelLength()); + } else if (value.IsFloatUnit(value.GetUnit())) { + coord.SetCoordValue(value.GetFloatValue()); } else if (value.IsPercentLengthUnit()) { coord.SetPercentValue(value.GetPercentValue()); } else { diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 4331e454dc..a7e5e4d4b9 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -2315,7 +2315,7 @@ CSSParserImpl::ParseMarginString(const nsSubstring& aBuffer, } else { UngetToken(); // Parse a margin, and check that there's nothing else after it. - marginParsed = ParseGroupedBoxProperty(VARIANT_LP, aValue, 0) && + marginParsed = ParseGroupedBoxProperty(VARIANT_LPN, aValue, 0) && !GetToken(true); } From 136f38ba8c141e8fbca2c1cfff3f1e84d6cb79e5 Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Sun, 24 Apr 2022 15:01:24 -0500 Subject: [PATCH 4/4] Issue #1879 - Follow-up: Update config/external/nss/target to security/target. --- config/recurse.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/recurse.mk b/config/recurse.mk index 6bf5670b57..30d915d19f 100644 --- a/config/recurse.mk +++ b/config/recurse.mk @@ -165,7 +165,7 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3) toolkit/library/target: widget/gtk/mozgtk/gtk3/target endif ifdef MOZ_LDAP_XPCOM -ldap/target: config/external/nss/target mozglue/build/target +ldap/target: security/target mozglue/build/target toolkit/library/target: ldap/target endif ifeq ($(MOZ_REPLACE_MALLOC_LINKAGE),dummy library)