aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2015-10-14 17:48:28 -0700
committerEli Friedman <eli.friedman@gmail.com>2015-10-15 14:03:56 -0700
commit57584e74c6fc192335ed3300ac75751bada0ff93 (patch)
treea75b0f9045238a8720e31d848433635222a06b58 /components/script/dom/document.rs
parent7a08b29201d7a6ec8fd2097fc60ca47e556898d5 (diff)
downloadservo-57584e74c6fc192335ed3300ac75751bada0ff93.tar.gz
servo-57584e74c6fc192335ed3300ac75751bada0ff93.zip
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>.
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 0419895233b..b849280e685 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -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
})
}