Skip to content
Merged
80 changes: 65 additions & 15 deletions css/css-typed-om/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,73 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
<script src="/resources/idlharness.js"></script>

<style>
body {
font-size: normal;
}
</style>

<script>
'use strict';

promise_test(t => {
return fetch('/interfaces/css-typed-om.idl')
.then(response => response.text())
.then(idls => {
var idl_array = new IdlArray();
idl_array.add_idls(idls);
idl_array.add_untested_idls('interface Element {};');
idl_array.add_untested_idls('interface CSSStyleRule {};');
idl_array.add_untested_idls('interface ElementCSSInlineStyle {};');
idl_array.add_objects({
// TODO: Add more objects.
});
idl_array.test();
t.done();
idl_test(
['css-typed-om'],
['cssom', 'SVG', 'geometry', 'html', 'dom'],
idl_array => {
try {
self.styleMap = document.styleSheets[0].rules[0].styleMap;
} catch (e) {}

try {
self.unitValue = CSSStyleValue.parse('height', '10px');
} catch (e) {}

try {
self.mathSum = CSSStyleValue.parse('width', 'calc(100% - 32px)');
} catch (e) {}

try {
self.transformValue = CSSStyleValue.parse('transform', 'translateX(0)');
} catch (e) {}

try {
self.rotate = CSSStyleValue.parse('transform', 'rotateX(0)')[0];
} catch (e) {}

try {
self.scale = CSSStyleValue.parse('transform', 'scale(1)')[0];
} catch (e) {}

try {
self.skew = CSSStyleValue.parse('transform', 'skew(0,0)')[0];
self.skewX = CSSStyleValue.parse('transform', 'skewX(0)')[0];
self.skewY = CSSStyleValue.parse('transform', 'skewY(0)')[0];
} catch (e) {}

try {
self.perspective = CSSStyleValue.parse('transform', 'perspective(0)')[0];
} catch (e) {}

try {
self.matrix = CSSStyleValue.parse('transform', 'matrix(0, 0, 0, 0, 0, 0)')[0];
} catch (e) {}

idl_array.add_objects({
StylePropertyMap: ['styleMap'],
CSSUnitValue: ['unitValue'],
CSSMathSum: ['mathSum'],
CSSTransformValue: ['transformValue'],
CSSTranslate: ['transformValue[0]'],
CSSRotate: ['rotate'],
CSSScale: ['scale'],
CSSSkew: ['skew'],
CSSSkewX: ['skewX'],
CSSSkewY: ['skewY'],
CSSPerspective: ['perspective'],
CSSMatrixComponent: ['matrix'],
});
}, 'CSS Typed OM IDL test');
},
'CSS Typed OM IDL test'
);
</script>
18 changes: 12 additions & 6 deletions interfaces/css-typed-om.idl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// GENERATED CONTENT - DO NOT EDIT
// Content of this file was automatically extracted from the CSS Typed OM spec.
// See https://drafts.css-houdini.org/css-typed-om/
// Content of this file was automatically extracted from the
// "CSS Typed OM Level 1" spec.
// See: https://drafts.css-houdini.org/css-typed-om-1/

[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
interface CSSStyleValue {
Expand Down Expand Up @@ -153,6 +154,14 @@ interface CSSMathMax : CSSMathValue {
readonly attribute CSSNumericArray values;
};

[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet),
Constructor(CSSNumberish min, CSSNumberish val, CSSNumberish max)]
interface CSSMathClamp : CSSMathValue {
readonly attribute CSSNumericValue min;
readonly attribute CSSNumericValue val;
readonly attribute CSSNumericValue max;
};

[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet)]
interface CSSNumericArray {
iterable<CSSNumericValue>;
Expand All @@ -167,11 +176,9 @@ enum CSSMathOperator {
"invert",
"min",
"max",
"clamp",
};

// FIXME: Uncomment this when IDLHarness supports CSS namespaces:
// https://github.com/web-platform-tests/wpt/issues/7583
/*
partial namespace CSS {
CSSUnitValue number(double value);
CSSUnitValue percent(double value);
Expand Down Expand Up @@ -220,7 +227,6 @@ partial namespace CSS {
// <flex>
CSSUnitValue fr(double value);
};
*/

[Exposed=(Window, Worker, PaintWorklet, LayoutWorklet),
Constructor(sequence<CSSTransformComponent> transforms)]
Expand Down