Commit 41116935 authored by Darren Shen's avatar Darren Shen Committed by Commit Bot

[css-typed-om] Add a 'values' attribute to all variadic CSSMathValues.

This patch adds the 'values' attribute to CSSMathSum/Product/Min/Max.
'values' is a CSSNumericArray, which is an array of CSSNumericValues
representing the arguments to the CSSMathValue. We make the variadic
CSSMathValues inherit from a new class CSSMathVariadic so that all the
boilerplate with working with multiple arguments are in one place.

Note that CSSNumericArray is not spec'd, but we based the implementation
off https://github.com/w3c/css-houdini-drafts/issues/486

Spec: https://drafts.css-houdini.org/css-typed-om-1/#complex-numeric

Bug: 776173
Change-Id: I1079b31993ecb02f31c2fe93ebf31c548fa6025c
Reviewed-on: https://chromium-review.googlesource.com/762887Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarRenée Wright <rjwright@chromium.org>
Commit-Queue: Darren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516223}
parent ecc9a74e
...@@ -16,17 +16,25 @@ CONSOLE MESSAGE: line 147: getter value ...@@ -16,17 +16,25 @@ CONSOLE MESSAGE: line 147: getter value
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter value CONSOLE MESSAGE: line 147: setter value
CONSOLE MESSAGE: line 147: interface CSSMathMax : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathMax : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathMin : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathMin : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathNegate : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathNegate : CSSMathValue
CONSOLE MESSAGE: line 147: getter value CONSOLE MESSAGE: line 147: getter value
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter value CONSOLE MESSAGE: line 147: setter value
CONSOLE MESSAGE: line 147: interface CSSMathProduct : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathProduct : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathSum : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathSum : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathValue : CSSNumericValue CONSOLE MESSAGE: line 147: interface CSSMathValue : CSSNumericValue
CONSOLE MESSAGE: line 147: getter operator CONSOLE MESSAGE: line 147: getter operator
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
...@@ -34,6 +42,9 @@ CONSOLE MESSAGE: line 147: interface CSSMatrixComponent : CSSTransformComponent ...@@ -34,6 +42,9 @@ CONSOLE MESSAGE: line 147: interface CSSMatrixComponent : CSSTransformComponent
CONSOLE MESSAGE: line 147: getter matrix CONSOLE MESSAGE: line 147: getter matrix
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter matrix CONSOLE MESSAGE: line 147: setter matrix
CONSOLE MESSAGE: line 147: interface CSSNumericArray
CONSOLE MESSAGE: line 147: getter length
CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: interface CSSNumericValue : CSSStyleValue CONSOLE MESSAGE: line 147: interface CSSNumericValue : CSSStyleValue
CONSOLE MESSAGE: line 147: method add CONSOLE MESSAGE: line 147: method add
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
...@@ -295,17 +306,25 @@ CONSOLE MESSAGE: line 147: getter value ...@@ -295,17 +306,25 @@ CONSOLE MESSAGE: line 147: getter value
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter value CONSOLE MESSAGE: line 147: setter value
CONSOLE MESSAGE: line 147: interface CSSMathMax : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathMax : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathMin : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathMin : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathNegate : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathNegate : CSSMathValue
CONSOLE MESSAGE: line 147: getter value CONSOLE MESSAGE: line 147: getter value
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter value CONSOLE MESSAGE: line 147: setter value
CONSOLE MESSAGE: line 147: interface CSSMathProduct : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathProduct : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathSum : CSSMathValue CONSOLE MESSAGE: line 147: interface CSSMathSum : CSSMathValue
CONSOLE MESSAGE: line 147: getter values
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter values
CONSOLE MESSAGE: line 147: interface CSSMathValue : CSSNumericValue CONSOLE MESSAGE: line 147: interface CSSMathValue : CSSNumericValue
CONSOLE MESSAGE: line 147: getter operator CONSOLE MESSAGE: line 147: getter operator
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
...@@ -313,6 +332,9 @@ CONSOLE MESSAGE: line 147: interface CSSMatrixComponent : CSSTransformComponent ...@@ -313,6 +332,9 @@ CONSOLE MESSAGE: line 147: interface CSSMatrixComponent : CSSTransformComponent
CONSOLE MESSAGE: line 147: getter matrix CONSOLE MESSAGE: line 147: getter matrix
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: setter matrix CONSOLE MESSAGE: line 147: setter matrix
CONSOLE MESSAGE: line 147: interface CSSNumericArray
CONSOLE MESSAGE: line 147: getter length
CONSOLE MESSAGE: line 147: method constructor
CONSOLE MESSAGE: line 147: interface CSSNumericValue : CSSStyleValue CONSOLE MESSAGE: line 147: interface CSSNumericValue : CSSStyleValue
CONSOLE MESSAGE: line 147: method add CONSOLE MESSAGE: line 147: method add
CONSOLE MESSAGE: line 147: method constructor CONSOLE MESSAGE: line 147: method constructor
......
...@@ -23,11 +23,14 @@ for (const {subclass, operator} of gVariadicMathValueSubclasses) { ...@@ -23,11 +23,14 @@ for (const {subclass, operator} of gVariadicMathValueSubclasses) {
test(() => { test(() => {
const result = new subclass(CSS.number(0)); const result = new subclass(CSS.number(0));
assert_equals(result.operator, operator); assert_equals(result.operator, operator);
assert_style_value_array_equals(result.values, [CSS.number(0)]);
}, subclass.name + ' can be constructed from a single number CSSUnitValue'); }, subclass.name + ' can be constructed from a single number CSSUnitValue');
test(() => { test(() => {
const result = new subclass(CSS.number(1), CSS.number(2), CSS.number(3), CSS.number(4), CSS.number(5)); const args = [CSS.number(1), CSS.number(2), CSS.number(3), CSS.number(4), CSS.number(5)]
const result = new subclass(...args);
assert_equals(result.operator, operator); assert_equals(result.operator, operator);
assert_style_value_array_equals(result.values, args);
}, subclass.name + ' can be constructed from more than one number CSSUnitValue'); }, subclass.name + ' can be constructed from more than one number CSSUnitValue');
test(() => { test(() => {
......
...@@ -646,10 +646,14 @@ interface CSSMathInvert : CSSMathValue ...@@ -646,10 +646,14 @@ interface CSSMathInvert : CSSMathValue
setter value setter value
interface CSSMathMax : CSSMathValue interface CSSMathMax : CSSMathValue
attribute @@toStringTag attribute @@toStringTag
getter values
method constructor method constructor
setter values
interface CSSMathMin : CSSMathValue interface CSSMathMin : CSSMathValue
attribute @@toStringTag attribute @@toStringTag
getter values
method constructor method constructor
setter values
interface CSSMathNegate : CSSMathValue interface CSSMathNegate : CSSMathValue
attribute @@toStringTag attribute @@toStringTag
getter value getter value
...@@ -657,10 +661,14 @@ interface CSSMathNegate : CSSMathValue ...@@ -657,10 +661,14 @@ interface CSSMathNegate : CSSMathValue
setter value setter value
interface CSSMathProduct : CSSMathValue interface CSSMathProduct : CSSMathValue
attribute @@toStringTag attribute @@toStringTag
getter values
method constructor method constructor
setter values
interface CSSMathSum : CSSMathValue interface CSSMathSum : CSSMathValue
attribute @@toStringTag attribute @@toStringTag
getter values
method constructor method constructor
setter values
interface CSSMathValue : CSSNumericValue interface CSSMathValue : CSSNumericValue
attribute @@toStringTag attribute @@toStringTag
getter operator getter operator
...@@ -679,6 +687,11 @@ interface CSSNamespaceRule : CSSRule ...@@ -679,6 +687,11 @@ interface CSSNamespaceRule : CSSRule
getter namespaceURI getter namespaceURI
getter prefix getter prefix
method constructor method constructor
interface CSSNumericArray
attribute @@toStringTag
getter length
method @@iterator
method constructor
interface CSSNumericValue : CSSStyleValue interface CSSNumericValue : CSSStyleValue
attribute @@toStringTag attribute @@toStringTag
method add method add
......
...@@ -81,6 +81,7 @@ core_idl_files = ...@@ -81,6 +81,7 @@ core_idl_files =
"css/cssom/CSSMathSum.idl", "css/cssom/CSSMathSum.idl",
"css/cssom/CSSMathProduct.idl", "css/cssom/CSSMathProduct.idl",
"css/cssom/CSSMathValue.idl", "css/cssom/CSSMathValue.idl",
"css/cssom/CSSNumericArray.idl",
"css/cssom/CSSNumericValue.idl", "css/cssom/CSSNumericValue.idl",
"css/cssom/CSSPerspective.idl", "css/cssom/CSSPerspective.idl",
"css/cssom/CSSPositionValue.idl", "css/cssom/CSSPositionValue.idl",
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#ifndef CSSMathMax_h #ifndef CSSMathMax_h
#define CSSMathMax_h #define CSSMathMax_h
#include "core/css/cssom/CSSMathValue.h" #include "core/css/cssom/CSSMathVariadic.h"
namespace blink { namespace blink {
// Represents the maximum of one or more CSSNumericValues. // Represents the maximum of one or more CSSNumericValues.
// See CSSMathMax.idl for more information about this class. // See CSSMathMax.idl for more information about this class.
class CORE_EXPORT CSSMathMax : public CSSMathValue { class CORE_EXPORT CSSMathMax final : public CSSMathVariadic {
WTF_MAKE_NONCOPYABLE(CSSMathMax); WTF_MAKE_NONCOPYABLE(CSSMathMax);
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathMax : public CSSMathValue { ...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathMax : public CSSMathValue {
// TODO(crbug.com/776173): Implement add typing. // TODO(crbug.com/776173): Implement add typing.
CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber); CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber);
return new CSSMathMax(args, type); return new CSSMathMax(CSSNumericArray::FromNumberishes(args), type);
} }
String getOperator() const final { return "max"; } String getOperator() const final { return "max"; }
...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathMax : public CSSMathValue { ...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathMax : public CSSMathValue {
StyleValueType GetType() const final { return CSSStyleValue::kMaxType; } StyleValueType GetType() const final { return CSSStyleValue::kMaxType; }
private: private:
CSSMathMax(const HeapVector<CSSNumberish>&, const CSSNumericValueType& type) CSSMathMax(CSSNumericArray* values, const CSSNumericValueType& type)
: CSSMathValue(type) {} : CSSMathVariadic(values, type) {}
}; };
} // namespace blink } // namespace blink
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
RaisesException=Constructor, RaisesException=Constructor,
RuntimeEnabled=CSSTypedOM RuntimeEnabled=CSSTypedOM
] interface CSSMathMax : CSSMathValue { ] interface CSSMathMax : CSSMathValue {
attribute CSSNumericArray values;
}; };
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#ifndef CSSMathMin_h #ifndef CSSMathMin_h
#define CSSMathMin_h #define CSSMathMin_h
#include "core/css/cssom/CSSMathValue.h" #include "core/css/cssom/CSSMathVariadic.h"
namespace blink { namespace blink {
// Represents the minimum of one or more CSSNumericValues. // Represents the minimum of one or more CSSNumericValues.
// See CSSMathMin.idl for more information about this class. // See CSSMathMin.idl for more information about this class.
class CORE_EXPORT CSSMathMin : public CSSMathValue { class CORE_EXPORT CSSMathMin final : public CSSMathVariadic {
WTF_MAKE_NONCOPYABLE(CSSMathMin); WTF_MAKE_NONCOPYABLE(CSSMathMin);
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathMin : public CSSMathValue { ...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathMin : public CSSMathValue {
// TODO(crbug.com/776173): Implement add typing. // TODO(crbug.com/776173): Implement add typing.
CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber); CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber);
return new CSSMathMin(args, type); return new CSSMathMin(CSSNumericArray::FromNumberishes(args), type);
} }
String getOperator() const final { return "min"; } String getOperator() const final { return "min"; }
...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathMin : public CSSMathValue { ...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathMin : public CSSMathValue {
StyleValueType GetType() const final { return CSSStyleValue::kMinType; } StyleValueType GetType() const final { return CSSStyleValue::kMinType; }
private: private:
CSSMathMin(const HeapVector<CSSNumberish>&, const CSSNumericValueType& type) CSSMathMin(CSSNumericArray* values, const CSSNumericValueType& type)
: CSSMathValue(type) {} : CSSMathVariadic(values, type) {}
}; };
} // namespace blink } // namespace blink
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
RaisesException=Constructor, RaisesException=Constructor,
RuntimeEnabled=CSSTypedOM RuntimeEnabled=CSSTypedOM
] interface CSSMathMin : CSSMathValue { ] interface CSSMathMin : CSSMathValue {
attribute CSSNumericArray values;
}; };
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#ifndef CSSMathProduct_h #ifndef CSSMathProduct_h
#define CSSMathProduct_h #define CSSMathProduct_h
#include "core/css/cssom/CSSMathValue.h" #include "core/css/cssom/CSSMathVariadic.h"
namespace blink { namespace blink {
// Represents the product of one or more CSSNumericValues. // Represents the product of one or more CSSNumericValues.
// See CSSMathProduct.idl for more information about this class. // See CSSMathProduct.idl for more information about this class.
class CORE_EXPORT CSSMathProduct : public CSSMathValue { class CORE_EXPORT CSSMathProduct final : public CSSMathVariadic {
WTF_MAKE_NONCOPYABLE(CSSMathProduct); WTF_MAKE_NONCOPYABLE(CSSMathProduct);
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathProduct : public CSSMathValue { ...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathProduct : public CSSMathValue {
// TODO(crbug.com/776173): Implement multiply typing. // TODO(crbug.com/776173): Implement multiply typing.
CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber); CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber);
return new CSSMathProduct(args, type); return new CSSMathProduct(CSSNumericArray::FromNumberishes(args), type);
} }
String getOperator() const final { return "product"; } String getOperator() const final { return "product"; }
...@@ -36,9 +36,8 @@ class CORE_EXPORT CSSMathProduct : public CSSMathValue { ...@@ -36,9 +36,8 @@ class CORE_EXPORT CSSMathProduct : public CSSMathValue {
StyleValueType GetType() const final { return CSSStyleValue::kProductType; } StyleValueType GetType() const final { return CSSStyleValue::kProductType; }
private: private:
CSSMathProduct(const HeapVector<CSSNumberish>&, CSSMathProduct(CSSNumericArray* values, const CSSNumericValueType& type)
const CSSNumericValueType& type) : CSSMathVariadic(values, type) {}
: CSSMathValue(type) {}
}; };
} // namespace blink } // namespace blink
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
RaisesException=Constructor, RaisesException=Constructor,
RuntimeEnabled=CSSTypedOM RuntimeEnabled=CSSTypedOM
] interface CSSMathProduct : CSSMathValue { ] interface CSSMathProduct : CSSMathValue {
attribute CSSNumericArray values;
}; };
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
#ifndef CSSMathSum_h #ifndef CSSMathSum_h
#define CSSMathSum_h #define CSSMathSum_h
#include "core/css/cssom/CSSMathValue.h" #include "core/css/cssom/CSSMathVariadic.h"
namespace blink { namespace blink {
// Represents the sum of one or more CSSNumericValues. // Represents the sum of one or more CSSNumericValues.
// See CSSMathSum.idl for more information about this class. // See CSSMathSum.idl for more information about this class.
class CORE_EXPORT CSSMathSum final : public CSSMathValue { class CORE_EXPORT CSSMathSum final : public CSSMathVariadic {
WTF_MAKE_NONCOPYABLE(CSSMathSum); WTF_MAKE_NONCOPYABLE(CSSMathSum);
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathSum final : public CSSMathValue { ...@@ -27,7 +27,7 @@ class CORE_EXPORT CSSMathSum final : public CSSMathValue {
// TODO(crbug.com/776173): Implement add typing. // TODO(crbug.com/776173): Implement add typing.
CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber); CSSNumericValueType type(CSSPrimitiveValue::UnitType::kNumber);
return new CSSMathSum(args, type); return new CSSMathSum(CSSNumericArray::FromNumberishes(args), type);
} }
String getOperator() const final { return "sum"; } String getOperator() const final { return "sum"; }
...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathSum final : public CSSMathValue { ...@@ -36,8 +36,8 @@ class CORE_EXPORT CSSMathSum final : public CSSMathValue {
StyleValueType GetType() const final { return CSSStyleValue::kSumType; } StyleValueType GetType() const final { return CSSStyleValue::kSumType; }
private: private:
CSSMathSum(const HeapVector<CSSNumberish>&, const CSSNumericValueType& type) CSSMathSum(CSSNumericArray* values, const CSSNumericValueType& type)
: CSSMathValue(type) {} : CSSMathVariadic(values, type) {}
}; };
} // namespace blink } // namespace blink
......
...@@ -10,4 +10,5 @@ ...@@ -10,4 +10,5 @@
RaisesException=Constructor, RaisesException=Constructor,
RuntimeEnabled=CSSTypedOM RuntimeEnabled=CSSTypedOM
] interface CSSMathSum : CSSMathValue { ] interface CSSMathSum : CSSMathValue {
attribute CSSNumericArray values;
}; };
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CSSMathVariadic_h
#define CSSMathVariadic_h
#include "core/css/cssom/CSSMathValue.h"
#include "core/css/cssom/CSSNumericArray.h"
namespace blink {
// Represents an arithmetic operation with one or more CSSNumericValues.
class CORE_EXPORT CSSMathVariadic : public CSSMathValue {
WTF_MAKE_NONCOPYABLE(CSSMathVariadic);
public:
CSSNumericArray* values() { return values_.Get(); }
void setValues(CSSNumericArray* values) { values_ = values; }
void Trace(Visitor* visitor) override {
visitor->Trace(values_);
CSSMathValue::Trace(visitor);
}
protected:
CSSMathVariadic(CSSNumericArray* values, const CSSNumericValueType& type)
: CSSMathValue(type), values_(values) {}
private:
Member<CSSNumericArray> values_;
};
} // namespace blink
#endif // CSSMathVariadic_h
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CSSNumericArray_h
#define CSSNumericArray_h
#include "core/css/cssom/CSSNumericValue.h"
namespace blink {
// See CSSNumericArray.idl for more information about this class.
class CORE_EXPORT CSSNumericArray final : public ScriptWrappable {
WTF_MAKE_NONCOPYABLE(CSSNumericArray);
DEFINE_WRAPPERTYPEINFO();
public:
// blink internal
static CSSNumericArray* Create(CSSNumericValueVector values) {
return new CSSNumericArray(std::move(values));
}
static CSSNumericArray* FromNumberishes(
const HeapVector<CSSNumberish>& values) {
CSSNumericValueVector result;
for (const CSSNumberish& value : values) {
result.push_back(CSSNumericValue::FromNumberish(value));
}
return new CSSNumericArray(result);
}
void Trace(Visitor* visitor) {
visitor->Trace(values_);
ScriptWrappable::Trace(visitor);
}
unsigned length() const { return values_.size(); }
CSSNumericValue* AnonymousIndexedGetter(unsigned index) {
if (index < values_.size())
return values_[index].Get();
return nullptr;
}
private:
explicit CSSNumericArray(CSSNumericValueVector values)
: values_(std::move(values)) {}
CSSNumericValueVector values_;
};
} // namespace blink
#endif // CSSNumericArray_h
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Represents the sum of one or more CSSNumericValues.
// https://drafts.css-houdini.org/css-typed-om-1/#cssmathsum
[
Exposed=(Window,PaintWorklet),
RaisesException=Constructor,
RuntimeEnabled=CSSTypedOM
] interface CSSNumericArray {
readonly attribute unsigned long length;
getter CSSNumericValue(unsigned long index);
};
...@@ -67,6 +67,8 @@ class CORE_EXPORT CSSNumericValue : public CSSStyleValue { ...@@ -67,6 +67,8 @@ class CORE_EXPORT CSSNumericValue : public CSSStyleValue {
CSSNumericValueType type_; CSSNumericValueType type_;
}; };
using CSSNumericValueVector = HeapVector<Member<CSSNumericValue>>;
} // namespace blink } // namespace blink
#endif // CSSNumericValue_h #endif // CSSNumericValue_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment