Commit 344d7238 authored by Hwanseung Lee's avatar Hwanseung Lee Committed by Commit Bot

[css-typed-om] update CSSUnparsedValue.idl

1. replace "DOMString or CSSVariableReferenceValue" with
 CSSUnparsedSegment using typedf keyword.
2. using sequence<> keyword instead of "..." in constructor

https://github.com/w3c/css-houdini-drafts/pull/619

Bug: 807525
Change-Id: I99c11c26dd2235e46e259e63991d0192a025bcb4
Reviewed-on: https://chromium-review.googlesource.com/904582Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: Hwanseung Lee <hs1217.lee@samsung.com>
Cr-Commit-Position: refs/heads/master@{#534906}
parent 83a3dfcc
This is a testharness.js-based test.
Found 237 tests; 215 PASS, 22 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 237 tests; 216 PASS, 21 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS CSS Typed OM IDL test
PASS CSSStyleValue interface: existence and properties of interface object
PASS CSSStyleValue interface object length
......@@ -28,7 +28,7 @@ PASS StylePropertyMap interface: operation delete(DOMString)
PASS StylePropertyMap interface: operation set(DOMString, [object Object],[object Object])
PASS StylePropertyMap interface: operation update(DOMString, UpdateFunction)
PASS CSSUnparsedValue interface: existence and properties of interface object
FAIL CSSUnparsedValue interface object length assert_equals: wrong value for CSSUnparsedValue.length expected 1 but got 0
PASS CSSUnparsedValue interface object length
PASS CSSUnparsedValue interface object name
PASS CSSUnparsedValue interface: existence and properties of interface prototype object
PASS CSSUnparsedValue interface: existence and properties of interface prototype object's "constructor" property
......
......@@ -29,22 +29,22 @@ const gTestCases = [
{
value: 'var(--A, 1em)',
expectedResult: [
new CSSVariableReferenceValue('--A', new CSSUnparsedValue(' 1em')),
new CSSVariableReferenceValue('--A', new CSSUnparsedValue([' 1em'])),
]
},
{
value: 'var(--A, var(--B))',
expectedResult: [
new CSSVariableReferenceValue('--A', new CSSUnparsedValue(' ', new CSSVariableReferenceValue('--B'))),
new CSSVariableReferenceValue('--A', new CSSUnparsedValue([' ', new CSSVariableReferenceValue('--B')])),
]
},
{
value: 'calc(42px + var(--foo, 15em) + var(--bar, var(--far) + 15px))',
expectedResult: [
'calc(42px + ',
new CSSVariableReferenceValue('--foo', new CSSUnparsedValue(' 15em')),
new CSSVariableReferenceValue('--foo', new CSSUnparsedValue([' 15em'])),
' + ',
new CSSVariableReferenceValue('--bar', new CSSUnparsedValue(' ', new CSSVariableReferenceValue('--far'), ' + 15px')),
new CSSVariableReferenceValue('--bar', new CSSUnparsedValue([' ', new CSSVariableReferenceValue('--far'), ' + 15px'])),
')',
]
},
......@@ -52,11 +52,11 @@ const gTestCases = [
for (const {value, expectedResult} of gTestCases) {
test(t => {
assert_string_normalizes_to(t, 'color', value, new CSSUnparsedValue(...expectedResult));
assert_string_normalizes_to(t, 'color', value, new CSSUnparsedValue(expectedResult));
}, 'Normalizing "' + value + '" on a CSS property returns correct CSSUnparsedValue');
test(t => {
assert_string_normalizes_to(t, '--X', value, new CSSUnparsedValue(...expectedResult));
assert_string_normalizes_to(t, '--X', value, new CSSUnparsedValue(expectedResult));
}, 'Normalizing "' + value + '" on a custom property returns correct CSSUnparsedValue');
}
......
......@@ -11,25 +11,25 @@
'use strict';
test(() => {
assert_equals(new CSSUnparsedValue('lem', 'on', 'ade').toString(), 'lemonade');
assert_equals(new CSSUnparsedValue(['lem', 'on', 'ade']).toString(), 'lemonade');
}, 'CSSUnparsedValue containing strings serializes to its concatenated contents');
test(() => {
assert_equals(new CSSUnparsedValue(
assert_equals(new CSSUnparsedValue([
new CSSVariableReferenceValue('--A',
new CSSUnparsedValue(new CSSVariableReferenceValue('--B'))),
new CSSVariableReferenceValue('--C')).toString(),
new CSSUnparsedValue([new CSSVariableReferenceValue('--B')])),
new CSSVariableReferenceValue('--C')]).toString(),
'var(--A,var(--B))var(--C)');
}, 'CSSUnparsedValue containing variable references serializes its ' +
'concatenated contents');
test(() => {
assert_equals(new CSSUnparsedValue('foo', 'bar ',
assert_equals(new CSSUnparsedValue(['foo', 'bar ',
new CSSVariableReferenceValue('--A',
new CSSUnparsedValue('baz ',
new CSSVariableReferenceValue('--B'), 'lemon')),
new CSSUnparsedValue(['baz ',
new CSSVariableReferenceValue('--B'), 'lemon'])),
new CSSVariableReferenceValue('--C',
new CSSUnparsedValue('ade'))).toString(),
new CSSUnparsedValue(['ade']))]).toString(),
'foobar var(--A,baz var(--B)lemon)var(--C,ade)');
}, 'CSSUnparsedValue containing mix of strings and variable references ' +
'serializes to its concatenated contents');
......
......@@ -37,7 +37,7 @@ const gTestArguments = [
for (const {args, description} of gTestArguments) {
test(() => {
const result = new CSSUnparsedValue(...args);
const result = new CSSUnparsedValue(args);
assert_not_equals(result, null,
'A CSSUnparsedValue should be created');
......
......@@ -22,7 +22,7 @@ test(() => {
test(() => {
const result = new CSSVariableReferenceValue('--foo',
new CSSUnparsedValue('lemon'));
new CSSUnparsedValue(['lemon']));
assert_not_equals(result, null,
'A CSSVariableReferenceValue should be created');
......@@ -30,7 +30,7 @@ test(() => {
'Variable member should be same as passed in the constructor');
assert_not_equals(result.fallback, null,
'Fallback member should not be null');
assert_style_value_equals(result.fallback, new CSSUnparsedValue('lemon'),
assert_style_value_equals(result.fallback, new CSSUnparsedValue(['lemon']),
'Fallback member should be as same as passed in the constructor');
}, 'CSSVariableReferenceValue can be constructed with fallback');
......
......@@ -38,7 +38,7 @@ test(() => {
test(() => {
const result = styleMap.get('--foo');
assert_style_value_equals(result, new CSSUnparsedValue(' auto'));
assert_style_value_equals(result, new CSSUnparsedValue([' auto']));
}, 'Computed StylePropertyMap contains custom property declarations in style rules');
test(() => {
......@@ -48,7 +48,7 @@ test(() => {
test(() => {
const result = styleMap.get('--bar');
assert_style_value_equals(result, new CSSUnparsedValue(' 5'));
assert_style_value_equals(result, new CSSUnparsedValue([' 5']));
}, 'Computed StylePropertyMap contains custom property declarations in inline rules');
test(() => {
......
......@@ -24,7 +24,7 @@ test(t => {
test(t => {
const styleMap = createComputedStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_equals(styleMap.get('--foo'),
new CSSUnparsedValue(' auto'));
new CSSUnparsedValue([' auto']));
}, 'Getting a valid custom property from computed style returns the ' +
'correct entry');
......
......@@ -31,7 +31,7 @@ test(t => {
test(t => {
const styleMap = createComputedStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue(' auto')]);
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue([' auto'])]);
}, 'Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry');
test(t => {
......
......@@ -34,9 +34,9 @@ test(t => {
test(t => {
const styleMap = createComputedStyleMap(t, '--A: A; --C: C; color: red; --B: B;');
assert_style_value_equals(findInStyleMap(styleMap, '--A'), new CSSUnparsedValue(' A'));
assert_style_value_equals(findInStyleMap(styleMap, '--B'), new CSSUnparsedValue(' B'));
assert_style_value_equals(findInStyleMap(styleMap, '--C'), new CSSUnparsedValue(' C'));
assert_style_value_equals(findInStyleMap(styleMap, '--A'), new CSSUnparsedValue([' A']));
assert_style_value_equals(findInStyleMap(styleMap, '--B'), new CSSUnparsedValue([' B']));
assert_style_value_equals(findInStyleMap(styleMap, '--C'), new CSSUnparsedValue([' C']));
}, 'StylePropertyMap iterator returns custom properties with the correct CSSStyleValue');
</script>
......@@ -45,7 +45,7 @@ test(() => {
}, 'Declared StylePropertyMap does not contain inline styles');
test(() => {
assert_style_value_equals(styleMap.get('--foo'), new CSSUnparsedValue(' auto'));
assert_style_value_equals(styleMap.get('--foo'), new CSSUnparsedValue([' auto']));
}, 'Declared StylePropertyMap contains custom property declarations');
test(() => {
......
......@@ -29,7 +29,7 @@ test(t => {
test(t => {
const styleMap = createDeclaredStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_equals(styleMap.get('--foo'),
new CSSUnparsedValue(' auto'));
new CSSUnparsedValue([' auto']));
}, 'Getting a valid custom property from CSS rule returns the ' +
'correct entry');
......
......@@ -36,7 +36,7 @@ test(t => {
test(t => {
const styleMap = createDeclaredStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue(' auto')]);
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue([' auto'])]);
}, 'Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry');
test(t => {
......
......@@ -42,9 +42,9 @@ test(t => {
assert_array_equals(keys, ['--A', '--B', '--C']);
assert_style_value_array_equals(values, [
new CSSUnparsedValue(' A'),
new CSSUnparsedValue(' B'),
new CSSUnparsedValue(' C'),
new CSSUnparsedValue([' A']),
new CSSUnparsedValue([' B']),
new CSSUnparsedValue([' C']),
])
}, 'StylePropertyMap iterator returns custom properties with the correct CSSStyleValue');
......
......@@ -63,11 +63,11 @@ test(t => {
test(t => {
let styleMap = createDeclaredStyleMap(t, '');
styleMap.set('--foo', new CSSUnparsedValue('auto'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('auto'));
styleMap.set('--foo', new CSSUnparsedValue(['auto']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['auto']));
styleMap.set('--foo', '20px');
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('20px'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['20px']));
}, 'Setting a custom property with CSSStyleValue or String updates its value');
test(t => {
......
......@@ -46,11 +46,11 @@ test(t => {
test(t => {
let styleMap = createDeclaredStyleMap(t, '');
styleMap.update('--foo', () => new CSSUnparsedValue('auto'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('auto'));
styleMap.update('--foo', () => new CSSUnparsedValue(['auto']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['auto']));
styleMap.update('--foo', () => new CSSUnparsedValue('20px'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('20px'));
styleMap.update('--foo', () => new CSSUnparsedValue(['20px']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['20px']));
}, 'Updating a custom property with CSSStyleValue updates its value');
test(t => {
......
......@@ -29,7 +29,7 @@ test(t => {
test(t => {
const styleMap = createInlineStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_equals(styleMap.get('--foo'),
new CSSUnparsedValue(' auto'));
new CSSUnparsedValue([' auto']));
}, 'Getting a valid custom property from inline style returns the ' +
'correct entry');
......
......@@ -36,7 +36,7 @@ test(t => {
test(t => {
const styleMap = createInlineStyleMap(t, '--foo: auto; --bar: 10px');
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue(' auto')]);
assert_style_value_array_equals(styleMap.getAll('--foo'), [new CSSUnparsedValue([' auto'])]);
}, 'Calling StylePropertyMap.getAll with a valid custom property returns a single element list with the correct entry');
test(t => {
......
......@@ -42,9 +42,9 @@ test(t => {
assert_array_equals(keys, ['--A', '--B', '--C']);
assert_style_value_array_equals(values, [
new CSSUnparsedValue(' A'),
new CSSUnparsedValue(' B'),
new CSSUnparsedValue(' C'),
new CSSUnparsedValue([' A']),
new CSSUnparsedValue([' B']),
new CSSUnparsedValue([' C']),
])
}, 'StylePropertyMap iterator returns custom properties with the correct CSSStyleValue');
......
......@@ -63,11 +63,11 @@ test(t => {
test(t => {
let styleMap = createInlineStyleMap(t, '');
styleMap.set('--foo', new CSSUnparsedValue('auto'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('auto'));
styleMap.set('--foo', new CSSUnparsedValue(['auto']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['auto']));
styleMap.set('--foo', '20px');
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('20px'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['20px']));
}, 'Setting a custom property with CSSStyleValue or String updates its value');
test(t => {
......
......@@ -46,11 +46,11 @@ test(t => {
test(t => {
let styleMap = createInlineStyleMap(t, '');
styleMap.update('--foo', () => new CSSUnparsedValue('auto'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('auto'));
styleMap.update('--foo', () => new CSSUnparsedValue(['auto']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['auto']));
styleMap.update('--foo', () => new CSSUnparsedValue('20px'));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue('20px'));
styleMap.update('--foo', () => new CSSUnparsedValue(['20px']));
assert_style_value_array_equals(styleMap.get('--foo'), new CSSUnparsedValue(['20px']));
}, 'Updating a custom property with CSSStyleValue updates its value');
test(t => {
......
......@@ -19,9 +19,9 @@ StringView FindVariableName(CSSParserTokenRange& range) {
return range.Consume().Value();
}
StringOrCSSVariableReferenceValue VariableReferenceValue(
CSSUnparsedSegment VariableReferenceValue(
const StringView& variable_name,
const HeapVector<StringOrCSSVariableReferenceValue>& tokens) {
const HeapVector<CSSUnparsedSegment>& tokens) {
CSSUnparsedValue* unparsed_value;
if (tokens.size() == 0)
unparsed_value = nullptr;
......@@ -31,19 +31,17 @@ StringOrCSSVariableReferenceValue VariableReferenceValue(
CSSStyleVariableReferenceValue* variable_reference =
CSSStyleVariableReferenceValue::Create(variable_name.ToString(),
unparsed_value);
return StringOrCSSVariableReferenceValue::FromCSSVariableReferenceValue(
variable_reference);
return CSSUnparsedSegment::FromCSSVariableReferenceValue(variable_reference);
}
HeapVector<StringOrCSSVariableReferenceValue> ParserTokenRangeToTokens(
HeapVector<CSSUnparsedSegment> ParserTokenRangeToTokens(
CSSParserTokenRange range) {
HeapVector<StringOrCSSVariableReferenceValue> tokens;
HeapVector<CSSUnparsedSegment> tokens;
StringBuilder builder;
while (!range.AtEnd()) {
if (range.Peek().FunctionId() == CSSValueVar) {
if (!builder.IsEmpty()) {
tokens.push_back(
StringOrCSSVariableReferenceValue::FromString(builder.ToString()));
tokens.push_back(CSSUnparsedSegment::FromString(builder.ToString()));
builder.Clear();
}
CSSParserTokenRange block = range.ConsumeBlock();
......@@ -58,8 +56,7 @@ HeapVector<StringOrCSSVariableReferenceValue> ParserTokenRangeToTokens(
}
}
if (!builder.IsEmpty()) {
tokens.push_back(
StringOrCSSVariableReferenceValue::FromString(builder.ToString()));
tokens.push_back(CSSUnparsedSegment::FromString(builder.ToString()));
}
return tokens;
}
......
......@@ -14,19 +14,20 @@ namespace blink {
class CSSVariableReferenceValue;
class CSSVariableData;
using CSSUnparsedSegment = StringOrCSSVariableReferenceValue;
class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue {
DEFINE_WRAPPERTYPEINFO();
public:
static CSSUnparsedValue* Create(
const HeapVector<StringOrCSSVariableReferenceValue>& tokens) {
const HeapVector<CSSUnparsedSegment>& tokens) {
return new CSSUnparsedValue(tokens);
}
// Blink-internal constructor
static CSSUnparsedValue* Create() {
return Create(HeapVector<StringOrCSSVariableReferenceValue>());
return Create(HeapVector<CSSUnparsedSegment>());
}
static CSSUnparsedValue* FromCSSValue(const CSSVariableReferenceValue&);
static CSSUnparsedValue* FromCSSValue(const CSSVariableData&);
......@@ -35,7 +36,7 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue {
StyleValueType GetType() const override { return kUnparsedType; }
StringOrCSSVariableReferenceValue AnonymousIndexedGetter(
CSSUnparsedSegment AnonymousIndexedGetter(
unsigned index,
ExceptionState& exception_state) const {
if (index < tokens_.size())
......@@ -51,13 +52,13 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue {
}
protected:
CSSUnparsedValue(const HeapVector<StringOrCSSVariableReferenceValue>& tokens)
CSSUnparsedValue(const HeapVector<CSSUnparsedSegment>& tokens)
: CSSStyleValue(), tokens_(tokens) {}
private:
static CSSUnparsedValue* FromString(const String& string) {
HeapVector<StringOrCSSVariableReferenceValue> tokens;
tokens.push_back(StringOrCSSVariableReferenceValue::FromString(string));
HeapVector<CSSUnparsedSegment> tokens;
tokens.push_back(CSSUnparsedSegment::FromString(string));
return Create(tokens);
}
......@@ -65,7 +66,7 @@ class CORE_EXPORT CSSUnparsedValue final : public CSSStyleValue {
FRIEND_TEST_ALL_PREFIXES(CSSVariableReferenceValueTest, MixedList);
HeapVector<StringOrCSSVariableReferenceValue> tokens_;
HeapVector<CSSUnparsedSegment> tokens_;
DISALLOW_COPY_AND_ASSIGN(CSSUnparsedValue);
};
......
......@@ -6,10 +6,12 @@
// They represent a list of string fragments and variable references.
// Spec: https://drafts.css-houdini.org/css-typed-om/#unparsedvalue-objects
[
Constructor((DOMString or CSSVariableReferenceValue)... members),
Constructor(sequence<CSSUnparsedSegment> members),
Exposed(Window CSSTypedOM, PaintWorklet CSSTypedOM)
] interface CSSUnparsedValue : CSSStyleValue {
iterable<(DOMString or CSSVariableReferenceValue)>;
iterable<CSSUnparsedSegment>;
readonly attribute unsigned long length;
[RaisesException] getter (DOMString or CSSVariableReferenceValue) (unsigned long index);
[RaisesException] getter CSSUnparsedSegment (unsigned long index);
};
typedef (DOMString or CSSVariableReferenceValue) CSSUnparsedSegment;
\ No newline at end of file
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