mirror of
https://github.com/servo/servo.git
synced 2025-06-09 00:53:26 +00:00
Pass a non-nullable string to NamedGetter.
There is no actual reason to use a nullable string here; all callers have a string they want to pass. The issue dates back to the time that DOMString was inherently nullable (before #1215); this API was not converted back to the non-nullable DOMString type after that landed.
This commit is contained in:
parent
4b516c184d
commit
e34bcaaa5f
2 changed files with 10 additions and 18 deletions
|
@ -3612,7 +3612,7 @@ class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
|
||||||
# properties that shadow prototype properties.
|
# properties that shadow prototype properties.
|
||||||
namedGet = ("\n" +
|
namedGet = ("\n" +
|
||||||
"if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
"if set == 0 && RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
||||||
" let name = Some(jsid_to_str(cx, id));\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
|
@ -3675,7 +3675,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
if not self.descriptor.operations['NamedCreator'] is namedSetter:
|
if not self.descriptor.operations['NamedCreator'] is namedSetter:
|
||||||
raise TypeError("Can't handle creator that's different from the setter")
|
raise TypeError("Can't handle creator that's different from the setter")
|
||||||
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) != 0 {\n" +
|
||||||
" let name = Some(jsid_to_str(cx, id));\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
|
@ -3683,7 +3683,7 @@ class CGDOMJSProxyHandler_defineProperty(CGAbstractExternMethod):
|
||||||
"}\n")
|
"}\n")
|
||||||
elif self.descriptor.operations['NamedGetter']:
|
elif self.descriptor.operations['NamedGetter']:
|
||||||
set += ("if RUST_JSID_IS_STRING(id) {\n" +
|
set += ("if RUST_JSID_IS_STRING(id) {\n" +
|
||||||
" let name = Some(jsid_to_str(cx, id));\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
|
@ -3724,7 +3724,7 @@ class CGDOMJSProxyHandler_hasOwn(CGAbstractExternMethod):
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter:
|
if namedGetter:
|
||||||
named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
named = ("if RUST_JSID_IS_STRING(id) != 0 && !HasPropertyOnPrototype(cx, proxy, id) {\n" +
|
||||||
" let name = Some(jsid_to_str(cx, id));\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
|
@ -3796,7 +3796,7 @@ if expando.is_not_null() {
|
||||||
namedGetter = self.descriptor.operations['NamedGetter']
|
namedGetter = self.descriptor.operations['NamedGetter']
|
||||||
if namedGetter and False: #XXXjdm unfinished
|
if namedGetter and False: #XXXjdm unfinished
|
||||||
getNamed = ("if (JSID_IS_STRING(id)) {\n" +
|
getNamed = ("if (JSID_IS_STRING(id)) {\n" +
|
||||||
" let name = Some(jsid_to_str(cx, id));\n" +
|
" let name = jsid_to_str(cx, id);\n" +
|
||||||
" let this = UnwrapProxy(proxy);\n" +
|
" let this = UnwrapProxy(proxy);\n" +
|
||||||
" let this = JS::from_raw(this);\n" +
|
" let this = JS::from_raw(this);\n" +
|
||||||
" let this = this.root();\n" +
|
" let this = this.root();\n" +
|
||||||
|
|
|
@ -124,7 +124,7 @@ pub trait HTMLCollectionMethods {
|
||||||
fn Item(&self, index: u32) -> Option<Temporary<Element>>;
|
fn Item(&self, index: u32) -> Option<Temporary<Element>>;
|
||||||
fn NamedItem(&self, key: DOMString) -> Option<Temporary<Element>>;
|
fn NamedItem(&self, key: DOMString) -> Option<Temporary<Element>>;
|
||||||
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Element>>;
|
fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option<Temporary<Element>>;
|
||||||
fn NamedGetter(&self, maybe_name: Option<DOMString>, found: &mut bool) -> Option<Temporary<Element>>;
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<Temporary<Element>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
||||||
|
@ -202,18 +202,10 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
||||||
maybe_elem
|
maybe_elem
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NamedGetter(&self, maybe_name: Option<DOMString>, found: &mut bool) -> Option<Temporary<Element>> {
|
fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option<Temporary<Element>> {
|
||||||
match maybe_name {
|
|
||||||
Some(name) => {
|
|
||||||
let maybe_elem = self.NamedItem(name);
|
let maybe_elem = self.NamedItem(name);
|
||||||
*found = maybe_elem.is_some();
|
*found = maybe_elem.is_some();
|
||||||
maybe_elem
|
maybe_elem
|
||||||
},
|
|
||||||
None => {
|
|
||||||
*found = false;
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue