Bug 1330698. Support string default values for unions containing USVString. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 13 Jan 2017 10:41:12 -0500
changeset 374347 b75e432a3b77eaa2be79082f5b0a2e4df5320e79
parent 374346 ecaa5f64caf6f68d46f2328a39393b8ad5d10ea2
child 374348 426c5f5536bffb00daa3b3a7bfb4dadfed68fb14
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1330698
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1330698. Support string default values for unions containing USVString. r=qdot
dom/bindings/Codegen.py
dom/bindings/test/TestBindingHeader.h
dom/bindings/test/TestCodeGen.webidl
dom/bindings/test/TestExampleGen.webidl
dom/bindings/test/TestJSImplGen.webidl
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -4423,17 +4423,19 @@ def getHandleDefault(defaultValue):
 
 def handleDefaultStringValue(defaultValue, method):
     """
     Returns a string which ends up calling 'method' with a (char_t*, length)
     pair that sets this string default value.  This string is suitable for
     passing as the second argument of handleDefault; in particular it does not
     end with a ';'
     """
-    assert defaultValue.type.isDOMString() or defaultValue.type.isByteString()
+    assert (defaultValue.type.isDOMString() or
+            defaultValue.type.isUSVString() or
+            defaultValue.type.isByteString())
     return ("static const %(char_t)s data[] = { %(data)s };\n"
             "%(method)s(data, ArrayLength(data) - 1)") % {
                 'char_t': "char" if defaultValue.type.isByteString() else "char16_t",
                 'method': method,
                 'data': ", ".join(["'" + char + "'" for char in
                                    defaultValue.value] + ["0"])
             }
 
--- a/dom/bindings/test/TestBindingHeader.h
+++ b/dom/bindings/test/TestBindingHeader.h
@@ -691,16 +691,19 @@ public:
   void PassUnionWithDefaultValue12(const UnrestrictedFloatOrString& arg);
   void PassUnionWithDefaultValue13(const UnrestrictedFloatOrString& arg);
   void PassUnionWithDefaultValue14(const DoubleOrByteString& arg);
   void PassUnionWithDefaultValue15(const DoubleOrByteString& arg);
   void PassUnionWithDefaultValue16(const DoubleOrByteString& arg);
   void PassUnionWithDefaultValue17(const DoubleOrSupportedType& arg);
   void PassUnionWithDefaultValue18(const DoubleOrSupportedType& arg);
   void PassUnionWithDefaultValue19(const DoubleOrSupportedType& arg);
+  void PassUnionWithDefaultValue20(const DoubleOrUSVString& arg);
+  void PassUnionWithDefaultValue21(const DoubleOrUSVString& arg);
+  void PassUnionWithDefaultValue22(const DoubleOrUSVString& arg);
 
   void PassNullableUnionWithDefaultValue1(const Nullable<DoubleOrString>& arg);
   void PassNullableUnionWithDefaultValue2(const Nullable<DoubleOrString>& arg);
   void PassNullableUnionWithDefaultValue3(const Nullable<DoubleOrString>& arg);
   void PassNullableUnionWithDefaultValue4(const Nullable<FloatOrString>& arg);
   void PassNullableUnionWithDefaultValue5(const Nullable<FloatOrString>& arg);
   void PassNullableUnionWithDefaultValue6(const Nullable<FloatOrString>& arg);
   void PassNullableUnionWithDefaultValue7(const Nullable<UnrestrictedDoubleOrString>& arg);
@@ -712,16 +715,20 @@ public:
   void PassNullableUnionWithDefaultValue13(const Nullable<DoubleOrByteString>& arg);
   void PassNullableUnionWithDefaultValue14(const Nullable<DoubleOrByteString>& arg);
   void PassNullableUnionWithDefaultValue15(const Nullable<DoubleOrByteString>& arg);
   void PassNullableUnionWithDefaultValue16(const Nullable<DoubleOrByteString>& arg);
   void PassNullableUnionWithDefaultValue17(const Nullable<DoubleOrSupportedType>& arg);
   void PassNullableUnionWithDefaultValue18(const Nullable<DoubleOrSupportedType>& arg);
   void PassNullableUnionWithDefaultValue19(const Nullable<DoubleOrSupportedType>& arg);
   void PassNullableUnionWithDefaultValue20(const Nullable<DoubleOrSupportedType>& arg);
