Remove intrinsic Root::r()

This commit is contained in:
Anthony Ramine 2016-05-13 14:20:00 +02:00
parent 51bcf516c8
commit 0b3ab875f4
55 changed files with 275 additions and 310 deletions

View file

@ -146,7 +146,7 @@ pub fn handle_get_layout(context: &BrowsingContext,
let window = context.active_window(); let window = context.active_window();
let elem = node.downcast::<Element>().expect("should be getting layout of element"); let elem = node.downcast::<Element>().expect("should be getting layout of element");
let computed_style = window.r().GetComputedStyle(elem, None); let computed_style = window.GetComputedStyle(elem, None);
reply.send(Some(ComputedNodeLayout { reply.send(Some(ComputedNodeLayout {
display: String::from(computed_style.Display()), display: String::from(computed_style.Display()),

View file

@ -83,11 +83,11 @@ pub fn synthetic_click_activation(element: &Element,
// https://html.spec.whatwg.org/multipage/#fire-a-synthetic-mouse-event // https://html.spec.whatwg.org/multipage/#fire-a-synthetic-mouse-event
let win = window_from_node(element); let win = window_from_node(element);
let target = element.upcast::<EventTarget>(); let target = element.upcast::<EventTarget>();
let mouse = MouseEvent::new(win.r(), let mouse = MouseEvent::new(&win,
DOMString::from("click"), DOMString::from("click"),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
Some(win.r()), Some(&win),
1, 1,
0, 0,
0, 0,

View file

@ -104,7 +104,7 @@ impl AttrMethods for Attr {
let value = owner.parse_attribute(&self.identifier.namespace, let value = owner.parse_attribute(&self.identifier.namespace,
self.local_name(), self.local_name(),
value); value);
self.set_value(value, owner.r()); self.set_value(value, &owner);
} else { } else {
*self.value.borrow_mut() = AttrValue::String(value.into()); *self.value.borrow_mut() = AttrValue::String(value.into());
} }
@ -200,12 +200,12 @@ impl Attr {
/// or removed from its older parent. /// or removed from its older parent.
pub fn set_owner(&self, owner: Option<&Element>) { pub fn set_owner(&self, owner: Option<&Element>) {
let ns = &self.identifier.namespace; let ns = &self.identifier.namespace;
match (self.owner().r(), owner) { match (self.owner(), owner) {
(Some(old), None) => { (Some(old), None) => {
// Already gone from the list of attributes of old owner. // Already gone from the list of attributes of old owner.
assert!(old.get_attribute(&ns, &self.identifier.local_name).r() != Some(self)) assert!(old.get_attribute(&ns, &self.identifier.local_name).r() != Some(self))
} }
(Some(old), Some(new)) => assert!(old == new), (Some(old), Some(new)) => assert!(&*old == new),
_ => {}, _ => {},
} }
self.owner.set(owner); self.owner.set(owner);

View file

@ -3256,12 +3256,7 @@ class CGPerSignatureCall(CGThing):
return "argc" return "argc"
def getArguments(self): def getArguments(self):
def process(arg, i): return [(a, process_arg("arg" + str(i), a)) for (i, a) in enumerate(self.arguments)]
argVal = "arg" + str(i)
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
argVal += ".r()"
return argVal
return [(a, process(a, i)) for (i, a) in enumerate(self.arguments)]
def isFallible(self): def isFallible(self):
return 'infallible' not in self.extendedAttributes return 'infallible' not in self.extendedAttributes
@ -4651,12 +4646,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
self.cgRoot.prepend(CGGeneric("rooted!(in(cx) let value = desc.value);")) self.cgRoot.prepend(CGGeneric("rooted!(in(cx) let value = desc.value);"))
def getArguments(self): def getArguments(self):
def process(arg): args = [(a, process_arg(a.identifier.name, a)) for a in self.arguments]
argVal = arg.identifier.name
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
argVal += ".r()"
return argVal
args = [(a, process(a)) for a in self.arguments]
return args return args
def wrap_return_value(self): def wrap_return_value(self):
@ -6775,6 +6765,15 @@ def camel_to_upper_snake(s):
return "_".join(m.group(0).upper() for m in re.finditer("[A-Z][a-z]*", s)) return "_".join(m.group(0).upper() for m in re.finditer("[A-Z][a-z]*", s))
def process_arg(expr, arg):
if arg.type.isGeckoInterface() and not arg.type.unroll().inner.isCallback():
if arg.type.nullable() or arg.type.isSequence() or arg.optional:
expr += ".r()"
else:
expr = "&" + expr
return expr
class GlobalGenRoots(): class GlobalGenRoots():
""" """
Roots for global codegen. Roots for global codegen.

View file

@ -473,7 +473,7 @@ impl<T: Reflectable> RootedReference<T> for Option<Rc<T>> {
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> { impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
fn r(&self) -> Option<&T> { fn r(&self) -> Option<&T> {
self.as_ref().map(|root| root.r()) self.as_ref().map(|root| &**root)
} }
} }
@ -615,12 +615,6 @@ impl<T: Reflectable> Root<T> {
pub fn from_ref(unrooted: &T) -> Root<T> { pub fn from_ref(unrooted: &T) -> Root<T> {
Root::new(unsafe { NonZero::new(&*unrooted) }) Root::new(unsafe { NonZero::new(&*unrooted) })
} }
/// Obtain a safe reference to the wrapped JS owned-value that cannot
/// outlive the lifetime of this root.
pub fn r(&self) -> &T {
&**self
}
} }
impl<T: Reflectable> Deref for Root<T> { impl<T: Reflectable> Deref for Root<T> {

View file

@ -232,7 +232,7 @@ impl CanvasRenderingContext2D {
canvas.origin_is_clean() canvas.origin_is_clean()
} }
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(image) => HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(image) =>
image.r().origin_is_clean(), image.origin_is_clean(),
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(image) => HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(image) =>
match image.get_url() { match image.get_url() {
None => true, None => true,
@ -280,23 +280,20 @@ impl CanvasRenderingContext2D {
-> ErrorResult { -> ErrorResult {
let result = match image { let result = match image {
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => {
self.draw_html_canvas_element(canvas.r(), self.draw_html_canvas_element(&canvas,
sx, sy, sw, sh, sx, sy, sw, sh,
dx, dy, dw, dh) dx, dy, dw, dh)
} }
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(ref image) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(ref image) => {
let context = image.r(); self.draw_html_canvas_element(&image.Canvas(),
let canvas = context.Canvas();
self.draw_html_canvas_element(canvas.r(),
sx, sy, sw, sh, sx, sy, sw, sh,
dx, dy, dw, dh) dx, dy, dw, dh)
} }
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(ref image) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(ref image) => {
let image_element = image.r();
// https://html.spec.whatwg.org/multipage/#img-error // https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state, // If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception // then throw an InvalidStateError exception
let (image_data, image_size) = match self.fetch_image_data(&image_element) { let (image_data, image_size) = match self.fetch_image_data(image) {
Some((mut data, size)) => { Some((mut data, size)) => {
// Pixels come from cache in BGRA order and drawImage expects RGBA so we // Pixels come from cache in BGRA order and drawImage expects RGBA so we
// have to swap the color values // have to swap the color values
@ -464,7 +461,7 @@ impl CanvasRenderingContext2D {
#[inline] #[inline]
fn request_image_from_cache(&self, url: Url) -> ImageResponse { fn request_image_from_cache(&self, url: Url) -> ImageResponse {
let window = window_from_node(&*self.canvas); let window = window_from_node(&*self.canvas);
canvas_utils::request_image_from_cache(window.r(), url) canvas_utils::request_image_from_cache(&window, url)
} }
fn create_drawable_rect(&self, x: f64, y: f64, w: f64, h: f64) -> Option<Rect<f32>> { fn create_drawable_rect(&self, x: f64, y: f64, w: f64, h: f64) -> Option<Rect<f32>> {
@ -941,14 +938,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
}, },
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => { StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => {
self.state.borrow_mut().stroke_style = self.state.borrow_mut().stroke_style =
CanvasFillOrStrokeStyle::Gradient(JS::from_ref(gradient.r())); CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient));
let msg = CanvasMsg::Canvas2d( let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style())); Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap(); self.ipc_renderer.send(msg).unwrap();
}, },
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => { StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => {
self.state.borrow_mut().stroke_style = self.state.borrow_mut().stroke_style =
CanvasFillOrStrokeStyle::Pattern(JS::from_ref(pattern.r())); CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern));
let msg = CanvasMsg::Canvas2d( let msg = CanvasMsg::Canvas2d(
Canvas2dMsg::SetStrokeStyle(pattern.to_fill_or_stroke_style())); Canvas2dMsg::SetStrokeStyle(pattern.to_fill_or_stroke_style()));
self.ipc_renderer.send(msg).unwrap(); self.ipc_renderer.send(msg).unwrap();
@ -1162,7 +1159,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
// https://html.spec.whatwg.org/multipage/#img-error // https://html.spec.whatwg.org/multipage/#img-error
// If the image argument is an HTMLImageElement object that is in the broken state, // If the image argument is an HTMLImageElement object that is in the broken state,
// then throw an InvalidStateError exception // then throw an InvalidStateError exception
try!(self.fetch_image_data(&image.r()).ok_or(Error::InvalidState)) try!(self.fetch_image_data(image).ok_or(Error::InvalidState))
}, },
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => { HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => {
let _ = canvas.get_or_init_2d_context(); let _ = canvas.get_or_init_2d_context();

View file

@ -33,6 +33,6 @@ impl Comment {
pub fn Constructor(global: &GlobalScope, data: DOMString) -> Fallible<Root<Comment>> { pub fn Constructor(global: &GlobalScope, data: DOMString) -> Fallible<Root<Comment>> {
let document = global.as_window().Document(); let document = global.as_window().Document();
Ok(Comment::new(data, document.r())) Ok(Comment::new(data, &document))
} }
} }

View file

@ -207,7 +207,7 @@ impl DedicatedWorkerGlobalScope {
} }
{ {
let _ar = AutoWorkerReset::new(global.r(), worker); let _ar = AutoWorkerReset::new(&global, worker);
scope.execute_script(DOMString::from(source)); scope.execute_script(DOMString::from(source));
} }

View file

@ -539,7 +539,7 @@ impl Document {
if &*(*elements)[head] == elem { if &*(*elements)[head] == elem {
head += 1; head += 1;
} }
if new_node == node.r() || head == elements.len() { if new_node == &*node || head == elements.len() {
break; break;
} }
} }
@ -1043,7 +1043,7 @@ impl Document {
} }
// Store the current mouse over target for next frame. // Store the current mouse over target for next frame.
prev_mouse_over_target.set(maybe_new_target.as_ref().map(|target| target.r())); prev_mouse_over_target.set(maybe_new_target.r());
self.window.reflow(ReflowGoal::ForDisplay, self.window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery, ReflowQueryType::NoQuery,
@ -1104,7 +1104,7 @@ impl Document {
let touch = Touch::new(window, let touch = Touch::new(window,
identifier, identifier,
target.r(), &target,
client_x, client_x,
client_y, // TODO: Get real screen coordinates? client_y, // TODO: Get real screen coordinates?
client_x, client_x,
@ -1163,7 +1163,7 @@ impl Document {
false, false,
false); false);
let event = event.upcast::<Event>(); let event = event.upcast::<Event>();
let result = event.fire(target.r()); let result = event.fire(&target);
window.reflow(ReflowGoal::ForDisplay, window.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery, ReflowQueryType::NoQuery,
@ -1308,13 +1308,13 @@ impl Document {
for node in nodes { for node in nodes {
match node { match node {
NodeOrString::Node(node) => { NodeOrString::Node(node) => {
try!(fragment.AppendChild(node.r())); try!(fragment.AppendChild(&node));
}, },
NodeOrString::String(string) => { NodeOrString::String(string) => {
let node = Root::upcast::<Node>(self.CreateTextNode(string)); let node = Root::upcast::<Node>(self.CreateTextNode(string));
// No try!() here because appending a text node // No try!() here because appending a text node
// should not fail. // should not fail.
fragment.AppendChild(node.r()).unwrap(); fragment.AppendChild(&node).unwrap();
} }
} }
} }
@ -1444,9 +1444,7 @@ impl Document {
let mut animation_frame_list = let mut animation_frame_list =
mem::replace(&mut *self.animation_frame_list.borrow_mut(), vec![]); mem::replace(&mut *self.animation_frame_list.borrow_mut(), vec![]);
self.running_animation_callbacks.set(true); self.running_animation_callbacks.set(true);
let performance = self.window.Performance(); let timing = self.window.Performance().Now();
let performance = performance.r();
let timing = performance.Now();
for (_, callback) in animation_frame_list.drain(..) { for (_, callback) in animation_frame_list.drain(..) {
if let Some(callback) = callback { if let Some(callback) = callback {
@ -1506,8 +1504,8 @@ impl Document {
// A finished resource load can potentially unblock parsing. In that case, resume the // A finished resource load can potentially unblock parsing. In that case, resume the
// parser so its loop can find out. // parser so its loop can find out.
if let Some(parser) = self.get_current_parser() { if let Some(parser) = self.get_current_parser() {
if parser.r().is_suspended() { if parser.is_suspended() {
parser.r().resume(); parser.resume();
} }
} else if self.reflow_timeout.get().is_none() { } else if self.reflow_timeout.get().is_none() {
// If we don't have a parser, and the reflow timer has been reset, explicitly // If we don't have a parser, and the reflow timer has been reset, explicitly
@ -1859,7 +1857,6 @@ impl Document {
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Document>> { pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Document>> {
let win = global.as_window(); let win = global.as_window();
let doc = win.Document(); let doc = win.Document();
let doc = doc.r();
let docloader = DocumentLoader::new(&*doc.loader()); let docloader = DocumentLoader::new(&*doc.loader());
Ok(Document::new(win, Ok(Document::new(win,
None, None,
@ -1898,7 +1895,7 @@ impl Document {
DocumentBinding::Wrap); DocumentBinding::Wrap);
{ {
let node = document.upcast::<Node>(); let node = document.upcast::<Node>();
node.set_owner_doc(document.r()); node.set_owner_doc(&document);
} }
document document
} }
@ -1908,7 +1905,7 @@ impl Document {
let maybe_node = doc.r().map(Castable::upcast::<Node>); let maybe_node = doc.r().map(Castable::upcast::<Node>);
let iter = maybe_node.iter() let iter = maybe_node.iter()
.flat_map(|node| node.traverse_preorder()) .flat_map(|node| node.traverse_preorder())
.filter(|node| callback(node.r())); .filter(|node| callback(&node));
NodeList::new_simple_list(&self.window, iter) NodeList::new_simple_list(&self.window, iter)
} }
@ -2592,7 +2589,7 @@ impl DocumentMethods for Document {
// Step 2. // Step 2.
let old_body = self.GetBody(); let old_body = self.GetBody();
if old_body.as_ref().map(|body| body.r()) == Some(new_body) { if old_body.r() == Some(new_body) {
return Ok(()); return Ok(());
} }
@ -2875,7 +2872,7 @@ impl DocumentMethods for Document {
{ {
// Step 1. // Step 1.
let mut elements = root.traverse_preorder() let mut elements = root.traverse_preorder()
.filter(|node| filter_by_name(&name, node.r())) .filter(|node| filter_by_name(&name, &node))
.peekable(); .peekable();
if let Some(first) = elements.next() { if let Some(first) = elements.next() {
if elements.peek().is_none() { if elements.peek().is_none() {

View file

@ -41,7 +41,7 @@ impl DocumentFragment {
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DocumentFragment>> { pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DocumentFragment>> {
let document = global.as_window().Document(); let document = global.as_window().Document();
Ok(DocumentFragment::new(document.r())) Ok(DocumentFragment::new(&document))
} }
} }

View file

@ -135,7 +135,7 @@ impl DOMImplementationMethods for DOMImplementation {
{ {
// Step 3. // Step 3.
let doc_node = doc.upcast::<Node>(); let doc_node = doc.upcast::<Node>();
let doc_type = DocumentType::new(DOMString::from("html"), None, None, doc.r()); let doc_type = DocumentType::new(DOMString::from("html"), None, None, &doc);
doc_node.AppendChild(doc_type.upcast()).unwrap(); doc_node.AppendChild(doc_type.upcast()).unwrap();
} }
@ -144,14 +144,14 @@ impl DOMImplementationMethods for DOMImplementation {
let doc_node = doc.upcast::<Node>(); let doc_node = doc.upcast::<Node>();
let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(atom!("html"), let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(atom!("html"),
None, None,
doc.r())); &doc));
doc_node.AppendChild(&doc_html).expect("Appending failed"); doc_node.AppendChild(&doc_html).expect("Appending failed");
{ {
// Step 5. // Step 5.
let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(atom!("head"), let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(atom!("head"),
None, None,
doc.r())); &doc));
doc_html.AppendChild(&doc_head).unwrap(); doc_html.AppendChild(&doc_head).unwrap();
// Step 6. // Step 6.
@ -162,18 +162,18 @@ impl DOMImplementationMethods for DOMImplementation {
let doc_title = let doc_title =
Root::upcast::<Node>(HTMLTitleElement::new(atom!("title"), Root::upcast::<Node>(HTMLTitleElement::new(atom!("title"),
None, None,
doc.r())); &doc));
doc_head.AppendChild(&doc_title).unwrap(); doc_head.AppendChild(&doc_title).unwrap();
// Step 6.2. // Step 6.2.
let title_text = Text::new(title_str, doc.r()); let title_text = Text::new(title_str, &doc);
doc_title.AppendChild(title_text.upcast()).unwrap(); doc_title.AppendChild(title_text.upcast()).unwrap();
} }
} }
} }
// Step 7. // Step 7.
let doc_body = HTMLBodyElement::new(atom!("body"), None, doc.r()); let doc_body = HTMLBodyElement::new(atom!("body"), None, &doc);
doc_html.AppendChild(doc_body.upcast()).unwrap(); doc_html.AppendChild(doc_body.upcast()).unwrap();
} }

View file

@ -57,7 +57,6 @@ impl DOMParserMethods for DOMParser {
let content_type = let content_type =
DOMString::from(DOMParserBinding::SupportedTypeValues::strings[ty as usize]); DOMString::from(DOMParserBinding::SupportedTypeValues::strings[ty as usize]);
let doc = self.window.Document(); let doc = self.window.Document();
let doc = doc.r();
let loader = DocumentLoader::new(&*doc.loader()); let loader = DocumentLoader::new(&*doc.loader());
match ty { match ty {
Text_html => { Text_html => {
@ -71,7 +70,7 @@ impl DOMParserMethods for DOMParser {
loader, loader,
None, None,
None); None);
parse_html(document.r(), s, url, ParseContext::Owner(None)); parse_html(&document, s, url, ParseContext::Owner(None));
document.set_ready_state(DocumentReadyState::Complete); document.set_ready_state(DocumentReadyState::Complete);
Ok(document) Ok(document)
} }
@ -87,7 +86,7 @@ impl DOMParserMethods for DOMParser {
loader, loader,
None, None,
None); None);
parse_xml(document.r(), s, url, xml::ParseContext::Owner(None)); parse_xml(&document, s, url, xml::ParseContext::Owner(None));
Ok(document) Ok(document)
} }
} }

View file

@ -28,7 +28,7 @@ impl DOMStringMap {
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> { pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
let window = window_from_node(element); let window = window_from_node(element);
reflect_dom_object(box DOMStringMap::new_inherited(element), reflect_dom_object(box DOMStringMap::new_inherited(element),
window.r(), &*window,
DOMStringMapBinding::Wrap) DOMStringMapBinding::Wrap)
} }
} }

View file

@ -33,7 +33,7 @@ impl DOMTokenList {
pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> { pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
let window = window_from_node(element); let window = window_from_node(element);
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()), reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
window.r(), &*window,
DOMTokenListBinding::Wrap) DOMTokenListBinding::Wrap)
} }
@ -55,7 +55,6 @@ impl DOMTokenListMethods for DOMTokenList {
// https://dom.spec.whatwg.org/#dom-domtokenlist-length // https://dom.spec.whatwg.org/#dom-domtokenlist-length
fn Length(&self) -> u32 { fn Length(&self) -> u32 {
self.attribute().map_or(0, |attr| { self.attribute().map_or(0, |attr| {
let attr = attr.r();
attr.value().as_tokens().len() attr.value().as_tokens().len()
}) as u32 }) as u32
} }
@ -72,7 +71,6 @@ impl DOMTokenListMethods for DOMTokenList {
fn Contains(&self, token: DOMString) -> bool { fn Contains(&self, token: DOMString) -> bool {
let token = Atom::from(token); let token = Atom::from(token);
self.attribute().map_or(false, |attr| { self.attribute().map_or(false, |attr| {
let attr = attr.r();
attr.value() attr.value()
.as_tokens() .as_tokens()
.iter() .iter()

View file

@ -1208,8 +1208,7 @@ impl Element {
pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> { pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> {
self.get_attribute(&ns!(), local_name).map(|attr| { self.get_attribute(&ns!(), local_name).map(|attr| {
attr.r() attr.value()
.value()
.as_tokens() .as_tokens()
.to_vec() .to_vec()
}).unwrap_or(vec!()) }).unwrap_or(vec!())
@ -1235,7 +1234,7 @@ impl Element {
match attribute { match attribute {
Some(ref attribute) => { Some(ref attribute) => {
match *attribute.r().value() { match *attribute.value() {
AttrValue::Int(_, value) => value, AttrValue::Int(_, value) => value,
_ => panic!("Expected an AttrValue::Int: \ _ => panic!("Expected an AttrValue::Int: \
implement parse_plain_attribute"), implement parse_plain_attribute"),
@ -1502,7 +1501,7 @@ impl ElementMethods for Element {
let old_attr = Root::from_ref(&*self.attrs.borrow()[position]); let old_attr = Root::from_ref(&*self.attrs.borrow()[position]);
// Step 3. // Step 3.
if old_attr.r() == attr { if &*old_attr == attr {
return Ok(Some(Root::from_ref(attr))); return Ok(Some(Root::from_ref(attr)));
} }
@ -1565,7 +1564,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname // https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
fn GetElementsByTagName(&self, localname: DOMString) -> Root<HTMLCollection> { fn GetElementsByTagName(&self, localname: DOMString) -> Root<HTMLCollection> {
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::by_tag_name(window.r(), self.upcast(), localname) HTMLCollection::by_tag_name(&window, self.upcast(), localname)
} }
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens // https://dom.spec.whatwg.org/#dom-element-getelementsbytagnamens
@ -1574,13 +1573,13 @@ impl ElementMethods for Element {
localname: DOMString) localname: DOMString)
-> Root<HTMLCollection> { -> Root<HTMLCollection> {
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::by_tag_name_ns(window.r(), self.upcast(), localname, maybe_ns) HTMLCollection::by_tag_name_ns(&window, self.upcast(), localname, maybe_ns)
} }
// https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname // https://dom.spec.whatwg.org/#dom-element-getelementsbyclassname
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> { fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::by_class_name(window.r(), self.upcast(), classes) HTMLCollection::by_class_name(&window, self.upcast(), classes)
} }
// https://drafts.csswg.org/cssom-view/#dom-element-getclientrects // https://drafts.csswg.org/cssom-view/#dom-element-getclientrects
@ -1594,7 +1593,7 @@ impl ElementMethods for Element {
rect.size.width.to_f64_px(), rect.size.width.to_f64_px(),
rect.size.height.to_f64_px()) rect.size.height.to_f64_px())
}); });
DOMRectList::new(win.r(), rects) DOMRectList::new(&win, rects)
} }
// https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect // https://drafts.csswg.org/cssom-view/#dom-element-getboundingclientrect
@ -1911,7 +1910,7 @@ impl ElementMethods for Element {
// Step 4. // Step 4.
NodeTypeId::DocumentFragment => { NodeTypeId::DocumentFragment => {
let body_elem = Element::create(QualName::new(ns!(html), atom!("body")), let body_elem = Element::create(QualName::new(ns!(html), atom!("body")),
None, context_document.r(), None, &context_document,
ElementCreator::ScriptCreated); ElementCreator::ScriptCreated);
Root::upcast(body_elem) Root::upcast(body_elem)
}, },
@ -1938,7 +1937,7 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-parentnode-children // https://dom.spec.whatwg.org/#dom-parentnode-children
fn Children(&self) -> Root<HTMLCollection> { fn Children(&self) -> Root<HTMLCollection> {
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::children(window.r(), self.upcast()) HTMLCollection::children(&window, self.upcast())
} }
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild // https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
@ -2638,8 +2637,6 @@ impl Element {
return; return;
} }
for ancestor in node.ancestors() { for ancestor in node.ancestors() {
let ancestor = ancestor;
let ancestor = ancestor.r();
if !ancestor.is::<HTMLFieldSetElement>() { if !ancestor.is::<HTMLFieldSetElement>() {
continue; continue;
} }

View file

@ -68,7 +68,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity // https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> { fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self); let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast()) ValidityState::new(&window, self.upcast())
} }
// https://html.spec.whatwg.org/multipage/#dom-fe-disabled // https://html.spec.whatwg.org/multipage/#dom-fe-disabled
@ -293,7 +293,7 @@ impl Activatable for HTMLButtonElement {
node.query_selector_iter(DOMString::from("button[type=submit]")).unwrap() node.query_selector_iter(DOMString::from("button[type=submit]")).unwrap()
.filter_map(Root::downcast::<HTMLButtonElement>) .filter_map(Root::downcast::<HTMLButtonElement>)
.find(|r| r.form_owner() == owner) .find(|r| r.form_owner() == owner)
.map(|s| synthetic_click_activation(s.r().as_element(), .map(|s| synthetic_click_activation(s.as_element(),
ctrl_key, ctrl_key,
shift_key, shift_key,
alt_key, alt_key,

View file

@ -106,7 +106,7 @@ impl HTMLCollection {
fn set_cached_cursor(&self, index: u32, element: Option<Root<Element>>) -> Option<Root<Element>> { fn set_cached_cursor(&self, index: u32, element: Option<Root<Element>>) -> Option<Root<Element>> {
if let Some(element) = element { if let Some(element) = element {
self.cached_cursor_index.set(OptionU32::some(index)); self.cached_cursor_index.set(OptionU32::some(index));
self.cached_cursor_element.set(Some(element.r())); self.cached_cursor_element.set(Some(&element));
Some(element) Some(element)
} else { } else {
None None
@ -284,13 +284,13 @@ impl HTMLCollectionMethods for HTMLCollection {
// Iterate forwards, starting at the cursor. // Iterate forwards, starting at the cursor.
let offset = index - (cached_index + 1); let offset = index - (cached_index + 1);
let node: Root<Node> = Root::upcast(element); let node: Root<Node> = Root::upcast(element);
self.set_cached_cursor(index, self.elements_iter_after(node.r()).nth(offset as usize)) self.set_cached_cursor(index, self.elements_iter_after(&node).nth(offset as usize))
} else { } else {
// The cursor is after the element we're looking for // The cursor is after the element we're looking for
// Iterate backwards, starting at the cursor. // Iterate backwards, starting at the cursor.
let offset = cached_index - (index + 1); let offset = cached_index - (index + 1);
let node: Root<Node> = Root::upcast(element); let node: Root<Node> = Root::upcast(element);
self.set_cached_cursor(index, self.elements_iter_before(node.r()).nth(offset as usize)) self.set_cached_cursor(index, self.elements_iter_before(&node).nth(offset as usize))
} }
} else { } else {
// Cache miss // Cache miss

View file

@ -52,6 +52,6 @@ impl HTMLDataListElementMethods for HTMLDataListElement {
} }
let filter = box HTMLDataListOptionsFilter; let filter = box HTMLDataListOptionsFilter;
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::create(window.r(), self.upcast(), filter) HTMLCollection::create(&window, self.upcast(), filter)
} }
} }

View file

@ -79,6 +79,6 @@ impl HTMLDialogElementMethods for HTMLDialogElement {
// TODO: Step 4 implement pending dialog stack removal // TODO: Step 4 implement pending dialog stack removal
// Step 5 // Step 5
win.dom_manipulation_task_source().queue_simple_event(target, atom!("close"), win.r()); win.dom_manipulation_task_source().queue_simple_event(target, atom!("close"), &win);
} }
} }

View file

@ -93,7 +93,6 @@ impl HTMLElement {
}, },
_ => { _ => {
if let Some(attr) = element.get_attribute(&ns!(), &atom!("draggable")) { if let Some(attr) = element.get_attribute(&ns!(), &atom!("draggable")) {
let attr = attr.r();
let value = attr.value(); let value = attr.value();
let is_true = match *value { let is_true = match *value {
AttrValue::String(ref string) => string == "true", AttrValue::String(ref string) => string == "true",
@ -116,7 +115,7 @@ impl HTMLElementMethods for HTMLElement {
fn Style(&self) -> Root<CSSStyleDeclaration> { fn Style(&self) -> Root<CSSStyleDeclaration> {
self.style_decl.or_init(|| { self.style_decl.or_init(|| {
let global = window_from_node(self); let global = window_from_node(self);
CSSStyleDeclaration::new(global.r(), self.upcast::<Element>(), None, CSSModificationAccess::ReadWrite) CSSStyleDeclaration::new(&global, self.upcast::<Element>(), None, CSSModificationAccess::ReadWrite)
}) })
} }
@ -482,7 +481,7 @@ impl HTMLElement {
let id = element.Id(); let id = element.Id();
let id = match &id as &str { let id = match &id as &str {
"" => return NodeList::new_simple_list(window.r(), ancestors), "" => return NodeList::new_simple_list(&window, ancestors),
id => id, id => id,
}; };
@ -495,7 +494,7 @@ impl HTMLElement {
.filter(|elem| elem.get_string_attribute(&atom!("for")) == id) .filter(|elem| elem.get_string_attribute(&atom!("for")) == id)
.map(Root::upcast::<Node>); .map(Root::upcast::<Node>);
NodeList::new_simple_list(window.r(), children.chain(ancestors)) NodeList::new_simple_list(&window, children.chain(ancestors))
} }
} }

View file

@ -59,13 +59,13 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
} }
let filter = box ElementsFilter; let filter = box ElementsFilter;
let window = window_from_node(self); let window = window_from_node(self);
HTMLCollection::create(window.r(), self.upcast(), filter) HTMLCollection::create(&window, self.upcast(), filter)
} }
// https://html.spec.whatwg.org/multipage/#dom-cva-validity // https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> { fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self); let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast()) ValidityState::new(&window, self.upcast())
} }
// https://html.spec.whatwg.org/multipage/#dom-fieldset-disabled // https://html.spec.whatwg.org/multipage/#dom-fieldset-disabled

View file

@ -220,7 +220,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
} }
let filter = box ElementsFilter { form: Root::from_ref(self) }; let filter = box ElementsFilter { form: Root::from_ref(self) };
let window = window_from_node(self); let window = window_from_node(self);
let elements = HTMLFormControlsCollection::new(window.r(), self.upcast(), filter); let elements = HTMLFormControlsCollection::new(&window, self.upcast(), filter);
self.elements.set(Some(&elements)); self.elements.set(Some(&elements));
elements elements
} }
@ -706,11 +706,11 @@ pub enum FormSubmittableElement {
impl FormSubmittableElement { impl FormSubmittableElement {
fn as_event_target(&self) -> &EventTarget { fn as_event_target(&self) -> &EventTarget {
match *self { match *self {
FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(), FormSubmittableElement::ButtonElement(ref button) => button.upcast(),
FormSubmittableElement::InputElement(ref input) => input.r().upcast(), FormSubmittableElement::InputElement(ref input) => input.upcast(),
FormSubmittableElement::ObjectElement(ref object) => object.r().upcast(), FormSubmittableElement::ObjectElement(ref object) => object.upcast(),
FormSubmittableElement::SelectElement(ref select) => select.r().upcast(), FormSubmittableElement::SelectElement(ref select) => select.upcast(),
FormSubmittableElement::TextAreaElement(ref textarea) => textarea.r().upcast() FormSubmittableElement::TextAreaElement(ref textarea) => textarea.upcast()
} }
} }
} }
@ -848,7 +848,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
if self.to_element().has_attribute(attr) { if self.to_element().has_attribute(attr) {
input(self) input(self)
} else { } else {
self.form_owner().map_or(DOMString::new(), |t| owner(t.r())) self.form_owner().map_or(DOMString::new(), |t| owner(&t))
} }
} }
@ -863,7 +863,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
if self.to_element().has_attribute(attr) { if self.to_element().has_attribute(attr) {
input(self) input(self)
} else { } else {
self.form_owner().map_or(false, |t| owner(t.r())) self.form_owner().map_or(false, |t| owner(&t))
} }
} }

View file

@ -220,7 +220,6 @@ impl HTMLIFrameElement {
pub fn set_visible(&self, visible: bool) { pub fn set_visible(&self, visible: bool) {
if let Some(pipeline_id) = self.pipeline_id.get() { if let Some(pipeline_id) = self.pipeline_id.get() {
let window = window_from_node(self); let window = window_from_node(self);
let window = window.r();
let msg = ConstellationMsg::SetVisible(pipeline_id, visible); let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap(); window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
} }
@ -265,7 +264,6 @@ impl HTMLIFrameElement {
pub fn get_content_window(&self) -> Option<Root<Window>> { pub fn get_content_window(&self) -> Option<Root<Window>> {
self.pipeline_id.get().and_then(|pipeline_id| { self.pipeline_id.get().and_then(|pipeline_id| {
let window = window_from_node(self); let window = window_from_node(self);
let window = window.r();
let browsing_context = window.browsing_context(); let browsing_context = window.browsing_context();
browsing_context.find_child_by_id(pipeline_id) browsing_context.find_child_by_id(pipeline_id)
}) })

View file

@ -87,7 +87,6 @@ impl Runnable for ImageResponseHandlerRunnable {
fn handler(self: Box<Self>) { fn handler(self: Box<Self>) {
// Update the image field // Update the image field
let element = self.element.root(); let element = self.element.root();
let element_ref = element.r();
let (image, metadata, trigger_image_load, trigger_image_error) = match self.image { let (image, metadata, trigger_image_load, trigger_image_error) = match self.image {
ImageResponse::Loaded(image) | ImageResponse::PlaceholderLoaded(image) => { ImageResponse::Loaded(image) | ImageResponse::PlaceholderLoaded(image) => {
(Some(image.clone()), Some(ImageMetadata { height: image.height, width: image.width } ), true, false) (Some(image.clone()), Some(ImageMetadata { height: image.height, width: image.width } ), true, false)
@ -97,8 +96,8 @@ impl Runnable for ImageResponseHandlerRunnable {
} }
ImageResponse::None => (None, None, false, true) ImageResponse::None => (None, None, false, true)
}; };
element_ref.current_request.borrow_mut().image = image; element.current_request.borrow_mut().image = image;
element_ref.current_request.borrow_mut().metadata = metadata; element.current_request.borrow_mut().metadata = metadata;
// Mark the node dirty // Mark the node dirty
let document = document_from_node(&*element); let document = document_from_node(&*element);
@ -115,7 +114,7 @@ impl Runnable for ImageResponseHandlerRunnable {
} }
// Trigger reflow // Trigger reflow
let window = window_from_node(document.r()); let window = window_from_node(&*document);
window.add_pending_reflow(); window.add_pending_reflow();
} }
} }
@ -229,7 +228,7 @@ impl HTMLImageElement {
width: Option<u32>, width: Option<u32>,
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> { height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
let document = global.as_window().Document(); let document = global.as_window().Document();
let image = HTMLImageElement::new(atom!("img"), None, document.r()); let image = HTMLImageElement::new(atom!("img"), None, &document);
if let Some(w) = width { if let Some(w) = width {
image.SetWidth(w); image.SetWidth(w);
} }

View file

@ -412,7 +412,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
ValueMode::Filename => { ValueMode::Filename => {
if value.is_empty() { if value.is_empty() {
let window = window_from_node(self); let window = window_from_node(self);
let fl = FileList::new(window.r(), vec![]); let fl = FileList::new(&window, vec![]);
self.filelist.set(Some(&fl)); self.filelist.set(Some(&fl));
} else { } else {
return Err(Error::InvalidState); return Err(Error::InvalidState);
@ -595,7 +595,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
atom!("select"), atom!("select"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
window.r()); &window);
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
} }
@ -631,7 +631,7 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>)
owner: Option<&HTMLFormElement>, group: Option<&Atom>) { owner: Option<&HTMLFormElement>, group: Option<&Atom>) {
let iter = doc_node.query_selector_iter(DOMString::from("input[type=radio]")).unwrap() let iter = doc_node.query_selector_iter(DOMString::from("input[type=radio]")).unwrap()
.filter_map(Root::downcast::<HTMLInputElement>) .filter_map(Root::downcast::<HTMLInputElement>)
.filter(|r| in_same_group(r.r(), owner, group) && broadcaster != r.r()); .filter(|r| in_same_group(&r, owner, group) && broadcaster != &**r);
for ref r in iter { for ref r in iter {
if r.Checked() { if r.Checked() {
r.SetChecked(false); r.SetChecked(false);
@ -813,7 +813,7 @@ impl HTMLInputElement {
match recv.recv().expect("IpcSender side error") { match recv.recv().expect("IpcSender side error") {
Ok(selected_files) => { Ok(selected_files) => {
for selected in selected_files { for selected in selected_files {
files.push(File::new_from_selected(window.r(), selected)); files.push(File::new_from_selected(&window, selected));
} }
}, },
Err(err) => error = Some(err), Err(err) => error = Some(err),
@ -836,7 +836,7 @@ impl HTMLInputElement {
match recv.recv().expect("IpcSender side error") { match recv.recv().expect("IpcSender side error") {
Ok(selected) => { Ok(selected) => {
files.push(File::new_from_selected(window.r(), selected)); files.push(File::new_from_selected(&window, selected));
}, },
Err(err) => error = Some(err), Err(err) => error = Some(err),
}; };
@ -845,7 +845,7 @@ impl HTMLInputElement {
if let Some(err) = error { if let Some(err) = error {
debug!("Input file select error: {:?}", err); debug!("Input file select error: {:?}", err);
} else { } else {
let filelist = FileList::new(window.r(), files); let filelist = FileList::new(&window, files);
self.filelist.set(Some(&filelist)); self.filelist.set(Some(&filelist));
target.fire_event("input", target.fire_event("input",
@ -931,7 +931,7 @@ impl VirtualMethods for HTMLInputElement {
if new_type == InputType::InputFile { if new_type == InputType::InputFile {
let window = window_from_node(self); let window = window_from_node(self);
let filelist = FileList::new(window.r(), vec![]); let filelist = FileList::new(&window, vec![]);
self.filelist.set(Some(&filelist)); self.filelist.set(Some(&filelist));
} }
@ -1124,7 +1124,7 @@ impl VirtualMethods for HTMLInputElement {
atom!("input"), atom!("input"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
window.r()); &window);
} }
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
@ -1200,7 +1200,7 @@ impl Activatable for HTMLInputElement {
.unwrap() .unwrap()
.filter_map(Root::downcast::<HTMLInputElement>) .filter_map(Root::downcast::<HTMLInputElement>)
.find(|r| { .find(|r| {
in_same_group(r.r(), owner.r(), group.as_ref()) && in_same_group(&*r, owner.r(), group.as_ref()) &&
r.Checked() r.Checked()
}); });
cache.checked_radio = checked_member.r().map(JS::from_ref); cache.checked_radio = checked_member.r().map(JS::from_ref);
@ -1349,7 +1349,7 @@ impl Activatable for HTMLInputElement {
return; return;
} }
form.submit(SubmittedFrom::NotFromForm, form.submit(SubmittedFrom::NotFromForm,
FormSubmitter::FormElement(form.r())); FormSubmitter::FormElement(&form));
} }
} }
} }

View file

@ -364,10 +364,7 @@ impl FetchResponseListener for StylesheetContext {
sheet.set_media(Some(media)); sheet.set_media(Some(media));
let sheet = Arc::new(sheet); let sheet = Arc::new(sheet);
let elem = elem.r(); let win = window_from_node(&*elem);
let document = document.r();
let win = window_from_node(elem);
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap(); win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*elem.stylesheet.borrow_mut() = Some(sheet); *elem.stylesheet.borrow_mut() = Some(sheet);

View file

@ -74,7 +74,7 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity // https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> { fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self); let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast()) ValidityState::new(&window, self.upcast())
} }
// https://html.spec.whatwg.org/multipage/#dom-object-type // https://html.spec.whatwg.org/multipage/#dom-object-type

View file

@ -41,10 +41,10 @@ impl HTMLOptionsCollection {
fn add_new_elements(&self, count: u32) -> ErrorResult { fn add_new_elements(&self, count: u32) -> ErrorResult {
let root = self.upcast().root_node(); let root = self.upcast().root_node();
let document = document_from_node(root.r()); let document = document_from_node(&*root);
for _ in 0..count { for _ in 0..count {
let element = HTMLOptionElement::new(atom!("option"), None, document.r()); let element = HTMLOptionElement::new(atom!("option"), None, &document);
let node = element.upcast::<Node>(); let node = element.upcast::<Node>();
try!(root.AppendChild(node)); try!(root.AppendChild(node));
}; };
@ -94,12 +94,12 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
let node = value.upcast::<Node>(); let node = value.upcast::<Node>();
let root = self.upcast().root_node(); let root = self.upcast().root_node();
if n >= 0 { if n >= 0 {
Node::pre_insert(node, root.r(), None).map(|_| ()) Node::pre_insert(node, &root, None).map(|_| ())
} else { } else {
let child = self.upcast().IndexedGetter(index).unwrap(); let child = self.upcast().IndexedGetter(index).unwrap();
let child_node = child.r().upcast::<Node>(); let child_node = child.upcast::<Node>();
root.r().ReplaceChild(node, child_node).map(|_| ()) root.ReplaceChild(node, child_node).map(|_| ())
} }
} else { } else {
// Step 1 // Step 1
@ -138,14 +138,14 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
}; };
// Step 1 // Step 1
if node.is_ancestor_of(root.r()) { if node.is_ancestor_of(&root) {
return Err(Error::HierarchyRequest); return Err(Error::HierarchyRequest);
} }
if let Some(HTMLElementOrLong::HTMLElement(ref before_element)) = before { if let Some(HTMLElementOrLong::HTMLElement(ref before_element)) = before {
// Step 2 // Step 2
let before_node = before_element.upcast::<Node>(); let before_node = before_element.upcast::<Node>();
if !root.r().is_ancestor_of(before_node) { if !root.is_ancestor_of(before_node) {
return Err(Error::NotFound); return Err(Error::NotFound);
} }
@ -173,13 +173,13 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
}; };
// Step 6 // Step 6
Node::pre_insert(node, parent.r(), reference_node.r()).map(|_| ()) Node::pre_insert(node, &parent, reference_node.r()).map(|_| ())
} }
// https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-remove // https://html.spec.whatwg.org/multipage/#dom-htmloptionscollection-remove
fn Remove(&self, index: i32) { fn Remove(&self, index: i32) {
if let Some(element) = self.upcast().IndexedGetter(index as u32) { if let Some(element) = self.upcast().IndexedGetter(index as u32) {
element.r().Remove(); element.Remove();
} }
} }
} }

View file

@ -44,7 +44,7 @@ impl HTMLOutputElementMethods for HTMLOutputElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity // https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> { fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self); let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast()) ValidityState::new(&window, self.upcast())
} }
// https://html.spec.whatwg.org/multipage/#dom-fae-form // https://html.spec.whatwg.org/multipage/#dom-fae-form

View file

@ -210,7 +210,7 @@ impl FetchResponseListener for ScriptContext {
*elem.load.borrow_mut() = Some(load); *elem.load.borrow_mut() = Some(load);
elem.ready_to_be_parser_executed.set(true); elem.ready_to_be_parser_executed.set(true);
let document = document_from_node(elem.r()); let document = document_from_node(&*elem);
document.finish_load(LoadType::Script(self.url.clone())); document.finish_load(LoadType::Script(self.url.clone()));
} }
} }
@ -447,7 +447,7 @@ impl HTMLScriptElement {
// TODO: make this suspension happen automatically. // TODO: make this suspension happen automatically.
if was_parser_inserted { if was_parser_inserted {
if let Some(parser) = doc.get_current_parser() { if let Some(parser) = doc.get_current_parser() {
parser.r().suspend(); parser.suspend();
} }
} }
NextParserState::Suspend NextParserState::Suspend
@ -495,7 +495,6 @@ impl HTMLScriptElement {
// Step 4. // Step 4.
let document = document_from_node(self); let document = document_from_node(self);
let document = document.r();
let old_script = document.GetCurrentScript(); let old_script = document.GetCurrentScript();
// Step 5.a.1. // Step 5.a.1.
@ -521,13 +520,13 @@ impl HTMLScriptElement {
if script.external { if script.external {
self.dispatch_load_event(); self.dispatch_load_event();
} else { } else {
window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("load"), window.r()); window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("load"), &window);
} }
} }
pub fn queue_error_event(&self) { pub fn queue_error_event(&self) {
let window = window_from_node(self); let window = window_from_node(self);
window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"), window.r()); window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"), &window);
} }
pub fn dispatch_before_script_execute_event(&self) -> EventStatus { pub fn dispatch_before_script_execute_event(&self) -> EventStatus {
@ -603,7 +602,6 @@ impl HTMLScriptElement {
bubbles: EventBubbles, bubbles: EventBubbles,
cancelable: EventCancelable) -> EventStatus { cancelable: EventCancelable) -> EventStatus {
let window = window_from_node(self); let window = window_from_node(self);
let window = window.r();
let event = Event::new(window.upcast(), type_, bubbles, cancelable); let event = Event::new(window.upcast(), type_, bubbles, cancelable);
event.fire(self.upcast()) event.fire(self.upcast())
} }

View file

@ -49,7 +49,7 @@ impl CollectionFilter for OptionsFilter {
match node.GetParentNode() { match node.GetParentNode() {
Some(optgroup) => Some(optgroup) =>
optgroup.is::<HTMLOptGroupElement>() && root.is_parent_of(optgroup.r()), optgroup.is::<HTMLOptGroupElement>() && root.is_parent_of(&optgroup),
None => false, None => false,
} }
} }
@ -97,11 +97,11 @@ impl HTMLSelectElement {
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) { for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
if opt.Selected() { if opt.Selected() {
opt.set_selectedness(false); opt.set_selectedness(false);
last_selected = Some(Root::from_ref(opt.r())); last_selected = Some(Root::from_ref(&opt));
} }
let element = opt.upcast::<Element>(); let element = opt.upcast::<Element>();
if first_enabled.is_none() && !element.disabled_state() { if first_enabled.is_none() && !element.disabled_state() {
first_enabled = Some(Root::from_ref(opt.r())); first_enabled = Some(Root::from_ref(&opt));
} }
} }
@ -164,7 +164,7 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
// https://html.spec.whatwg.org/multipage/#dom-cva-validity // https://html.spec.whatwg.org/multipage/#dom-cva-validity
fn Validity(&self) -> Root<ValidityState> { fn Validity(&self) -> Root<ValidityState> {
let window = window_from_node(self); let window = window_from_node(self);
ValidityState::new(window.r(), self.upcast()) ValidityState::new(&window, self.upcast())
} }
// Note: this function currently only exists for union.html. // Note: this function currently only exists for union.html.
@ -219,8 +219,8 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
fn Options(&self) -> Root<HTMLOptionsCollection> { fn Options(&self) -> Root<HTMLOptionsCollection> {
self.options.or_init(|| { self.options.or_init(|| {
let window = window_from_node(self); let window = window_from_node(self);
HTMLOptionsCollection::new(window.r(), HTMLOptionsCollection::new(
self.upcast(), box OptionsFilter) &window, self.upcast(), box OptionsFilter)
}) })
} }

View file

@ -72,7 +72,7 @@ impl HTMLStyleElement {
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap(); win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
*self.stylesheet.borrow_mut() = Some(sheet); *self.stylesheet.borrow_mut() = Some(sheet);
let doc = document_from_node(self); let doc = document_from_node(self);
doc.r().invalidate_stylesheets(); doc.invalidate_stylesheets();
} }
pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> { pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> {

View file

@ -71,7 +71,7 @@ impl HTMLTableCellElementMethods for HTMLTableCellElement {
}; };
parent_children.filter(|c| c.is::<HTMLTableCellElement>()) parent_children.filter(|c| c.is::<HTMLTableCellElement>())
.position(|c| c.r() == self_node) .position(|c| &*c == self_node)
.map_or(-1, |p| p as i32) .map_or(-1, |p| p as i32)
} }
} }

View file

@ -117,7 +117,7 @@ impl HTMLTableElement {
let section = HTMLTableSectionElement::new(atom.clone(), let section = HTMLTableSectionElement::new(atom.clone(),
None, None,
document_from_node(self).r()); &document_from_node(self));
match atom { match atom {
&atom!("thead") => self.SetTHead(Some(&section)), &atom!("thead") => self.SetTHead(Some(&section)),
&atom!("tfoot") => self.SetTFoot(Some(&section)), &atom!("tfoot") => self.SetTFoot(Some(&section)),
@ -150,7 +150,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-rows // https://html.spec.whatwg.org/multipage/#dom-table-rows
fn Rows(&self) -> Root<HTMLCollection> { fn Rows(&self) -> Root<HTMLCollection> {
let filter = self.get_rows(); let filter = self.get_rows();
HTMLCollection::new(window_from_node(self).r(), self.upcast(), box filter) HTMLCollection::new(&window_from_node(self), self.upcast(), box filter)
} }
// https://html.spec.whatwg.org/multipage/#dom-table-caption // https://html.spec.whatwg.org/multipage/#dom-table-caption
@ -178,8 +178,8 @@ impl HTMLTableElementMethods for HTMLTableElement {
None => { None => {
let caption = HTMLTableCaptionElement::new(atom!("caption"), let caption = HTMLTableCaptionElement::new(atom!("caption"),
None, None,
document_from_node(self).r()); &document_from_node(self));
self.SetCaption(Some(caption.r())); self.SetCaption(Some(&caption));
caption caption
} }
} }
@ -264,7 +264,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
self.tbodies.or_init(|| { self.tbodies.or_init(|| {
let window = window_from_node(self); let window = window_from_node(self);
let filter = box TBodiesFilter; let filter = box TBodiesFilter;
HTMLCollection::create(window.r(), self.upcast(), filter) HTMLCollection::create(&window, self.upcast(), filter)
}) })
} }
@ -273,7 +273,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
fn CreateTBody(&self) -> Root<HTMLTableSectionElement> { fn CreateTBody(&self) -> Root<HTMLTableSectionElement> {
let tbody = HTMLTableSectionElement::new(atom!("tbody"), let tbody = HTMLTableSectionElement::new(atom!("tbody"),
None, None,
document_from_node(self).r()); &document_from_node(self));
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();
let last_tbody = let last_tbody =
node.rev_children() node.rev_children()
@ -298,7 +298,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
let new_row = HTMLTableRowElement::new(atom!("tr"), let new_row = HTMLTableRowElement::new(atom!("tr"),
None, None,
document_from_node(self).r()); &document_from_node(self));
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();
if number_of_row_elements == 0 { if number_of_row_elements == 0 {

View file

@ -77,7 +77,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
self.cells.or_init(|| { self.cells.or_init(|| {
let window = window_from_node(self); let window = window_from_node(self);
let filter = box CellsFilter; let filter = box CellsFilter;
HTMLCollection::create(window.r(), self.upcast(), filter) HTMLCollection::create(&window, self.upcast(), filter)
}) })
} }
@ -87,7 +87,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
node.insert_cell_or_row( node.insert_cell_or_row(
index, index,
|| self.Cells(), || self.Cells(),
|| HTMLTableDataCellElement::new(atom!("td"), None, node.owner_doc().r())) || HTMLTableDataCellElement::new(atom!("td"), None, &node.owner_doc()))
} }
// https://html.spec.whatwg.org/multipage/#dom-tr-deletecell // https://html.spec.whatwg.org/multipage/#dom-tr-deletecell

View file

@ -62,7 +62,7 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
node.insert_cell_or_row( node.insert_cell_or_row(
index, index,
|| self.Rows(), || self.Rows(),
|| HTMLTableRowElement::new(atom!("tr"), None, node.owner_doc().r())) || HTMLTableRowElement::new(atom!("tr"), None, &node.owner_doc()))
} }
// https://html.spec.whatwg.org/multipage/#dom-tbody-deleterow // https://html.spec.whatwg.org/multipage/#dom-tbody-deleterow

View file

@ -263,7 +263,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
atom!("select"), atom!("select"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
window.r()); &window);
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
} }
} }
@ -387,7 +387,7 @@ impl VirtualMethods for HTMLTextAreaElement {
atom!("input"), atom!("input"),
EventBubbles::Bubbles, EventBubbles::Bubbles,
EventCancelable::NotCancelable, EventCancelable::NotCancelable,
window.r()); &window);
} }
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);

View file

@ -218,7 +218,7 @@ impl Node {
}, },
Some(ref prev_sibling) => { Some(ref prev_sibling) => {
prev_sibling.next_sibling.set(Some(new_child)); prev_sibling.next_sibling.set(Some(new_child));
new_child.prev_sibling.set(Some(prev_sibling.r())); new_child.prev_sibling.set(Some(&prev_sibling));
}, },
} }
before.prev_sibling.set(Some(new_child)); before.prev_sibling.set(Some(new_child));
@ -517,7 +517,7 @@ impl Node {
} }
pub fn is_ancestor_of(&self, parent: &Node) -> bool { pub fn is_ancestor_of(&self, parent: &Node) -> bool {
parent.ancestors().any(|ancestor| ancestor.r() == self) parent.ancestors().any(|ancestor| &*ancestor == self)
} }
pub fn following_siblings(&self) -> NodeSiblingIterator { pub fn following_siblings(&self) -> NodeSiblingIterator {
@ -553,7 +553,7 @@ impl Node {
} }
pub fn is_parent_of(&self, child: &Node) -> bool { pub fn is_parent_of(&self, child: &Node) -> bool {
child.parent_node.get().map_or(false, |ref parent| parent.r() == self) child.parent_node.get().map_or(false, |parent| &*parent == self)
} }
pub fn to_trusted_node_address(&self) -> TrustedNodeAddress { pub fn to_trusted_node_address(&self) -> TrustedNodeAddress {
@ -692,7 +692,7 @@ impl Node {
let node = try!(doc.node_from_nodes_and_strings(nodes)); let node = try!(doc.node_from_nodes_and_strings(nodes));
// Step 2. // Step 2.
let first_child = self.first_child.get(); let first_child = self.first_child.get();
Node::pre_insert(node.r(), self, first_child.r()).map(|_| ()) Node::pre_insert(&node, self, first_child.r()).map(|_| ())
} }
// https://dom.spec.whatwg.org/#dom-parentnode-append // https://dom.spec.whatwg.org/#dom-parentnode-append
@ -701,7 +701,7 @@ impl Node {
let doc = self.owner_doc(); let doc = self.owner_doc();
let node = try!(doc.node_from_nodes_and_strings(nodes)); let node = try!(doc.node_from_nodes_and_strings(nodes));
// Step 2. // Step 2.
self.AppendChild(node.r()).map(|_| ()) self.AppendChild(&node).map(|_| ())
} }
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector // https://dom.spec.whatwg.org/#dom-parentnode-queryselector
@ -744,7 +744,7 @@ impl Node {
pub fn query_selector_all(&self, selectors: DOMString) -> Fallible<Root<NodeList>> { pub fn query_selector_all(&self, selectors: DOMString) -> Fallible<Root<NodeList>> {
let window = window_from_node(self); let window = window_from_node(self);
let iter = try!(self.query_selector_iter(selectors)); let iter = try!(self.query_selector_iter(selectors));
Ok(NodeList::new_simple_list(window.r(), iter)) Ok(NodeList::new_simple_list(&window, iter))
} }
pub fn ancestors(&self) -> AncestorIterator { pub fn ancestors(&self) -> AncestorIterator {
@ -789,7 +789,7 @@ impl Node {
pub fn remove_self(&self) { pub fn remove_self(&self) {
if let Some(ref parent) = self.GetParentNode() { if let Some(ref parent) = self.GetParentNode() {
Node::remove(self, parent.r(), SuppressObserver::Unsuppressed); Node::remove(self, &parent, SuppressObserver::Unsuppressed);
} }
} }
@ -827,7 +827,7 @@ impl Node {
// https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#dfn-concept-parse-fragment
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> { pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
let context_document = document_from_node(self); let context_document = document_from_node(self);
let fragment = DocumentFragment::new(context_document.r()); let fragment = DocumentFragment::new(&context_document);
if context_document.is_html_document() { if context_document.is_html_document() {
parse_html_fragment(self.upcast(), markup, fragment.upcast()); parse_html_fragment(self.upcast(), markup, fragment.upcast());
} else { } else {
@ -1502,7 +1502,7 @@ impl Node {
match child { match child {
Some(child) => { Some(child) => {
if parent.children() if parent.children()
.take_while(|c| c.r() != child) .take_while(|c| &**c != child)
.any(|c| c.is::<Element>()) .any(|c| c.is::<Element>())
{ {
return Err(Error::HierarchyRequest); return Err(Error::HierarchyRequest);
@ -1540,7 +1540,7 @@ impl Node {
// Step 4. // Step 4.
let document = document_from_node(parent); let document = document_from_node(parent);
Node::adopt(node, document.r()); Node::adopt(node, &document);
// Step 5. // Step 5.
Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed); Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed);
@ -1645,7 +1645,7 @@ impl Node {
fn pre_remove(child: &Node, parent: &Node) -> Fallible<Root<Node>> { fn pre_remove(child: &Node, parent: &Node) -> Fallible<Root<Node>> {
// Step 1. // Step 1.
match child.GetParentNode() { match child.GetParentNode() {
Some(ref node) if node.r() != parent => return Err(Error::NotFound), Some(ref node) if &**node != parent => return Err(Error::NotFound),
None => return Err(Error::NotFound), None => return Err(Error::NotFound),
_ => () _ => ()
} }
@ -1659,7 +1659,7 @@ impl Node {
// https://dom.spec.whatwg.org/#concept-node-remove // https://dom.spec.whatwg.org/#concept-node-remove
fn remove(node: &Node, parent: &Node, suppress_observers: SuppressObserver) { fn remove(node: &Node, parent: &Node, suppress_observers: SuppressObserver) {
assert!(node.GetParentNode().map_or(false, |node_parent| node_parent.r() == parent)); assert!(node.GetParentNode().map_or(false, |node_parent| &*node_parent == parent));
let cached_index = { let cached_index = {
if parent.ranges.is_empty() { if parent.ranges.is_empty() {
None None
@ -1708,11 +1708,12 @@ impl Node {
let doctype = node.downcast::<DocumentType>().unwrap(); let doctype = node.downcast::<DocumentType>().unwrap();
let doctype = DocumentType::new(doctype.name().clone(), let doctype = DocumentType::new(doctype.name().clone(),
Some(doctype.public_id().clone()), Some(doctype.public_id().clone()),
Some(doctype.system_id().clone()), document.r()); Some(doctype.system_id().clone()),
&document);
Root::upcast::<Node>(doctype) Root::upcast::<Node>(doctype)
}, },
NodeTypeId::DocumentFragment => { NodeTypeId::DocumentFragment => {
let doc_fragment = DocumentFragment::new(document.r()); let doc_fragment = DocumentFragment::new(&document);
Root::upcast::<Node>(doc_fragment) Root::upcast::<Node>(doc_fragment)
}, },
NodeTypeId::CharacterData(_) => { NodeTypeId::CharacterData(_) => {
@ -1743,7 +1744,7 @@ impl Node {
}; };
let element = Element::create(name, let element = Element::create(name,
element.prefix().as_ref().map(|p| Atom::from(&**p)), element.prefix().as_ref().map(|p| Atom::from(&**p)),
document.r(), ElementCreator::ScriptCreated); &document, ElementCreator::ScriptCreated);
Root::upcast::<Node>(element) Root::upcast::<Node>(element)
}, },
}; };
@ -1751,7 +1752,7 @@ impl Node {
// Step 3. // Step 3.
let document = match copy.downcast::<Document>() { let document = match copy.downcast::<Document>() {
Some(doc) => Root::from_ref(doc), Some(doc) => Root::from_ref(doc),
None => Root::from_ref(document.r()), None => Root::from_ref(&*document),
}; };
assert!(copy.owner_doc() == document); assert!(copy.owner_doc() == document);
@ -1779,14 +1780,14 @@ impl Node {
} }
// Step 5: cloning steps. // Step 5: cloning steps.
vtable_for(&node).cloning_steps(copy.r(), maybe_doc, clone_children); vtable_for(&node).cloning_steps(&copy, maybe_doc, clone_children);
// Step 6. // Step 6.
if clone_children == CloneChildrenFlag::CloneChildren { if clone_children == CloneChildrenFlag::CloneChildren {
for child in node.children() { for child in node.children() {
let child_copy = Node::clone(child.r(), Some(document.r()), let child_copy = Node::clone(&child, Some(&document),
clone_children); clone_children);
let _inserted_node = Node::pre_insert(child_copy.r(), copy.r(), None); let _inserted_node = Node::pre_insert(&child_copy, &copy, None);
} }
} }
@ -2121,12 +2122,12 @@ impl NodeMethods for Node {
NodeTypeId::DocumentType => { NodeTypeId::DocumentType => {
if self.children() if self.children()
.any(|c| c.is_doctype() && .any(|c| c.is_doctype() &&
c.r() != child) &*c != child)
{ {
return Err(Error::HierarchyRequest); return Err(Error::HierarchyRequest);
} }
if self.children() if self.children()
.take_while(|c| c.r() != child) .take_while(|c| &**c != child)
.any(|c| c.is::<Element>()) .any(|c| c.is::<Element>())
{ {
return Err(Error::HierarchyRequest); return Err(Error::HierarchyRequest);
@ -2151,7 +2152,7 @@ impl NodeMethods for Node {
// Step 10. // Step 10.
let document = document_from_node(self); let document = document_from_node(self);
Node::adopt(node, document.r()); Node::adopt(node, &document);
let removed_child = if node != child { let removed_child = if node != child {
// Step 11. // Step 11.
@ -2294,7 +2295,7 @@ impl NodeMethods for Node {
// Step 6. // Step 6.
this.children().zip(node.children()).all(|(child, other_child)| { this.children().zip(node.children()).all(|(child, other_child)| {
is_equal_node(child.r(), other_child.r()) is_equal_node(&child, &other_child)
}) })
} }
match maybe_node { match maybe_node {
@ -2322,7 +2323,7 @@ impl NodeMethods for Node {
let mut lastself = Root::from_ref(self); let mut lastself = Root::from_ref(self);
let mut lastother = Root::from_ref(other); let mut lastother = Root::from_ref(other);
for ancestor in self.ancestors() { for ancestor in self.ancestors() {
if ancestor.r() == other { if &*ancestor == other {
// step 4. // step 4.
return NodeConstants::DOCUMENT_POSITION_CONTAINS + return NodeConstants::DOCUMENT_POSITION_CONTAINS +
NodeConstants::DOCUMENT_POSITION_PRECEDING; NodeConstants::DOCUMENT_POSITION_PRECEDING;
@ -2330,7 +2331,7 @@ impl NodeMethods for Node {
lastself = ancestor; lastself = ancestor;
} }
for ancestor in other.ancestors() { for ancestor in other.ancestors() {
if ancestor.r() == self { if &*ancestor == self {
// step 5. // step 5.
return NodeConstants::DOCUMENT_POSITION_CONTAINED_BY + return NodeConstants::DOCUMENT_POSITION_CONTAINED_BY +
NodeConstants::DOCUMENT_POSITION_FOLLOWING; NodeConstants::DOCUMENT_POSITION_FOLLOWING;
@ -2354,11 +2355,11 @@ impl NodeMethods for Node {
} }
for child in lastself.traverse_preorder() { for child in lastself.traverse_preorder() {
if child.r() == other { if &*child == other {
// step 6. // step 6.
return NodeConstants::DOCUMENT_POSITION_PRECEDING; return NodeConstants::DOCUMENT_POSITION_PRECEDING;
} }
if child.r() == self { if &*child == self {
// step 7. // step 7.
return NodeConstants::DOCUMENT_POSITION_FOLLOWING; return NodeConstants::DOCUMENT_POSITION_FOLLOWING;
} }

View file

@ -107,12 +107,12 @@ impl NodeIteratorMethods for NodeIterator {
before_node = false; before_node = false;
// Step 3-2. // Step 3-2.
let result = try!(self.accept_node(node.r())); let result = try!(self.accept_node(&node));
// Step 3-3. // Step 3-3.
if result == NodeFilterConstants::FILTER_ACCEPT { if result == NodeFilterConstants::FILTER_ACCEPT {
// Step 4. // Step 4.
self.reference_node.set(node.r()); self.reference_node.set(&node);
self.pointer_before_reference_node.set(before_node); self.pointer_before_reference_node.set(before_node);
return Ok(Some(node)); return Ok(Some(node));
@ -122,12 +122,12 @@ impl NodeIteratorMethods for NodeIterator {
// Step 3-1. // Step 3-1.
for following_node in node.following_nodes(&self.root_node) { for following_node in node.following_nodes(&self.root_node) {
// Step 3-2. // Step 3-2.
let result = try!(self.accept_node(following_node.r())); let result = try!(self.accept_node(&following_node));
// Step 3-3. // Step 3-3.
if result == NodeFilterConstants::FILTER_ACCEPT { if result == NodeFilterConstants::FILTER_ACCEPT {
// Step 4. // Step 4.
self.reference_node.set(following_node.r()); self.reference_node.set(&following_node);
self.pointer_before_reference_node.set(before_node); self.pointer_before_reference_node.set(before_node);
return Ok(Some(following_node)); return Ok(Some(following_node));
@ -151,12 +151,12 @@ impl NodeIteratorMethods for NodeIterator {
before_node = true; before_node = true;
// Step 3-2. // Step 3-2.
let result = try!(self.accept_node(node.r())); let result = try!(self.accept_node(&node));
// Step 3-3. // Step 3-3.
if result == NodeFilterConstants::FILTER_ACCEPT { if result == NodeFilterConstants::FILTER_ACCEPT {
// Step 4. // Step 4.
self.reference_node.set(node.r()); self.reference_node.set(&node);
self.pointer_before_reference_node.set(before_node); self.pointer_before_reference_node.set(before_node);
return Ok(Some(node)); return Ok(Some(node));
@ -166,12 +166,12 @@ impl NodeIteratorMethods for NodeIterator {
// Step 3-1. // Step 3-1.
for preceding_node in node.preceding_nodes(&self.root_node) { for preceding_node in node.preceding_nodes(&self.root_node) {
// Step 3-2. // Step 3-2.
let result = try!(self.accept_node(preceding_node.r())); let result = try!(self.accept_node(&preceding_node));
// Step 3-3. // Step 3-3.
if result == NodeFilterConstants::FILTER_ACCEPT { if result == NodeFilterConstants::FILTER_ACCEPT {
// Step 4. // Step 4.
self.reference_node.set(preceding_node.r()); self.reference_node.set(&preceding_node);
self.pointer_before_reference_node.set(before_node); self.pointer_before_reference_node.set(before_node);
return Ok(Some(preceding_node)); return Ok(Some(preceding_node));

View file

@ -174,7 +174,7 @@ impl ChildrenList {
.nth(index as usize) .nth(index as usize)
.unwrap() .unwrap()
}; };
self.last_visited.set(Some(last_visited.r())); self.last_visited.set(Some(&last_visited));
self.last_index.set(index); self.last_index.set(index);
Some(last_visited) Some(last_visited)
} }

View file

@ -38,7 +38,7 @@ impl PerformanceTiming {
-> Root<PerformanceTiming> { -> Root<PerformanceTiming> {
let timing = PerformanceTiming::new_inherited(navigation_start, let timing = PerformanceTiming::new_inherited(navigation_start,
navigation_start_precise, navigation_start_precise,
window.Document().r()); &window.Document());
reflect_dom_object(box timing, reflect_dom_object(box timing,
window, window,
PerformanceTimingBinding::Wrap) PerformanceTimingBinding::Wrap)

View file

@ -72,7 +72,7 @@ impl Range {
// https://dom.spec.whatwg.org/#dom-range // https://dom.spec.whatwg.org/#dom-range
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Range>> { pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Range>> {
let document = global.as_window().Document(); let document = global.as_window().Document();
Ok(Range::new_with_doc(document.r())) Ok(Range::new_with_doc(&document))
} }
// https://dom.spec.whatwg.org/#contained // https://dom.spec.whatwg.org/#contained
@ -100,7 +100,7 @@ impl Range {
let common_ancestor = self.CommonAncestorContainer(); let common_ancestor = self.CommonAncestorContainer();
let first_contained_child = let first_contained_child =
if start_node.is_inclusive_ancestor_of(end_node.r()) { if start_node.is_inclusive_ancestor_of(&end_node) {
// Step 7. // Step 7.
None None
} else { } else {
@ -110,7 +110,7 @@ impl Range {
}; };
let last_contained_child = let last_contained_child =
if end_node.is_inclusive_ancestor_of(start_node.r()) { if end_node.is_inclusive_ancestor_of(&start_node) {
// Step 9. // Step 9.
None None
} else { } else {
@ -270,25 +270,25 @@ impl RangeMethods for Range {
// https://dom.spec.whatwg.org/#dom-range-setstartbefore // https://dom.spec.whatwg.org/#dom-range-setstartbefore
fn SetStartBefore(&self, node: &Node) -> ErrorResult { fn SetStartBefore(&self, node: &Node) -> ErrorResult {
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType)); let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
self.SetStart(parent.r(), node.index()) self.SetStart(&parent, node.index())
} }
// https://dom.spec.whatwg.org/#dom-range-setstartafter // https://dom.spec.whatwg.org/#dom-range-setstartafter
fn SetStartAfter(&self, node: &Node) -> ErrorResult { fn SetStartAfter(&self, node: &Node) -> ErrorResult {
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType)); let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
self.SetStart(parent.r(), node.index() + 1) self.SetStart(&parent, node.index() + 1)
} }
// https://dom.spec.whatwg.org/#dom-range-setendbefore // https://dom.spec.whatwg.org/#dom-range-setendbefore
fn SetEndBefore(&self, node: &Node) -> ErrorResult { fn SetEndBefore(&self, node: &Node) -> ErrorResult {
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType)); let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
self.SetEnd(parent.r(), node.index()) self.SetEnd(&parent, node.index())
} }
// https://dom.spec.whatwg.org/#dom-range-setendafter // https://dom.spec.whatwg.org/#dom-range-setendafter
fn SetEndAfter(&self, node: &Node) -> ErrorResult { fn SetEndAfter(&self, node: &Node) -> ErrorResult {
let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType)); let parent = try!(node.GetParentNode().ok_or(Error::InvalidNodeType));
self.SetEnd(parent.r(), node.index() + 1) self.SetEnd(&parent, node.index() + 1)
} }
// https://dom.spec.whatwg.org/#dom-range-collapse // https://dom.spec.whatwg.org/#dom-range-collapse
@ -417,9 +417,9 @@ impl RangeMethods for Range {
// Step 4. // Step 4.
let offset = node.index(); let offset = node.index();
// Step 5. // Step 5.
Ordering::Greater == bp_position(parent.r(), offset + 1, Ordering::Greater == bp_position(&parent, offset + 1,
&start_node, self.StartOffset()).unwrap() && &start_node, self.StartOffset()).unwrap() &&
Ordering::Less == bp_position(parent.r(), offset, Ordering::Less == bp_position(&parent, offset,
&self.EndContainer(), self.EndOffset()).unwrap() &self.EndContainer(), self.EndOffset()).unwrap()
} }
@ -433,7 +433,7 @@ impl RangeMethods for Range {
let end_offset = self.EndOffset(); let end_offset = self.EndOffset();
// Step 1. // Step 1.
let fragment = DocumentFragment::new(start_node.owner_doc().r()); let fragment = DocumentFragment::new(&start_node.owner_doc());
// Step 2. // Step 2.
if self.start == self.end { if self.start == self.end {
@ -471,10 +471,10 @@ impl RangeMethods for Range {
// Step 14.2. // Step 14.2.
try!(fragment.upcast::<Node>().AppendChild(&clone)); try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 14.3. // Step 14.3.
let subrange = Range::new(clone.owner_doc().r(), let subrange = Range::new(&clone.owner_doc(),
start_node.r(), &start_node,
start_offset, start_offset,
child.r(), &child,
child.len()); child.len());
// Step 14.4. // Step 14.4.
let subfragment = try!(subrange.CloneContents()); let subfragment = try!(subrange.CloneContents());
@ -506,10 +506,10 @@ impl RangeMethods for Range {
// Step 17.2. // Step 17.2.
try!(fragment.upcast::<Node>().AppendChild(&clone)); try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 17.3. // Step 17.3.
let subrange = Range::new(clone.owner_doc().r(), let subrange = Range::new(&clone.owner_doc(),
child.r(), &child,
0, 0,
end_node.r(), &end_node,
end_offset); end_offset);
// Step 17.4. // Step 17.4.
let subfragment = try!(subrange.CloneContents()); let subfragment = try!(subrange.CloneContents());
@ -532,7 +532,7 @@ impl RangeMethods for Range {
let end_offset = self.EndOffset(); let end_offset = self.EndOffset();
// Step 1. // Step 1.
let fragment = DocumentFragment::new(start_node.owner_doc().r()); let fragment = DocumentFragment::new(&start_node.owner_doc());
// Step 2. // Step 2.
if self.Collapsed() { if self.Collapsed() {
@ -561,9 +561,9 @@ impl RangeMethods for Range {
let (first_contained_child, last_contained_child, contained_children) = let (first_contained_child, last_contained_child, contained_children) =
try!(self.contained_children()); try!(self.contained_children());
let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(end_node.r()) { let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(&end_node) {
// Step 13. // Step 13.
(Root::from_ref(start_node.r()), start_offset) (Root::from_ref(&*start_node), start_offset)
} else { } else {
// Step 14.1-2. // Step 14.1-2.
let reference_node = start_node.ancestors() let reference_node = start_node.ancestors()
@ -595,10 +595,10 @@ impl RangeMethods for Range {
// Step 16.2. // Step 16.2.
try!(fragment.upcast::<Node>().AppendChild(&clone)); try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 16.3. // Step 16.3.
let subrange = Range::new(clone.owner_doc().r(), let subrange = Range::new(&clone.owner_doc(),
start_node.r(), &start_node,
start_offset, start_offset,
child.r(), &child,
child.len()); child.len());
// Step 16.4. // Step 16.4.
let subfragment = try!(subrange.ExtractContents()); let subfragment = try!(subrange.ExtractContents());
@ -630,10 +630,10 @@ impl RangeMethods for Range {
// Step 19.2. // Step 19.2.
try!(fragment.upcast::<Node>().AppendChild(&clone)); try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 19.3. // Step 19.3.
let subrange = Range::new(clone.owner_doc().r(), let subrange = Range::new(&clone.owner_doc(),
child.r(), &child,
0, 0,
end_node.r(), &end_node,
end_offset); end_offset);
// Step 19.4. // Step 19.4.
let subfragment = try!(subrange.ExtractContents()); let subfragment = try!(subrange.ExtractContents());
@ -643,8 +643,8 @@ impl RangeMethods for Range {
} }
// Step 20. // Step 20.
try!(self.SetStart(new_node.r(), new_offset)); try!(self.SetStart(&new_node, new_offset));
try!(self.SetEnd(new_node.r(), new_offset)); try!(self.SetEnd(&new_node, new_offset));
// Step 21. // Step 21.
Ok(fragment) Ok(fragment)
@ -682,16 +682,16 @@ impl RangeMethods for Range {
None => return Err(Error::HierarchyRequest) None => return Err(Error::HierarchyRequest)
}; };
// Step 5. // Step 5.
(Some(Root::from_ref(start_node.r())), parent) (Some(Root::from_ref(&*start_node)), parent)
} else { } else {
// Steps 4-5. // Steps 4-5.
let child = start_node.ChildNodes().Item(start_offset); let child = start_node.ChildNodes().Item(start_offset);
(child, Root::from_ref(start_node.r())) (child, Root::from_ref(&*start_node))
}; };
// Step 6. // Step 6.
try!(Node::ensure_pre_insertion_validity(node, try!(Node::ensure_pre_insertion_validity(node,
parent.r(), &parent,
reference_node.r())); reference_node.r()));
// Step 7. // Step 7.
@ -701,7 +701,7 @@ impl RangeMethods for Range {
Some(text) => { Some(text) => {
split_text = try!(text.SplitText(start_offset)); split_text = try!(text.SplitText(start_offset));
let new_reference = Root::upcast::<Node>(split_text); let new_reference = Root::upcast::<Node>(split_text);
assert!(new_reference.GetParentNode().r() == Some(parent.r())); assert!(new_reference.GetParentNode().r() == Some(&parent));
Some(new_reference) Some(new_reference)
}, },
_ => reference_node _ => reference_node
@ -729,11 +729,11 @@ impl RangeMethods for Range {
}; };
// Step 12. // Step 12.
try!(Node::pre_insert(node, parent.r(), reference_node.r())); try!(Node::pre_insert(node, &parent, reference_node.r()));
// Step 13. // Step 13.
if self.Collapsed() { if self.Collapsed() {
self.set_end(parent.r(), new_offset); self.set_end(&parent, new_offset);
} }
Ok(()) Ok(())
@ -765,21 +765,21 @@ impl RangeMethods for Range {
rooted_vec!(let mut contained_children); rooted_vec!(let mut contained_children);
let ancestor = self.CommonAncestorContainer(); let ancestor = self.CommonAncestorContainer();
let mut iter = start_node.following_nodes(ancestor.r()); let mut iter = start_node.following_nodes(&ancestor);
let mut next = iter.next(); let mut next = iter.next();
while let Some(child) = next { while let Some(child) = next {
if self.contains(child.r()) { if self.contains(&child) {
contained_children.push(JS::from_ref(child.r())); contained_children.push(JS::from_ref(&*child));
next = iter.next_skipping_children(); next = iter.next_skipping_children();
} else { } else {
next = iter.next(); next = iter.next();
} }
} }
let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(end_node.r()) { let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(&end_node) {
// Step 5. // Step 5.
(Root::from_ref(start_node.r()), start_offset) (Root::from_ref(&*start_node), start_offset)
} else { } else {
// Step 6. // Step 6.
fn compute_reference(start_node: &Node, end_node: &Node) -> (Root<Node>, u32) { fn compute_reference(start_node: &Node, end_node: &Node) -> (Root<Node>, u32) {
@ -793,7 +793,7 @@ impl RangeMethods for Range {
unreachable!() unreachable!()
} }
compute_reference(start_node.r(), end_node.r()) compute_reference(&start_node, &end_node)
}; };
// Step 7. // Step 7.
@ -814,8 +814,8 @@ impl RangeMethods for Range {
} }
// Step 10. // Step 10.
self.SetStart(new_node.r(), new_offset).unwrap(); self.SetStart(&new_node, new_offset).unwrap();
self.SetEnd(new_node.r(), new_offset).unwrap(); self.SetEnd(&new_node, new_offset).unwrap();
Ok(()) Ok(())
} }
@ -825,8 +825,8 @@ impl RangeMethods for Range {
let start = self.StartContainer(); let start = self.StartContainer();
let end = self.EndContainer(); let end = self.EndContainer();
if start.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(end.r()) && !n.is::<Text>()) || if start.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(&end) && !n.is::<Text>()) ||
end.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(start.r()) && !n.is::<Text>()) { end.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(&start) && !n.is::<Text>()) {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
@ -878,7 +878,7 @@ impl RangeMethods for Range {
// Step 4. // Step 4.
let ancestor = self.CommonAncestorContainer(); let ancestor = self.CommonAncestorContainer();
let mut iter = start_node.following_nodes(ancestor.r()) let mut iter = start_node.following_nodes(&ancestor)
.filter_map(Root::downcast::<Text>); .filter_map(Root::downcast::<Text>);
while let Some(child) = iter.next() { while let Some(child) = iter.next() {
@ -1004,7 +1004,7 @@ fn bp_position(a_node: &Node, a_offset: u32,
// Step 3-1, 3-2. // Step 3-1, 3-2.
let mut b_ancestors = b_node.inclusive_ancestors(); let mut b_ancestors = b_node.inclusive_ancestors();
let child = b_ancestors.find(|child| { let child = b_ancestors.find(|child| {
child.GetParentNode().unwrap().r() == a_node &*child.GetParentNode().unwrap() == a_node
}).unwrap(); }).unwrap();
// Step 3-3. // Step 3-3.
if child.index() < a_offset { if child.index() < a_offset {

View file

@ -163,7 +163,7 @@ impl<'a> TreeSink for Sink {
fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) { fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) {
while let Some(ref child) = node.GetFirstChild() { while let Some(ref child) = node.GetFirstChild() {
new_parent.AppendChild(child.r()).unwrap(); new_parent.AppendChild(&child).unwrap();
} }
} }
@ -200,7 +200,7 @@ impl<'a> Serializable for &'a Node {
}; };
for handle in children { for handle in children {
try!(handle.r().serialize(serializer, IncludeNode)); try!((&*handle).serialize(serializer, IncludeNode));
} }
if traversal_scope == IncludeNode { if traversal_scope == IncludeNode {
@ -211,7 +211,7 @@ impl<'a> Serializable for &'a Node {
(ChildrenOnly, NodeTypeId::Document(_)) => { (ChildrenOnly, NodeTypeId::Document(_)) => {
for handle in node.children() { for handle in node.children() {
try!(handle.r().serialize(serializer, IncludeNode)); try!((&*handle).serialize(serializer, IncludeNode));
} }
Ok(()) Ok(())
}, },
@ -307,12 +307,11 @@ pub fn parse_html_fragment(context_node: &Node,
output: &Node) { output: &Node) {
let window = window_from_node(context_node); let window = window_from_node(context_node);
let context_document = document_from_node(context_node); let context_document = document_from_node(context_node);
let context_document = context_document.r();
let url = context_document.url(); let url = context_document.url();
// Step 1. // Step 1.
let loader = DocumentLoader::new(&*context_document.loader()); let loader = DocumentLoader::new(&*context_document.loader());
let document = Document::new(window.r(), None, Some(url.clone()), let document = Document::new(&window, None, Some(url.clone()),
IsHTMLDocument::HTMLDocument, IsHTMLDocument::HTMLDocument,
None, None, None, None,
DocumentSource::FromParser, DocumentSource::FromParser,
@ -329,11 +328,11 @@ pub fn parse_html_fragment(context_node: &Node,
context_elem: context_node, context_elem: context_node,
form_elem: form.r(), form_elem: form.r(),
}; };
parse_html(document.r(), input, url.clone(), ParseContext::Fragment(fragment_context)); parse_html(&document, input, url.clone(), ParseContext::Fragment(fragment_context));
// Step 14. // Step 14.
let root_element = document.GetDocumentElement().expect("no document element"); let root_element = document.GetDocumentElement().expect("no document element");
for child in root_element.upcast::<Node>().children() { for child in root_element.upcast::<Node>().children() {
output.AppendChild(child.r()).unwrap(); output.AppendChild(&child).unwrap();
} }
} }

View file

@ -82,7 +82,7 @@ impl<'a> TreeSink for Sink {
Root::upcast(text) Root::upcast(text)
} }
}; };
assert!(parent.AppendChild(child.r()).is_ok()); assert!(parent.AppendChild(&child).is_ok());
} }
fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril, fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril,

View file

@ -180,8 +180,7 @@ impl Runnable for StorageEventRunnable {
fn main_thread_handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) { fn main_thread_handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
let this = *self; let this = *self;
let storage_root = this.element.root(); let storage = this.element.root();
let storage = storage_root.r();
let global = storage.global(); let global = storage.global();
let ev_url = storage.get_url(); let ev_url = storage.get_url();
@ -191,13 +190,12 @@ impl Runnable for StorageEventRunnable {
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from), this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
DOMString::from(ev_url.to_string()), DOMString::from(ev_url.to_string()),
Some(storage) Some(&storage)
); );
let root_context = script_thread.root_browsing_context(); let root_context = script_thread.root_browsing_context();
for it_context in root_context.iter() { for it_context in root_context.iter() {
let it_window_root = it_context.active_window(); let it_window = it_context.active_window();
let it_window = it_window_root.r();
assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url())); assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url()));
// TODO: Such a Document object is not necessarily fully active, but events fired on such // TODO: Such a Document object is not necessarily fully active, but events fired on such
// objects are ignored by the event loop until the Document becomes fully active again. // objects are ignored by the event loop until the Document becomes fully active again.

View file

@ -37,7 +37,7 @@ impl Text {
pub fn Constructor(global: &GlobalScope, text: DOMString) -> Fallible<Root<Text>> { pub fn Constructor(global: &GlobalScope, text: DOMString) -> Fallible<Root<Text>> {
let document = global.as_window().Document(); let document = global.as_window().Document();
Ok(Text::new(text, document.r())) Ok(Text::new(text, &document))
} }
} }

View file

@ -96,14 +96,14 @@ impl TreeWalkerMethods for TreeWalker {
// "1. Let node be the value of the currentNode attribute." // "1. Let node be the value of the currentNode attribute."
let mut node = self.current_node.get(); let mut node = self.current_node.get();
// "2. While node is not null and is not root, run these substeps:" // "2. While node is not null and is not root, run these substeps:"
while !self.is_root_node(node.r()) { while !self.is_root_node(&node) {
// "1. Let node be node's parent." // "1. Let node be node's parent."
match node.GetParentNode() { match node.GetParentNode() {
Some(n) => { Some(n) => {
node = n; node = n;
// "2. If node is not null and filtering node returns FILTER_ACCEPT, // "2. If node is not null and filtering node returns FILTER_ACCEPT,
// then set the currentNode attribute to node, return node." // then set the currentNode attribute to node, return node."
if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(&node)) {
self.current_node.set(&node); self.current_node.set(&node);
return Ok(Some(node)) return Ok(Some(node))
} }
@ -148,7 +148,7 @@ impl TreeWalkerMethods for TreeWalker {
// "1. Let node be the value of the currentNode attribute." // "1. Let node be the value of the currentNode attribute."
let mut node = self.current_node.get(); let mut node = self.current_node.get();
// "2. While node is not root, run these substeps:" // "2. While node is not root, run these substeps:"
while !self.is_root_node(node.r()) { while !self.is_root_node(&node) {
// "1. Let sibling be the previous sibling of node." // "1. Let sibling be the previous sibling of node."
let mut sibling_op = node.GetPreviousSibling(); let mut sibling_op = node.GetPreviousSibling();
// "2. While sibling is not null, run these subsubsteps:" // "2. While sibling is not null, run these subsubsteps:"
@ -162,7 +162,7 @@ impl TreeWalkerMethods for TreeWalker {
// "4. If result is FILTER_ACCEPT, then // "4. If result is FILTER_ACCEPT, then
// set the currentNode attribute to node and return node." // set the currentNode attribute to node and return node."
loop { loop {
let result = try!(self.accept_node(node.r())); let result = try!(self.accept_node(&node));
match result { match result {
NodeFilterConstants::FILTER_REJECT => break, NodeFilterConstants::FILTER_REJECT => break,
_ if node.GetFirstChild().is_some() => _ if node.GetFirstChild().is_some() =>
@ -178,7 +178,7 @@ impl TreeWalkerMethods for TreeWalker {
sibling_op = node.GetPreviousSibling() sibling_op = node.GetPreviousSibling()
} }
// "3. If node is root or node's parent is null, return null." // "3. If node is root or node's parent is null, return null."
if self.is_root_node(node.r()) || node.GetParentNode().is_none() { if self.is_root_node(&node) || node.GetParentNode().is_none() {
return Ok(None) return Ok(None)
} }
// "4. Set node to its parent." // "4. Set node to its parent."
@ -191,7 +191,7 @@ impl TreeWalkerMethods for TreeWalker {
} }
// "5. Filter node and if the return value is FILTER_ACCEPT, then // "5. Filter node and if the return value is FILTER_ACCEPT, then
// set the currentNode attribute to node and return node." // set the currentNode attribute to node and return node."
if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(&node)) {
self.current_node.set(&node); self.current_node.set(&node);
return Ok(Some(node)) return Ok(Some(node))
} }
@ -219,7 +219,7 @@ impl TreeWalkerMethods for TreeWalker {
// "1. Set node to its first child." // "1. Set node to its first child."
node = child; node = child;
// "2. Filter node and set result to the return value." // "2. Filter node and set result to the return value."
result = try!(self.accept_node(node.r())); result = try!(self.accept_node(&node));
// "3. If result is FILTER_ACCEPT, then // "3. If result is FILTER_ACCEPT, then
// set the currentNode attribute to node and return node." // set the currentNode attribute to node and return node."
if NodeFilterConstants::FILTER_ACCEPT == result { if NodeFilterConstants::FILTER_ACCEPT == result {
@ -232,12 +232,12 @@ impl TreeWalkerMethods for TreeWalker {
// "2. If a node is following node and is not following root, // "2. If a node is following node and is not following root,
// set node to the first such node." // set node to the first such node."
// "Otherwise, return null." // "Otherwise, return null."
match self.first_following_node_not_following_root(node.r()) { match self.first_following_node_not_following_root(&node) {
None => return Ok(None), None => return Ok(None),
Some(n) => { Some(n) => {
node = n; node = n;
// "3. Filter node and set result to the return value." // "3. Filter node and set result to the return value."
result = try!(self.accept_node(node.r())); result = try!(self.accept_node(&node));
// "4. If result is FILTER_ACCEPT, then // "4. If result is FILTER_ACCEPT, then
// set the currentNode attribute to node and return node." // set the currentNode attribute to node and return node."
if NodeFilterConstants::FILTER_ACCEPT == result { if NodeFilterConstants::FILTER_ACCEPT == result {
@ -269,7 +269,7 @@ impl TreeWalker {
// "2. Set node to node's first child if type is first, and node's last child if type is last." // "2. Set node to node's first child if type is first, and node's last child if type is last."
// "3. If node is null, return null." // "3. If node is null, return null."
let mut node = match next_child(cur.r()) { let mut node = match next_child(&cur) {
Some(node) => node, Some(node) => node,
None => return Ok(None), None => return Ok(None),
}; };
@ -277,19 +277,19 @@ impl TreeWalker {
// 4. Main: Repeat these substeps: // 4. Main: Repeat these substeps:
'main: loop { 'main: loop {
// "1. Filter node and let result be the return value." // "1. Filter node and let result be the return value."
let result = try!(self.accept_node(node.r())); let result = try!(self.accept_node(&node));
match result { match result {
// "2. If result is FILTER_ACCEPT, then set the currentNode // "2. If result is FILTER_ACCEPT, then set the currentNode
// attribute to node and return node." // attribute to node and return node."
NodeFilterConstants::FILTER_ACCEPT => { NodeFilterConstants::FILTER_ACCEPT => {
self.current_node.set(&node); self.current_node.set(&node);
return Ok(Some(Root::from_ref(node.r()))) return Ok(Some(Root::from_ref(&node)))
}, },
// "3. If result is FILTER_SKIP, run these subsubsteps:" // "3. If result is FILTER_SKIP, run these subsubsteps:"
NodeFilterConstants::FILTER_SKIP => { NodeFilterConstants::FILTER_SKIP => {
// "1. Let child be node's first child if type is first, // "1. Let child be node's first child if type is first,
// and node's last child if type is last." // and node's last child if type is last."
match next_child(node.r()) { match next_child(&node) {
// "2. If child is not null, set node to child and goto Main." // "2. If child is not null, set node to child and goto Main."
Some(child) => { Some(child) => {
node = child; node = child;
@ -304,7 +304,7 @@ impl TreeWalker {
loop { loop {
// "1. Let sibling be node's next sibling if type is next, // "1. Let sibling be node's next sibling if type is next,
// and node's previous sibling if type is previous." // and node's previous sibling if type is previous."
match next_sibling(node.r()) { match next_sibling(&node) {
// "2. If sibling is not null, // "2. If sibling is not null,
// set node to sibling and goto Main." // set node to sibling and goto Main."
Some(sibling) => { Some(sibling) => {
@ -318,8 +318,8 @@ impl TreeWalker {
// or parent is currentNode attribute's value, // or parent is currentNode attribute's value,
// return null." // return null."
None => return Ok(None), None => return Ok(None),
Some(ref parent) if self.is_root_node(parent.r()) Some(ref parent) if self.is_root_node(&parent)
|| self.is_current_node(parent.r()) => || self.is_current_node(&parent) =>
return Ok(None), return Ok(None),
// "5. Otherwise, set node to parent." // "5. Otherwise, set node to parent."
Some(parent) => node = parent Some(parent) => node = parent
@ -342,20 +342,20 @@ impl TreeWalker {
// "1. Let node be the value of the currentNode attribute." // "1. Let node be the value of the currentNode attribute."
let mut node = self.current_node.get(); let mut node = self.current_node.get();
// "2. If node is root, return null." // "2. If node is root, return null."
if self.is_root_node(node.r()) { if self.is_root_node(&node) {
return Ok(None) return Ok(None)
} }
// "3. Run these substeps:" // "3. Run these substeps:"
loop { loop {
// "1. Let sibling be node's next sibling if type is next, // "1. Let sibling be node's next sibling if type is next,
// and node's previous sibling if type is previous." // and node's previous sibling if type is previous."
let mut sibling_op = next_sibling(node.r()); let mut sibling_op = next_sibling(&node);
// "2. While sibling is not null, run these subsubsteps:" // "2. While sibling is not null, run these subsubsteps:"
while sibling_op.is_some() { while sibling_op.is_some() {
// "1. Set node to sibling." // "1. Set node to sibling."
node = sibling_op.unwrap(); node = sibling_op.unwrap();
// "2. Filter node and let result be the return value." // "2. Filter node and let result be the return value."
let result = try!(self.accept_node(node.r())); let result = try!(self.accept_node(&node));
// "3. If result is FILTER_ACCEPT, then set the currentNode // "3. If result is FILTER_ACCEPT, then set the currentNode
// attribute to node and return node." // attribute to node and return node."
if NodeFilterConstants::FILTER_ACCEPT == result { if NodeFilterConstants::FILTER_ACCEPT == result {
@ -365,13 +365,13 @@ impl TreeWalker {
// "4. Set sibling to node's first child if type is next, // "4. Set sibling to node's first child if type is next,
// and node's last child if type is previous." // and node's last child if type is previous."
sibling_op = next_child(node.r()); sibling_op = next_child(&node);
// "5. If result is FILTER_REJECT or sibling is null, // "5. If result is FILTER_REJECT or sibling is null,
// then set sibling to node's next sibling if type is next, // then set sibling to node's next sibling if type is next,
// and node's previous sibling if type is previous." // and node's previous sibling if type is previous."
match (result, &sibling_op) { match (result, &sibling_op) {
(NodeFilterConstants::FILTER_REJECT, _) (NodeFilterConstants::FILTER_REJECT, _)
| (_, &None) => sibling_op = next_sibling(node.r()), | (_, &None) => sibling_op = next_sibling(&node),
_ => {} _ => {}
} }
} }
@ -379,11 +379,11 @@ impl TreeWalker {
match node.GetParentNode() { match node.GetParentNode() {
// "4. If node is null or is root, return null." // "4. If node is null or is root, return null."
None => return Ok(None), None => return Ok(None),
Some(ref n) if self.is_root_node(n.r()) => return Ok(None), Some(ref n) if self.is_root_node(&n) => return Ok(None),
// "5. Filter node and if the return value is FILTER_ACCEPT, then return null." // "5. Filter node and if the return value is FILTER_ACCEPT, then return null."
Some(n) => { Some(n) => {
node = n; node = n;
if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(&node)) {
return Ok(None) return Ok(None)
} }
} }
@ -400,7 +400,7 @@ impl TreeWalker {
match node.GetNextSibling() { match node.GetNextSibling() {
None => { None => {
let mut candidate = Root::from_ref(node); let mut candidate = Root::from_ref(node);
while !self.is_root_node(candidate.r()) && candidate.GetNextSibling().is_none() { while !self.is_root_node(&candidate) && candidate.GetNextSibling().is_none() {
match candidate.GetParentNode() { match candidate.GetParentNode() {
None => None =>
// This can happen if the user set the current node to somewhere // This can happen if the user set the current node to somewhere
@ -409,7 +409,7 @@ impl TreeWalker {
Some(n) => candidate = n Some(n) => candidate = n
} }
} }
if self.is_root_node(candidate.r()) { if self.is_root_node(&candidate) {
None None
} else { } else {
candidate.GetNextSibling() candidate.GetNextSibling()

View file

@ -21,7 +21,6 @@ pub fn load_script(head: &HTMLHeadElement) {
let node = head.upcast::<Node>(); let node = head.upcast::<Node>();
let first_child = node.GetFirstChild(); let first_child = node.GetFirstChild();
let doc = node.owner_doc(); let doc = node.owner_doc();
let doc = doc.r();
let path = if &**path_str == "" { let path = if &**path_str == "" {
if let Ok(mut p) = resources_dir_path() { if let Ok(mut p) = resources_dir_path() {
@ -46,7 +45,6 @@ pub fn load_script(head: &HTMLHeadElement) {
_ => continue _ => continue
}; };
let new_script = doc.CreateElement(DOMString::from("script")).unwrap(); let new_script = doc.CreateElement(DOMString::from("script")).unwrap();
let new_script = new_script.r();
new_script.set_string_attribute(&atom!("src"), DOMString::from(name)); new_script.set_string_attribute(&atom!("src"), DOMString::from(name));
node.InsertBefore(new_script.upcast(), first_child.r()).unwrap(); node.InsertBefore(new_script.upcast(), first_child.r()).unwrap();
} }

View file

@ -342,7 +342,7 @@ impl WebGLRenderingContext {
let window = window_from_node(&*self.canvas); let window = window_from_node(&*self.canvas);
let img = match canvas_utils::request_image_from_cache(window.r(), img_url) { let img = match canvas_utils::request_image_from_cache(&window, img_url) {
ImageResponse::Loaded(img) => img, ImageResponse::Loaded(img) => img,
ImageResponse::PlaceholderLoaded(_) | ImageResponse::None | ImageResponse::PlaceholderLoaded(_) | ImageResponse::None |
ImageResponse::MetadataLoaded(_) ImageResponse::MetadataLoaded(_)
@ -368,7 +368,6 @@ impl WebGLRenderingContext {
// but we need to refactor it moving it to `HTMLCanvasElement` and support // but we need to refactor it moving it to `HTMLCanvasElement` and support
// WebGLContext (probably via GetPixels()). // WebGLContext (probably via GetPixels()).
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLCanvasElement(canvas) => { ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLCanvasElement(canvas) => {
let canvas = canvas.r();
if let Some((mut data, size)) = canvas.fetch_all_data() { if let Some((mut data, size)) = canvas.fetch_all_data() {
byte_swap(&mut data); byte_swap(&mut data);
(data, size) (data, size)

View file

@ -242,7 +242,7 @@ impl WebSocket {
// Step 7. // Step 7.
let ws = WebSocket::new(global, resource_url.clone()); let ws = WebSocket::new(global, resource_url.clone());
let address = Trusted::new(ws.r()); let address = Trusted::new(&*ws);
let connect_data = WebSocketConnectData { let connect_data = WebSocketConnectData {
resource_url: resource_url.clone(), resource_url: resource_url.clone(),

View file

@ -81,7 +81,7 @@ impl Worker {
let (sender, receiver) = channel(); let (sender, receiver) = channel();
let closing = Arc::new(AtomicBool::new(false)); let closing = Arc::new(AtomicBool::new(false));
let worker = Worker::new(global, sender.clone(), closing.clone()); let worker = Worker::new(global, sender.clone(), closing.clone());
let worker_ref = Trusted::new(worker.r()); let worker_ref = Trusted::new(&*worker);
let worker_load_origin = WorkerScriptLoadOrigin { let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None, referrer_url: None,

View file

@ -69,7 +69,7 @@ impl XMLDocument {
XMLDocumentBinding::Wrap); XMLDocumentBinding::Wrap);
{ {
let node = doc.upcast::<Node>(); let node = doc.upcast::<Node>();
node.set_owner_doc(&doc.r().document); node.set_owner_doc(&doc.document);
} }
doc doc
} }

View file

@ -306,7 +306,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
username: Option<USVString>, password: Option<USVString>) -> ErrorResult { username: Option<USVString>, password: Option<USVString>) -> ErrorResult {
// Step 1 // Step 1
if let Some(window) = Root::downcast::<Window>(self.global()) { if let Some(window) = Root::downcast::<Window>(self.global()) {
if !window.Document().r().is_fully_active() { if !window.Document().is_fully_active() {
return Err(Error::InvalidState); return Err(Error::InvalidState);
} }
} }
@ -1111,7 +1111,7 @@ impl XMLHttpRequest {
// Step 3, 4 // Step 3, 4
let bytes = self.response.borrow().to_vec(); let bytes = self.response.borrow().to_vec();
let blob = Blob::new(&self.global(), BlobImpl::new_from_bytes(bytes), mime); let blob = Blob::new(&self.global(), BlobImpl::new_from_bytes(bytes), mime);
self.response_blob.set(Some(blob.r())); self.response_blob.set(Some(&blob));
blob blob
} }
@ -1156,7 +1156,7 @@ impl XMLHttpRequest {
// Step 9 // Step 9
temp_doc.set_encoding(charset); temp_doc.set_encoding(charset);
// Step 13 // Step 13
self.response_xml.set(Some(temp_doc.r())); self.response_xml.set(Some(&temp_doc));
return self.response_xml.get(); return self.response_xml.get();
} }
@ -1199,7 +1199,7 @@ impl XMLHttpRequest {
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap(); let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
let document = self.new_doc(IsHTMLDocument::HTMLDocument); let document = self.new_doc(IsHTMLDocument::HTMLDocument);
// TODO: Disable scripting while parsing // TODO: Disable scripting while parsing
parse_html(document.r(), parse_html(&document,
DOMString::from(decoded), DOMString::from(decoded),
wr.get_url(), wr.get_url(),
ParseContext::Owner(Some(wr.pipeline_id()))); ParseContext::Owner(Some(wr.pipeline_id())));
@ -1212,7 +1212,7 @@ impl XMLHttpRequest {
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap(); let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
let document = self.new_doc(IsHTMLDocument::NonHTMLDocument); let document = self.new_doc(IsHTMLDocument::NonHTMLDocument);
// TODO: Disable scripting while parsing // TODO: Disable scripting while parsing
parse_xml(document.r(), parse_xml(&document,
DOMString::from(decoded), DOMString::from(decoded),
wr.get_url(), wr.get_url(),
xml::ParseContext::Owner(Some(wr.pipeline_id()))); xml::ParseContext::Owner(Some(wr.pipeline_id())));
@ -1223,7 +1223,6 @@ impl XMLHttpRequest {
let wr = self.global(); let wr = self.global();
let win = wr.as_window(); let win = wr.as_window();
let doc = win.Document(); let doc = win.Document();
let doc = doc.r();
let docloader = DocumentLoader::new(&*doc.loader()); let docloader = DocumentLoader::new(&*doc.loader());
let base = wr.get_url(); let base = wr.get_url();
let parsed_url = match base.join(&self.ResponseURL().0) { let parsed_url = match base.join(&self.ResponseURL().0) {

View file

@ -163,8 +163,8 @@ impl FetchResponseListener for FetchContext {
fn process_response_eof(&mut self, _response: Result<(), NetworkError>) { fn process_response_eof(&mut self, _response: Result<(), NetworkError>) {
let response = self.response_object.root(); let response = self.response_object.root();
let global = response.global(); let global = response.global();
let cx = global.r().get_cx(); let cx = global.get_cx();
let _ac = JSAutoCompartment::new(cx, global.r().reflector().get_jsobject().get()); let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
response.finish(mem::replace(&mut self.body, vec![])); response.finish(mem::replace(&mut self.body, vec![]));
// TODO // TODO
// ... trailerObject is not supported in Servo yet. // ... trailerObject is not supported in Servo yet.

View file

@ -1181,7 +1181,6 @@ impl ScriptThread {
Some(browsing_context) => browsing_context.active_document(), Some(browsing_context) => browsing_context.active_document(),
None => return warn!("Message sent to closed pipeline {}.", pipeline), None => return warn!("Message sent to closed pipeline {}.", pipeline),
}; };
let doc = doc.r();
if doc.loader().is_blocked() { if doc.loader().is_blocked() {
return; return;
} }
@ -1189,19 +1188,19 @@ impl ScriptThread {
doc.mut_loader().inhibit_events(); doc.mut_loader().inhibit_events();
// https://html.spec.whatwg.org/multipage/#the-end step 7 // https://html.spec.whatwg.org/multipage/#the-end step 7
let handler = box DocumentProgressHandler::new(Trusted::new(doc)); let handler = box DocumentProgressHandler::new(Trusted::new(&doc));
self.dom_manipulation_task_source.queue(handler, doc.window().upcast()).unwrap(); self.dom_manipulation_task_source.queue(handler, doc.window().upcast()).unwrap();
if let Some(fragment) = doc.url().fragment() { if let Some(fragment) = doc.url().fragment() {
self.check_and_scroll_fragment(fragment, pipeline, doc); self.check_and_scroll_fragment(fragment, pipeline, &doc);
} }
} }
fn check_and_scroll_fragment(&self, fragment: &str, pipeline_id: PipelineId, doc: &Document) { fn check_and_scroll_fragment(&self, fragment: &str, pipeline_id: PipelineId, doc: &Document) {
match doc.find_fragment_node(fragment) { match doc.find_fragment_node(fragment) {
Some(ref node) => { Some(ref node) => {
doc.set_target_element(Some(node.r())); doc.set_target_element(Some(&node));
self.scroll_fragment_point(pipeline_id, node.r()); self.scroll_fragment_point(pipeline_id, &node);
} }
None => { None => {
doc.set_target_element(None); doc.set_target_element(None);
@ -1726,7 +1725,7 @@ impl ScriptThread {
None None
}; };
let document = Document::new(window.r(), let document = Document::new(&window,
Some(&browsing_context), Some(&browsing_context),
Some(final_url.clone()), Some(final_url.clone()),
is_html_document, is_html_document,
@ -1793,12 +1792,12 @@ impl ScriptThread {
}; };
if is_xml { if is_xml {
parse_xml(document.r(), parse_xml(&document,
parse_input, parse_input,
final_url, final_url,
xml::ParseContext::Owner(Some(incomplete.pipeline_id))); xml::ParseContext::Owner(Some(incomplete.pipeline_id)));
} else { } else {
parse_html(document.r(), parse_html(&document,
parse_input, parse_input,
final_url, final_url,
ParseContext::Owner(Some(incomplete.pipeline_id))); ParseContext::Owner(Some(incomplete.pipeline_id)));
@ -1857,7 +1856,7 @@ impl ScriptThread {
fn rebuild_and_force_reflow(&self, context: &BrowsingContext, reason: ReflowReason) { fn rebuild_and_force_reflow(&self, context: &BrowsingContext, reason: ReflowReason) {
let document = context.active_document(); let document = context.active_document();
document.dirty_all_nodes(); document.dirty_all_nodes();
let window = window_from_node(document.r()); let window = window_from_node(&*document);
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason); window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason);
} }
@ -1956,7 +1955,7 @@ impl ScriptThread {
Some(browsing_context) => browsing_context.active_document(), Some(browsing_context) => browsing_context.active_document(),
None => return warn!("Message sent to closed pipeline {}.", pipeline_id), None => return warn!("Message sent to closed pipeline {}.", pipeline_id),
}; };
document.r().handle_touchpad_pressure_event(self.js_runtime.rt(), point, pressure, phase); document.handle_touchpad_pressure_event(self.js_runtime.rt(), point, pressure, phase);
} }
KeyEvent(ch, key, state, modifiers) => { KeyEvent(ch, key, state, modifiers) => {
@ -2015,7 +2014,7 @@ impl ScriptThread {
let url = document.url(); let url = document.url();
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] && if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get { load_data.method == Method::Get {
self.check_and_scroll_fragment(fragment, parent_pipeline_id, document.r()); self.check_and_scroll_fragment(fragment, parent_pipeline_id, &document);
return; return;
} }
} }
@ -2055,15 +2054,15 @@ impl ScriptThread {
let fragment_node = window.steal_fragment_name() let fragment_node = window.steal_fragment_name()
.and_then(|name| document.find_fragment_node(&*name)); .and_then(|name| document.find_fragment_node(&*name));
match fragment_node { match fragment_node {
Some(ref node) => self.scroll_fragment_point(pipeline_id, node.r()), Some(ref node) => self.scroll_fragment_point(pipeline_id, &node),
None => {} None => {}
} }
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports // http://dev.w3.org/csswg/cssom-view/#resizing-viewports
if size_type == WindowSizeType::Resize { if size_type == WindowSizeType::Resize {
let uievent = UIEvent::new(window.r(), let uievent = UIEvent::new(&window,
DOMString::from("resize"), EventBubbles::DoesNotBubble, DOMString::from("resize"), EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable, Some(window.r()), EventCancelable::NotCancelable, Some(&window),
0i32); 0i32);
uievent.upcast::<Event>().fire(window.upcast()); uievent.upcast::<Event>().fire(window.upcast());
} }
@ -2128,7 +2127,7 @@ impl ScriptThread {
debug!("kicking off initial reflow of {:?}", final_url); debug!("kicking off initial reflow of {:?}", final_url);
document.disarm_reflow_timeout(); document.disarm_reflow_timeout();
document.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); document.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
let window = window_from_node(document.r()); let window = window_from_node(&*document);
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad); window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad);
// No more reflow required // No more reflow required