commit 85d1d9d7cbac461fe8a4c9d4acab577b81319933
parent 4ebb3d151a1c7c0a45f48a887eb94563637302c8
Author: Jan Varga <jvarga@igalia.com>
Date: Tue, 2 Dec 2025 10:13:22 +0000
Bug 1990419 - Add missing pieces to CSSNumericArray for Typed OM reification; r=firefox-style-system-reviewers,dshin
This patch extends CSSNumericArray with functionality required for reification
of calculated <length> values in CSS Typed OM. These additions are part of the
initial infrastructure needed to expose math values through the TypedValue
enum and enable relevant WPT reification tests.
Differential Revision: https://phabricator.services.mozilla.com/D270610
Diffstat:
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/layout/style/typedom/CSSNumericArray.cpp b/layout/style/typedom/CSSNumericArray.cpp
@@ -8,12 +8,14 @@
#include "mozilla/Assertions.h"
#include "mozilla/dom/CSSNumericArrayBinding.h"
+#include "mozilla/dom/CSSNumericValue.h"
#include "nsCycleCollectionParticipant.h"
namespace mozilla::dom {
-CSSNumericArray::CSSNumericArray(nsCOMPtr<nsISupports> aParent)
- : mParent(std::move(aParent)) {
+CSSNumericArray::CSSNumericArray(nsCOMPtr<nsISupports> aParent,
+ nsTArray<RefPtr<CSSNumericValue>> aValues)
+ : mParent(std::move(aParent)), mValues(std::move(aValues)) {
MOZ_ASSERT(mParent);
}
@@ -23,7 +25,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CSSNumericArray)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CSSNumericArray, mParent)
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(CSSNumericArray, mParent, mValues)
nsISupports* CSSNumericArray::GetParentObject() const { return mParent; }
@@ -34,9 +36,17 @@ JSObject* CSSNumericArray::WrapObject(JSContext* aCx,
// start of CSSNumericArray Web IDL implementation
-uint32_t CSSNumericArray::Length() const { return 0; }
+// https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericarray-length
+uint32_t CSSNumericArray::Length() const { return mValues.Length(); }
+// https://drafts.css-houdini.org/css-typed-om-1/#cssnumericarray-indexed-property-getter
CSSNumericValue* CSSNumericArray::IndexedGetter(uint32_t aIndex, bool& aFound) {
+ if (aIndex < mValues.Length()) {
+ aFound = true;
+ return mValues[aIndex];
+ }
+
+ aFound = false;
return nullptr;
}
diff --git a/layout/style/typedom/CSSNumericArray.h b/layout/style/typedom/CSSNumericArray.h
@@ -14,6 +14,7 @@
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsISupportsImpl.h"
+#include "nsTArray.h"
#include "nsWrapperCache.h"
namespace mozilla {
@@ -22,7 +23,8 @@ namespace dom {
class CSSNumericArray final : public nsISupports, public nsWrapperCache {
public:
- explicit CSSNumericArray(nsCOMPtr<nsISupports> aParent);
+ CSSNumericArray(nsCOMPtr<nsISupports> aParent,
+ nsTArray<RefPtr<CSSNumericValue>> aValues);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(CSSNumericArray)
@@ -34,8 +36,10 @@ class CSSNumericArray final : public nsISupports, public nsWrapperCache {
// start of CSSNumericArray Web IDL declarations
+ // https://drafts.css-houdini.org/css-typed-om-1/#dom-cssnumericarray-length
uint32_t Length() const;
+ // https://drafts.css-houdini.org/css-typed-om-1/#cssnumericarray-indexed-property-getter
CSSNumericValue* IndexedGetter(uint32_t aIndex, bool& aFound);
// end of CSSNumericArray Web IDL declarations
@@ -44,6 +48,7 @@ class CSSNumericArray final : public nsISupports, public nsWrapperCache {
virtual ~CSSNumericArray() = default;
nsCOMPtr<nsISupports> mParent;
+ nsTArray<RefPtr<CSSNumericValue>> mValues;
};
} // namespace dom