aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/domimplementation.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-10-19 06:32:05 -0600
committerbors-servo <metajack+bors@gmail.com>2015-10-19 06:32:05 -0600
commit1a376aa75d5de8781b17a673850860f8afd2c28f (patch)
tree01650fefa8cb00280835382dfb60c15b57b0dce0 /components/script/dom/domimplementation.rs
parent50ad1b064d6e85e84707d83ca8f4b5b541b6b8da (diff)
parent6dc42dd1d6979cea7059b055de7f0d6f93c14338 (diff)
downloadservo-1a376aa75d5de8781b17a673850860f8afd2c28f.tar.gz
servo-1a376aa75d5de8781b17a673850860f8afd2c28f.zip
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 -->
Diffstat (limited to 'components/script/dom/domimplementation.rs')
-rw-r--r--components/script/dom/domimplementation.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs
index d66cba67bc0..93eb8cf8e0a 100644
--- a/components/script/dom/domimplementation.rs
+++ b/components/script/dom/domimplementation.rs
@@ -42,7 +42,7 @@ impl DOMImplementation {
pub fn new(document: &Document) -> Root<DOMImplementation> {
let window = document.window();
reflect_dom_object(box DOMImplementation::new_inherited(document),
- GlobalRef::Window(window.r()),
+ GlobalRef::Window(window),
DOMImplementationBinding::Wrap)
}
}
@@ -53,20 +53,17 @@ impl DOMImplementationMethods for DOMImplementation {
fn CreateDocumentType(&self, qualified_name: DOMString, pubid: DOMString, sysid: DOMString)
-> Fallible<Root<DocumentType>> {
try!(validate_qualified_name(&qualified_name));
- let document = self.document.root();
- Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), document.r()))
+ Ok(DocumentType::new(qualified_name, Some(pubid), Some(sysid), &self.document))
}
// https://dom.spec.whatwg.org/#dom-domimplementation-createdocument
fn CreateDocument(&self, namespace: Option<DOMString>, qname: DOMString,
maybe_doctype: Option<&DocumentType>) -> Fallible<Root<Document>> {
- let doc = self.document.root();
- let doc = doc.r();
- let win = doc.window();
- let loader = DocumentLoader::new(&*doc.loader());
+ let win = self.document.window();
+ let loader = DocumentLoader::new(&self.document.loader());
// Step 1.
- let doc = Document::new(win.r(), None, IsHTMLDocument::NonHTMLDocument,
+ let doc = Document::new(win, None, IsHTMLDocument::NonHTMLDocument,
None, None, DocumentSource::NotFromParser, loader);
// Step 2-3.
let maybe_elem = if qname.is_empty() {
@@ -108,13 +105,11 @@ impl DOMImplementationMethods for DOMImplementation {
// https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
fn CreateHTMLDocument(&self, title: Option<DOMString>) -> Root<Document> {
- let document = self.document.root();
- let document = document.r();
- let win = document.window();
- let loader = DocumentLoader::new(&*document.loader());
+ let win = self.document.window();
+ let loader = DocumentLoader::new(&self.document.loader());
// Step 1-2.
- let doc = Document::new(win.r(), None, IsHTMLDocument::HTMLDocument, None, None,
+ let doc = Document::new(win, None, IsHTMLDocument::HTMLDocument, None, None,
DocumentSource::NotFromParser, loader);
{