tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 39d16c1561a2b235aa0606926b0949d32d7a7557
parent ff5c473041f83e1a6e51585ab07880596e6b682b
Author: Jan Varga <jvarga@igalia.com>
Date:   Mon, 17 Nov 2025 22:00:49 +0000

Bug 1990419 – Store CSSPropertyId in CSSUnsupportedValue instead of a string; r=emilio,firefox-style-system-reviewers

Switch CSSUnsupportedValue from storing its associated property as a string to
storing a CSSPropertyId. This makes it easier to support custom properties in
the future.

Having mPropertyId also enables adding a future assertion in upcoming
CSSUnsupportedValue::ToCssTextWithProperty to ensure the caller provided
property id matches the associated one, preventing accidental misuse.

Differential Revision: https://phabricator.services.mozilla.com/D271809

Diffstat:
Mlayout/style/typedom/CSSUnsupportedValue.cpp | 6+++---
Mlayout/style/typedom/CSSUnsupportedValue.h | 6+++---
Mlayout/style/typedom/StylePropertyMapReadOnly.cpp | 8+++++---
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/layout/style/typedom/CSSUnsupportedValue.cpp b/layout/style/typedom/CSSUnsupportedValue.cpp @@ -12,14 +12,14 @@ namespace mozilla::dom { CSSUnsupportedValue::CSSUnsupportedValue(nsCOMPtr<nsISupports> aParent, - const nsACString& aProperty, + const CSSPropertyId& aPropertyId, RefPtr<DeclarationBlock> aDeclarations) : CSSStyleValue(std::move(aParent), ValueType::Unsupported), - mProperty(aProperty), + mPropertyId(aPropertyId), mDeclarations(std::move(aDeclarations)) {} void CSSUnsupportedValue::GetValue(nsACString& aRetVal) const { - mDeclarations->GetPropertyValue(mProperty, aRetVal); + mDeclarations->GetPropertyValueById(mPropertyId, aRetVal); } CSSUnsupportedValue& CSSStyleValue::GetAsCSSUnsupportedValue() { diff --git a/layout/style/typedom/CSSUnsupportedValue.h b/layout/style/typedom/CSSUnsupportedValue.h @@ -7,9 +7,9 @@ #ifndef LAYOUT_STYLE_TYPEDOM_CSSUNSUPPORTEDVALUE_H_ #define LAYOUT_STYLE_TYPEDOM_CSSUNSUPPORTEDVALUE_H_ +#include "mozilla/CSSPropertyId.h" #include "mozilla/RefPtr.h" #include "mozilla/dom/CSSStyleValue.h" -#include "nsString.h" template <class T> class nsCOMPtr; @@ -30,7 +30,7 @@ namespace dom { class CSSUnsupportedValue final : public CSSStyleValue { public: CSSUnsupportedValue(nsCOMPtr<nsISupports> aParent, - const nsACString& aProperty, + const CSSPropertyId& aPropertyId, RefPtr<DeclarationBlock> aDeclarations); void GetValue(nsACString& aRetVal) const; @@ -38,7 +38,7 @@ class CSSUnsupportedValue final : public CSSStyleValue { private: virtual ~CSSUnsupportedValue() = default; - nsCString mProperty; + CSSPropertyId mPropertyId; RefPtr<DeclarationBlock> mDeclarations; }; diff --git a/layout/style/typedom/StylePropertyMapReadOnly.cpp b/layout/style/typedom/StylePropertyMapReadOnly.cpp @@ -124,8 +124,8 @@ void StylePropertyMapReadOnly::Get(const nsACString& aProperty, // Step 2. - NonCustomCSSPropertyId propId = nsCSSProps::LookupProperty(aProperty); - if (propId == eCSSProperty_UNKNOWN) { + NonCustomCSSPropertyId id = nsCSSProps::LookupProperty(aProperty); + if (id == eCSSProperty_UNKNOWN) { aRv.ThrowTypeError("Invalid property: "_ns + aProperty); return; } @@ -155,12 +155,14 @@ void StylePropertyMapReadOnly::Get(const nsACString& aProperty, } if (result.IsUnsupported()) { + auto propertyId = CSSPropertyId::FromIdOrCustomProperty(id, aProperty); + auto rawBlock = result.AsUnsupported(); auto block = MakeRefPtr<DeclarationBlock>(rawBlock.Consume()); auto unsupportedValue = - MakeRefPtr<CSSUnsupportedValue>(mParent, aProperty, std::move(block)); + MakeRefPtr<CSSUnsupportedValue>(mParent, propertyId, std::move(block)); aRetVal.SetAsCSSStyleValue() = std::move(unsupportedValue); return;