mirror of
https://github.com/servo/servo.git
synced 2025-07-16 11:53:39 +01:00
auto merge of #3884 : brunoabinader/servo/dataset, r=jdm
This is a sub-task for #2974.
This commit is contained in:
commit
46154fb7ac
8 changed files with 91 additions and 23 deletions
|
@ -2091,7 +2091,7 @@ class CGDefineProxyHandler(CGAbstractMethod):
|
||||||
let traps = ProxyTraps {
|
let traps = ProxyTraps {
|
||||||
getPropertyDescriptor: Some(getPropertyDescriptor),
|
getPropertyDescriptor: Some(getPropertyDescriptor),
|
||||||
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
||||||
defineProperty: Some(defineProperty),
|
defineProperty: Some(defineProperty_),
|
||||||
getOwnPropertyNames: ptr::null(),
|
getOwnPropertyNames: ptr::null(),
|
||||||
delete_: Some(delete_),
|
delete_: Some(delete_),
|
||||||
enumerate: ptr::null(),
|
enumerate: ptr::null(),
|
||||||
|
@ -3506,7 +3506,8 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
||||||
# arguments[0] is the index or name of the item that we're setting.
|
# arguments[0] is the index or name of the item that we're setting.
|
||||||
argument = arguments[1]
|
argument = arguments[1]
|
||||||
template, _, declType, needsRooting = getJSToNativeConversionTemplate(
|
template, _, declType, needsRooting = getJSToNativeConversionTemplate(
|
||||||
argument.type, descriptor, treatNullAs=argument.treatNullAs)
|
argument.type, descriptor, treatNullAs=argument.treatNullAs,
|
||||||
|
exceptionCode="return false;")
|
||||||
templateValues = {
|
templateValues = {
|
||||||
"val": "(*desc).value",
|
"val": "(*desc).value",
|
||||||
}
|
}
|
||||||
|
@ -4033,7 +4034,8 @@ class CGInterfaceTrait(CGThing):
|
||||||
|
|
||||||
def members():
|
def members():
|
||||||
for m in descriptor.interface.members:
|
for m in descriptor.interface.members:
|
||||||
if m.isMethod() and not m.isStatic():
|
if m.isMethod() and not m.isStatic() \
|
||||||
|
and not m.isIdentifierLess():
|
||||||
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
name = CGSpecializedMethod.makeNativeName(descriptor, m)
|
||||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
||||||
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
||||||
|
@ -4064,7 +4066,10 @@ class CGInterfaceTrait(CGThing):
|
||||||
rettype, arguments = operation.signatures()[0]
|
rettype, arguments = operation.signatures()[0]
|
||||||
|
|
||||||
infallible = 'infallible' in descriptor.getExtendedAttributes(operation)
|
infallible = 'infallible' in descriptor.getExtendedAttributes(operation)
|
||||||
arguments = method_arguments(rettype, arguments, ("found", "&mut bool"))
|
if operation.isGetter():
|
||||||
|
arguments = method_arguments(rettype, arguments, ("found", "&mut bool"))
|
||||||
|
else:
|
||||||
|
arguments = method_arguments(rettype, arguments)
|
||||||
rettype = return_type(rettype, infallible)
|
rettype = return_type(rettype, infallible)
|
||||||
yield name, arguments, rettype
|
yield name, arguments, rettype
|
||||||
|
|
||||||
|
@ -4551,7 +4556,7 @@ class CGBindingRoot(CGThing):
|
||||||
'dom::bindings::error::throw_dom_exception',
|
'dom::bindings::error::throw_dom_exception',
|
||||||
'dom::bindings::error::throw_type_error',
|
'dom::bindings::error::throw_type_error',
|
||||||
'dom::bindings::proxyhandler',
|
'dom::bindings::proxyhandler',
|
||||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
'dom::bindings::proxyhandler::{_obj_toString, defineProperty_}',
|
||||||
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
||||||
'dom::bindings::proxyhandler::{delete_, getPropertyDescriptor}',
|
'dom::bindings::proxyhandler::{delete_, getPropertyDescriptor}',
|
||||||
'dom::bindings::str::ByteString',
|
'dom::bindings::str::ByteString',
|
||||||
|
|
|
@ -208,9 +208,6 @@ class Descriptor(DescriptorProvider):
|
||||||
addIndexedOrNamedOperation('Creator', m)
|
addIndexedOrNamedOperation('Creator', m)
|
||||||
if m.isDeleter():
|
if m.isDeleter():
|
||||||
addIndexedOrNamedOperation('Deleter', m)
|
addIndexedOrNamedOperation('Deleter', m)
|
||||||
raise TypeError("deleter specified on %s but we "
|
|
||||||
"don't support deleters yet" %
|
|
||||||
self.interface.identifier.name)
|
|
||||||
|
|
||||||
iface.setUserData('hasConcreteDescendant', True)
|
iface.setUserData('hasConcreteDescendant', True)
|
||||||
iface = iface.parent
|
iface = iface.parent
|
||||||
|
|
|
@ -48,7 +48,7 @@ pub unsafe extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObj
|
||||||
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc) != 0
|
JS_GetPropertyDescriptorById(cx, proto, id, JSRESOLVE_QUALIFIED, desc) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub unsafe extern fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
desc: *mut JSPropertyDescriptor) -> bool {
|
desc: *mut JSPropertyDescriptor) -> bool {
|
||||||
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
|
static JSMSG_GETTER_ONLY: libc::c_uint = 160;
|
||||||
|
|
||||||
|
@ -72,11 +72,6 @@ pub unsafe fn defineProperty_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid
|
||||||
(*desc).setter, (*desc).attrs) != 0;
|
(*desc).setter, (*desc).attrs) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
|
||||||
desc: *mut JSPropertyDescriptor) -> bool {
|
|
||||||
defineProperty_(cx, proxy, id, desc)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
pub unsafe extern fn delete_(cx: *mut JSContext, proxy: *mut JSObject, id: jsid,
|
||||||
bp: *mut bool) -> bool {
|
bp: *mut bool) -> bool {
|
||||||
let expando = EnsureExpandoObject(cx, proxy);
|
let expando = EnsureExpandoObject(cx, proxy);
|
||||||
|
|
66
components/script/dom/domstringmap.rs
Normal file
66
components/script/dom/domstringmap.rs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom::bindings::cell::DOMRefCell;
|
||||||
|
use dom::bindings::codegen::Bindings::DOMStringMapBinding;
|
||||||
|
use dom::bindings::codegen::Bindings::DOMStringMapBinding::DOMStringMapMethods;
|
||||||
|
use dom::bindings::global::GlobalRef;
|
||||||
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
use std::collections::hashmap::HashMap;
|
||||||
|
|
||||||
|
#[dom_struct]
|
||||||
|
pub struct DOMStringMap {
|
||||||
|
map: DOMRefCell<HashMap<DOMString, DOMString>>,
|
||||||
|
reflector_: Reflector,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DOMStringMap {
|
||||||
|
fn new_inherited() -> DOMStringMap {
|
||||||
|
DOMStringMap {
|
||||||
|
map: DOMRefCell::new(HashMap::new()),
|
||||||
|
reflector_: Reflector::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new(global: &GlobalRef) -> Temporary<DOMStringMap> {
|
||||||
|
reflect_dom_object(box DOMStringMap::new_inherited(),
|
||||||
|
global, DOMStringMapBinding::Wrap)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> DOMStringMapMethods for JSRef<'a, DOMStringMap> {
|
||||||
|
fn NamedCreator(self, name: DOMString, value: DOMString) {
|
||||||
|
self.map.borrow_mut().insert(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn NamedDeleter(self, name: DOMString) {
|
||||||
|
self.map.borrow_mut().remove(&name);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn NamedSetter(self, name: DOMString, value: DOMString) {
|
||||||
|
self.map.borrow_mut().insert(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn NamedGetter(self, name: DOMString, found: &mut bool) -> DOMString {
|
||||||
|
match self.map.borrow().find(&name) {
|
||||||
|
Some(value) => {
|
||||||
|
*found = true;
|
||||||
|
value.clone()
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
*found = false;
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Reflectable for DOMStringMap {
|
||||||
|
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||||
|
&self.reflector_
|
||||||
|
}
|
||||||
|
}
|
12
components/script/dom/webidls/DOMStringMap.webidl
Normal file
12
components/script/dom/webidls/DOMStringMap.webidl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/#the-domstringmap-interface
|
||||||
|
[OverrideBuiltins]
|
||||||
|
interface DOMStringMap {
|
||||||
|
getter DOMString (DOMString name);
|
||||||
|
setter creator void (DOMString name, DOMString value);
|
||||||
|
deleter void (DOMString name);
|
||||||
|
};
|
|
@ -89,6 +89,7 @@ pub mod dom {
|
||||||
pub mod characterdata;
|
pub mod characterdata;
|
||||||
pub mod domrect;
|
pub mod domrect;
|
||||||
pub mod domrectlist;
|
pub mod domrectlist;
|
||||||
|
pub mod domstringmap;
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod console;
|
pub mod console;
|
||||||
mod create;
|
mod create;
|
||||||
|
|
|
@ -67,6 +67,7 @@ var interfaceNamesInGlobalScope = [
|
||||||
"DOMImplementation",
|
"DOMImplementation",
|
||||||
"DOMParser",
|
"DOMParser",
|
||||||
"DOMTokenList",
|
"DOMTokenList",
|
||||||
|
"DOMStringMap",
|
||||||
"Element",
|
"Element",
|
||||||
"Event",
|
"Event",
|
||||||
"EventTarget",
|
"EventTarget",
|
||||||
|
|
|
@ -1692,18 +1692,9 @@
|
||||||
[PropertyNodeList interface: operation getValues()]
|
[PropertyNodeList interface: operation getValues()]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[DOMStringMap interface: existence and properties of interface object]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[DOMStringMap interface object length]
|
[DOMStringMap interface object length]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[DOMStringMap interface: existence and properties of interface prototype object]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[DOMStringMap interface: existence and properties of interface prototype object\'s "constructor" property]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[DOMStringMap must be primary interface of document.head.dataset]
|
[DOMStringMap must be primary interface of document.head.dataset]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue