mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Remove needless mutabilities from script crate.
This commit is contained in:
parent
7fcade294c
commit
975fee82da
9 changed files with 19 additions and 19 deletions
|
@ -186,7 +186,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_anchor_href(&self, href: DOMString) {
|
fn load_anchor_href(&self, href: DOMString) {
|
||||||
let mut window = self.window.root();
|
let window = self.window.root();
|
||||||
window.load_url(href);
|
window.load_url(href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ impl Document {
|
||||||
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<Window>, Box<Document>) -> JS<Document>)
|
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<Window>, Box<Document>) -> JS<Document>)
|
||||||
-> Temporary<Document> {
|
-> Temporary<Document> {
|
||||||
assert!(document.reflector().get_jsobject().is_null());
|
assert!(document.reflector().get_jsobject().is_null());
|
||||||
let mut raw_doc = reflect_dom_object(document, window, wrap_fn).root();
|
let raw_doc = reflect_dom_object(document, window, wrap_fn).root();
|
||||||
assert!(raw_doc.reflector().get_jsobject().is_not_null());
|
assert!(raw_doc.reflector().get_jsobject().is_not_null());
|
||||||
|
|
||||||
let doc_alias = raw_doc.clone();
|
let doc_alias = raw_doc.clone();
|
||||||
|
@ -693,7 +693,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
let element: &JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||||
element.get_attribute(Null, "name").root().map_or(false, |mut attr| {
|
element.get_attribute(Null, "name").root().map_or(false, |attr| {
|
||||||
attr.value().as_slice() == name.as_slice()
|
attr.value().as_slice() == name.as_slice()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -804,7 +804,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Location(&self) -> Temporary<Location> {
|
fn Location(&self) -> Temporary<Location> {
|
||||||
let mut window = self.window.root();
|
let window = self.window.root();
|
||||||
window.Location()
|
window.Location()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
||||||
let win = self.owner.root();
|
let win = self.owner.root();
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let mut doc = Document::new(&win.root_ref(), None, NonHTMLDocument, None).root();
|
let doc = Document::new(&win.root_ref(), None, NonHTMLDocument, None).root();
|
||||||
// Step 2-3.
|
// Step 2-3.
|
||||||
let maybe_elem = if qname.is_empty() {
|
let maybe_elem = if qname.is_empty() {
|
||||||
None
|
None
|
||||||
|
|
|
@ -794,7 +794,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
"id" => {
|
"id" => {
|
||||||
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
if node.is_in_doc() {
|
if node.is_in_doc() {
|
||||||
let mut doc = document_from_node(self).root();
|
let doc = document_from_node(self).root();
|
||||||
doc.register_named_element(self, value.clone());
|
doc.register_named_element(self, value.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -817,7 +817,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
||||||
"id" => {
|
"id" => {
|
||||||
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
if node.is_in_doc() {
|
if node.is_in_doc() {
|
||||||
let mut doc = document_from_node(self).root();
|
let doc = document_from_node(self).root();
|
||||||
doc.unregister_named_element(self, value);
|
doc.unregister_named_element(self, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> {
|
||||||
let value = href.Value();
|
let value = href.Value();
|
||||||
debug!("clicked on link to {:s}", value);
|
debug!("clicked on link to {:s}", value);
|
||||||
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
let node: &JSRef<Node> = NodeCast::from_ref(self);
|
||||||
let mut doc = node.owner_doc().root();
|
let doc = node.owner_doc().root();
|
||||||
doc.load_anchor_href(value);
|
doc.load_anchor_href(value);
|
||||||
}
|
}
|
||||||
None => ()
|
None => ()
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLBodyElement> {
|
||||||
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
"onbeforeunload", "onhashchange", "onlanguagechange", "onmessage",
|
||||||
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
|
"onoffline", "ononline", "onpagehide", "onpageshow", "onpopstate",
|
||||||
"onstorage", "onresize", "onunload", "onerror"];
|
"onstorage", "onresize", "onunload", "onerror"];
|
||||||
let mut window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let (cx, url, reflector) = (window.get_cx(),
|
let (cx, url, reflector) = (window.get_cx(),
|
||||||
window.get_url(),
|
window.get_url(),
|
||||||
window.reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLElement> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if name.as_slice().starts_with("on") {
|
if name.as_slice().starts_with("on") {
|
||||||
let mut window = window_from_node(self).root();
|
let window = window_from_node(self).root();
|
||||||
let (cx, url, reflector) = (window.get_cx(),
|
let (cx, url, reflector) = (window.get_cx(),
|
||||||
window.get_url(),
|
window.get_url(),
|
||||||
window.reflector().get_jsobject());
|
window.reflector().get_jsobject());
|
||||||
|
|
|
@ -1137,7 +1137,7 @@ impl Node {
|
||||||
for node in nodes.mut_iter() {
|
for node in nodes.mut_iter() {
|
||||||
parent.add_child(node, child);
|
parent.add_child(node, child);
|
||||||
let is_in_doc = parent.is_in_doc();
|
let is_in_doc = parent.is_in_doc();
|
||||||
for mut kid in node.traverse_preorder() {
|
for kid in node.traverse_preorder() {
|
||||||
if is_in_doc {
|
if is_in_doc {
|
||||||
kid.flags.deref().borrow_mut().insert(IsInDoc);
|
kid.flags.deref().borrow_mut().insert(IsInDoc);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1248,7 +1248,7 @@ impl Node {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
// XXXabinader: clone() for each node as trait?
|
// XXXabinader: clone() for each node as trait?
|
||||||
let mut copy: Root<Node> = match node.type_id() {
|
let copy: Root<Node> = match node.type_id() {
|
||||||
DoctypeNodeTypeId => {
|
DoctypeNodeTypeId => {
|
||||||
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
||||||
let doctype = doctype.deref();
|
let doctype = doctype.deref();
|
||||||
|
|
|
@ -379,7 +379,7 @@ pub fn parse_html(page: &Page,
|
||||||
SvgNs => namespace::SVG,
|
SvgNs => namespace::SVG,
|
||||||
ns => fail!("Not expecting namespace {:?}", ns),
|
ns => fail!("Not expecting namespace {:?}", ns),
|
||||||
};
|
};
|
||||||
let mut element: Root<Element> = build_element_from_tag(tag.name.clone(), namespace, *tmp).root();
|
let element: Root<Element> = build_element_from_tag(tag.name.clone(), namespace, *tmp).root();
|
||||||
|
|
||||||
debug!("-- attach attrs");
|
debug!("-- attach attrs");
|
||||||
for attr in tag.attributes.iter() {
|
for attr in tag.attributes.iter() {
|
||||||
|
|
|
@ -540,11 +540,11 @@ impl ScriptTask {
|
||||||
let cx = self.js_context.borrow();
|
let cx = self.js_context.borrow();
|
||||||
let cx = cx.get_ref();
|
let cx = cx.get_ref();
|
||||||
// Create the window and document objects.
|
// Create the window and document objects.
|
||||||
let mut window = Window::new(cx.deref().ptr,
|
let window = Window::new(cx.deref().ptr,
|
||||||
page.clone(),
|
page.clone(),
|
||||||
self.chan.clone(),
|
self.chan.clone(),
|
||||||
self.compositor.dup(),
|
self.compositor.dup(),
|
||||||
self.image_cache_task.clone()).root();
|
self.image_cache_task.clone()).root();
|
||||||
let document = Document::new(&*window, Some(url.clone()), HTMLDocument, None).root();
|
let document = Document::new(&*window, Some(url.clone()), HTMLDocument, None).root();
|
||||||
window.deref().init_browser_context(&*document);
|
window.deref().init_browser_context(&*document);
|
||||||
|
|
||||||
|
@ -679,7 +679,7 @@ impl ScriptTask {
|
||||||
};
|
};
|
||||||
|
|
||||||
match window.root() {
|
match window.root() {
|
||||||
Some(mut window) => {
|
Some(window) => {
|
||||||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
||||||
let uievent = UIEvent::new(&window.clone(),
|
let uievent = UIEvent::new(&window.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue