diff options
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/browsercontext.rs | 2 | ||||
-rw-r--r-- | components/script/dom/document.rs | 32 | ||||
-rw-r--r-- | components/script/dom/domimplementation.rs | 6 | ||||
-rw-r--r-- | components/script/dom/element.rs | 2 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 1 | ||||
-rw-r--r-- | components/script/dom/htmlinputelement.rs | 2 | ||||
-rw-r--r-- | components/script/dom/htmltextareaelement.rs | 2 | ||||
-rw-r--r-- | components/script/dom/node.rs | 8 | ||||
-rw-r--r-- | components/script/dom/nodeiterator.rs | 3 | ||||
-rw-r--r-- | components/script/dom/range.rs | 3 | ||||
-rw-r--r-- | components/script/dom/servohtmlparser.rs | 6 | ||||
-rw-r--r-- | components/script/dom/treewalker.rs | 3 |
12 files changed, 31 insertions, 39 deletions
diff --git a/components/script/dom/browsercontext.rs b/components/script/dom/browsercontext.rs index 55e070ef10f..2b00f346c1e 100644 --- a/components/script/dom/browsercontext.rs +++ b/components/script/dom/browsercontext.rs @@ -49,7 +49,7 @@ impl BrowsingContext { } pub fn active_window(&self) -> Root<Window> { - self.active_document().window() + Root::from_ref(self.active_document().window()) } pub fn frame_element(&self) -> Option<&Element> { diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 5aa4f257d37..20d04269ada 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -232,8 +232,8 @@ impl Document { } #[inline] - pub fn window(&self) -> Root<Window> { - self.window.root() + pub fn window(&self) -> &Window { + &*self.window } #[inline] @@ -539,8 +539,6 @@ impl Document { /// Sends this document's title to the compositor. pub fn send_title_to_compositor(&self) { let window = self.window(); - // FIXME(https://github.com/rust-lang/rust/issues/23338) - let window = window.r(); let compositor = window.compositor(); compositor.send(ScriptToCompositorMsg::SetTitle(window.pipeline(), Some(self.Title()))).unwrap(); } @@ -1094,7 +1092,7 @@ impl Document { IsHTMLDocument::NonHTMLDocument }; let new_doc = Document::new( - &*self.window(), None, doctype, None, None, + self.window(), None, doctype, None, None, DocumentSource::NotFromParser, DocumentLoader::new(&self.loader())); new_doc.appropriate_template_contents_owner_document.set(Some(&new_doc)); new_doc @@ -1789,9 +1787,8 @@ impl DocumentMethods for Document { } // Step 4. *found = true; - let window = self.window(); let filter = NamedElementFilter { name: name }; - let collection = HTMLCollection::create(window.r(), root, box filter); + let collection = HTMLCollection::create(self.window(), root, box filter); collection.r().reflector().get_jsobject().get() } @@ -1849,13 +1846,15 @@ impl DocumentProgressHandler { fn dispatch_dom_content_loaded(&self) { let document = self.addr.root(); let window = document.r().window(); - let event = Event::new(GlobalRef::Window(window.r()), "DOMContentLoaded".to_owned(), + let event = Event::new(GlobalRef::Window(window), "DOMContentLoaded".to_owned(), EventBubbles::DoesNotBubble, EventCancelable::NotCancelable); let doctarget = EventTargetCast::from_ref(document.r()); let _ = doctarget.DispatchEvent(event.r()); - window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::DOMContentLoaded); + window.reflow(ReflowGoal::ForDisplay, + ReflowQueryType::NoQuery, + ReflowReason::DOMContentLoaded); } fn set_ready_state_complete(&self) { @@ -1866,16 +1865,15 @@ impl DocumentProgressHandler { fn dispatch_load(&self) { let document = self.addr.root(); let window = document.r().window(); - let event = Event::new(GlobalRef::Window(window.r()), "load".to_owned(), + let event = Event::new(GlobalRef::Window(window), "load".to_owned(), EventBubbles::DoesNotBubble, EventCancelable::NotCancelable); - let wintarget = EventTargetCast::from_ref(window.r()); + let wintarget = EventTargetCast::from_ref(window); let doctarget = EventTargetCast::from_ref(document.r()); event.r().set_trusted(true); let _ = wintarget.dispatch_event_with_target(doctarget, event.r()); - let window_ref = window.r(); - let browsing_context = window_ref.browsing_context(); + let browsing_context = window.browsing_context(); let browsing_context = browsing_context.as_ref().unwrap(); if let Some(frame_element) = browsing_context.frame_element() { @@ -1892,9 +1890,9 @@ impl DocumentProgressHandler { // https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd); - window_ref.reflow(ReflowGoal::ForDisplay, - ReflowQueryType::NoQuery, - ReflowReason::DocumentLoaded); + window.reflow(ReflowGoal::ForDisplay, + ReflowQueryType::NoQuery, + ReflowReason::DocumentLoaded); } } @@ -1902,7 +1900,7 @@ impl Runnable for DocumentProgressHandler { fn handler(self: Box<DocumentProgressHandler>) { let document = self.addr.root(); let window = document.r().window(); - if window.r().is_alive() { + if window.is_alive() { match self.task { DocumentProgressTask::DOMContentLoaded => { self.dispatch_dom_content_loaded(); diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index d66cba67bc0..e506c7369c8 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) } } @@ -66,7 +66,7 @@ impl DOMImplementationMethods for DOMImplementation { let loader = DocumentLoader::new(&*doc.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() { @@ -114,7 +114,7 @@ impl DOMImplementationMethods for DOMImplementation { let loader = DocumentLoader::new(&*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); { diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 651142df713..bc55e2ebbc2 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1143,7 +1143,7 @@ impl ElementMethods for Element { node.owner_doc() }; let window = doc.r().window(); - NamedNodeMap::new(window.r(), self) + NamedNodeMap::new(window, self) }) } diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index c07022306d6..9e58d68a4e2 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -100,7 +100,6 @@ impl HTMLImageElement { let node = NodeCast::from_ref(self); let document = node.owner_doc(); let window = document.r().window(); - let window = window.r(); let image_cache = window.image_cache_task(); match value { None => { diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index cdfe8716775..51984c73be7 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -106,7 +106,7 @@ static DEFAULT_INPUT_SIZE: u32 = 20; impl HTMLInputElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLInputElement { - let chan = document.window().r().constellation_chan(); + let chan = document.window().constellation_chan(); HTMLInputElement { htmlelement: HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE, diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 19cd81e6519..199ddb2326e 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -84,7 +84,7 @@ impl HTMLTextAreaElement { fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: &Document) -> HTMLTextAreaElement { - let chan = document.window().r().constellation_chan(); + let chan = document.window().constellation_chan(); HTMLTextAreaElement { htmlelement: HTMLElement::new_inherited_with_flags(NodeFlags::new() | IN_ENABLED_STATE, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index daacdd09fa0..7674a29340b 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1341,7 +1341,7 @@ impl Node { wrap_fn: extern "Rust" fn(*mut JSContext, GlobalRef, Box<N>) -> Root<N>) -> Root<N> { let window = document.window(); - reflect_dom_object(node, GlobalRef::Window(window.r()), wrap_fn) + reflect_dom_object(node, GlobalRef::Window(window), wrap_fn) } pub fn new_inherited(doc: &Document) -> Node { @@ -1688,7 +1688,7 @@ impl Node { }; let window = document.window(); let loader = DocumentLoader::new(&*document.loader()); - let document = Document::new(window.r(), Some((*document.url()).clone()), + let document = Document::new(window, Some((*document.url()).clone()), is_html_doc, None, None, DocumentSource::NotFromParser, loader); NodeCast::from_root(document) @@ -1929,7 +1929,7 @@ impl NodeMethods for Node { self.child_list.or_init(|| { let doc = self.owner_doc(); let window = doc.r().window(); - NodeList::new_child_list(window.r(), self) + NodeList::new_child_list(window, self) }) } @@ -2428,7 +2428,7 @@ pub fn document_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Docume pub fn window_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Window> { let document = document_from_node(derived); - document.r().window() + Root::from_ref(document.r().window()) } impl VirtualMethods for Node { diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index c7152231776..0194215da2d 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -47,9 +47,8 @@ impl NodeIterator { root_node: &Node, what_to_show: u32, filter: Filter) -> Root<NodeIterator> { - let window = document.window(); reflect_dom_object(box NodeIterator::new_inherited(root_node, what_to_show, filter), - GlobalRef::Window(window.r()), + GlobalRef::Window(document.window()), NodeIteratorBinding::Wrap) } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 0b9a5cc0dbf..52ab9d24d66 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -49,10 +49,9 @@ impl Range { start_container: &Node, start_offset: u32, end_container: &Node, end_offset: u32) -> Root<Range> { - let window = document.window(); reflect_dom_object(box Range::new_inherited(start_container, start_offset, end_container, end_offset), - GlobalRef::Window(window.r()), + GlobalRef::Window(document.window()), RangeBinding::Wrap) } diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs index 9b319e66a9a..6d00e702180 100644 --- a/components/script/dom/servohtmlparser.rs +++ b/components/script/dom/servohtmlparser.rs @@ -214,7 +214,6 @@ impl ServoHTMLParser { #[allow(unrooted_must_root)] pub fn new(base_url: Option<Url>, document: &Document, pipeline: Option<PipelineId>) -> Root<ServoHTMLParser> { - let window = document.window(); let sink = Sink { base_url: base_url, document: JS::from_ref(document), @@ -237,14 +236,13 @@ impl ServoHTMLParser { pipeline: pipeline, }; - reflect_dom_object(box parser, GlobalRef::Window(window.r()), + reflect_dom_object(box parser, GlobalRef::Window(document.window()), ServoHTMLParserBinding::Wrap) } #[allow(unrooted_must_root)] pub fn new_for_fragment(base_url: Option<Url>, document: &Document, fragment_context: FragmentContext) -> Root<ServoHTMLParser> { - let window = document.window(); let sink = Sink { base_url: base_url, document: JS::from_ref(document), @@ -275,7 +273,7 @@ impl ServoHTMLParser { pipeline: None, }; - reflect_dom_object(box parser, GlobalRef::Window(window.r()), + reflect_dom_object(box parser, GlobalRef::Window(document.window()), ServoHTMLParserBinding::Wrap) } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index 7f4646a1618..f19e8383ddf 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -45,9 +45,8 @@ impl TreeWalker { root_node: &Node, what_to_show: u32, filter: Filter) -> Root<TreeWalker> { - let window = document.window(); reflect_dom_object(box TreeWalker::new_inherited(root_node, what_to_show, filter), - GlobalRef::Window(window.r()), + GlobalRef::Window(document.window()), TreeWalkerBinding::Wrap) } |