aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen/parser/WebIDL.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/bindings/codegen/parser/WebIDL.py')
-rw-r--r--components/script/dom/bindings/codegen/parser/WebIDL.py70
1 files changed, 31 insertions, 39 deletions
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
index da32340dda6..878c221f01c 100644
--- a/components/script/dom/bindings/codegen/parser/WebIDL.py
+++ b/components/script/dom/bindings/codegen/parser/WebIDL.py
@@ -1261,10 +1261,7 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
member.getExtendedAttribute("ChromeOnly") or
member.getExtendedAttribute("Pref") or
member.getExtendedAttribute("Func") or
- member.getExtendedAttribute("SecureContext") or
- member.getExtendedAttribute("AvailableIn") or
- member.getExtendedAttribute("CheckAnyPermissions") or
- member.getExtendedAttribute("CheckAllPermissions")):
+ member.getExtendedAttribute("SecureContext")):
raise WebIDLError("[Alias] must not be used on a "
"conditionally exposed operation",
[member.location])
@@ -1290,17 +1287,11 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
alias,
[member.location, m.location])
- for attribute in ["CheckAnyPermissions", "CheckAllPermissions"]:
- if (self.getExtendedAttribute(attribute) and
- self._exposureGlobalNames != set([self.parentScope.primaryGlobalName])):
- raise WebIDLError("[%s] used on an interface that is "
- "not %s-only" %
- (attribute, self.parentScope.primaryGlobalName),
- [self.location])
-
# Conditional exposure makes no sense for interfaces with no
# interface object, unless they're navigator properties.
- if (self.isExposedConditionally() and
+ # And SecureContext makes sense for interfaces with no interface object,
+ # since it is also propagated to interface members.
+ if (self.isExposedConditionally(exclusions=["SecureContext"]) and
not self.hasInterfaceObject() and
not self.isNavigatorProperty()):
raise WebIDLError("Interface with no interface object is "
@@ -1538,8 +1529,8 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
"SecureContext",
"CheckAnyPermissions",
"CheckAllPermissions" ]
- def isExposedConditionally(self):
- return any(self.getExtendedAttribute(a) for a in self.conditionExtendedAttributes)
+ def isExposedConditionally(self, exclusions=[]):
+ return any(((not a in exclusions) and self.getExtendedAttribute(a)) for a in self.conditionExtendedAttributes)
class IDLInterface(IDLInterfaceOrNamespace):
def __init__(self, location, parentScope, name, parent, members,
@@ -1715,10 +1706,7 @@ class IDLInterface(IDLInterfaceOrNamespace):
identifier == "JSImplementation" or
identifier == "HeaderFile" or
identifier == "NavigatorProperty" or
- identifier == "AvailableIn" or
identifier == "Func" or
- identifier == "CheckAnyPermissions" or
- identifier == "CheckAllPermissions" or
identifier == "Deprecated"):
# Known extended attributes that take a string value
if not attr.hasValue():
@@ -2170,7 +2158,7 @@ class IDLUnresolvedType(IDLType):
return typedefType.complete(scope)
elif obj.isCallback() and not obj.isInterface():
assert self.name.name == obj.identifier.name
- return IDLCallbackType(self.location, obj)
+ return IDLCallbackType(obj.location, obj)
if self._promiseInnerType and not self._promiseInnerType.isComplete():
self._promiseInnerType = self._promiseInnerType.complete(scope)
@@ -2503,10 +2491,18 @@ class IDLUnionType(IDLType):
return type.name
for (i, type) in enumerate(self.memberTypes):
- if not type.isComplete():
+ # Exclude typedefs because if given "typedef (B or C) test",
+ # we want AOrTest, not AOrBOrC
+ if not type.isComplete() and not isinstance(type, IDLTypedefType):
self.memberTypes[i] = type.complete(scope)
self.name = "Or".join(typeName(type) for type in self.memberTypes)
+
+ # We do this again to complete the typedef types
+ for (i, type) in enumerate(self.memberTypes):
+ if not type.isComplete():
+ self.memberTypes[i] = type.complete(scope)
+
self.flatMemberTypes = list(self.memberTypes)
i = 0
while i < len(self.flatMemberTypes):
@@ -3391,6 +3387,11 @@ class IDLValue(IDLObject):
# extra normalization step.
assert self.type.isDOMString()
return self
+ elif self.type.isString() and type.isByteString():
+ # Allow ByteStrings to use default value just like
+ # DOMString. No coercion is required here.
+ assert self.type.isDOMString()
+ return self
raise WebIDLError("Cannot coerce type %s to type %s." %
(self.type, type), [location])
@@ -3539,14 +3540,6 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
IDLExposureMixins.finish(self, scope)
def validate(self):
- for attribute in ["CheckAnyPermissions", "CheckAllPermissions"]:
- if (self.getExtendedAttribute(attribute) and
- self.exposureSet != set([self._globalScope.primaryGlobalName])):
- raise WebIDLError("[%s] used on an interface member that is "
- "not %s-only" %
- (attribute, self.parentScope.primaryGlobalName),
- [self.location])
-
if self.isAttr() or self.isMethod():
if self.affects == "Everything" and self.dependsOn != "Everything":
raise WebIDLError("Interface member is flagged as affecting "
@@ -3963,10 +3956,7 @@ class IDLConst(IDLInterfaceMember):
elif (identifier == "Pref" or
identifier == "ChromeOnly" or
identifier == "Func" or
- identifier == "SecureContext" or
- identifier == "AvailableIn" or
- identifier == "CheckAnyPermissions" or
- identifier == "CheckAllPermissions"):
+ identifier == "SecureContext"):
# Known attributes that we don't need to do anything with here
pass
else:
@@ -4306,11 +4296,8 @@ class IDLAttribute(IDLInterfaceMember):
identifier == "Func" or
identifier == "SecureContext" or
identifier == "Frozen" or
- identifier == "AvailableIn" or
identifier == "NewObject" or
identifier == "UnsafeInPrerendering" or
- identifier == "CheckAnyPermissions" or
- identifier == "CheckAllPermissions" or
identifier == "BinaryName"):
# Known attributes that we don't need to do anything with here
pass
@@ -5032,9 +5019,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
identifier == "Deprecated" or
identifier == "Func" or
identifier == "SecureContext" or
- identifier == "AvailableIn" or
- identifier == "CheckAnyPermissions" or
- identifier == "CheckAllPermissions" or
identifier == "BinaryName" or
identifier == "StaticClassOverride"):
# Known attributes that we don't need to do anything with here
@@ -5759,6 +5743,14 @@ class Parser(Tokenizer):
booleanType = BuiltinTypes[IDLBuiltinType.Types.boolean]
p[0] = IDLValue(location, booleanType, p[1])
+ def p_ConstValueByteString(self, p):
+ """
+ ConstValue : BYTESTRING
+ """
+ location = self.getLocation(p, 1)
+ bytestringType = BuiltinTypes[IDLBuiltinType.Types.bytestring]
+ p[0] = IDLValue(location, bytestringType, p[1])
+
def p_ConstValueInteger(self, p):
"""
ConstValue : INTEGER
@@ -6521,7 +6513,7 @@ class Parser(Tokenizer):
type = IDLTypedefType(self.getLocation(p, 1), obj.innerType,
obj.identifier.name)
elif obj.isCallback() and not obj.isInterface():
- type = IDLCallbackType(self.getLocation(p, 1), obj)
+ type = IDLCallbackType(obj.location, obj)
else:
type = IDLWrapperType(self.getLocation(p, 1), p[1])
p[0] = self.handleModifiers(type, p[2])