mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Make get() and set() on MutNullableHeap use the correct types.
get() must always return a rooted value, because we have no way of ensuring the value won't be invalidated. set() takes an &T because it's convenient; there isn't any need to expose JS<T>.
This commit is contained in:
parent
7a08b29201
commit
57584e74c6
11 changed files with 68 additions and 67 deletions
|
@ -297,7 +297,7 @@ impl Document {
|
|||
.filter_map(HTMLBaseElementCast::to_root)
|
||||
.filter(|element| ElementCast::from_ref(&**element).has_attribute(&atom!("href")))
|
||||
.next();
|
||||
self.base_element.set(base.map(|element| JS::from_ref(&*element)));
|
||||
self.base_element.set(base.as_ref().map(Root::r));
|
||||
}
|
||||
|
||||
pub fn quirks_mode(&self) -> QuirksMode {
|
||||
|
@ -506,7 +506,7 @@ impl Document {
|
|||
/// Request that the given element receive focus once the current transaction is complete.
|
||||
pub fn request_focus(&self, elem: &Element) {
|
||||
if elem.is_focusable_area() {
|
||||
self.possibly_focused.set(Some(JS::from_ref(elem)))
|
||||
self.possibly_focused.set(Some(elem))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -520,7 +520,7 @@ impl Document {
|
|||
node.set_focus_state(false);
|
||||
}
|
||||
|
||||
self.focused.set(self.possibly_focused.get());
|
||||
self.focused.set(self.possibly_focused.get().r());
|
||||
|
||||
if let Some(ref elem) = self.focused.get_rooted() {
|
||||
let node = NodeCast::from_ref(elem.r());
|
||||
|
@ -852,7 +852,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn set_current_script(&self, script: Option<&HTMLScriptElement>) {
|
||||
self.current_script.set(script.map(JS::from_ref));
|
||||
self.current_script.set(script);
|
||||
}
|
||||
|
||||
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
|
||||
|
@ -959,7 +959,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn set_current_parser(&self, script: Option<&ServoHTMLParser>) {
|
||||
self.current_parser.set(script.map(JS::from_ref));
|
||||
self.current_parser.set(script);
|
||||
}
|
||||
|
||||
pub fn get_current_parser(&self) -> Option<Root<ServoHTMLParser>> {
|
||||
|
@ -1119,8 +1119,7 @@ impl Document {
|
|||
let new_doc = Document::new(
|
||||
&*self.window(), None, doctype, None, None,
|
||||
DocumentSource::NotFromParser, DocumentLoader::new(&self.loader()));
|
||||
new_doc.appropriate_template_contents_owner_document.set(
|
||||
Some(JS::from_ref(&*new_doc)));
|
||||
new_doc.appropriate_template_contents_owner_document.set(Some(&new_doc));
|
||||
new_doc
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue