@@ -789,13 +789,60 @@ or acting as if nothing exists at that location otherwise.
789
789
CSSOM {#cssom}
790
790
==============
791
791
792
+ The {{CSSFunctionRule}} Interface {#the-function-interface}
793
+ -----------------------------------------------------------
794
+
792
795
The {{CSSFunctionRule}} interface represents a ''@function'' rule.
793
796
794
797
<pre class='idl' export>
795
798
[Exposed=Window]
796
- interface CSSFunctionRule : CSSGroupingRule { };
799
+ interface CSSFunctionRule : CSSGroupingRule {
800
+ readonly attribute CSSOMString name;
801
+ sequence<FunctionParameter> getParameters();
802
+ readonly attribute CSSOMString returnType;
803
+ };
797
804
</pre>
798
805
806
+ <dl dfn-for=CSSFunctionRule dfn-type=attribute>
807
+ <dt> <dfn>name</dfn>
808
+ <dd>
809
+ The name of the [=custom function=] .
810
+
811
+ <dt> <dfn>returnType</dfn>
812
+ <dd>
813
+ The [=custom function/return type=] of the [=custom function=] ,
814
+ represented as a [[css-properties-values-api-1#syntax-strings|syntax string]] .
815
+ If the [=custom function=] has no return type,
816
+ returns <code> "type(*)"</code> .
817
+ </dl>
818
+
819
+
820
+ <pre class='idl' export>
821
+ dictionary FunctionParameter {
822
+ required CSSOMString name;
823
+ required CSSOMString type;
824
+ CSSOMString? defaultValue;
825
+ };
826
+ </pre>
827
+
828
+ <dl dfn-for=FunctionParameter>
829
+ <dt> name
830
+ <dd>
831
+ The name of the [=function parameter=] .
832
+
833
+ <dt> type
834
+ <dd>
835
+ The [=parameter type|type=] of the [=function parameter=] ,
836
+ represented as a [[css-properties-values-api-1#syntax-strings|syntax string]] ,
837
+ or <code> "type(*)"</code> if the [=function parameter|parameter=] has no type.
838
+
839
+ <dt> defaultValue
840
+ <dd>
841
+ The [=default value=] of the [=function parameter=] ,
842
+ or `null` if the argument does not have a default.
843
+ </dl>
844
+
845
+
799
846
While declarations may be specified directly within a ''@function'' rule,
800
847
they are not represented as such in the CSSOM.
801
848
Instead, consecutive segments of declarations
@@ -834,6 +881,77 @@ Note: This also applies to the "leading" declarations in the ''@function'' rule,
834
881
</pre>
835
882
</div>
836
883
884
+ <div algorithm>
885
+ To <dfn export>serialize a CSSFunctionRule</dfn> ,
886
+ return the concatenation of the following:
887
+
888
+ 1. The string <code> "@function"</code> followed by a single SPACE (U+0020).
889
+ 2. The result of performing <a>serialize an identifier</a>
890
+ on the name of the [=custom function=] ,
891
+ followed by a single LEFT PARENTHESIS (U+0028).
892
+ 4. The result of [=serialize a function parameter=]
893
+ on each of the [=custom function's=] [=function parameter|parameters=] ,
894
+ all joined by <code> ", "</code>
895
+ (COMMA U+002C, followed by a single SPACE U+0020).
896
+ 5. A single RIGHT PARENTHESIS (U+0029).
897
+ 6. If the [=custom function=] has [=custom function/return type=] ,
898
+ and that [=custom function/return type=]
899
+ is not the [=universal syntax definition=] ("*"):
900
+ * A single SPACE (U+0020),
901
+ followed by the string <code> "returns"</code> ,
902
+ followed by a single SPACE (U+0020).
903
+ * The result of performing [=serialize a CSS type=]
904
+ on that [=custom function/return type|type=] ,
905
+ followed by a single SPACE (U+0020).
906
+
907
+ 7. A single LEFT CURLY BRACKET (U+007B),
908
+ followed by a SPACE (U+0020).
909
+
910
+ 8. The result of performing [=serialize a CSS rule=]
911
+ on each rule in cssRules,
912
+ filtering out empty strings,
913
+ all joined by a single SPACE (U+0020).
914
+
915
+ Note: [=Serialize a CSS rule=] can return an empty string
916
+ when serializing an empty {{CSSFunctionDeclarations}} rule.
917
+
918
+ 9. A single SPACE (U+0020),
919
+ followed by a single RIGHT CURLY BRACKET (U+007D).
920
+ </div>
921
+
922
+ <div algorithm>
923
+ To <dfn export>serialize a function parameter</dfn> ,
924
+ return the concatenation of the following:
925
+
926
+ 1. The result of performing <a>serialize an identifier</a>
927
+ on the name of the [=function parameter=] .
928
+ 2. If the [=function parameter=] has a [=parameter type|type=] ,
929
+ and that [=parameter type|type=]
930
+ is not the [=universal syntax definition=] :
931
+ * A single SPACE (U+0020),
932
+ followed by the result of performing [=serialize a CSS type=]
933
+ on that [=parameter type|type=] .
934
+ 3. If the [=function parameter=] has a [=default value=] :
935
+ * A single COLON (U+003A),
936
+ followed by a single SPACE (U+0020),
937
+ followed by the result of performing [=serialize a CSS value=]
938
+ on that value.
939
+ </div>
940
+
941
+ <div algorithm>
942
+ To <dfn export>serialize a CSS type</dfn> ,
943
+ return the concatenation of the following:
944
+ 1. If the <<css-type>> consists of a single <<syntax-component>> ,
945
+ return the corresponding [[css-properties-values-api-1#syntax-strings|syntax string]] .
946
+ 2. Otherwise,
947
+ return the concatenation of the following:
948
+ * The string <code> "type("</code> ,
949
+ i.e. <code> "type"</code>
950
+ followed by a single LEFT PARENTHESIS (U+0028).
951
+ * The corresponding [[css-properties-values-api-1#syntax-strings|syntax string]] .
952
+ * The string <code> ")"</code> ,
953
+ i.e. a single RIGHT PARENTHESIS (U+0029).
954
+ </div>
837
955
838
956
The {{CSSFunctionDeclarations}} Interface {#the-function-declarations-interface}
839
957
--------------------------------------------------------------------------------
0 commit comments