aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-20 13:01:02 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-20 13:01:02 -0700
commit172db80703fc19ff078f2f46fb299cadd99a483b (patch)
tree09184aec85214913683a7dc81b39bdcb091de10c
parent276f74b1ddec9dfa4cb053eb0802f95bd5ed6b66 (diff)
parent00f863b4fea0cac93dd2d77964d4b2e6f1f5ccba (diff)
downloadservo-172db80703fc19ff078f2f46fb299cadd99a483b.tar.gz
servo-172db80703fc19ff078f2f46fb299cadd99a483b.zip
auto merge of #4882 : chmanchester/servo/stringifiers, r=Ms2ger
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py33
-rw-r--r--components/script/dom/bindings/codegen/Configuration.py59
-rw-r--r--components/script/dom/location.rs4
-rw-r--r--components/script/dom/webidls/URLUtils.webidl5
-rw-r--r--tests/wpt/metadata/dom/nodes/Node-properties.html.ini6
-rw-r--r--tests/wpt/metadata/html/browsers/history/the-location-interface/location-stringifier.html.ini14
6 files changed, 69 insertions, 52 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index ebac6455b1f..29a81f771af 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -68,6 +68,13 @@ def stripTrailingWhitespace(text):
return '\n'.join(lines) + tail
def MakeNativeName(name):
+ # The gecko counterpart to this file uses the BinaryName machinery
+ # for this purpose (#4435 is the servo issue for BinaryName).
+ replacements = {
+ "__stringifier": "Stringify",
+ }
+ if name in replacements:
+ return replacements[name]
return name[0].upper() + name[1:]
builtinNames = {
@@ -1218,13 +1225,25 @@ class MethodDefiner(PropertyDefiner):
"length": 0,
"flags": "JSPROP_ENUMERATE" })
+ if not static:
+ stringifier = descriptor.operations['Stringifier']
+ if stringifier:
+ self.regular.append({
+ "name": "toString",
+ "nativeName": stringifier.identifier.name,
+ "length": 0,
+ "flags": "JSPROP_ENUMERATE"
+ })
+
+
def generateArray(self, array, name):
if len(array) == 0:
return ""
def specData(m):
if m.get("methodInfo", True):
- jitinfo = ("&%s_methodinfo" % m["name"])
+ identifier = m.get("nativeName", m["name"])
+ jitinfo = "&%s_methodinfo" % identifier
accessor = "genericMethod as NonNullJSNative"
else:
jitinfo = "0 as *const JSJitInfo"
@@ -4100,8 +4119,8 @@ class CGInterfaceTrait(CGThing):
def members():
for m in descriptor.interface.members:
- if m.isMethod() and not m.isStatic() \
- and not m.isIdentifierLess():
+ if (m.isMethod() and not m.isStatic() and
+ (not m.isIdentifierLess() or m.isStringifier())):
name = CGSpecializedMethod.makeNativeName(descriptor, m)
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
for idx, (rettype, arguments) in enumerate(m.signatures()):
@@ -4169,7 +4188,8 @@ class CGDescriptor(CGThing):
(hasMethod, hasGetter, hasLenientGetter,
hasSetter, hasLenientSetter) = False, False, False, False, False
for m in descriptor.interface.members:
- if m.isMethod() and not m.isIdentifierLess():
+ if (m.isMethod() and
+ (not m.isIdentifierLess() or m == descriptor.operations["Stringifier"])):
if m.isStatic():
assert descriptor.interface.hasInterfaceObject()
cgThings.append(CGStaticMethod(descriptor, m))
@@ -4178,6 +4198,11 @@ class CGDescriptor(CGThing):
cgThings.append(CGMemberJITInfo(descriptor, m))
hasMethod = True
elif m.isAttr():
+ if m.stringifier:
+ raise TypeError("Stringifier attributes not supported yet. "
+ "See bug 824857.\n"
+ "%s" % m.location)
+
if m.isStatic():
assert descriptor.interface.hasInterfaceObject()
cgThings.append(CGStaticGetter(descriptor, m))
diff --git a/components/script/dom/bindings/codegen/Configuration.py b/components/script/dom/bindings/codegen/Configuration.py
index 22efa56f6d7..8944070f09c 100644
--- a/components/script/dom/bindings/codegen/Configuration.py
+++ b/components/script/dom/bindings/codegen/Configuration.py
@@ -166,28 +166,37 @@ class Descriptor(DescriptorProvider):
# If we're concrete, we need to crawl our ancestor interfaces and mark
# them as having a concrete descendant.
self.concrete = desc.get('concrete', True)
+
+ self.operations = {
+ 'IndexedGetter': None,
+ 'IndexedSetter': None,
+ 'IndexedCreator': None,
+ 'IndexedDeleter': None,
+ 'NamedGetter': None,
+ 'NamedSetter': None,
+ 'NamedCreator': None,
+ 'NamedDeleter': None,
+ 'Stringifier': None,
+ }
+
+ def addOperation(operation, m):
+ if not self.operations[operation]:
+ self.operations[operation] = m
+
+ # Since stringifiers go on the prototype, we only need to worry
+ # about our own stringifier, not those of our ancestor interfaces.
+ for m in self.interface.members:
+ if m.isMethod() and m.isStringifier():
+ addOperation('Stringifier', m)
+
if self.concrete:
self.proxy = False
- operations = {
- 'IndexedGetter': None,
- 'IndexedSetter': None,
- 'IndexedCreator': None,
- 'IndexedDeleter': None,
- 'NamedGetter': None,
- 'NamedSetter': None,
- 'NamedCreator': None,
- 'NamedDeleter': None,
- 'Stringifier': None
- }
iface = self.interface
while iface:
for m in iface.members:
if not m.isMethod():
continue
- def addOperation(operation, m):
- if not operations[operation]:
- operations[operation] = m
def addIndexedOrNamedOperation(operation, m):
self.proxy = True
if m.isIndexed():
@@ -196,24 +205,20 @@ class Descriptor(DescriptorProvider):
assert m.isNamed()
operation = 'Named' + operation
addOperation(operation, m)
-
- if m.isStringifier():
- addOperation('Stringifier', m)
- else:
- if m.isGetter():
- addIndexedOrNamedOperation('Getter', m)
- if m.isSetter():
- addIndexedOrNamedOperation('Setter', m)
- if m.isCreator():
- addIndexedOrNamedOperation('Creator', m)
- if m.isDeleter():
- addIndexedOrNamedOperation('Deleter', m)
+
+ if m.isGetter():
+ addIndexedOrNamedOperation('Getter', m)
+ if m.isSetter():
+ addIndexedOrNamedOperation('Setter', m)
+ if m.isCreator():
+ addIndexedOrNamedOperation('Creator', m)
+ if m.isDeleter():
+ addIndexedOrNamedOperation('Deleter', m)
iface.setUserData('hasConcreteDescendant', True)
iface = iface.parent
if self.proxy:
- self.operations = operations
iface = self.interface
while iface:
iface.setUserData('hasProxyDescendant', True)
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs
index 4f4c44e4015..614b623e5b9 100644
--- a/components/script/dom/location.rs
+++ b/components/script/dom/location.rs
@@ -47,6 +47,10 @@ impl<'a> LocationMethods for JSRef<'a, Location> {
UrlHelper::Href(&self.page.get_url())
}
+ fn Stringify(self) -> DOMString {
+ self.Href()
+ }
+
fn Search(self) -> DOMString {
UrlHelper::Search(&self.page.get_url())
}
diff --git a/components/script/dom/webidls/URLUtils.webidl b/components/script/dom/webidls/URLUtils.webidl
index 58fe13c5508..4abb2048917 100644
--- a/components/script/dom/webidls/URLUtils.webidl
+++ b/components/script/dom/webidls/URLUtils.webidl
@@ -9,7 +9,6 @@ interface URLUtils {
//stringifier attribute ScalarValueString href;
readonly attribute DOMString href;
//readonly attribute ScalarValueString origin;
-
// attribute ScalarValueString protocol;
// attribute ScalarValueString username;
// attribute ScalarValueString password;
@@ -22,4 +21,8 @@ interface URLUtils {
// attribute URLSearchParams searchParams;
// attribute ScalarValueString hash;
readonly attribute DOMString hash;
+
+ // This is only doing as well as gecko right now, bug 824857 is on file for
+ // adding attribute stringifier support.
+ stringifier;
};
diff --git a/tests/wpt/metadata/dom/nodes/Node-properties.html.ini b/tests/wpt/metadata/dom/nodes/Node-properties.html.ini
index 9ed603101f1..67eab93616a 100644
--- a/tests/wpt/metadata/dom/nodes/Node-properties.html.ini
+++ b/tests/wpt/metadata/dom/nodes/Node-properties.html.ini
@@ -57,12 +57,6 @@
[detachedPara2.firstElementChild]
expected: FAIL
- [document.URL]
- expected: FAIL
-
- [document.documentURI]
- expected: FAIL
-
[foreignPara1.previousElementSibling]
expected: FAIL
diff --git a/tests/wpt/metadata/html/browsers/history/the-location-interface/location-stringifier.html.ini b/tests/wpt/metadata/html/browsers/history/the-location-interface/location-stringifier.html.ini
deleted file mode 100644
index ee6fe32a626..00000000000
--- a/tests/wpt/metadata/html/browsers/history/the-location-interface/location-stringifier.html.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-[location-stringifier.html]
- type: testharness
- [Location stringifier]
- expected: FAIL
-
- [Location stringifier 1]
- expected: FAIL
-
- [Location stringifier 3]
- expected: FAIL
-
- [Location stringifier 4]
- expected: FAIL
-