mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Update the WebIDL parser
This commit is contained in:
parent
7ac2464302
commit
60f0f8eaa5
4 changed files with 31 additions and 46 deletions
|
@ -1261,10 +1261,7 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
|
||||||
member.getExtendedAttribute("ChromeOnly") or
|
member.getExtendedAttribute("ChromeOnly") or
|
||||||
member.getExtendedAttribute("Pref") or
|
member.getExtendedAttribute("Pref") or
|
||||||
member.getExtendedAttribute("Func") or
|
member.getExtendedAttribute("Func") or
|
||||||
member.getExtendedAttribute("SecureContext") or
|
member.getExtendedAttribute("SecureContext")):
|
||||||
member.getExtendedAttribute("AvailableIn") or
|
|
||||||
member.getExtendedAttribute("CheckAnyPermissions") or
|
|
||||||
member.getExtendedAttribute("CheckAllPermissions")):
|
|
||||||
raise WebIDLError("[Alias] must not be used on a "
|
raise WebIDLError("[Alias] must not be used on a "
|
||||||
"conditionally exposed operation",
|
"conditionally exposed operation",
|
||||||
[member.location])
|
[member.location])
|
||||||
|
@ -1290,17 +1287,11 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
|
||||||
alias,
|
alias,
|
||||||
[member.location, m.location])
|
[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
|
# Conditional exposure makes no sense for interfaces with no
|
||||||
# interface object, unless they're navigator properties.
|
# 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.hasInterfaceObject() and
|
||||||
not self.isNavigatorProperty()):
|
not self.isNavigatorProperty()):
|
||||||
raise WebIDLError("Interface with no interface object is "
|
raise WebIDLError("Interface with no interface object is "
|
||||||
|
@ -1538,8 +1529,8 @@ class IDLInterfaceOrNamespace(IDLObjectWithScope, IDLExposureMixins):
|
||||||
"SecureContext",
|
"SecureContext",
|
||||||
"CheckAnyPermissions",
|
"CheckAnyPermissions",
|
||||||
"CheckAllPermissions" ]
|
"CheckAllPermissions" ]
|
||||||
def isExposedConditionally(self):
|
def isExposedConditionally(self, exclusions=[]):
|
||||||
return any(self.getExtendedAttribute(a) for a in self.conditionExtendedAttributes)
|
return any(((not a in exclusions) and self.getExtendedAttribute(a)) for a in self.conditionExtendedAttributes)
|
||||||
|
|
||||||
class IDLInterface(IDLInterfaceOrNamespace):
|
class IDLInterface(IDLInterfaceOrNamespace):
|
||||||
def __init__(self, location, parentScope, name, parent, members,
|
def __init__(self, location, parentScope, name, parent, members,
|
||||||
|
@ -1715,10 +1706,7 @@ class IDLInterface(IDLInterfaceOrNamespace):
|
||||||
identifier == "JSImplementation" or
|
identifier == "JSImplementation" or
|
||||||
identifier == "HeaderFile" or
|
identifier == "HeaderFile" or
|
||||||
identifier == "NavigatorProperty" or
|
identifier == "NavigatorProperty" or
|
||||||
identifier == "AvailableIn" or
|
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "CheckAnyPermissions" or
|
|
||||||
identifier == "CheckAllPermissions" or
|
|
||||||
identifier == "Deprecated"):
|
identifier == "Deprecated"):
|
||||||
# Known extended attributes that take a string value
|
# Known extended attributes that take a string value
|
||||||
if not attr.hasValue():
|
if not attr.hasValue():
|
||||||
|
@ -3544,14 +3532,6 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
|
||||||
IDLExposureMixins.finish(self, scope)
|
IDLExposureMixins.finish(self, scope)
|
||||||
|
|
||||||
def validate(self):
|
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.isAttr() or self.isMethod():
|
||||||
if self.affects == "Everything" and self.dependsOn != "Everything":
|
if self.affects == "Everything" and self.dependsOn != "Everything":
|
||||||
raise WebIDLError("Interface member is flagged as affecting "
|
raise WebIDLError("Interface member is flagged as affecting "
|
||||||
|
@ -3968,10 +3948,7 @@ class IDLConst(IDLInterfaceMember):
|
||||||
elif (identifier == "Pref" or
|
elif (identifier == "Pref" or
|
||||||
identifier == "ChromeOnly" or
|
identifier == "ChromeOnly" or
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "SecureContext" or
|
identifier == "SecureContext"):
|
||||||
identifier == "AvailableIn" or
|
|
||||||
identifier == "CheckAnyPermissions" or
|
|
||||||
identifier == "CheckAllPermissions"):
|
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -4311,11 +4288,8 @@ class IDLAttribute(IDLInterfaceMember):
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "SecureContext" or
|
identifier == "SecureContext" or
|
||||||
identifier == "Frozen" or
|
identifier == "Frozen" or
|
||||||
identifier == "AvailableIn" or
|
|
||||||
identifier == "NewObject" or
|
identifier == "NewObject" or
|
||||||
identifier == "UnsafeInPrerendering" or
|
identifier == "UnsafeInPrerendering" or
|
||||||
identifier == "CheckAnyPermissions" or
|
|
||||||
identifier == "CheckAllPermissions" or
|
|
||||||
identifier == "BinaryName"):
|
identifier == "BinaryName"):
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
pass
|
pass
|
||||||
|
@ -5037,9 +5011,6 @@ class IDLMethod(IDLInterfaceMember, IDLScope):
|
||||||
identifier == "Deprecated" or
|
identifier == "Deprecated" or
|
||||||
identifier == "Func" or
|
identifier == "Func" or
|
||||||
identifier == "SecureContext" or
|
identifier == "SecureContext" or
|
||||||
identifier == "AvailableIn" or
|
|
||||||
identifier == "CheckAnyPermissions" or
|
|
||||||
identifier == "CheckAllPermissions" or
|
|
||||||
identifier == "BinaryName" or
|
identifier == "BinaryName" or
|
||||||
identifier == "StaticClassOverride"):
|
identifier == "StaticClassOverride"):
|
||||||
# Known attributes that we don't need to do anything with here
|
# Known attributes that we don't need to do anything with here
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
|
diff --git a/components/script/dom/bindings/codegen/parser/WebIDL.py b/components/script/dom/bindings/codegen/parser/WebIDL.py
|
||||||
index da32340..81c52b7 100644
|
index da32340..81c52b7 100644
|
||||||
--- a/components/script/dom/bindings/codegen/parser/WebIDL.py
|
--- WebIDL.py
|
||||||
+++ b/components/script/dom/bindings/codegen/parser/WebIDL.py
|
+++ WebIDL.py
|
||||||
@@ -2170,7 +2170,7 @@ class IDLUnresolvedType(IDLType):
|
@@ -2170,7 +2170,7 @@ class IDLUnresolvedType(IDLType):
|
||||||
return typedefType.complete(scope)
|
return typedefType.complete(scope)
|
||||||
elif obj.isCallback() and not obj.isInterface():
|
elif obj.isCallback() and not obj.isInterface():
|
||||||
|
@ -19,4 +19,4 @@ index da32340..81c52b7 100644
|
||||||
+ type = IDLCallbackType(obj.location, obj)
|
+ type = IDLCallbackType(obj.location, obj)
|
||||||
else:
|
else:
|
||||||
type = IDLWrapperType(self.getLocation(p, 1), p[1])
|
type = IDLWrapperType(self.getLocation(p, 1), p[1])
|
||||||
p[0] = self.handleModifiers(type, p[2])
|
p[0] = self.handleModifiers(type, p[2])
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
+++ WebIDL.py
|
+++ WebIDL.py
|
||||||
@@ -1239,12 +1239,6 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
@@ -1239,12 +1239,6 @@ class IDLInterface(IDLObjectWithScope, IDLExposureMixins):
|
||||||
alias,
|
alias,
|
||||||
[member.location, m.location])
|
[member.location, m.location])
|
||||||
|
|
||||||
- if (self.getExtendedAttribute("Pref") and
|
- if (self.getExtendedAttribute("Pref") and
|
||||||
- self._exposureGlobalNames != set([self.parentScope.primaryGlobalName])):
|
- self._exposureGlobalNames != set([self.parentScope.primaryGlobalName])):
|
||||||
|
@ -10,9 +10,9 @@
|
||||||
- self.parentScope.primaryGlobalName,
|
- self.parentScope.primaryGlobalName,
|
||||||
- [self.location])
|
- [self.location])
|
||||||
-
|
-
|
||||||
for attribute in ["CheckAnyPermissions", "CheckAllPermissions"]:
|
# Conditional exposure makes no sense for interfaces with no
|
||||||
if (self.getExtendedAttribute(attribute) and
|
# interface object, unless they're navigator properties.
|
||||||
self._exposureGlobalNames != set([self.parentScope.primaryGlobalName])):
|
# And SecureContext makes sense for interfaces with no interface object,
|
||||||
@@ -3459,12 +3453,6 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
|
@@ -3459,12 +3453,6 @@ class IDLInterfaceMember(IDLObjectWithIdentifier, IDLExposureMixins):
|
||||||
IDLExposureMixins.finish(self, scope)
|
IDLExposureMixins.finish(self, scope)
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@
|
||||||
- "%s-only" % self._globalScope.primaryGlobalName,
|
- "%s-only" % self._globalScope.primaryGlobalName,
|
||||||
- [self.location])
|
- [self.location])
|
||||||
-
|
-
|
||||||
for attribute in ["CheckAnyPermissions", "CheckAllPermissions"]:
|
if self.isAttr() or self.isMethod():
|
||||||
if (self.getExtendedAttribute(attribute) and
|
if self.affects == "Everything" and self.dependsOn != "Everything":
|
||||||
self.exposureSet != set([self._globalScope.primaryGlobalName])):
|
raise WebIDLError("Interface member is flagged as affecting "
|
||||||
|
|
|
@ -316,3 +316,17 @@ def WebIDLTest(parser, harness):
|
||||||
harness.ok(results[0].members[3].getExtendedAttribute("SecureContext") is None,
|
harness.ok(results[0].members[3].getExtendedAttribute("SecureContext") is None,
|
||||||
"Methods copied from non-[SecureContext] interface should not be [SecureContext]")
|
"Methods copied from non-[SecureContext] interface should not be [SecureContext]")
|
||||||
|
|
||||||
|
# Test SecureContext and NoInterfaceObject
|
||||||
|
parser = parser.reset()
|
||||||
|
parser.parse("""
|
||||||
|
[NoInterfaceObject, SecureContext]
|
||||||
|
interface TestSecureContextNoInterfaceObject {
|
||||||
|
void testSecureMethod(byte foo);
|
||||||
|
};
|
||||||
|
""")
|
||||||
|
results = parser.finish()
|
||||||
|
harness.check(len(results[0].members), 1, "TestSecureContextNoInterfaceObject should have only one member")
|
||||||
|
harness.ok(results[0].getExtendedAttribute("SecureContext"),
|
||||||
|
"Interface should have [SecureContext] extended attribute")
|
||||||
|
harness.ok(results[0].members[0].getExtendedAttribute("SecureContext"),
|
||||||
|
"Interface member should have [SecureContext] extended attribute")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue