mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #8060 - nox:deref-js, r=Ms2ger
Implement Deref<Target=T> for JS<T> where T: Reflectable We can only borrow `JS<T>` from rooted things, so it's safe to deref it. The only types that provide mutable `JS<T>` things are `MutHeap<JS<T>>` and `MutNullableHeap<JS<T>>`, which don't actually expose that they contain `JS<T>` values. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8060) <!-- Reviewable:end -->
This commit is contained in:
commit
1a376aa75d
23 changed files with 187 additions and 274 deletions
|
@ -1308,7 +1308,7 @@ impl Node {
|
|||
wrap_fn: extern "Rust" fn(*mut JSContext, GlobalRef, Box<N>) -> Root<N>)
|
||||
-> Root<N> {
|
||||
let window = document.window();
|
||||
reflect_dom_object(node, GlobalRef::Window(window.r()), wrap_fn)
|
||||
reflect_dom_object(node, GlobalRef::Window(window), wrap_fn)
|
||||
}
|
||||
|
||||
pub fn new_inherited(doc: &Document) -> Node {
|
||||
|
@ -1651,7 +1651,7 @@ impl Node {
|
|||
};
|
||||
let window = document.window();
|
||||
let loader = DocumentLoader::new(&*document.loader());
|
||||
let document = Document::new(window.r(), Some((*document.url()).clone()),
|
||||
let document = Document::new(window, Some((*document.url()).clone()),
|
||||
is_html_doc, None,
|
||||
None, DocumentSource::NotFromParser, loader);
|
||||
NodeCast::from_root(document)
|
||||
|
@ -1892,7 +1892,7 @@ impl NodeMethods for Node {
|
|||
self.child_list.or_init(|| {
|
||||
let doc = self.owner_doc();
|
||||
let window = doc.r().window();
|
||||
NodeList::new_child_list(window.r(), self)
|
||||
NodeList::new_child_list(window, self)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2391,7 +2391,7 @@ pub fn document_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Docume
|
|||
|
||||
pub fn window_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Window> {
|
||||
let document = document_from_node(derived);
|
||||
document.r().window()
|
||||
Root::from_ref(document.r().window())
|
||||
}
|
||||
|
||||
impl VirtualMethods for Node {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue