Bug 826606 - Set uninitialized values for DeviceProximityEvent according to spec. r=dougt,smaug,khuey

This commit is contained in:
William Chen 2013-01-08 09:36:05 -08:00
Родитель 58cf683f4d
Коммит c61a8f2dd1
4 изменённых файлов: 20 добавлений и 8 удалений

Просмотреть файл

@ -426,6 +426,10 @@ is(e.min, 0, "min should be 0");
is(e.max, 2, "max should be 2");
document.dispatchEvent(e);
is(receivedEvent, e, "Wrong event!");
e = new DeviceProximityEvent("hello");
is(e.value, Infinity, "Uninitialized value should be infinity");
is(e.min, -Infinity, "Uninitialized min should be -infinity");
is(e.max, Infinity, "Uninitialized max should be infinity");
// UserProximityEvent
e = new UserProximityEvent("hello", {near: true});

Просмотреть файл

@ -21,7 +21,7 @@ interface nsIDOMDeviceProximityEvent : nsIDOMEvent
dictionary DeviceProximityEventInit : EventInit
{
double value;
double min;
double max;
double value = Infinity;
double min = -Infinity;
double max = Infinity;
};

Просмотреть файл

@ -265,18 +265,23 @@ def init_value(attribute):
return "JSVAL_VOID"
return "0"
else:
if realtype.count("double") and attribute.defvalue == "Infinity":
return "MOZ_DOUBLE_POSITIVE_INFINITY()"
if realtype.count("double") and attribute.defvalue == "-Infinity":
return "MOZ_DOUBLE_NEGATIVE_INFINITY()"
if realtype.count("nsAString"):
return "NS_LITERAL_STRING(\"%s\")" % attribute.defvalue
if realtype.count("nsACString"):
return "NS_LITERAL_CSTRING(\"%s\")" % attribute.defvalue
raise xpidl.IDLError("Default value is not supported for type %s" % realtype)
raise xpidl.IDLError("Default value of %s is not supported for type %s" %
(attribute.defvalue, realtype), attribute.location)
def write_header(iface, fd):
attributes = []
for member in iface.members:
if isinstance(member, xpidl.Attribute):
attributes.append(member)
fd.write("class %s" % iface.name)
if iface.base is not None:
fd.write(" : public %s" % iface.base)
@ -287,7 +292,7 @@ def write_header(iface, fd):
fd.write(" // If aCx or aVal is null, NS_OK is returned and \n"
" // dictionary will use the default values. \n"
" nsresult Init(JSContext* aCx, const jsval* aVal);\n")
fd.write("\n")
for member in attributes:

Просмотреть файл

@ -1009,7 +1009,8 @@ class IDLParser(object):
'raises': 'RAISES',
'readonly': 'READONLY',
'native': 'NATIVE',
'typedef': 'TYPEDEF'
'typedef': 'TYPEDEF',
'Infinity': 'INFINITY'
}
tokens = [
@ -1439,9 +1440,11 @@ class IDLParser(object):
def p_optdefvalue(self, p):
"""optdefvalue : '=' STRING
| '=' INFINITY
| '=' '-' INFINITY
| """
if len(p) > 1:
p[0] = p[2]
p[0] = "".join(p[2:])
else:
p[0] = None