diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-10-17 02:03:55 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-10-17 02:07:52 +0200 |
commit | 1f31d5b856ba33a32336f0c24e658f0bac21eede (patch) | |
tree | c8c186c6a9b3fcfc8e66c0d5f46515b795f4ca8a | |
parent | 6c7f37061b5c356c4d045bfd23b33e84220e39f9 (diff) | |
download | servo-1f31d5b856ba33a32336f0c24e658f0bac21eede.tar.gz servo-1f31d5b856ba33a32336f0c24e658f0bac21eede.zip |
Return a reference in BrowserContext::active_document()
-rw-r--r-- | components/script/dom/browsercontext.rs | 7 | ||||
-rw-r--r-- | components/script/dom/document.rs | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 2 |
3 files changed, 5 insertions, 6 deletions
diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs index af2bfbdc81e..87d90f8e64f 100644 --- a/components/script/dom/browsercontext.rs +++ b/components/script/dom/browsercontext.rs @@ -44,13 +44,12 @@ impl BrowsingContext { } } - pub fn active_document(&self) -> Root<Document> { - self.history[self.active_index].document.root() + pub fn active_document(&self) -> &Document { + &*self.history[self.active_index].document } pub fn active_window(&self) -> Root<Window> { - let doc = self.active_document(); - doc.r().window() + self.active_document().window() } pub fn frame_element(&self) -> Option<Root<Element>> { diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 175cc68ea9d..e0a8154de92 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -254,7 +254,7 @@ impl Document { let browsing_context = browsing_context.as_ref().unwrap(); let active_document = browsing_context.active_document(); - if self != active_document.r() { + if self != active_document { return false; } // FIXME: It should also check whether the browser context is top-level or not diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 4ada66c36cc..b5c794dcac2 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -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 |