mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
window: avoid NonNull<JSObject> in NamedGetter (#35508)
Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
This commit is contained in:
parent
f5ed44c3aa
commit
56199fd153
3 changed files with 8 additions and 22 deletions
|
@ -9,7 +9,6 @@ use std::collections::hash_map::Entry;
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use std::default::Default;
|
||||
use std::io::{stderr, stdout, Write};
|
||||
use std::ptr::NonNull;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
@ -88,7 +87,7 @@ use super::bindings::codegen::Bindings::MessagePortBinding::StructuredSerializeO
|
|||
use super::bindings::trace::HashMapTracedValues;
|
||||
use crate::dom::bindings::cell::{DomRefCell, Ref};
|
||||
use crate::dom::bindings::codegen::Bindings::DocumentBinding::{
|
||||
DocumentMethods, DocumentReadyState,
|
||||
DocumentMethods, DocumentReadyState, NamedPropertyValue,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::HistoryBinding::History_Binding::HistoryMethods;
|
||||
|
@ -1475,9 +1474,8 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
self.as_global_scope().is_secure_context()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#named-access-on-the-window-object
|
||||
#[allow(unsafe_code)]
|
||||
fn NamedGetter(&self, _cx: JSContext, name: DOMString) -> Option<NonNull<JSObject>> {
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-window-nameditem>
|
||||
fn NamedGetter(&self, name: DOMString) -> Option<NamedPropertyValue> {
|
||||
if name.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
@ -1517,11 +1515,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
.downcast::<HTMLIFrameElement>()
|
||||
.and_then(|iframe| iframe.GetContentWindow())
|
||||
{
|
||||
unsafe {
|
||||
return Some(NonNull::new_unchecked(
|
||||
nested_window_proxy.reflector().get_jsobject().get(),
|
||||
));
|
||||
}
|
||||
return Some(NamedPropertyValue::WindowProxy(nested_window_proxy));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1531,11 +1525,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
|
||||
if elements.next().is_none() {
|
||||
// Step 3.
|
||||
unsafe {
|
||||
return Some(NonNull::new_unchecked(
|
||||
first.reflector().get_jsobject().get(),
|
||||
));
|
||||
}
|
||||
return Some(NamedPropertyValue::Element(DomRoot::from_ref(first)));
|
||||
}
|
||||
|
||||
// Step 4.
|
||||
|
@ -1569,11 +1559,7 @@ impl WindowMethods<crate::DomTypeHolder> for Window {
|
|||
document.upcast(),
|
||||
Box::new(WindowNamedGetter { name }),
|
||||
);
|
||||
unsafe {
|
||||
Some(NonNull::new_unchecked(
|
||||
collection.reflector().get_jsobject().get(),
|
||||
))
|
||||
}
|
||||
Some(NamedPropertyValue::HTMLCollection(collection))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
|
||||
|
|
|
@ -132,7 +132,7 @@ unsafe extern "C" fn get_own_property_descriptor(
|
|||
|
||||
let window = Root::downcast::<Window>(GlobalScope::from_object(proxy.get()))
|
||||
.expect("global is not a window");
|
||||
if let Some(obj) = window.NamedGetter(cx, s.into()) {
|
||||
if let Some(obj) = window.NamedGetter(s.into()) {
|
||||
rooted!(in(*cx) let mut rval = UndefinedValue());
|
||||
obj.to_jsval(*cx, rval.handle_mut());
|
||||
set_property_descriptor(
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
optional DOMString features = "");
|
||||
//getter WindowProxy (unsigned long index);
|
||||
|
||||
getter object (DOMString name);
|
||||
getter NamedPropertyValue (DOMString name);
|
||||
|
||||
// the user agent
|
||||
readonly attribute Navigator navigator;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue