mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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
|
@ -381,7 +381,7 @@ impl WindowMethods for Window {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-0
|
||||
fn Document(&self) -> Root<Document> {
|
||||
self.browsing_context().as_ref().unwrap().active_document()
|
||||
Root::from_ref(self.browsing_context().as_ref().unwrap().active_document())
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location
|
||||
|
@ -411,7 +411,7 @@ impl WindowMethods for Window {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-frameelement
|
||||
fn GetFrameElement(&self) -> Option<Root<Element>> {
|
||||
self.browsing_context().as_ref().unwrap().frame_element()
|
||||
self.browsing_context().as_ref().unwrap().frame_element().map(Root::from_ref)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-navigator
|
||||
|
@ -1248,11 +1248,11 @@ impl Window {
|
|||
let browsing_context = browsing_context.as_ref().unwrap();
|
||||
|
||||
browsing_context.frame_element().map(|frame_element| {
|
||||
let window = window_from_node(frame_element.r());
|
||||
let window = window_from_node(frame_element);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let r = window.r();
|
||||
let context = r.browsing_context();
|
||||
context.as_ref().unwrap().active_window()
|
||||
Root::from_ref(context.as_ref().unwrap().active_window())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue