aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py8
-rw-r--r--components/script/dom/bindings/codegen/parser/WebIDL.py5
-rw-r--r--components/script/dom/webidls/TestBinding.webidl16
3 files changed, 15 insertions, 14 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 27f68a312e4..f1b239a1922 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -97,8 +97,8 @@ numericTags = [
IDLType.Tags.int16, IDLType.Tags.uint16,
IDLType.Tags.int32, IDLType.Tags.uint32,
IDLType.Tags.int64, IDLType.Tags.uint64,
- IDLType.Tags.unrestricted_float, IDLType.Tags.float,
- IDLType.Tags.unrestricted_double, IDLType.Tags.double
+ IDLType.Tags.unrestricted_float,
+ IDLType.Tags.unrestricted_double
]
@@ -1056,7 +1056,9 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None,
defaultStr = "None"
else:
tag = defaultValue.type.tag()
- if tag in numericTags:
+ if tag in [IDLType.Tags.float, IDLType.Tags.double]:
+ defaultStr = "Finite::wrap(%s)" % defaultValue.value
+ elif tag in numericTags:
defaultStr = str(defaultValue.value)
else:
assert(tag == IDLType.Tags.bool)
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
index a40c563ae35..5741ab8fce5 100644
--- a/components/script/dom/bindings/codegen/parser/WebIDL.py
+++ b/components/script/dom/bindings/codegen/parser/WebIDL.py
@@ -2920,8 +2920,7 @@ class IDLValue(IDLObject):
elif self.type.isInteger() and type.isFloat():
# Convert an integer literal into float
if -2**24 <= self.value <= 2**24:
- floatType = BuiltinTypes[IDLBuiltinType.Types.float]
- return IDLValue(self.location, floatType, float(self.value))
+ return IDLValue(self.location, type, float(self.value))
else:
raise WebIDLError("Converting value %s to %s will lose precision." %
(self.value, type), [location])
@@ -2939,7 +2938,7 @@ class IDLValue(IDLObject):
math.isnan(self.value))):
raise WebIDLError("Trying to convert unrestricted value %s to non-unrestricted"
% self.value, [location]);
- return self
+ return IDLValue(self.location, type, self.value)
elif self.type.isString() and type.isUSVString():
# Allow USVStrings to use default value just like
# DOMString. No coercion is required in this case as Codegen.py
diff --git a/components/script/dom/webidls/TestBinding.webidl b/components/script/dom/webidls/TestBinding.webidl
index 379f3e1e51c..68ac9bb8b30 100644
--- a/components/script/dom/webidls/TestBinding.webidl
+++ b/components/script/dom/webidls/TestBinding.webidl
@@ -39,10 +39,10 @@ dictionary TestDictionaryDefaults {
unsigned long unsignedLongValue = 7;
long long longLongValue = 7;
unsigned long long unsignedLongLongValue = 7;
- // unrestricted float unrestrictedFloatValue = 7.0;
- // float floatValue = 7.0;
- // unrestricted double UnrestrictedDoubleValue = 7.0;
- // double doubleValue = 7.0;
+ unrestricted float unrestrictedFloatValue = 7.0;
+ float floatValue = 7.0;
+ unrestricted double UnrestrictedDoubleValue = 7.0;
+ double doubleValue = 7.0;
DOMString stringValue = "foo";
USVString usvstringValue = "foo";
TestEnum enumValue = "bar";
@@ -57,10 +57,10 @@ dictionary TestDictionaryDefaults {
unsigned long? nullableUnsignedLongValue = 7;
long long? nullableLongLongValue = 7;
unsigned long long? nullableUnsignedLongLongValue = 7;
- // unrestricted float? nullableUnrestrictedFloatValue = 7.0;
- // float? nullableFloatValue = 7.0;
- // unrestricted double? nullableUnrestrictedDoubleValue = 7.0;
- // double? nullableDoubleValue = 7.0;
+ unrestricted float? nullableUnrestrictedFloatValue = 7.0;
+ float? nullableFloatValue = 7.0;
+ unrestricted double? nullableUnrestrictedDoubleValue = 7.0;
+ double? nullableDoubleValue = 7.0;
DOMString? nullableStringValue = "foo";
USVString? nullableUsvstringValue = "foo";
// TestEnum? nullableEnumValue = "bar";