mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +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 {
|
||||
getPropertyDescriptor: Some(getPropertyDescriptor),
|
||||
getOwnPropertyDescriptor: Some(getOwnPropertyDescriptor),
|
||||
defineProperty: Some(defineProperty),
|
||||
defineProperty: Some(defineProperty_),
|
||||
getOwnPropertyNames: ptr::null(),
|
||||
delete_: Some(delete_),
|
||||
enumerate: ptr::null(),
|
||||
|
@ -3506,7 +3506,8 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
# arguments[0] is the index or name of the item that we're setting.
|
||||
argument = arguments[1]
|
||||
template, _, declType, needsRooting = getJSToNativeConversionTemplate(
|
||||
argument.type, descriptor, treatNullAs=argument.treatNullAs)
|
||||
argument.type, descriptor, treatNullAs=argument.treatNullAs,
|
||||
exceptionCode="return false;")
|
||||
templateValues = {
|
||||
"val": "(*desc).value",
|
||||
}
|
||||
|
@ -4033,7 +4034,8 @@ class CGInterfaceTrait(CGThing):
|
|||
|
||||
def 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)
|
||||
infallible = 'infallible' in descriptor.getExtendedAttributes(m)
|
||||
for idx, (rettype, arguments) in enumerate(m.signatures()):
|
||||
|
@ -4064,7 +4066,10 @@ class CGInterfaceTrait(CGThing):
|
|||
rettype, arguments = operation.signatures()[0]
|
||||
|
||||
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)
|
||||
yield name, arguments, rettype
|
||||
|
||||
|
@ -4551,7 +4556,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::bindings::error::throw_dom_exception',
|
||||
'dom::bindings::error::throw_type_error',
|
||||
'dom::bindings::proxyhandler',
|
||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty}',
|
||||
'dom::bindings::proxyhandler::{_obj_toString, defineProperty_}',
|
||||
'dom::bindings::proxyhandler::{FillPropertyDescriptor, GetExpandoObject}',
|
||||
'dom::bindings::proxyhandler::{delete_, getPropertyDescriptor}',
|
||||
'dom::bindings::str::ByteString',
|
||||
|
|
|
@ -208,9 +208,6 @@ class Descriptor(DescriptorProvider):
|
|||
addIndexedOrNamedOperation('Creator', m)
|
||||
if m.isDeleter():
|
||||
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 = 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
|
||||
}
|
||||
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
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,
|
||||
bp: *mut bool) -> bool {
|
||||
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 domrect;
|
||||
pub mod domrectlist;
|
||||
pub mod domstringmap;
|
||||
pub mod comment;
|
||||
pub mod console;
|
||||
mod create;
|
||||
|
|
|
@ -67,6 +67,7 @@ var interfaceNamesInGlobalScope = [
|
|||
"DOMImplementation",
|
||||
"DOMParser",
|
||||
"DOMTokenList",
|
||||
"DOMStringMap",
|
||||
"Element",
|
||||
"Event",
|
||||
"EventTarget",
|
||||
|
|
|
@ -1692,18 +1692,9 @@
|
|||
[PropertyNodeList interface: operation getValues()]
|
||||
expected: FAIL
|
||||
|
||||
[DOMStringMap interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[DOMStringMap interface object length]
|
||||
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]
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue