зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #3620 - Remove unnecessary `deref()`s (fixes #3586) (from ttaubert:issue/3586-remove-derefs); r=Manishearth
r? @Manishearth Source-Repo: https://github.com/servo/servo Source-Revision: 510f8a817f8144dd5046886d4ca7c612f19a3d08
This commit is contained in:
Родитель
c3ef958820
Коммит
fc4bdae442
|
@ -75,7 +75,7 @@ impl FontHandleMethods for FontHandle {
|
|||
let ft_ctx: FT_Library = fctx.ctx.ctx;
|
||||
if ft_ctx.is_null() { return Err(()); }
|
||||
|
||||
let bytes = &template.deref().bytes;
|
||||
let bytes = &template.bytes;
|
||||
let face_result = create_face_from_buffer(ft_ctx, bytes.as_ptr(), bytes.len(), pt_size);
|
||||
|
||||
// TODO: this could be more simply written as result::chain
|
||||
|
|
|
@ -124,7 +124,7 @@ impl<'a> AttrMethods for JSRef<'a, Attr> {
|
|||
|
||||
fn SetValue(self, value: DOMString) {
|
||||
let owner = self.owner.root();
|
||||
let value = owner.deref().parse_attribute(&self.namespace, self.local_name(), value);
|
||||
let value = owner.parse_attribute(&self.namespace, self.local_name(), value);
|
||||
self.set_value(ReplacedAttr, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -5465,7 +5465,7 @@ class GlobalGenRoots():
|
|||
cast = [CGGeneric(string.Template('''pub trait ${castTraitName} {
|
||||
#[inline(always)]
|
||||
fn to_ref<'a, T: ${toBound}+Reflectable>(base: JSRef<'a, T>) -> Option<JSRef<'a, Self>> {
|
||||
match base.deref().${checkFn}() {
|
||||
match base.${checkFn}() {
|
||||
true => unsafe { Some(base.transmute()) },
|
||||
false => None
|
||||
}
|
||||
|
@ -5473,7 +5473,7 @@ class GlobalGenRoots():
|
|||
|
||||
#[inline(always)]
|
||||
fn to_borrowed_ref<'a, 'b, T: ${toBound}+Reflectable>(base: &'a JSRef<'b, T>) -> Option<&'a JSRef<'b, Self>> {
|
||||
match base.deref().${checkFn}() {
|
||||
match base.${checkFn}() {
|
||||
true => unsafe { Some(base.transmute_borrowed()) },
|
||||
false => None
|
||||
}
|
||||
|
|
|
@ -660,7 +660,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut
|
|||
IDLInterface::get_prototype_depth(None::<window::Window>))
|
||||
.unwrap()
|
||||
.root();
|
||||
win.deref().browser_context.borrow().as_ref().unwrap().window_proxy()
|
||||
win.browser_context.borrow().as_ref().unwrap().window_proxy()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ impl BrowserContext {
|
|||
|
||||
pub fn active_window(&self) -> Temporary<Window> {
|
||||
let doc = self.active_document().root();
|
||||
Temporary::new(doc.deref().window.clone())
|
||||
Temporary::new(doc.window.clone())
|
||||
}
|
||||
|
||||
pub fn window_proxy(&self) -> *mut JSObject {
|
||||
|
@ -48,14 +48,14 @@ impl BrowserContext {
|
|||
|
||||
fn create_window_proxy(&mut self) {
|
||||
let win = self.active_window().root();
|
||||
let page = win.deref().page();
|
||||
let page = win.page();
|
||||
let js_info = page.js_info();
|
||||
|
||||
let WindowProxyHandler(handler) = js_info.as_ref().unwrap().dom_static.windowproxy_handler;
|
||||
assert!(handler.is_not_null());
|
||||
|
||||
let parent = win.deref().reflector().get_jsobject();
|
||||
let cx = js_info.as_ref().unwrap().js_context.deref().ptr;
|
||||
let parent = win.reflector().get_jsobject();
|
||||
let cx = js_info.as_ref().unwrap().js_context.ptr;
|
||||
let wrapper = with_compartment(cx, parent, || unsafe {
|
||||
WrapperNew(cx, parent, handler)
|
||||
});
|
||||
|
|
|
@ -45,7 +45,7 @@ impl CustomEvent {
|
|||
}
|
||||
pub fn new(global: &GlobalRef, type_: DOMString, bubbles: bool, cancelable: bool, detail: JSVal) -> Temporary<CustomEvent> {
|
||||
let ev = CustomEvent::new_uninitialized(global).root();
|
||||
ev.deref().InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
||||
ev.InitCustomEvent(global.get_cx(), type_, bubbles, cancelable, detail);
|
||||
Temporary::from_rooted(*ev)
|
||||
}
|
||||
pub fn Constructor(global: &GlobalRef,
|
||||
|
|
|
@ -279,7 +279,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
let check_anchor = |&node: &JSRef<HTMLAnchorElement>| {
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(node);
|
||||
elem.get_attribute(ns!(""), "name").root().map_or(false, |attr| {
|
||||
attr.deref().value().as_slice() == fragid.as_slice()
|
||||
attr.value().as_slice() == fragid.as_slice()
|
||||
})
|
||||
};
|
||||
let doc_node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
|
@ -642,7 +642,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
for child in title_elem.children() {
|
||||
if child.is_text() {
|
||||
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
||||
title.push_str(text.deref().characterdata.data.borrow().as_slice());
|
||||
title.push_str(text.characterdata.data.borrow().as_slice());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -132,13 +132,11 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
{
|
||||
// Step 4.
|
||||
let doc_html: Root<Node> = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_string(), None, *doc)).root();
|
||||
let doc_html = doc_html.deref();
|
||||
assert!(doc_node.AppendChild(*doc_html).is_ok());
|
||||
|
||||
{
|
||||
// Step 5.
|
||||
let doc_head: Root<Node> = NodeCast::from_temporary(HTMLHeadElement::new("head".to_string(), None, *doc)).root();
|
||||
let doc_head = doc_head.deref();
|
||||
assert!(doc_html.AppendChild(*doc_head).is_ok());
|
||||
|
||||
// Step 6.
|
||||
|
@ -147,12 +145,10 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
Some(title_str) => {
|
||||
// Step 6.1.
|
||||
let doc_title: Root<Node> = NodeCast::from_temporary(HTMLTitleElement::new("title".to_string(), None, *doc)).root();
|
||||
let doc_title = doc_title.deref();
|
||||
assert!(doc_head.AppendChild(*doc_title).is_ok());
|
||||
|
||||
// Step 6.2.
|
||||
let title_text: Root<Text> = Text::new(title_str, *doc).root();
|
||||
let title_text = title_text.deref();
|
||||
assert!(doc_title.AppendChild(NodeCast::from_ref(*title_text)).is_ok());
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +156,6 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
|
||||
// Step 7.
|
||||
let doc_body: Root<HTMLBodyElement> = HTMLBodyElement::new("body".to_string(), None, *doc).root();
|
||||
let doc_body = doc_body.deref();
|
||||
assert!(doc_html.AppendChild(NodeCast::from_ref(*doc_body)).is_ok());
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ trait PrivateDOMTokenListHelpers {
|
|||
impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> {
|
||||
fn attribute(self) -> Option<Temporary<Attr>> {
|
||||
let element = self.element.root();
|
||||
element.deref().get_attribute(ns!(""), self.local_name)
|
||||
element.get_attribute(ns!(""), self.local_name)
|
||||
}
|
||||
|
||||
fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<&'a str> {
|
||||
|
|
|
@ -385,7 +385,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
fn do_set_attribute(self, local_name: Atom, value: AttrValue,
|
||||
name: Atom, namespace: Namespace,
|
||||
prefix: Option<DOMString>, cb: |JSRef<Attr>| -> bool) {
|
||||
let idx = self.deref().attrs.borrow().iter()
|
||||
let idx = self.attrs.borrow().iter()
|
||||
.map(|attr| attr.root())
|
||||
.position(|attr| cb(*attr));
|
||||
let (idx, set_type) = match idx {
|
||||
|
@ -394,12 +394,12 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
let window = window_from_node(self).root();
|
||||
let attr = Attr::new(*window, local_name, value.clone(),
|
||||
name, namespace.clone(), prefix, self);
|
||||
self.deref().attrs.borrow_mut().push_unrooted(&attr);
|
||||
(self.deref().attrs.borrow().len() - 1, FirstSetAttr)
|
||||
self.attrs.borrow_mut().push_unrooted(&attr);
|
||||
(self.attrs.borrow().len() - 1, FirstSetAttr)
|
||||
}
|
||||
};
|
||||
|
||||
(*self.deref().attrs.borrow())[idx].root().set_value(set_type, value);
|
||||
(*self.attrs.borrow())[idx].root().set_value(set_type, value);
|
||||
}
|
||||
|
||||
fn parse_attribute(self, namespace: &Namespace, local_name: &Atom,
|
||||
|
@ -416,7 +416,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
let (_, local_name) = get_attribute_parts(name);
|
||||
let local_name = Atom::from_slice(local_name);
|
||||
|
||||
let idx = self.deref().attrs.borrow().iter().map(|attr| attr.root()).position(|attr| {
|
||||
let idx = self.attrs.borrow().iter().map(|attr| attr.root()).position(|attr| {
|
||||
*attr.local_name() == local_name
|
||||
});
|
||||
|
||||
|
@ -429,13 +429,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
}
|
||||
|
||||
if namespace == ns!("") {
|
||||
let removed_raw_value = (*self.deref().attrs.borrow())[idx].root().Value();
|
||||
let removed_raw_value = (*self.attrs.borrow())[idx].root().Value();
|
||||
vtable_for(&NodeCast::from_ref(self))
|
||||
.before_remove_attr(&local_name,
|
||||
removed_raw_value);
|
||||
}
|
||||
|
||||
self.deref().attrs.borrow_mut().remove(idx);
|
||||
self.attrs.borrow_mut().remove(idx);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -448,13 +448,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
_ => ContentChangedDocumentDamage
|
||||
};
|
||||
let document = node.owner_doc().root();
|
||||
document.deref().damage_and_reflow(damage);
|
||||
document.damage_and_reflow(damage);
|
||||
}
|
||||
}
|
||||
|
||||
fn has_class(&self, name: &str) -> bool {
|
||||
self.get_attribute(ns!(""), "class").root().map(|attr| {
|
||||
attr.deref().value().tokens().map(|mut tokens| {
|
||||
attr.value().tokens().map(|mut tokens| {
|
||||
tokens.any(|atom| atom.as_slice() == name)
|
||||
}).unwrap_or(false)
|
||||
}).unwrap_or(false)
|
||||
|
@ -471,7 +471,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
true => Atom::from_slice(name.to_ascii_lower().as_slice()),
|
||||
false => Atom::from_slice(name)
|
||||
};
|
||||
self.deref().attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
|
||||
self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
|
||||
*attr.local_name() == name && attr.namespace == ns!("")
|
||||
})
|
||||
}
|
||||
|
@ -507,10 +507,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
fn get_string_attribute(self, name: &str) -> DOMString {
|
||||
assert!(name == name.to_ascii_lower().as_slice());
|
||||
match self.get_attribute(ns!(""), name) {
|
||||
Some(x) => {
|
||||
let x = x.root();
|
||||
x.deref().Value()
|
||||
}
|
||||
Some(x) => x.root().Value(),
|
||||
None => "".to_string()
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +526,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
|||
let attribute = self.get_attribute(ns!(""), name).root();
|
||||
match attribute {
|
||||
Some(attribute) => {
|
||||
match *attribute.deref().value() {
|
||||
match *attribute.value() {
|
||||
UIntAttrValue(_, value) => value,
|
||||
_ => fail!("Expected a UIntAttrValue"),
|
||||
}
|
||||
|
@ -610,7 +607,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
node.owner_doc().root()
|
||||
};
|
||||
let window = doc.deref().window.root();
|
||||
let window = doc.window.root();
|
||||
let list = NamedNodeMap::new(*window, self);
|
||||
self.attr_list.assign(Some(list));
|
||||
}
|
||||
|
@ -625,7 +622,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
name
|
||||
};
|
||||
self.get_attribute(ns!(""), name.as_slice()).root()
|
||||
.map(|s| s.deref().Value())
|
||||
.map(|s| s.Value())
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-element-getattributens
|
||||
|
@ -634,7 +631,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
local_name: DOMString) -> Option<DOMString> {
|
||||
let namespace = namespace::from_domstring(namespace);
|
||||
self.get_attribute(namespace, local_name.as_slice()).root()
|
||||
.map(|attr| attr.deref().Value())
|
||||
.map(|attr| attr.Value())
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-element-setattribute
|
||||
|
@ -663,7 +660,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
let name = Atom::from_slice(name.as_slice());
|
||||
let value = self.parse_attribute(&ns!(""), &name, value);
|
||||
self.do_set_attribute(name.clone(), value, name.clone(), ns!(""), None, |attr| {
|
||||
attr.deref().name.as_slice() == name.as_slice()
|
||||
attr.name.as_slice() == name.as_slice()
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
@ -887,9 +884,9 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
match name.as_slice() {
|
||||
"style" => {
|
||||
let doc = document_from_node(*self).root();
|
||||
let base_url = doc.deref().url().clone();
|
||||
let base_url = doc.url().clone();
|
||||
let style = Some(style::parse_style_attribute(value.as_slice(), &base_url));
|
||||
*self.deref().style_attribute.borrow_mut() = style;
|
||||
*self.style_attribute.borrow_mut() = style;
|
||||
}
|
||||
"id" => {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
|
@ -913,7 +910,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
|
||||
match name.as_slice() {
|
||||
"style" => {
|
||||
*self.deref().style_attribute.borrow_mut() = None;
|
||||
*self.style_attribute.borrow_mut() = None;
|
||||
}
|
||||
"id" => {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
|
@ -948,10 +945,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
match self.get_attribute(ns!(""), "id").root() {
|
||||
Some(attr) => {
|
||||
let doc = document_from_node(*self).root();
|
||||
let value = attr.deref().Value();
|
||||
let value = attr.Value();
|
||||
if !value.is_empty() {
|
||||
let value = Atom::from_slice(value.as_slice());
|
||||
doc.deref().register_named_element(*self, value);
|
||||
doc.register_named_element(*self, value);
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
@ -969,10 +966,10 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
match self.get_attribute(ns!(""), "id").root() {
|
||||
Some(attr) => {
|
||||
let doc = document_from_node(*self).root();
|
||||
let value = attr.deref().Value();
|
||||
let value = attr.Value();
|
||||
if !value.is_empty() {
|
||||
let value = Atom::from_slice(value.as_slice());
|
||||
doc.deref().unregister_named_element(*self, value);
|
||||
doc.unregister_named_element(*self, value);
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
|
@ -983,12 +980,12 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
|
|||
impl<'a> style::TElement<'a> for JSRef<'a, Element> {
|
||||
fn get_attr(self, namespace: &Namespace, attr: &str) -> Option<&'a str> {
|
||||
self.get_attribute(namespace.clone(), attr).root().map(|attr| {
|
||||
unsafe { mem::transmute(attr.deref().value().as_slice()) }
|
||||
unsafe { mem::transmute(attr.value().as_slice()) }
|
||||
})
|
||||
}
|
||||
fn get_attrs(self, attr: &str) -> Vec<&'a str> {
|
||||
self.get_attributes(attr).iter().map(|attr| attr.root()).map(|attr| {
|
||||
unsafe { mem::transmute(attr.deref().value().as_slice()) }
|
||||
unsafe { mem::transmute(attr.value().as_slice()) }
|
||||
}).collect()
|
||||
}
|
||||
fn get_link(self) -> Option<&'a str> {
|
||||
|
|
|
@ -121,7 +121,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
fn dispatch_event_with_target(self,
|
||||
target: Option<JSRef<EventTarget>>,
|
||||
event: JSRef<Event>) -> Fallible<bool> {
|
||||
if event.deref().dispatching.get() || !event.deref().initialized.get() {
|
||||
if event.dispatching.get() || !event.initialized.get() {
|
||||
return Err(InvalidState);
|
||||
}
|
||||
Ok(dispatch_event(self, target, event))
|
||||
|
|
|
@ -49,12 +49,12 @@ impl HTMLBodyElement {
|
|||
impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> {
|
||||
fn GetOnunload(self) -> Option<EventHandlerNonNull> {
|
||||
let win = window_from_node(self).root();
|
||||
win.deref().GetOnunload()
|
||||
win.GetOnunload()
|
||||
}
|
||||
|
||||
fn SetOnunload(self, listener: Option<EventHandlerNonNull>) {
|
||||
let win = window_from_node(self).root();
|
||||
win.deref().SetOnunload(listener)
|
||||
win.SetOnunload(listener)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,11 +120,11 @@ impl HTMLCollection {
|
|||
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
||||
let ns_match = match self.namespace_filter {
|
||||
Some(ref namespace) => {
|
||||
elem.deref().namespace == *namespace
|
||||
elem.namespace == *namespace
|
||||
},
|
||||
None => true
|
||||
};
|
||||
ns_match && elem.deref().local_name == self.tag
|
||||
ns_match && elem.local_name == self.tag
|
||||
}
|
||||
}
|
||||
let filter = TagNameNSFilter {
|
||||
|
@ -170,7 +170,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
|||
Static(ref elems) => elems.len() as u32,
|
||||
Live(ref root, ref filter) => {
|
||||
let root = root.root();
|
||||
root.deref().traverse_preorder()
|
||||
root.traverse_preorder()
|
||||
.filter(|&child| {
|
||||
let elem: Option<JSRef<Element>> = ElementCast::to_ref(child);
|
||||
elem.map_or(false, |elem| filter.filter(elem, *root))
|
||||
|
@ -188,7 +188,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
|||
.map(|elem| Temporary::new(elem.clone())),
|
||||
Live(ref root, ref filter) => {
|
||||
let root = root.root();
|
||||
root.deref().traverse_preorder()
|
||||
root.traverse_preorder()
|
||||
.filter_map(|node| {
|
||||
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
|
||||
match elem {
|
||||
|
@ -220,7 +220,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
|||
.map(|maybe_elem| Temporary::from_rooted(*maybe_elem)),
|
||||
Live(ref root, ref filter) => {
|
||||
let root = root.root();
|
||||
root.deref().traverse_preorder()
|
||||
root.traverse_preorder()
|
||||
.filter_map(|node| {
|
||||
let elem: Option<JSRef<Element>> = ElementCast::to_ref(node);
|
||||
match elem {
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
|||
fn GetOnload(self) -> Option<EventHandlerNonNull> {
|
||||
if self.is_body_or_frameset() {
|
||||
let win = window_from_node(self).root();
|
||||
win.deref().GetOnload()
|
||||
win.GetOnload()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> {
|
|||
fn SetOnload(self, listener: Option<EventHandlerNonNull>) {
|
||||
if self.is_body_or_frameset() {
|
||||
let win = window_from_node(self).root();
|
||||
win.deref().SetOnload(listener)
|
||||
win.SetOnload(listener)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
|
|||
static tag_names: StaticStringVec = &["button", "fieldset", "input",
|
||||
"keygen", "object", "output", "select", "textarea"];
|
||||
let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
|
||||
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.deref().local_name.as_slice())
|
||||
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.local_name.as_slice())
|
||||
}
|
||||
}
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
|
|
|
@ -74,12 +74,12 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
|||
fn get_url(self) -> Option<Url> {
|
||||
let element: JSRef<Element> = ElementCast::from_ref(self);
|
||||
element.get_attribute(ns!(""), "src").root().and_then(|src| {
|
||||
let url = src.deref().value();
|
||||
let url = src.value();
|
||||
if url.as_slice().is_empty() {
|
||||
None
|
||||
} else {
|
||||
let window = window_from_node(self).root();
|
||||
UrlParser::new().base_url(&window.deref().page().get_url())
|
||||
UrlParser::new().base_url(&window.page().get_url())
|
||||
.parse(url.as_slice()).ok()
|
||||
}
|
||||
})
|
||||
|
@ -99,10 +99,10 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
|
|||
|
||||
// Subpage Id
|
||||
let window = window_from_node(self).root();
|
||||
let page = window.deref().page();
|
||||
let page = window.page();
|
||||
let subpage_id = page.get_next_subpage_id();
|
||||
|
||||
self.deref().size.set(Some(IFrameSize {
|
||||
self.size.set(Some(IFrameSize {
|
||||
pipeline_id: page.id,
|
||||
subpage_id: subpage_id,
|
||||
}));
|
||||
|
@ -152,7 +152,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
|||
fn GetContentWindow(self) -> Option<Temporary<Window>> {
|
||||
self.size.get().and_then(|size| {
|
||||
let window = window_from_node(self).root();
|
||||
let children = window.deref().page.children.borrow();
|
||||
let children = window.page.children.borrow();
|
||||
let child = children.iter().find(|child| {
|
||||
child.subpage_id.unwrap() == size.subpage_id
|
||||
});
|
||||
|
@ -190,7 +190,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
|||
_ => AllowNothing
|
||||
} as u8;
|
||||
}
|
||||
self.deref().sandbox.set(Some(modes));
|
||||
self.sandbox.set(Some(modes));
|
||||
}
|
||||
|
||||
if "src" == name.as_slice() {
|
||||
|
@ -208,7 +208,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
|
|||
}
|
||||
|
||||
if "sandbox" == name.as_slice() {
|
||||
self.deref().sandbox.set(None);
|
||||
self.sandbox.set(None);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
|
|||
fn update_image(self, value: Option<(DOMString, &Url)>) {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||
let document = node.owner_doc().root();
|
||||
let window = document.deref().window.root();
|
||||
let window = document.window.root();
|
||||
let image_cache = &window.image_cache_task;
|
||||
match value {
|
||||
None => {
|
||||
|
@ -176,7 +176,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLImageElement> {
|
|||
|
||||
if "src" == name.as_slice() {
|
||||
let window = window_from_node(*self).root();
|
||||
let url = window.deref().get_url();
|
||||
let url = window.get_url();
|
||||
self.update_image(Some((value, &url)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ impl HTMLLinkElement {
|
|||
|
||||
fn get_attr(element: JSRef<Element>, name: &str) -> Option<String> {
|
||||
let elem = element.get_attribute(ns!(""), name).root();
|
||||
elem.map(|e| e.deref().value().as_slice().to_string())
|
||||
elem.map(|e| e.value().as_slice().to_string())
|
||||
}
|
||||
|
||||
fn is_stylesheet(value: &Option<String>) -> bool {
|
||||
|
@ -116,9 +116,9 @@ trait PrivateHTMLLinkElementHelpers {
|
|||
impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
|
||||
fn handle_stylesheet_url(self, href: &str) {
|
||||
let window = window_from_node(self).root();
|
||||
match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) {
|
||||
match UrlParser::new().base_url(&window.page().get_url()).parse(href) {
|
||||
Ok(url) => {
|
||||
let LayoutChan(ref layout_chan) = window.deref().page().layout_chan;
|
||||
let LayoutChan(ref layout_chan) = window.page().layout_chan;
|
||||
layout_chan.send(LoadStylesheetMsg(url));
|
||||
}
|
||||
Err(e) => debug!("Parsing url {:s} failed: {:?}", href, e)
|
||||
|
|
|
@ -102,7 +102,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
|
|||
|
||||
if "data" == name.as_slice() {
|
||||
let window = window_from_node(*self).root();
|
||||
self.process_data_url(window.deref().image_cache_task.clone());
|
||||
self.process_data_url(window.image_cache_task.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
|
|||
|
||||
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
|
||||
html.push_str("<!--");
|
||||
html.push_str(comment.deref().characterdata.data.borrow().as_slice());
|
||||
html.push_str(comment.characterdata.data.borrow().as_slice());
|
||||
html.push_str("-->");
|
||||
}
|
||||
|
||||
|
@ -78,49 +78,49 @@ fn serialize_text(text: JSRef<Text>, html: &mut String) {
|
|||
match text_node.parent_node().map(|node| node.root()) {
|
||||
Some(ref parent) if parent.is_element() => {
|
||||
let elem: JSRef<Element> = ElementCast::to_ref(**parent).unwrap();
|
||||
match elem.deref().local_name.as_slice() {
|
||||
match elem.local_name.as_slice() {
|
||||
"style" | "script" | "xmp" | "iframe" |
|
||||
"noembed" | "noframes" | "plaintext" |
|
||||
"noscript" if elem.deref().namespace == ns!(HTML)
|
||||
=> html.push_str(text.deref().characterdata.data.borrow().as_slice()),
|
||||
_ => escape(text.deref().characterdata.data.borrow().as_slice(), false, html)
|
||||
"noscript" if elem.namespace == ns!(HTML)
|
||||
=> html.push_str(text.characterdata.data.borrow().as_slice()),
|
||||
_ => escape(text.characterdata.data.borrow().as_slice(), false, html)
|
||||
}
|
||||
}
|
||||
_ => escape(text.deref().characterdata.data.borrow().as_slice(), false, html)
|
||||
_ => escape(text.characterdata.data.borrow().as_slice(), false, html)
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInstruction>,
|
||||
html: &mut String) {
|
||||
html.push_str("<?");
|
||||
html.push_str(processing_instruction.deref().target.as_slice());
|
||||
html.push_str(processing_instruction.target.as_slice());
|
||||
html.push_char(' ');
|
||||
html.push_str(processing_instruction.deref().characterdata.data.borrow().as_slice());
|
||||
html.push_str(processing_instruction.characterdata.data.borrow().as_slice());
|
||||
html.push_str("?>");
|
||||
}
|
||||
|
||||
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
||||
html.push_str("<!DOCTYPE");
|
||||
html.push_str(doctype.deref().name.as_slice());
|
||||
html.push_str(doctype.name.as_slice());
|
||||
html.push_char('>');
|
||||
}
|
||||
|
||||
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
|
||||
html.push_char('<');
|
||||
html.push_str(elem.deref().local_name.as_slice());
|
||||
for attr in elem.deref().attrs.borrow().iter() {
|
||||
html.push_str(elem.local_name.as_slice());
|
||||
for attr in elem.attrs.borrow().iter() {
|
||||
let attr = attr.root();
|
||||
serialize_attr(*attr, html);
|
||||
};
|
||||
html.push_char('>');
|
||||
|
||||
match elem.deref().local_name.as_slice() {
|
||||
"pre" | "listing" | "textarea" if elem.deref().namespace == ns!(HTML) => {
|
||||
match elem.local_name.as_slice() {
|
||||
"pre" | "listing" | "textarea" if elem.namespace == ns!(HTML) => {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(elem);
|
||||
match node.first_child().map(|child| child.root()) {
|
||||
Some(ref child) if child.is_text() => {
|
||||
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
||||
if text.deref().data.borrow().len() > 0 && text.deref().data.borrow().as_slice().char_at(0) == '\n' {
|
||||
if text.data.borrow().len() > 0 && text.data.borrow().as_slice().char_at(0) == '\n' {
|
||||
html.push_char('\x0A');
|
||||
}
|
||||
},
|
||||
|
@ -131,26 +131,26 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
|||
}
|
||||
|
||||
if !(elem.is_void()) {
|
||||
open_elements.push(elem.deref().local_name.as_slice().to_string());
|
||||
open_elements.push(elem.local_name.as_slice().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
||||
html.push_char(' ');
|
||||
if attr.deref().namespace == ns!(XML) {
|
||||
if attr.namespace == ns!(XML) {
|
||||
html.push_str("xml:");
|
||||
html.push_str(attr.local_name().as_slice());
|
||||
} else if attr.deref().namespace == ns!(XMLNS) &&
|
||||
} else if attr.namespace == ns!(XMLNS) &&
|
||||
*attr.local_name() == Atom::from_slice("xmlns") {
|
||||
html.push_str("xmlns");
|
||||
} else if attr.deref().namespace == ns!(XMLNS) {
|
||||
} else if attr.namespace == ns!(XMLNS) {
|
||||
html.push_str("xmlns:");
|
||||
html.push_str(attr.local_name().as_slice());
|
||||
} else if attr.deref().namespace == ns!(XLink) {
|
||||
} else if attr.namespace == ns!(XLink) {
|
||||
html.push_str("xlink:");
|
||||
html.push_str(attr.local_name().as_slice());
|
||||
} else {
|
||||
html.push_str(attr.deref().name.as_slice());
|
||||
html.push_str(attr.name.as_slice());
|
||||
};
|
||||
html.push_str("=\"");
|
||||
escape(attr.value().as_slice(), true, html);
|
||||
|
|
|
@ -53,11 +53,11 @@ impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> {
|
|||
assert!(node.is_in_doc());
|
||||
|
||||
let win = window_from_node(node).root();
|
||||
let url = win.deref().page().get_url();
|
||||
let url = win.page().get_url();
|
||||
|
||||
let data = node.GetTextContent().expect("Element.textContent must be a string");
|
||||
let sheet = Stylesheet::from_str(data.as_slice(), url);
|
||||
let LayoutChan(ref layout_chan) = win.deref().page().layout_chan;
|
||||
let LayoutChan(ref layout_chan) = win.page().layout_chan;
|
||||
layout_chan.send(AddStylesheetMsg(sheet));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
let parent = self.parent_node().root();
|
||||
parent.map(|parent| vtable_for(&*parent).child_inserted(self));
|
||||
|
||||
document.deref().content_changed();
|
||||
document.content_changed();
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#node-is-removed
|
||||
|
@ -283,7 +283,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
vtable_for(&node).unbind_from_tree(parent_in_doc);
|
||||
}
|
||||
|
||||
document.deref().content_changed();
|
||||
document.content_changed();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -295,7 +295,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
/// Fails unless `new_child` is disconnected from the tree.
|
||||
fn add_child(self, new_child: JSRef<Node>, before: Option<JSRef<Node>>) {
|
||||
let doc = self.owner_doc().root();
|
||||
doc.deref().wait_until_safe_to_modify_dom();
|
||||
doc.wait_until_safe_to_modify_dom();
|
||||
|
||||
assert!(new_child.parent_node().is_none());
|
||||
assert!(new_child.prev_sibling().is_none());
|
||||
|
@ -338,7 +338,7 @@ impl<'a> PrivateNodeHelpers for JSRef<'a, Node> {
|
|||
/// Fails unless `child` is a child of this node.
|
||||
fn remove_child(self, child: JSRef<Node>) {
|
||||
let doc = self.owner_doc().root();
|
||||
doc.deref().wait_until_safe_to_modify_dom();
|
||||
doc.wait_until_safe_to_modify_dom();
|
||||
|
||||
assert!(child.parent_node().root().root_ref() == Some(self));
|
||||
|
||||
|
@ -454,34 +454,34 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
fn is_in_doc(self) -> bool {
|
||||
self.deref().flags.borrow().contains(IsInDoc)
|
||||
self.flags.borrow().contains(IsInDoc)
|
||||
}
|
||||
|
||||
/// Returns the type ID of this node. Fails if this node is borrowed mutably.
|
||||
fn type_id(self) -> NodeTypeId {
|
||||
self.deref().type_id
|
||||
self.type_id
|
||||
}
|
||||
|
||||
fn parent_node(self) -> Option<Temporary<Node>> {
|
||||
self.deref().parent_node.get()
|
||||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn first_child(self) -> Option<Temporary<Node>> {
|
||||
self.deref().first_child.get()
|
||||
self.first_child.get()
|
||||
}
|
||||
|
||||
fn last_child(self) -> Option<Temporary<Node>> {
|
||||
self.deref().last_child.get()
|
||||
self.last_child.get()
|
||||
}
|
||||
|
||||
/// Returns the previous sibling of this node. Fails if this node is borrowed mutably.
|
||||
fn prev_sibling(self) -> Option<Temporary<Node>> {
|
||||
self.deref().prev_sibling.get()
|
||||
self.prev_sibling.get()
|
||||
}
|
||||
|
||||
/// Returns the next sibling of this node. Fails if this node is borrowed mutably.
|
||||
fn next_sibling(self) -> Option<Temporary<Node>> {
|
||||
self.deref().next_sibling.get()
|
||||
self.next_sibling.get()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -574,7 +574,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
fn following_siblings(self) -> AbstractNodeChildrenIterator<'a> {
|
||||
AbstractNodeChildrenIterator {
|
||||
current_node: self.next_sibling().root().map(|next| next.deref().clone()),
|
||||
current_node: self.next_sibling().root().map(|next| next.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
fn get_bounding_content_box(self) -> Rect<Au> {
|
||||
let window = window_from_node(self).root();
|
||||
let page = window.deref().page();
|
||||
let page = window.page();
|
||||
let addr = self.to_trusted_node_address();
|
||||
|
||||
let ContentBoxResponse(rect) = page.layout().content_box(addr);
|
||||
|
@ -600,7 +600,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
fn get_content_boxes(self) -> Vec<Rect<Au>> {
|
||||
let window = window_from_node(self).root();
|
||||
let page = window.deref().page();
|
||||
let page = window.page();
|
||||
let addr = self.to_trusted_node_address();
|
||||
let ContentBoxesResponse(rects) = page.layout().content_boxes(addr);
|
||||
rects
|
||||
|
@ -683,7 +683,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
fn wait_until_safe_to_modify_dom(self) {
|
||||
let document = self.owner_doc().root();
|
||||
document.deref().wait_until_safe_to_modify_dom();
|
||||
document.wait_until_safe_to_modify_dom();
|
||||
}
|
||||
|
||||
fn remove_self(self) {
|
||||
|
@ -955,10 +955,10 @@ impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator {
|
|||
},
|
||||
None if JS::from_rooted(*node) == self.start_node => None,
|
||||
None => {
|
||||
match node.deref().next_sibling().root() {
|
||||
match node.next_sibling().root() {
|
||||
Some(sibling) => Some(JS::from_rooted(*sibling)),
|
||||
None => {
|
||||
let mut candidate = node.deref().clone();
|
||||
let mut candidate = node.clone();
|
||||
while candidate.next_sibling().is_none() {
|
||||
candidate = (*candidate.parent_node()
|
||||
.expect("Got to root without reaching start node")
|
||||
|
@ -969,7 +969,7 @@ impl<'a> Iterator<JSRef<'a, Node>> for NodeIterator {
|
|||
}
|
||||
}
|
||||
if JS::from_rooted(candidate) != self.start_node {
|
||||
candidate.next_sibling().map(|node| JS::from_rooted(*node.root().deref()))
|
||||
candidate.next_sibling().map(|node| JS::from_rooted(*node.root()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -1326,7 +1326,7 @@ impl Node {
|
|||
// Step 8.
|
||||
parent.remove_child(node);
|
||||
|
||||
node.deref().flags.borrow_mut().remove(IsInDoc);
|
||||
node.flags.borrow_mut().remove(IsInDoc);
|
||||
|
||||
// Step 9.
|
||||
match suppress_observers {
|
||||
|
@ -1350,7 +1350,6 @@ impl Node {
|
|||
let copy: Root<Node> = match node.type_id() {
|
||||
DoctypeNodeTypeId => {
|
||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
||||
let doctype = doctype.deref();
|
||||
let doctype = DocumentType::new(doctype.name.clone(),
|
||||
Some(doctype.public_id.clone()),
|
||||
Some(doctype.system_id.clone()), *document);
|
||||
|
@ -1362,7 +1361,6 @@ impl Node {
|
|||
},
|
||||
CommentNodeTypeId => {
|
||||
let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
|
||||
let comment = comment.deref();
|
||||
let comment = Comment::new(comment.characterdata.data.borrow().clone(), *document);
|
||||
NodeCast::from_temporary(comment)
|
||||
},
|
||||
|
@ -1379,20 +1377,17 @@ impl Node {
|
|||
},
|
||||
ElementNodeTypeId(..) => {
|
||||
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
let element = element.deref();
|
||||
let element = build_element_from_tag(element.local_name.as_slice().to_string(),
|
||||
element.namespace.clone(), Some(element.prefix.as_slice().to_string()), *document);
|
||||
NodeCast::from_temporary(element)
|
||||
},
|
||||
TextNodeTypeId => {
|
||||
let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
|
||||
let text = text.deref();
|
||||
let text = Text::new(text.characterdata.data.borrow().clone(), *document);
|
||||
NodeCast::from_temporary(text)
|
||||
},
|
||||
ProcessingInstructionNodeTypeId => {
|
||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||
let pi = pi.deref();
|
||||
let pi = ProcessingInstruction::new(pi.target.clone(),
|
||||
pi.characterdata.data.borrow().clone(), *document);
|
||||
NodeCast::from_temporary(pi)
|
||||
|
@ -1421,13 +1416,13 @@ impl Node {
|
|||
let copy_elem: JSRef<Element> = ElementCast::to_ref(*copy).unwrap();
|
||||
|
||||
// FIXME: https://github.com/mozilla/servo/issues/1737
|
||||
let window = document.deref().window.root();
|
||||
for attr in node_elem.deref().attrs.borrow().iter().map(|attr| attr.root()) {
|
||||
copy_elem.deref().attrs.borrow_mut().push_unrooted(
|
||||
let window = document.window.root();
|
||||
for attr in node_elem.attrs.borrow().iter().map(|attr| attr.root()) {
|
||||
copy_elem.attrs.borrow_mut().push_unrooted(
|
||||
&Attr::new(*window,
|
||||
attr.local_name().clone(), attr.deref().value().clone(),
|
||||
attr.deref().name.clone(), attr.deref().namespace.clone(),
|
||||
attr.deref().prefix.clone(), copy_elem));
|
||||
attr.local_name().clone(), attr.value().clone(),
|
||||
attr.name.clone(), attr.namespace.clone(),
|
||||
attr.prefix.clone(), copy_elem));
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
|
@ -1509,7 +1504,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
CommentNodeTypeId => "#comment".to_string(),
|
||||
DoctypeNodeTypeId => {
|
||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
|
||||
doctype.deref().name.clone()
|
||||
doctype.name.clone()
|
||||
},
|
||||
DocumentFragmentNodeTypeId => "#document-fragment".to_string(),
|
||||
DocumentNodeTypeId => "#document".to_string()
|
||||
|
@ -1564,7 +1559,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
let doc = self.owner_doc().root();
|
||||
let window = doc.deref().window.root();
|
||||
let window = doc.window.root();
|
||||
let child_list = NodeList::new_child_list(*window, self);
|
||||
self.child_list.assign(Some(child_list));
|
||||
self.child_list.get().unwrap()
|
||||
|
@ -1649,7 +1644,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
None
|
||||
} else {
|
||||
let document = self.owner_doc().root();
|
||||
Some(NodeCast::from_temporary(document.deref().CreateTextNode(value)))
|
||||
Some(NodeCast::from_temporary(document.CreateTextNode(value)))
|
||||
}.root();
|
||||
|
||||
// Step 3.
|
||||
|
@ -1665,7 +1660,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
|
||||
// Notify the document that the content of this node is different
|
||||
let document = self.owner_doc().root();
|
||||
document.deref().content_changed();
|
||||
document.content_changed();
|
||||
}
|
||||
DoctypeNodeTypeId |
|
||||
DocumentNodeTypeId => {}
|
||||
|
@ -1856,16 +1851,14 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
fn is_equal_doctype(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||
let doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(node).unwrap();
|
||||
let other_doctype: JSRef<DocumentType> = DocumentTypeCast::to_ref(other).unwrap();
|
||||
(doctype.deref().name == other_doctype.deref().name) &&
|
||||
(doctype.deref().public_id == other_doctype.deref().public_id) &&
|
||||
(doctype.deref().system_id == other_doctype.deref().system_id)
|
||||
(doctype.name == other_doctype.name) &&
|
||||
(doctype.public_id == other_doctype.public_id) &&
|
||||
(doctype.system_id == other_doctype.system_id)
|
||||
}
|
||||
fn is_equal_element(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
let other_element: JSRef<Element> = ElementCast::to_ref(other).unwrap();
|
||||
// FIXME: namespace prefix
|
||||
let element = element.deref();
|
||||
let other_element = other_element.deref();
|
||||
(element.namespace == other_element.namespace) &&
|
||||
(element.local_name == other_element.local_name) &&
|
||||
(element.attrs.borrow().len() == other_element.attrs.borrow().len())
|
||||
|
@ -1873,25 +1866,23 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
fn is_equal_processinginstruction(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||
let other_pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(other).unwrap();
|
||||
(pi.deref().target == other_pi.deref().target) &&
|
||||
(*pi.deref().characterdata.data.borrow() == *other_pi.deref().characterdata.data.borrow())
|
||||
(pi.target == other_pi.target) &&
|
||||
(*pi.characterdata.data.borrow() == *other_pi.characterdata.data.borrow())
|
||||
}
|
||||
fn is_equal_characterdata(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(node).unwrap();
|
||||
let other_characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(other).unwrap();
|
||||
*characterdata.deref().data.borrow() == *other_characterdata.deref().data.borrow()
|
||||
*characterdata.data.borrow() == *other_characterdata.data.borrow()
|
||||
}
|
||||
fn is_equal_element_attrs(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||
let other_element: JSRef<Element> = ElementCast::to_ref(other).unwrap();
|
||||
let element = element.deref();
|
||||
let other_element = other_element.deref();
|
||||
assert!(element.attrs.borrow().len() == other_element.attrs.borrow().len());
|
||||
element.attrs.borrow().iter().map(|attr| attr.root()).all(|attr| {
|
||||
other_element.attrs.borrow().iter().map(|attr| attr.root()).any(|other_attr| {
|
||||
(attr.namespace == other_attr.namespace) &&
|
||||
(attr.local_name() == other_attr.local_name()) &&
|
||||
(attr.deref().value().as_slice() == other_attr.deref().value().as_slice())
|
||||
(attr.value().as_slice() == other_attr.value().as_slice())
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -2026,7 +2017,7 @@ pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Tempora
|
|||
|
||||
pub fn window_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Window> {
|
||||
let document = document_from_node(derived).root();
|
||||
Temporary::new(document.deref().window.clone())
|
||||
Temporary::new(document.window.clone())
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, Node> {
|
||||
|
@ -2114,12 +2105,12 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
|
|||
match attr.namespace {
|
||||
style::SpecificNamespace(ref ns) => {
|
||||
self.as_element().get_attribute(ns.clone(), name).root()
|
||||
.map_or(false, |attr| test(attr.deref().value().as_slice()))
|
||||
.map_or(false, |attr| test(attr.value().as_slice()))
|
||||
},
|
||||
style::AnyNamespace => {
|
||||
self.as_element().get_attributes(name).iter()
|
||||
.map(|attr| attr.root())
|
||||
.any(|attr| test(attr.deref().value().as_slice()))
|
||||
.any(|attr| test(attr.value().as_slice()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
|
|||
Simple(ref elems) => elems.len() as u32,
|
||||
Children(ref node) => {
|
||||
let node = node.root();
|
||||
node.deref().children().count() as u32
|
||||
node.children().count() as u32
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
|
|||
Simple(ref elems) => Some(Temporary::new(elems[index as uint].clone())),
|
||||
Children(ref node) => {
|
||||
let node = node.root();
|
||||
node.deref().children().nth(index as uint)
|
||||
node.children().nth(index as uint)
|
||||
.map(|child| Temporary::from_rooted(child))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ impl UIEvent {
|
|||
view: Option<JSRef<Window>>,
|
||||
detail: i32) -> Temporary<UIEvent> {
|
||||
let ev = UIEvent::new_uninitialized(window).root();
|
||||
ev.deref().InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
||||
ev.InitUIEvent(type_, can_bubble, cancelable, view, detail);
|
||||
Temporary::from_rooted(*ev)
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ impl URLSearchParams {
|
|||
},
|
||||
Some(eURLSearchParams(u)) => {
|
||||
let u = u.root();
|
||||
let mut map = usp.deref().data.borrow_mut();
|
||||
let mut map = usp.data.borrow_mut();
|
||||
*map = u.data.borrow().clone();
|
||||
},
|
||||
None => {}
|
||||
|
|
|
@ -221,7 +221,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
|
||||
fn Location(self) -> Temporary<Location> {
|
||||
if self.location.get().is_none() {
|
||||
let page = self.deref().page.clone();
|
||||
let page = self.page.clone();
|
||||
let location = Location::new(self, page);
|
||||
self.location.assign(Some(location));
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ impl XMLHttpRequest {
|
|||
pub fn handle_xhr_progress(addr: TrustedXHRAddress, progress: XHRProgress) {
|
||||
unsafe {
|
||||
let xhr = JS::from_trusted_xhr_address(addr).root();
|
||||
xhr.deref().process_partial_response(progress);
|
||||
xhr.process_partial_response(progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -363,7 +363,7 @@ pub fn parse_html(page: &Page,
|
|||
let tmp = &*tmp_borrow;
|
||||
let doctype_node = DocumentType::new(name, public_id, system_id, *tmp).root();
|
||||
unsafe {
|
||||
doctype_node.deref().to_hubbub_node()
|
||||
doctype_node.to_hubbub_node()
|
||||
}
|
||||
},
|
||||
create_element: |tag: Box<hubbub::Tag>| {
|
||||
|
@ -394,7 +394,7 @@ pub fn parse_html(page: &Page,
|
|||
prefix.map(|p| p.to_string()));
|
||||
}
|
||||
|
||||
unsafe { element.deref().to_hubbub_node() }
|
||||
unsafe { element.to_hubbub_node() }
|
||||
},
|
||||
create_text: |data: String| {
|
||||
debug!("create text");
|
||||
|
@ -402,7 +402,7 @@ pub fn parse_html(page: &Page,
|
|||
let tmp_borrow = doc_cell.borrow();
|
||||
let tmp = &*tmp_borrow;
|
||||
let text = Text::new(data, *tmp).root();
|
||||
unsafe { text.deref().to_hubbub_node() }
|
||||
unsafe { text.to_hubbub_node() }
|
||||
},
|
||||
ref_node: |_| {},
|
||||
unref_node: |_| {},
|
||||
|
@ -411,7 +411,7 @@ pub fn parse_html(page: &Page,
|
|||
debug!("append child {:x} {:x}", parent, child);
|
||||
let child: Root<Node> = from_hubbub_node(child).root();
|
||||
let parent: Root<Node> = from_hubbub_node(parent).root();
|
||||
assert!(parent.deref().AppendChild(*child).is_ok());
|
||||
assert!(parent.AppendChild(*child).is_ok());
|
||||
}
|
||||
child
|
||||
},
|
||||
|
@ -473,7 +473,7 @@ pub fn parse_html(page: &Page,
|
|||
let script_element: JSRef<Element> = ElementCast::from_ref(script);
|
||||
match script_element.get_attribute(ns!(""), "src").root() {
|
||||
Some(src) => {
|
||||
debug!("found script: {:s}", src.deref().Value());
|
||||
debug!("found script: {:s}", src.Value());
|
||||
let mut url_parser = UrlParser::new();
|
||||
match base_url {
|
||||
None => (),
|
||||
|
@ -481,9 +481,9 @@ pub fn parse_html(page: &Page,
|
|||
url_parser.base_url(base_url);
|
||||
}
|
||||
};
|
||||
match url_parser.parse(src.deref().value().as_slice()) {
|
||||
match url_parser.parse(src.value().as_slice()) {
|
||||
Ok(new_url) => js_chan2.send(JSTaskNewFile(new_url)),
|
||||
Err(e) => debug!("Parsing url {:s} failed: {:?}", src.deref().Value(), e)
|
||||
Err(e) => debug!("Parsing url {:s} failed: {:?}", src.Value(), e)
|
||||
};
|
||||
}
|
||||
None => {
|
||||
|
@ -493,7 +493,7 @@ pub fn parse_html(page: &Page,
|
|||
for child in scriptnode.children() {
|
||||
debug!("child = {:?}", child);
|
||||
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
||||
data.push_str(text.deref().characterdata.data.borrow().as_slice());
|
||||
data.push_str(text.characterdata.data.borrow().as_slice());
|
||||
}
|
||||
|
||||
debug!("script data = {:?}", data);
|
||||
|
|
|
@ -393,7 +393,7 @@ impl Page {
|
|||
pub fn hit_test(&self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
|
||||
let frame = self.frame();
|
||||
let document = frame.as_ref().unwrap().document.root();
|
||||
let root = document.deref().GetDocumentElement().root();
|
||||
let root = document.GetDocumentElement().root();
|
||||
if root.is_none() {
|
||||
return None;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ impl Page {
|
|||
pub fn get_nodes_under_mouse(&self, point: &Point2D<f32>) -> Option<Vec<UntrustedNodeAddress>> {
|
||||
let frame = self.frame();
|
||||
let document = frame.as_ref().unwrap().document.root();
|
||||
let root = document.deref().GetDocumentElement().root();
|
||||
let root = document.GetDocumentElement().root();
|
||||
if root.is_none() {
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -725,7 +725,7 @@ impl ScriptTask {
|
|||
let cx = self.js_context.borrow();
|
||||
let cx = cx.as_ref().unwrap();
|
||||
// Create the window and document objects.
|
||||
let window = Window::new(cx.deref().ptr,
|
||||
let window = Window::new(cx.ptr,
|
||||
page.clone(),
|
||||
self.chan.clone(),
|
||||
self.control_chan.clone(),
|
||||
|
@ -743,7 +743,7 @@ impl ScriptTask {
|
|||
let document = Document::new(*window, Some(doc_url), HTMLDocument,
|
||||
None).root();
|
||||
|
||||
window.deref().init_browser_context(*document);
|
||||
window.init_browser_context(*document);
|
||||
|
||||
self.compositor.set_ready_state(pipeline_id, Loading);
|
||||
|
||||
|
@ -796,7 +796,7 @@ impl ScriptTask {
|
|||
|
||||
// Kick off the initial reflow of the page.
|
||||
debug!("kicking off initial reflow of {}", url);
|
||||
document.deref().content_changed();
|
||||
document.content_changed();
|
||||
window.flush_layout(ReflowForDisplay);
|
||||
|
||||
{
|
||||
|
@ -930,7 +930,7 @@ impl ScriptTask {
|
|||
|
||||
let temp_node =
|
||||
node::from_untrusted_node_address(
|
||||
self.js_runtime.deref().ptr, node_address).root();
|
||||
self.js_runtime.ptr, node_address).root();
|
||||
|
||||
let maybe_node = if !temp_node.is_element() {
|
||||
temp_node.ancestors().find(|node| node.is_element())
|
||||
|
@ -980,7 +980,7 @@ impl ScriptTask {
|
|||
Some(ref mut mouse_over_targets) => {
|
||||
for node in mouse_over_targets.iter_mut() {
|
||||
let node = node.root();
|
||||
node.deref().set_hover_state(false);
|
||||
node.set_hover_state(false);
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
|
@ -990,7 +990,7 @@ impl ScriptTask {
|
|||
|
||||
let temp_node =
|
||||
node::from_untrusted_node_address(
|
||||
self.js_runtime.deref().ptr, *node_address);
|
||||
self.js_runtime.ptr, *node_address);
|
||||
|
||||
let maybe_node = temp_node.root().ancestors().find(|node| node.is_element());
|
||||
match maybe_node {
|
||||
|
|
Загрузка…
Ссылка в новой задаче