+  void PassNullableUnionWithDefaultValue21(const Nullable<DoubleOrUSVString>& arg);
+  void PassNullableUnionWithDefaultValue22(const Nullable<DoubleOrUSVString>& arg);
+  void PassNullableUnionWithDefaultValue23(const Nullable<DoubleOrUSVString>& arg);
+  void PassNullableUnionWithDefaultValue24(const Nullable<DoubleOrUSVString>& arg);
 
   void PassSequenceOfUnions(const Sequence<OwningCanvasPatternOrCanvasGradient>&);
   void PassSequenceOfUnions2(JSContext*, const Sequence<OwningObjectOrLong>&);
   void PassVariadicUnion(const Sequence<OwningCanvasPatternOrCanvasGradient>&);
 
   void PassSequenceOfNullableUnions(const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&);
   void PassVariadicNullableUnion(const Sequence<Nullable<OwningCanvasPatternOrCanvasGradient>>&);
   void PassMozMapOfUnions(const MozMap<OwningCanvasPatternOrCanvasGradient>&);
--- a/dom/bindings/test/TestCodeGen.webidl
+++ b/dom/bindings/test/TestCodeGen.webidl
@@ -670,16 +670,19 @@ interface TestInterface {
   void passUnionWithDefaultValue12(optional (unrestricted float or DOMString) arg = 1);
   void passUnionWithDefaultValue13(optional (unrestricted float or DOMString) arg = Infinity);
   void passUnionWithDefaultValue14(optional (double or ByteString) arg = "");
   void passUnionWithDefaultValue15(optional (double or ByteString) arg = 1);
   void passUnionWithDefaultValue16(optional (double or ByteString) arg = 1.5);
   void passUnionWithDefaultValue17(optional (double or SupportedType) arg = "text/html");
   void passUnionWithDefaultValue18(optional (double or SupportedType) arg = 1);
   void passUnionWithDefaultValue19(optional (double or SupportedType) arg = 1.5);
+  void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
+  void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
+  void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
 
   void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue3(optional (double or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue4(optional (float or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue5(optional (float or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue6(optional (float or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue7(optional (unrestricted double or DOMString)? arg = "");
@@ -691,16 +694,20 @@ interface TestInterface {
   void passNullableUnionWithDefaultValue13(optional (double or ByteString)? arg = "");
   void passNullableUnionWithDefaultValue14(optional (double or ByteString)? arg = 1);
   void passNullableUnionWithDefaultValue15(optional (double or ByteString)? arg = 1.5);
   void passNullableUnionWithDefaultValue16(optional (double or ByteString)? arg = null);
   void passNullableUnionWithDefaultValue17(optional (double or SupportedType)? arg = "text/html");
   void passNullableUnionWithDefaultValue18(optional (double or SupportedType)? arg = 1);
   void passNullableUnionWithDefaultValue19(optional (double or SupportedType)? arg = 1.5);
   void passNullableUnionWithDefaultValue20(optional (double or SupportedType)? arg = null);
+  void passNullableUnionWithDefaultValue21(optional (double or USVString)? arg = "abc");
+  void passNullableUnionWithDefaultValue22(optional (double or USVString)? arg = 1);
+  void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
+  void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
 
   void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
   void passSequenceOfUnions2(sequence<(object or long)> arg);
   void passVariadicUnion((CanvasPattern or CanvasGradient)... arg);
 
   void passSequenceOfNullableUnions(sequence<(CanvasPattern or CanvasGradient)?> arg);
   void passVariadicNullableUnion((CanvasPattern or CanvasGradient)?... arg);
   void passMozMapOfUnions(MozMap<(CanvasPattern or CanvasGradient)> arg);
--- a/dom/bindings/test/TestExampleGen.webidl
+++ b/dom/bindings/test/TestExampleGen.webidl
@@ -505,16 +505,19 @@ interface TestExampleInterface {
   void passUnionWithDefaultValue12(optional (unrestricted float or DOMString) arg = 1);
   void passUnionWithDefaultValue13(optional (unrestricted float or DOMString) arg = Infinity);
   void passUnionWithDefaultValue14(optional (double or ByteString) arg = "");
   void passUnionWithDefaultValue15(optional (double or ByteString) arg = 1);
   void passUnionWithDefaultValue16(optional (double or ByteString) arg = 1.5);
   void passUnionWithDefaultValue17(optional (double or SupportedType) arg = "text/html");
   void passUnionWithDefaultValue18(optional (double or SupportedType) arg = 1);
   void passUnionWithDefaultValue19(optional (double or SupportedType) arg = 1.5);
+  void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
+  void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
+  void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
 
   void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue3(optional (double or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue4(optional (float or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue5(optional (float or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue6(optional (float or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue7(optional (unrestricted double or DOMString)? arg = "");
@@ -526,16 +529,20 @@ interface TestExampleInterface {
   void passNullableUnionWithDefaultValue13(optional (double or ByteString)? arg = "");
   void passNullableUnionWithDefaultValue14(optional (double or ByteString)? arg = 1);
   void passNullableUnionWithDefaultValue15(optional (double or ByteString)? arg = 1.5);
   void passNullableUnionWithDefaultValue16(optional (double or ByteString)? arg = null);
   void passNullableUnionWithDefaultValue17(optional (double or SupportedType)? arg = "text/html");
   void passNullableUnionWithDefaultValue18(optional (double or SupportedType)? arg = 1);
   void passNullableUnionWithDefaultValue19(optional (double or SupportedType)? arg = 1.5);
   void passNullableUnionWithDefaultValue20(optional (double or SupportedType)? arg = null);
+  void passNullableUnionWithDefaultValue21(optional (double or USVString)? arg = "abc");
+  void passNullableUnionWithDefaultValue22(optional (double or USVString)? arg = 1);
+  void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
+  void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
 
   void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
   void passSequenceOfUnions2(sequence<(object or long)> arg);
   void passVariadicUnion((CanvasPattern or CanvasGradient)... arg);
 
   void passSequenceOfNullableUnions(sequence<(CanvasPattern or CanvasGradient)?> arg);
   void passVariadicNullableUnion((CanvasPattern or CanvasGradient)?... arg);
   void passMozMapOfUnions(MozMap<(CanvasPattern or CanvasGradient)> arg);
--- a/dom/bindings/test/TestJSImplGen.webidl
+++ b/dom/bindings/test/TestJSImplGen.webidl
@@ -517,16 +517,19 @@ interface TestJSImplInterface {
   void passUnionWithDefaultValue12(optional (unrestricted float or DOMString) arg = 1);
   void passUnionWithDefaultValue13(optional (unrestricted float or DOMString) arg = Infinity);
   void passUnionWithDefaultValue14(optional (double or ByteString) arg = "");
   void passUnionWithDefaultValue15(optional (double or ByteString) arg = 1);
   void passUnionWithDefaultValue16(optional (double or ByteString) arg = 1.5);
   void passUnionWithDefaultValue17(optional (double or SupportedType) arg = "text/html");
   void passUnionWithDefaultValue18(optional (double or SupportedType) arg = 1);
   void passUnionWithDefaultValue19(optional (double or SupportedType) arg = 1.5);
+  void passUnionWithDefaultValue20(optional (double or USVString) arg = "abc");
+  void passUnionWithDefaultValue21(optional (double or USVString) arg = 1);
+  void passUnionWithDefaultValue22(optional (double or USVString) arg = 1.5);
 
   void passNullableUnionWithDefaultValue1(optional (double or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue2(optional (double or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue3(optional (double or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue4(optional (float or DOMString)? arg = "");
   void passNullableUnionWithDefaultValue5(optional (float or DOMString)? arg = 1);
   void passNullableUnionWithDefaultValue6(optional (float or DOMString)? arg = null);
   void passNullableUnionWithDefaultValue7(optional (unrestricted double or DOMString)? arg = "");
@@ -538,16 +541,20 @@ interface TestJSImplInterface {
   void passNullableUnionWithDefaultValue13(optional (double or ByteString)? arg = "");
   void passNullableUnionWithDefaultValue14(optional (double or ByteString)? arg = 1);
   void passNullableUnionWithDefaultValue15(optional (double or ByteString)? arg = 1.5);
   void passNullableUnionWithDefaultValue16(optional (double or ByteString)? arg = null);
   void passNullableUnionWithDefaultValue17(optional (double or SupportedType)? arg = "text/html");
   void passNullableUnionWithDefaultValue18(optional (double or SupportedType)? arg = 1);
   void passNullableUnionWithDefaultValue19(optional (double or SupportedType)? arg = 1.5);
   void passNullableUnionWithDefaultValue20(optional (double or SupportedType)? arg = null);
+  void passNullableUnionWithDefaultValue21(optional (double or USVString)? arg = "abc");
+  void passNullableUnionWithDefaultValue22(optional (double or USVString)? arg = 1);
+  void passNullableUnionWithDefaultValue23(optional (double or USVString)? arg = 1.5);
+  void passNullableUnionWithDefaultValue24(optional (double or USVString)? arg = null);
 
   void passSequenceOfUnions(sequence<(CanvasPattern or CanvasGradient)> arg);
   void passSequenceOfUnions2(sequence<(object or long)> arg);
   void passVariadicUnion((CanvasPattern or CanvasGradient)... arg);
 
   void passSequenceOfNullableUnions(sequence<(CanvasPattern or CanvasGradient)?> arg);
   void passVariadicNullableUnion((CanvasPattern or CanvasGradient)?... arg);
   void passMozMapOfUnions(MozMap<(CanvasPattern or CanvasGradient)> arg);