mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Remove intrinsic Root::r()
This commit is contained in:
parent
51bcf516c8
commit
0b3ab875f4
55 changed files with 275 additions and 310 deletions
|
@ -146,7 +146,7 @@ pub fn handle_get_layout(context: &BrowsingContext,
|
|||
|
||||
let window = context.active_window();
|
||||
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 {
|
||||
display: String::from(computed_style.Display()),
|
||||
|
|
|
@ -83,11 +83,11 @@ pub fn synthetic_click_activation(element: &Element,
|
|||
// https://html.spec.whatwg.org/multipage/#fire-a-synthetic-mouse-event
|
||||
let win = window_from_node(element);
|
||||
let target = element.upcast::<EventTarget>();
|
||||
let mouse = MouseEvent::new(win.r(),
|
||||
let mouse = MouseEvent::new(&win,
|
||||
DOMString::from("click"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable,
|
||||
Some(win.r()),
|
||||
Some(&win),
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
|
|
|
@ -104,7 +104,7 @@ impl AttrMethods for Attr {
|
|||
let value = owner.parse_attribute(&self.identifier.namespace,
|
||||
self.local_name(),
|
||||
value);
|
||||
self.set_value(value, owner.r());
|
||||
self.set_value(value, &owner);
|
||||
} else {
|
||||
*self.value.borrow_mut() = AttrValue::String(value.into());
|
||||
}
|
||||
|
@ -200,12 +200,12 @@ impl Attr {
|
|||
/// or removed from its older parent.
|
||||
pub fn set_owner(&self, owner: Option<&Element>) {
|
||||
let ns = &self.identifier.namespace;
|
||||
match (self.owner().r(), owner) {
|
||||
match (self.owner(), owner) {
|
||||
(Some(old), None) => {
|
||||
// Already gone from the list of attributes of old owner.
|
||||
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);
|
||||
|
|
|
@ -3256,12 +3256,7 @@ class CGPerSignatureCall(CGThing):
|
|||
return "argc"
|
||||
|
||||
def getArguments(self):
|
||||
def process(arg, i):
|
||||
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)]
|
||||
return [(a, process_arg("arg" + str(i), a)) for (i, a) in enumerate(self.arguments)]
|
||||
|
||||
def isFallible(self):
|
||||
return 'infallible' not in self.extendedAttributes
|
||||
|
@ -4651,12 +4646,7 @@ class CGProxySpecialOperation(CGPerSignatureCall):
|
|||
self.cgRoot.prepend(CGGeneric("rooted!(in(cx) let value = desc.value);"))
|
||||
|
||||
def getArguments(self):
|
||||
def process(arg):
|
||||
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]
|
||||
args = [(a, process_arg(a.identifier.name, a)) for a in self.arguments]
|
||||
return args
|
||||
|
||||
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))
|
||||
|
||||
|
||||
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():
|
||||
"""
|
||||
Roots for global codegen.
|
||||
|
|
|
@ -473,7 +473,7 @@ impl<T: Reflectable> RootedReference<T> for Option<Rc<T>> {
|
|||
|
||||
impl<T: Reflectable> RootedReference<T> for Option<Root<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> {
|
||||
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> {
|
||||
|
|
|
@ -232,7 +232,7 @@ impl CanvasRenderingContext2D {
|
|||
canvas.origin_is_clean()
|
||||
}
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(image) =>
|
||||
image.r().origin_is_clean(),
|
||||
image.origin_is_clean(),
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(image) =>
|
||||
match image.get_url() {
|
||||
None => true,
|
||||
|
@ -280,23 +280,20 @@ impl CanvasRenderingContext2D {
|
|||
-> ErrorResult {
|
||||
let result = match image {
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLCanvasElement(ref canvas) => {
|
||||
self.draw_html_canvas_element(canvas.r(),
|
||||
self.draw_html_canvas_element(&canvas,
|
||||
sx, sy, sw, sh,
|
||||
dx, dy, dw, dh)
|
||||
}
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::CanvasRenderingContext2D(ref image) => {
|
||||
let context = image.r();
|
||||
let canvas = context.Canvas();
|
||||
self.draw_html_canvas_element(canvas.r(),
|
||||
self.draw_html_canvas_element(&image.Canvas(),
|
||||
sx, sy, sw, sh,
|
||||
dx, dy, dw, dh)
|
||||
}
|
||||
HTMLImageElementOrHTMLCanvasElementOrCanvasRenderingContext2D::HTMLImageElement(ref image) => {
|
||||
let image_element = image.r();
|
||||
// https://html.spec.whatwg.org/multipage/#img-error
|
||||
// If the image argument is an HTMLImageElement object that is in the broken state,
|
||||
// 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)) => {
|
||||
// Pixels come from cache in BGRA order and drawImage expects RGBA so we
|
||||
// have to swap the color values
|
||||
|
@ -464,7 +461,7 @@ impl CanvasRenderingContext2D {
|
|||
#[inline]
|
||||
fn request_image_from_cache(&self, url: Url) -> ImageResponse {
|
||||
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>> {
|
||||
|
@ -941,14 +938,14 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
},
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasGradient(gradient) => {
|
||||
self.state.borrow_mut().stroke_style =
|
||||
CanvasFillOrStrokeStyle::Gradient(JS::from_ref(gradient.r()));
|
||||
CanvasFillOrStrokeStyle::Gradient(JS::from_ref(&*gradient));
|
||||
let msg = CanvasMsg::Canvas2d(
|
||||
Canvas2dMsg::SetStrokeStyle(gradient.to_fill_or_stroke_style()));
|
||||
self.ipc_renderer.send(msg).unwrap();
|
||||
},
|
||||
StringOrCanvasGradientOrCanvasPattern::CanvasPattern(pattern) => {
|
||||
self.state.borrow_mut().stroke_style =
|
||||
CanvasFillOrStrokeStyle::Pattern(JS::from_ref(pattern.r()));
|
||||
CanvasFillOrStrokeStyle::Pattern(JS::from_ref(&*pattern));
|
||||
let msg = CanvasMsg::Canvas2d(
|
||||
Canvas2dMsg::SetStrokeStyle(pattern.to_fill_or_stroke_style()));
|
||||
self.ipc_renderer.send(msg).unwrap();
|
||||
|
@ -1162,7 +1159,7 @@ impl CanvasRenderingContext2DMethods for CanvasRenderingContext2D {
|
|||
// https://html.spec.whatwg.org/multipage/#img-error
|
||||
// If the image argument is an HTMLImageElement object that is in the broken state,
|
||||
// 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) => {
|
||||
let _ = canvas.get_or_init_2d_context();
|
||||
|
|
|
@ -33,6 +33,6 @@ impl Comment {
|
|||
|
||||
pub fn Constructor(global: &GlobalScope, data: DOMString) -> Fallible<Root<Comment>> {
|
||||
let document = global.as_window().Document();
|
||||
Ok(Comment::new(data, document.r()))
|
||||
Ok(Comment::new(data, &document))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
|
|
|
@ -539,7 +539,7 @@ impl Document {
|
|||
if &*(*elements)[head] == elem {
|
||||
head += 1;
|
||||
}
|
||||
if new_node == node.r() || head == elements.len() {
|
||||
if new_node == &*node || head == elements.len() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1043,7 +1043,7 @@ impl Document {
|
|||
}
|
||||
|
||||
// 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,
|
||||
ReflowQueryType::NoQuery,
|
||||
|
@ -1104,7 +1104,7 @@ impl Document {
|
|||
|
||||
let touch = Touch::new(window,
|
||||
identifier,
|
||||
target.r(),
|
||||
&target,
|
||||
client_x,
|
||||
client_y, // TODO: Get real screen coordinates?
|
||||
client_x,
|
||||
|
@ -1163,7 +1163,7 @@ impl Document {
|
|||
false,
|
||||
false);
|
||||
let event = event.upcast::<Event>();
|
||||
let result = event.fire(target.r());
|
||||
let result = event.fire(&target);
|
||||
|
||||
window.reflow(ReflowGoal::ForDisplay,
|
||||
ReflowQueryType::NoQuery,
|
||||
|
@ -1308,13 +1308,13 @@ impl Document {
|
|||
for node in nodes {
|
||||
match node {
|
||||
NodeOrString::Node(node) => {
|
||||
try!(fragment.AppendChild(node.r()));
|
||||
try!(fragment.AppendChild(&node));
|
||||
},
|
||||
NodeOrString::String(string) => {
|
||||
let node = Root::upcast::<Node>(self.CreateTextNode(string));
|
||||
// No try!() here because appending a text node
|
||||
// should not fail.
|
||||
fragment.AppendChild(node.r()).unwrap();
|
||||
fragment.AppendChild(&node).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1444,9 +1444,7 @@ impl Document {
|
|||
let mut animation_frame_list =
|
||||
mem::replace(&mut *self.animation_frame_list.borrow_mut(), vec![]);
|
||||
self.running_animation_callbacks.set(true);
|
||||
let performance = self.window.Performance();
|
||||
let performance = performance.r();
|
||||
let timing = performance.Now();
|
||||
let timing = self.window.Performance().Now();
|
||||
|
||||
for (_, callback) in animation_frame_list.drain(..) {
|
||||
if let Some(callback) = callback {
|
||||
|
@ -1506,8 +1504,8 @@ impl Document {
|
|||
// A finished resource load can potentially unblock parsing. In that case, resume the
|
||||
// parser so its loop can find out.
|
||||
if let Some(parser) = self.get_current_parser() {
|
||||
if parser.r().is_suspended() {
|
||||
parser.r().resume();
|
||||
if parser.is_suspended() {
|
||||
parser.resume();
|
||||
}
|
||||
} else if self.reflow_timeout.get().is_none() {
|
||||
// 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>> {
|
||||
let win = global.as_window();
|
||||
let doc = win.Document();
|
||||
let doc = doc.r();
|
||||
let docloader = DocumentLoader::new(&*doc.loader());
|
||||
Ok(Document::new(win,
|
||||
None,
|
||||
|
@ -1898,7 +1895,7 @@ impl Document {
|
|||
DocumentBinding::Wrap);
|
||||
{
|
||||
let node = document.upcast::<Node>();
|
||||
node.set_owner_doc(document.r());
|
||||
node.set_owner_doc(&document);
|
||||
}
|
||||
document
|
||||
}
|
||||
|
@ -1908,7 +1905,7 @@ impl Document {
|
|||
let maybe_node = doc.r().map(Castable::upcast::<Node>);
|
||||
let iter = maybe_node.iter()
|
||||
.flat_map(|node| node.traverse_preorder())
|
||||
.filter(|node| callback(node.r()));
|
||||
.filter(|node| callback(&node));
|
||||
NodeList::new_simple_list(&self.window, iter)
|
||||
}
|
||||
|
||||
|
@ -2592,7 +2589,7 @@ impl DocumentMethods for Document {
|
|||
|
||||
// Step 2.
|
||||
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(());
|
||||
}
|
||||
|
||||
|
@ -2875,7 +2872,7 @@ impl DocumentMethods for Document {
|
|||
{
|
||||
// Step 1.
|
||||
let mut elements = root.traverse_preorder()
|
||||
.filter(|node| filter_by_name(&name, node.r()))
|
||||
.filter(|node| filter_by_name(&name, &node))
|
||||
.peekable();
|
||||
if let Some(first) = elements.next() {
|
||||
if elements.peek().is_none() {
|
||||
|
|
|
@ -41,7 +41,7 @@ impl DocumentFragment {
|
|||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<DocumentFragment>> {
|
||||
let document = global.as_window().Document();
|
||||
|
||||
Ok(DocumentFragment::new(document.r()))
|
||||
Ok(DocumentFragment::new(&document))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
{
|
||||
// Step 3.
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -144,14 +144,14 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
let doc_node = doc.upcast::<Node>();
|
||||
let doc_html = Root::upcast::<Node>(HTMLHtmlElement::new(atom!("html"),
|
||||
None,
|
||||
doc.r()));
|
||||
&doc));
|
||||
doc_node.AppendChild(&doc_html).expect("Appending failed");
|
||||
|
||||
{
|
||||
// Step 5.
|
||||
let doc_head = Root::upcast::<Node>(HTMLHeadElement::new(atom!("head"),
|
||||
None,
|
||||
doc.r()));
|
||||
&doc));
|
||||
doc_html.AppendChild(&doc_head).unwrap();
|
||||
|
||||
// Step 6.
|
||||
|
@ -162,18 +162,18 @@ impl DOMImplementationMethods for DOMImplementation {
|
|||
let doc_title =
|
||||
Root::upcast::<Node>(HTMLTitleElement::new(atom!("title"),
|
||||
None,
|
||||
doc.r()));
|
||||
&doc));
|
||||
doc_head.AppendChild(&doc_title).unwrap();
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@ impl DOMParserMethods for DOMParser {
|
|||
let content_type =
|
||||
DOMString::from(DOMParserBinding::SupportedTypeValues::strings[ty as usize]);
|
||||
let doc = self.window.Document();
|
||||
let doc = doc.r();
|
||||
let loader = DocumentLoader::new(&*doc.loader());
|
||||
match ty {
|
||||
Text_html => {
|
||||
|
@ -71,7 +70,7 @@ impl DOMParserMethods for DOMParser {
|
|||
loader,
|
||||
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);
|
||||
Ok(document)
|
||||
}
|
||||
|
@ -87,7 +86,7 @@ impl DOMParserMethods for DOMParser {
|
|||
loader,
|
||||
None,
|
||||
None);
|
||||
parse_xml(document.r(), s, url, xml::ParseContext::Owner(None));
|
||||
parse_xml(&document, s, url, xml::ParseContext::Owner(None));
|
||||
Ok(document)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl DOMStringMap {
|
|||
pub fn new(element: &HTMLElement) -> Root<DOMStringMap> {
|
||||
let window = window_from_node(element);
|
||||
reflect_dom_object(box DOMStringMap::new_inherited(element),
|
||||
window.r(),
|
||||
&*window,
|
||||
DOMStringMapBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ impl DOMTokenList {
|
|||
pub fn new(element: &Element, local_name: &Atom) -> Root<DOMTokenList> {
|
||||
let window = window_from_node(element);
|
||||
reflect_dom_object(box DOMTokenList::new_inherited(element, local_name.clone()),
|
||||
window.r(),
|
||||
&*window,
|
||||
DOMTokenListBinding::Wrap)
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,6 @@ impl DOMTokenListMethods for DOMTokenList {
|
|||
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
||||
fn Length(&self) -> u32 {
|
||||
self.attribute().map_or(0, |attr| {
|
||||
let attr = attr.r();
|
||||
attr.value().as_tokens().len()
|
||||
}) as u32
|
||||
}
|
||||
|
@ -72,7 +71,6 @@ impl DOMTokenListMethods for DOMTokenList {
|
|||
fn Contains(&self, token: DOMString) -> bool {
|
||||
let token = Atom::from(token);
|
||||
self.attribute().map_or(false, |attr| {
|
||||
let attr = attr.r();
|
||||
attr.value()
|
||||
.as_tokens()
|
||||
.iter()
|
||||
|
|
|
@ -1208,8 +1208,7 @@ impl Element {
|
|||
|
||||
pub fn get_tokenlist_attribute(&self, local_name: &Atom) -> Vec<Atom> {
|
||||
self.get_attribute(&ns!(), local_name).map(|attr| {
|
||||
attr.r()
|
||||
.value()
|
||||
attr.value()
|
||||
.as_tokens()
|
||||
.to_vec()
|
||||
}).unwrap_or(vec!())
|
||||
|
@ -1235,7 +1234,7 @@ impl Element {
|
|||
|
||||
match attribute {
|
||||
Some(ref attribute) => {
|
||||
match *attribute.r().value() {
|
||||
match *attribute.value() {
|
||||
AttrValue::Int(_, value) => value,
|
||||
_ => panic!("Expected an AttrValue::Int: \
|
||||
implement parse_plain_attribute"),
|
||||
|
@ -1502,7 +1501,7 @@ impl ElementMethods for Element {
|
|||
let old_attr = Root::from_ref(&*self.attrs.borrow()[position]);
|
||||
|
||||
// Step 3.
|
||||
if old_attr.r() == attr {
|
||||
if &*old_attr == attr {
|
||||
return Ok(Some(Root::from_ref(attr)));
|
||||
}
|
||||
|
||||
|
@ -1565,7 +1564,7 @@ impl ElementMethods for Element {
|
|||
// https://dom.spec.whatwg.org/#dom-element-getelementsbytagname
|
||||
fn GetElementsByTagName(&self, localname: DOMString) -> Root<HTMLCollection> {
|
||||
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
|
||||
|
@ -1574,13 +1573,13 @@ impl ElementMethods for Element {
|
|||
localname: DOMString)
|
||||
-> Root<HTMLCollection> {
|
||||
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
|
||||
fn GetElementsByClassName(&self, classes: DOMString) -> Root<HTMLCollection> {
|
||||
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
|
||||
|
@ -1594,7 +1593,7 @@ impl ElementMethods for Element {
|
|||
rect.size.width.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
|
||||
|
@ -1911,7 +1910,7 @@ impl ElementMethods for Element {
|
|||
// Step 4.
|
||||
NodeTypeId::DocumentFragment => {
|
||||
let body_elem = Element::create(QualName::new(ns!(html), atom!("body")),
|
||||
None, context_document.r(),
|
||||
None, &context_document,
|
||||
ElementCreator::ScriptCreated);
|
||||
Root::upcast(body_elem)
|
||||
},
|
||||
|
@ -1938,7 +1937,7 @@ impl ElementMethods for Element {
|
|||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
fn Children(&self) -> Root<HTMLCollection> {
|
||||
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
|
||||
|
@ -2638,8 +2637,6 @@ impl Element {
|
|||
return;
|
||||
}
|
||||
for ancestor in node.ancestors() {
|
||||
let ancestor = ancestor;
|
||||
let ancestor = ancestor.r();
|
||||
if !ancestor.is::<HTMLFieldSetElement>() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||
fn Validity(&self) -> Root<ValidityState> {
|
||||
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
|
||||
|
@ -293,7 +293,7 @@ impl Activatable for HTMLButtonElement {
|
|||
node.query_selector_iter(DOMString::from("button[type=submit]")).unwrap()
|
||||
.filter_map(Root::downcast::<HTMLButtonElement>)
|
||||
.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,
|
||||
shift_key,
|
||||
alt_key,
|
||||
|
|
|
@ -106,7 +106,7 @@ impl HTMLCollection {
|
|||
fn set_cached_cursor(&self, index: u32, element: Option<Root<Element>>) -> Option<Root<Element>> {
|
||||
if let Some(element) = element {
|
||||
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)
|
||||
} else {
|
||||
None
|
||||
|
@ -284,13 +284,13 @@ impl HTMLCollectionMethods for HTMLCollection {
|
|||
// Iterate forwards, starting at the cursor.
|
||||
let offset = index - (cached_index + 1);
|
||||
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 {
|
||||
// The cursor is after the element we're looking for
|
||||
// Iterate backwards, starting at the cursor.
|
||||
let offset = cached_index - (index + 1);
|
||||
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 {
|
||||
// Cache miss
|
||||
|
|
|
@ -52,6 +52,6 @@ impl HTMLDataListElementMethods for HTMLDataListElement {
|
|||
}
|
||||
let filter = box HTMLDataListOptionsFilter;
|
||||
let window = window_from_node(self);
|
||||
HTMLCollection::create(window.r(), self.upcast(), filter)
|
||||
HTMLCollection::create(&window, self.upcast(), filter)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ impl HTMLDialogElementMethods for HTMLDialogElement {
|
|||
// TODO: Step 4 implement pending dialog stack removal
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,6 @@ impl HTMLElement {
|
|||
},
|
||||
_ => {
|
||||
if let Some(attr) = element.get_attribute(&ns!(), &atom!("draggable")) {
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
let is_true = match *value {
|
||||
AttrValue::String(ref string) => string == "true",
|
||||
|
@ -116,7 +115,7 @@ impl HTMLElementMethods for HTMLElement {
|
|||
fn Style(&self) -> Root<CSSStyleDeclaration> {
|
||||
self.style_decl.or_init(|| {
|
||||
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 = match &id as &str {
|
||||
"" => return NodeList::new_simple_list(window.r(), ancestors),
|
||||
"" => return NodeList::new_simple_list(&window, ancestors),
|
||||
id => id,
|
||||
};
|
||||
|
||||
|
@ -495,7 +494,7 @@ impl HTMLElement {
|
|||
.filter(|elem| elem.get_string_attribute(&atom!("for")) == id)
|
||||
.map(Root::upcast::<Node>);
|
||||
|
||||
NodeList::new_simple_list(window.r(), children.chain(ancestors))
|
||||
NodeList::new_simple_list(&window, children.chain(ancestors))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,13 +59,13 @@ impl HTMLFieldSetElementMethods for HTMLFieldSetElement {
|
|||
}
|
||||
let filter = box ElementsFilter;
|
||||
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
|
||||
fn Validity(&self) -> Root<ValidityState> {
|
||||
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
|
||||
|
|
|
@ -220,7 +220,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
|||
}
|
||||
let filter = box ElementsFilter { form: Root::from_ref(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));
|
||||
elements
|
||||
}
|
||||
|
@ -706,11 +706,11 @@ pub enum FormSubmittableElement {
|
|||
impl FormSubmittableElement {
|
||||
fn as_event_target(&self) -> &EventTarget {
|
||||
match *self {
|
||||
FormSubmittableElement::ButtonElement(ref button) => button.r().upcast(),
|
||||
FormSubmittableElement::InputElement(ref input) => input.r().upcast(),
|
||||
FormSubmittableElement::ObjectElement(ref object) => object.r().upcast(),
|
||||
FormSubmittableElement::SelectElement(ref select) => select.r().upcast(),
|
||||
FormSubmittableElement::TextAreaElement(ref textarea) => textarea.r().upcast()
|
||||
FormSubmittableElement::ButtonElement(ref button) => button.upcast(),
|
||||
FormSubmittableElement::InputElement(ref input) => input.upcast(),
|
||||
FormSubmittableElement::ObjectElement(ref object) => object.upcast(),
|
||||
FormSubmittableElement::SelectElement(ref select) => select.upcast(),
|
||||
FormSubmittableElement::TextAreaElement(ref textarea) => textarea.upcast()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
|
|||
if self.to_element().has_attribute(attr) {
|
||||
input(self)
|
||||
} 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) {
|
||||
input(self)
|
||||
} else {
|
||||
self.form_owner().map_or(false, |t| owner(t.r()))
|
||||
self.form_owner().map_or(false, |t| owner(&t))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,6 @@ impl HTMLIFrameElement {
|
|||
pub fn set_visible(&self, visible: bool) {
|
||||
if let Some(pipeline_id) = self.pipeline_id.get() {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let msg = ConstellationMsg::SetVisible(pipeline_id, visible);
|
||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||
}
|
||||
|
@ -265,7 +264,6 @@ impl HTMLIFrameElement {
|
|||
pub fn get_content_window(&self) -> Option<Root<Window>> {
|
||||
self.pipeline_id.get().and_then(|pipeline_id| {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let browsing_context = window.browsing_context();
|
||||
browsing_context.find_child_by_id(pipeline_id)
|
||||
})
|
||||
|
|
|
@ -87,7 +87,6 @@ impl Runnable for ImageResponseHandlerRunnable {
|
|||
fn handler(self: Box<Self>) {
|
||||
// Update the image field
|
||||
let element = self.element.root();
|
||||
let element_ref = element.r();
|
||||
let (image, metadata, trigger_image_load, trigger_image_error) = match self.image {
|
||||
ImageResponse::Loaded(image) | ImageResponse::PlaceholderLoaded(image) => {
|
||||
(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)
|
||||
};
|
||||
element_ref.current_request.borrow_mut().image = image;
|
||||
element_ref.current_request.borrow_mut().metadata = metadata;
|
||||
element.current_request.borrow_mut().image = image;
|
||||
element.current_request.borrow_mut().metadata = metadata;
|
||||
|
||||
// Mark the node dirty
|
||||
let document = document_from_node(&*element);
|
||||
|
@ -115,7 +114,7 @@ impl Runnable for ImageResponseHandlerRunnable {
|
|||
}
|
||||
|
||||
// Trigger reflow
|
||||
let window = window_from_node(document.r());
|
||||
let window = window_from_node(&*document);
|
||||
window.add_pending_reflow();
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +228,7 @@ impl HTMLImageElement {
|
|||
width: Option<u32>,
|
||||
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
|
||||
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 {
|
||||
image.SetWidth(w);
|
||||
}
|
||||
|
|
|
@ -412,7 +412,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
|
|||
ValueMode::Filename => {
|
||||
if value.is_empty() {
|
||||
let window = window_from_node(self);
|
||||
let fl = FileList::new(window.r(), vec![]);
|
||||
let fl = FileList::new(&window, vec![]);
|
||||
self.filelist.set(Some(&fl));
|
||||
} else {
|
||||
return Err(Error::InvalidState);
|
||||
|
@ -595,7 +595,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
|
|||
atom!("select"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
window.r());
|
||||
&window);
|
||||
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>) {
|
||||
let iter = doc_node.query_selector_iter(DOMString::from("input[type=radio]")).unwrap()
|
||||
.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 {
|
||||
if r.Checked() {
|
||||
r.SetChecked(false);
|
||||
|
@ -813,7 +813,7 @@ impl HTMLInputElement {
|
|||
match recv.recv().expect("IpcSender side error") {
|
||||
Ok(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),
|
||||
|
@ -836,7 +836,7 @@ impl HTMLInputElement {
|
|||
|
||||
match recv.recv().expect("IpcSender side error") {
|
||||
Ok(selected) => {
|
||||
files.push(File::new_from_selected(window.r(), selected));
|
||||
files.push(File::new_from_selected(&window, selected));
|
||||
},
|
||||
Err(err) => error = Some(err),
|
||||
};
|
||||
|
@ -845,7 +845,7 @@ impl HTMLInputElement {
|
|||
if let Some(err) = error {
|
||||
debug!("Input file select error: {:?}", err);
|
||||
} else {
|
||||
let filelist = FileList::new(window.r(), files);
|
||||
let filelist = FileList::new(&window, files);
|
||||
self.filelist.set(Some(&filelist));
|
||||
|
||||
target.fire_event("input",
|
||||
|
@ -931,7 +931,7 @@ impl VirtualMethods for HTMLInputElement {
|
|||
|
||||
if new_type == InputType::InputFile {
|
||||
let window = window_from_node(self);
|
||||
let filelist = FileList::new(window.r(), vec![]);
|
||||
let filelist = FileList::new(&window, vec![]);
|
||||
self.filelist.set(Some(&filelist));
|
||||
}
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ impl VirtualMethods for HTMLInputElement {
|
|||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
window.r());
|
||||
&window);
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
|
@ -1200,7 +1200,7 @@ impl Activatable for HTMLInputElement {
|
|||
.unwrap()
|
||||
.filter_map(Root::downcast::<HTMLInputElement>)
|
||||
.find(|r| {
|
||||
in_same_group(r.r(), owner.r(), group.as_ref()) &&
|
||||
in_same_group(&*r, owner.r(), group.as_ref()) &&
|
||||
r.Checked()
|
||||
});
|
||||
cache.checked_radio = checked_member.r().map(JS::from_ref);
|
||||
|
@ -1349,7 +1349,7 @@ impl Activatable for HTMLInputElement {
|
|||
return;
|
||||
}
|
||||
form.submit(SubmittedFrom::NotFromForm,
|
||||
FormSubmitter::FormElement(form.r()));
|
||||
FormSubmitter::FormElement(&form));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -364,10 +364,7 @@ impl FetchResponseListener for StylesheetContext {
|
|||
sheet.set_media(Some(media));
|
||||
let sheet = Arc::new(sheet);
|
||||
|
||||
let elem = elem.r();
|
||||
let document = document.r();
|
||||
|
||||
let win = window_from_node(elem);
|
||||
let win = window_from_node(&*elem);
|
||||
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
||||
|
||||
*elem.stylesheet.borrow_mut() = Some(sheet);
|
||||
|
|
|
@ -74,7 +74,7 @@ impl HTMLObjectElementMethods for HTMLObjectElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||
fn Validity(&self) -> Root<ValidityState> {
|
||||
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
|
||||
|
|
|
@ -41,10 +41,10 @@ impl HTMLOptionsCollection {
|
|||
|
||||
fn add_new_elements(&self, count: u32) -> ErrorResult {
|
||||
let root = self.upcast().root_node();
|
||||
let document = document_from_node(root.r());
|
||||
let document = document_from_node(&*root);
|
||||
|
||||
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>();
|
||||
try!(root.AppendChild(node));
|
||||
};
|
||||
|
@ -94,12 +94,12 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
|
|||
let node = value.upcast::<Node>();
|
||||
let root = self.upcast().root_node();
|
||||
if n >= 0 {
|
||||
Node::pre_insert(node, root.r(), None).map(|_| ())
|
||||
Node::pre_insert(node, &root, None).map(|_| ())
|
||||
} else {
|
||||
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 {
|
||||
// Step 1
|
||||
|
@ -138,14 +138,14 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
|
|||
};
|
||||
|
||||
// Step 1
|
||||
if node.is_ancestor_of(root.r()) {
|
||||
if node.is_ancestor_of(&root) {
|
||||
return Err(Error::HierarchyRequest);
|
||||
}
|
||||
|
||||
if let Some(HTMLElementOrLong::HTMLElement(ref before_element)) = before {
|
||||
// Step 2
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -173,13 +173,13 @@ impl HTMLOptionsCollectionMethods for HTMLOptionsCollection {
|
|||
};
|
||||
|
||||
// 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
|
||||
fn Remove(&self, index: i32) {
|
||||
if let Some(element) = self.upcast().IndexedGetter(index as u32) {
|
||||
element.r().Remove();
|
||||
element.Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ impl HTMLOutputElementMethods for HTMLOutputElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-cva-validity
|
||||
fn Validity(&self) -> Root<ValidityState> {
|
||||
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
|
||||
|
|
|
@ -210,7 +210,7 @@ impl FetchResponseListener for ScriptContext {
|
|||
*elem.load.borrow_mut() = Some(load);
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ impl HTMLScriptElement {
|
|||
// TODO: make this suspension happen automatically.
|
||||
if was_parser_inserted {
|
||||
if let Some(parser) = doc.get_current_parser() {
|
||||
parser.r().suspend();
|
||||
parser.suspend();
|
||||
}
|
||||
}
|
||||
NextParserState::Suspend
|
||||
|
@ -495,7 +495,6 @@ impl HTMLScriptElement {
|
|||
|
||||
// Step 4.
|
||||
let document = document_from_node(self);
|
||||
let document = document.r();
|
||||
let old_script = document.GetCurrentScript();
|
||||
|
||||
// Step 5.a.1.
|
||||
|
@ -521,13 +520,13 @@ impl HTMLScriptElement {
|
|||
if script.external {
|
||||
self.dispatch_load_event();
|
||||
} 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) {
|
||||
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 {
|
||||
|
@ -603,7 +602,6 @@ impl HTMLScriptElement {
|
|||
bubbles: EventBubbles,
|
||||
cancelable: EventCancelable) -> EventStatus {
|
||||
let window = window_from_node(self);
|
||||
let window = window.r();
|
||||
let event = Event::new(window.upcast(), type_, bubbles, cancelable);
|
||||
event.fire(self.upcast())
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ impl CollectionFilter for OptionsFilter {
|
|||
|
||||
match node.GetParentNode() {
|
||||
Some(optgroup) =>
|
||||
optgroup.is::<HTMLOptGroupElement>() && root.is_parent_of(optgroup.r()),
|
||||
optgroup.is::<HTMLOptGroupElement>() && root.is_parent_of(&optgroup),
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
|
@ -97,11 +97,11 @@ impl HTMLSelectElement {
|
|||
for opt in node.traverse_preorder().filter_map(Root::downcast::<HTMLOptionElement>) {
|
||||
if opt.Selected() {
|
||||
opt.set_selectedness(false);
|
||||
last_selected = Some(Root::from_ref(opt.r()));
|
||||
last_selected = Some(Root::from_ref(&opt));
|
||||
}
|
||||
let element = opt.upcast::<Element>();
|
||||
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
|
||||
fn Validity(&self) -> Root<ValidityState> {
|
||||
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.
|
||||
|
@ -219,8 +219,8 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
|
|||
fn Options(&self) -> Root<HTMLOptionsCollection> {
|
||||
self.options.or_init(|| {
|
||||
let window = window_from_node(self);
|
||||
HTMLOptionsCollection::new(window.r(),
|
||||
self.upcast(), box OptionsFilter)
|
||||
HTMLOptionsCollection::new(
|
||||
&window, self.upcast(), box OptionsFilter)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ impl HTMLStyleElement {
|
|||
win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap();
|
||||
*self.stylesheet.borrow_mut() = Some(sheet);
|
||||
let doc = document_from_node(self);
|
||||
doc.r().invalidate_stylesheets();
|
||||
doc.invalidate_stylesheets();
|
||||
}
|
||||
|
||||
pub fn get_stylesheet(&self) -> Option<Arc<Stylesheet>> {
|
||||
|
|
|
@ -71,7 +71,7 @@ impl HTMLTableCellElementMethods for 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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ impl HTMLTableElement {
|
|||
|
||||
let section = HTMLTableSectionElement::new(atom.clone(),
|
||||
None,
|
||||
document_from_node(self).r());
|
||||
&document_from_node(self));
|
||||
match atom {
|
||||
&atom!("thead") => self.SetTHead(Some(§ion)),
|
||||
&atom!("tfoot") => self.SetTFoot(Some(§ion)),
|
||||
|
@ -150,7 +150,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
// https://html.spec.whatwg.org/multipage/#dom-table-rows
|
||||
fn Rows(&self) -> Root<HTMLCollection> {
|
||||
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
|
||||
|
@ -178,8 +178,8 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
None => {
|
||||
let caption = HTMLTableCaptionElement::new(atom!("caption"),
|
||||
None,
|
||||
document_from_node(self).r());
|
||||
self.SetCaption(Some(caption.r()));
|
||||
&document_from_node(self));
|
||||
self.SetCaption(Some(&caption));
|
||||
caption
|
||||
}
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
self.tbodies.or_init(|| {
|
||||
let window = window_from_node(self);
|
||||
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> {
|
||||
let tbody = HTMLTableSectionElement::new(atom!("tbody"),
|
||||
None,
|
||||
document_from_node(self).r());
|
||||
&document_from_node(self));
|
||||
let node = self.upcast::<Node>();
|
||||
let last_tbody =
|
||||
node.rev_children()
|
||||
|
@ -298,7 +298,7 @@ impl HTMLTableElementMethods for HTMLTableElement {
|
|||
|
||||
let new_row = HTMLTableRowElement::new(atom!("tr"),
|
||||
None,
|
||||
document_from_node(self).r());
|
||||
&document_from_node(self));
|
||||
let node = self.upcast::<Node>();
|
||||
|
||||
if number_of_row_elements == 0 {
|
||||
|
|
|
@ -77,7 +77,7 @@ impl HTMLTableRowElementMethods for HTMLTableRowElement {
|
|||
self.cells.or_init(|| {
|
||||
let window = window_from_node(self);
|
||||
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(
|
||||
index,
|
||||
|| 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
|
||||
|
|
|
@ -62,7 +62,7 @@ impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
|
|||
node.insert_cell_or_row(
|
||||
index,
|
||||
|| 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
|
||||
|
|
|
@ -263,7 +263,7 @@ impl HTMLTextAreaElementMethods for HTMLTextAreaElement {
|
|||
atom!("select"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
window.r());
|
||||
&window);
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +387,7 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
atom!("input"),
|
||||
EventBubbles::Bubbles,
|
||||
EventCancelable::NotCancelable,
|
||||
window.r());
|
||||
&window);
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||
|
|
|
@ -218,7 +218,7 @@ impl Node {
|
|||
},
|
||||
Some(ref prev_sibling) => {
|
||||
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));
|
||||
|
@ -517,7 +517,7 @@ impl Node {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -553,7 +553,7 @@ impl Node {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -692,7 +692,7 @@ impl Node {
|
|||
let node = try!(doc.node_from_nodes_and_strings(nodes));
|
||||
// Step 2.
|
||||
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
|
||||
|
@ -701,7 +701,7 @@ impl Node {
|
|||
let doc = self.owner_doc();
|
||||
let node = try!(doc.node_from_nodes_and_strings(nodes));
|
||||
// Step 2.
|
||||
self.AppendChild(node.r()).map(|_| ())
|
||||
self.AppendChild(&node).map(|_| ())
|
||||
}
|
||||
|
||||
// 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>> {
|
||||
let window = window_from_node(self);
|
||||
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 {
|
||||
|
@ -789,7 +789,7 @@ impl Node {
|
|||
|
||||
pub fn remove_self(&self) {
|
||||
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
|
||||
pub fn parse_fragment(&self, markup: DOMString) -> Fallible<Root<DocumentFragment>> {
|
||||
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() {
|
||||
parse_html_fragment(self.upcast(), markup, fragment.upcast());
|
||||
} else {
|
||||
|
@ -1502,7 +1502,7 @@ impl Node {
|
|||
match child {
|
||||
Some(child) => {
|
||||
if parent.children()
|
||||
.take_while(|c| c.r() != child)
|
||||
.take_while(|c| &**c != child)
|
||||
.any(|c| c.is::<Element>())
|
||||
{
|
||||
return Err(Error::HierarchyRequest);
|
||||
|
@ -1540,7 +1540,7 @@ impl Node {
|
|||
|
||||
// Step 4.
|
||||
let document = document_from_node(parent);
|
||||
Node::adopt(node, document.r());
|
||||
Node::adopt(node, &document);
|
||||
|
||||
// Step 5.
|
||||
Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed);
|
||||
|
@ -1645,7 +1645,7 @@ impl Node {
|
|||
fn pre_remove(child: &Node, parent: &Node) -> Fallible<Root<Node>> {
|
||||
// Step 1.
|
||||
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),
|
||||
_ => ()
|
||||
}
|
||||
|
@ -1659,7 +1659,7 @@ impl Node {
|
|||
|
||||
// https://dom.spec.whatwg.org/#concept-node-remove
|
||||
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 = {
|
||||
if parent.ranges.is_empty() {
|
||||
None
|
||||
|
@ -1708,11 +1708,12 @@ impl Node {
|
|||
let doctype = node.downcast::<DocumentType>().unwrap();
|
||||
let doctype = DocumentType::new(doctype.name().clone(),
|
||||
Some(doctype.public_id().clone()),
|
||||
Some(doctype.system_id().clone()), document.r());
|
||||
Some(doctype.system_id().clone()),
|
||||
&document);
|
||||
Root::upcast::<Node>(doctype)
|
||||
},
|
||||
NodeTypeId::DocumentFragment => {
|
||||
let doc_fragment = DocumentFragment::new(document.r());
|
||||
let doc_fragment = DocumentFragment::new(&document);
|
||||
Root::upcast::<Node>(doc_fragment)
|
||||
},
|
||||
NodeTypeId::CharacterData(_) => {
|
||||
|
@ -1743,7 +1744,7 @@ impl Node {
|
|||
};
|
||||
let element = Element::create(name,
|
||||
element.prefix().as_ref().map(|p| Atom::from(&**p)),
|
||||
document.r(), ElementCreator::ScriptCreated);
|
||||
&document, ElementCreator::ScriptCreated);
|
||||
Root::upcast::<Node>(element)
|
||||
},
|
||||
};
|
||||
|
@ -1751,7 +1752,7 @@ impl Node {
|
|||
// Step 3.
|
||||
let document = match copy.downcast::<Document>() {
|
||||
Some(doc) => Root::from_ref(doc),
|
||||
None => Root::from_ref(document.r()),
|
||||
None => Root::from_ref(&*document),
|
||||
};
|
||||
assert!(copy.owner_doc() == document);
|
||||
|
||||
|
@ -1779,14 +1780,14 @@ impl Node {
|
|||
}
|
||||
|
||||
// Step 5: cloning steps.
|
||||
vtable_for(&node).cloning_steps(copy.r(), maybe_doc, clone_children);
|
||||
vtable_for(&node).cloning_steps(©, maybe_doc, clone_children);
|
||||
|
||||
// Step 6.
|
||||
if clone_children == CloneChildrenFlag::CloneChildren {
|
||||
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);
|
||||
let _inserted_node = Node::pre_insert(child_copy.r(), copy.r(), None);
|
||||
let _inserted_node = Node::pre_insert(&child_copy, ©, None);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2121,12 +2122,12 @@ impl NodeMethods for Node {
|
|||
NodeTypeId::DocumentType => {
|
||||
if self.children()
|
||||
.any(|c| c.is_doctype() &&
|
||||
c.r() != child)
|
||||
&*c != child)
|
||||
{
|
||||
return Err(Error::HierarchyRequest);
|
||||
}
|
||||
if self.children()
|
||||
.take_while(|c| c.r() != child)
|
||||
.take_while(|c| &**c != child)
|
||||
.any(|c| c.is::<Element>())
|
||||
{
|
||||
return Err(Error::HierarchyRequest);
|
||||
|
@ -2151,7 +2152,7 @@ impl NodeMethods for Node {
|
|||
|
||||
// Step 10.
|
||||
let document = document_from_node(self);
|
||||
Node::adopt(node, document.r());
|
||||
Node::adopt(node, &document);
|
||||
|
||||
let removed_child = if node != child {
|
||||
// Step 11.
|
||||
|
@ -2294,7 +2295,7 @@ impl NodeMethods for Node {
|
|||
|
||||
// Step 6.
|
||||
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 {
|
||||
|
@ -2322,7 +2323,7 @@ impl NodeMethods for Node {
|
|||
let mut lastself = Root::from_ref(self);
|
||||
let mut lastother = Root::from_ref(other);
|
||||
for ancestor in self.ancestors() {
|
||||
if ancestor.r() == other {
|
||||
if &*ancestor == other {
|
||||
// step 4.
|
||||
return NodeConstants::DOCUMENT_POSITION_CONTAINS +
|
||||
NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
||||
|
@ -2330,7 +2331,7 @@ impl NodeMethods for Node {
|
|||
lastself = ancestor;
|
||||
}
|
||||
for ancestor in other.ancestors() {
|
||||
if ancestor.r() == self {
|
||||
if &*ancestor == self {
|
||||
// step 5.
|
||||
return NodeConstants::DOCUMENT_POSITION_CONTAINED_BY +
|
||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING;
|
||||
|
@ -2354,11 +2355,11 @@ impl NodeMethods for Node {
|
|||
}
|
||||
|
||||
for child in lastself.traverse_preorder() {
|
||||
if child.r() == other {
|
||||
if &*child == other {
|
||||
// step 6.
|
||||
return NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
||||
}
|
||||
if child.r() == self {
|
||||
if &*child == self {
|
||||
// step 7.
|
||||
return NodeConstants::DOCUMENT_POSITION_FOLLOWING;
|
||||
}
|
||||
|
|
|
@ -107,12 +107,12 @@ impl NodeIteratorMethods for NodeIterator {
|
|||
before_node = false;
|
||||
|
||||
// Step 3-2.
|
||||
let result = try!(self.accept_node(node.r()));
|
||||
let result = try!(self.accept_node(&node));
|
||||
|
||||
// Step 3-3.
|
||||
if result == NodeFilterConstants::FILTER_ACCEPT {
|
||||
// Step 4.
|
||||
self.reference_node.set(node.r());
|
||||
self.reference_node.set(&node);
|
||||
self.pointer_before_reference_node.set(before_node);
|
||||
|
||||
return Ok(Some(node));
|
||||
|
@ -122,12 +122,12 @@ impl NodeIteratorMethods for NodeIterator {
|
|||
// Step 3-1.
|
||||
for following_node in node.following_nodes(&self.root_node) {
|
||||
// Step 3-2.
|
||||
let result = try!(self.accept_node(following_node.r()));
|
||||
let result = try!(self.accept_node(&following_node));
|
||||
|
||||
// Step 3-3.
|
||||
if result == NodeFilterConstants::FILTER_ACCEPT {
|
||||
// Step 4.
|
||||
self.reference_node.set(following_node.r());
|
||||
self.reference_node.set(&following_node);
|
||||
self.pointer_before_reference_node.set(before_node);
|
||||
|
||||
return Ok(Some(following_node));
|
||||
|
@ -151,12 +151,12 @@ impl NodeIteratorMethods for NodeIterator {
|
|||
before_node = true;
|
||||
|
||||
// Step 3-2.
|
||||
let result = try!(self.accept_node(node.r()));
|
||||
let result = try!(self.accept_node(&node));
|
||||
|
||||
// Step 3-3.
|
||||
if result == NodeFilterConstants::FILTER_ACCEPT {
|
||||
// Step 4.
|
||||
self.reference_node.set(node.r());
|
||||
self.reference_node.set(&node);
|
||||
self.pointer_before_reference_node.set(before_node);
|
||||
|
||||
return Ok(Some(node));
|
||||
|
@ -166,12 +166,12 @@ impl NodeIteratorMethods for NodeIterator {
|
|||
// Step 3-1.
|
||||
for preceding_node in node.preceding_nodes(&self.root_node) {
|
||||
// Step 3-2.
|
||||
let result = try!(self.accept_node(preceding_node.r()));
|
||||
let result = try!(self.accept_node(&preceding_node));
|
||||
|
||||
// Step 3-3.
|
||||
if result == NodeFilterConstants::FILTER_ACCEPT {
|
||||
// Step 4.
|
||||
self.reference_node.set(preceding_node.r());
|
||||
self.reference_node.set(&preceding_node);
|
||||
self.pointer_before_reference_node.set(before_node);
|
||||
|
||||
return Ok(Some(preceding_node));
|
||||
|
|
|
@ -174,7 +174,7 @@ impl ChildrenList {
|
|||
.nth(index as usize)
|
||||
.unwrap()
|
||||
};
|
||||
self.last_visited.set(Some(last_visited.r()));
|
||||
self.last_visited.set(Some(&last_visited));
|
||||
self.last_index.set(index);
|
||||
Some(last_visited)
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ impl PerformanceTiming {
|
|||
-> Root<PerformanceTiming> {
|
||||
let timing = PerformanceTiming::new_inherited(navigation_start,
|
||||
navigation_start_precise,
|
||||
window.Document().r());
|
||||
&window.Document());
|
||||
reflect_dom_object(box timing,
|
||||
window,
|
||||
PerformanceTimingBinding::Wrap)
|
||||
|
|
|
@ -72,7 +72,7 @@ impl Range {
|
|||
// https://dom.spec.whatwg.org/#dom-range
|
||||
pub fn Constructor(global: &GlobalScope) -> Fallible<Root<Range>> {
|
||||
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
|
||||
|
@ -100,7 +100,7 @@ impl Range {
|
|||
let common_ancestor = self.CommonAncestorContainer();
|
||||
|
||||
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.
|
||||
None
|
||||
} else {
|
||||
|
@ -110,7 +110,7 @@ impl Range {
|
|||
};
|
||||
|
||||
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.
|
||||
None
|
||||
} else {
|
||||
|
@ -270,25 +270,25 @@ impl RangeMethods for Range {
|
|||
// https://dom.spec.whatwg.org/#dom-range-setstartbefore
|
||||
fn SetStartBefore(&self, node: &Node) -> ErrorResult {
|
||||
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
|
||||
fn SetStartAfter(&self, node: &Node) -> ErrorResult {
|
||||
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
|
||||
fn SetEndBefore(&self, node: &Node) -> ErrorResult {
|
||||
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
|
||||
fn SetEndAfter(&self, node: &Node) -> ErrorResult {
|
||||
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
|
||||
|
@ -417,9 +417,9 @@ impl RangeMethods for Range {
|
|||
// Step 4.
|
||||
let offset = node.index();
|
||||
// Step 5.
|
||||
Ordering::Greater == bp_position(parent.r(), offset + 1,
|
||||
Ordering::Greater == bp_position(&parent, offset + 1,
|
||||
&start_node, self.StartOffset()).unwrap() &&
|
||||
Ordering::Less == bp_position(parent.r(), offset,
|
||||
Ordering::Less == bp_position(&parent, offset,
|
||||
&self.EndContainer(), self.EndOffset()).unwrap()
|
||||
}
|
||||
|
||||
|
@ -433,7 +433,7 @@ impl RangeMethods for Range {
|
|||
let end_offset = self.EndOffset();
|
||||
|
||||
// Step 1.
|
||||
let fragment = DocumentFragment::new(start_node.owner_doc().r());
|
||||
let fragment = DocumentFragment::new(&start_node.owner_doc());
|
||||
|
||||
// Step 2.
|
||||
if self.start == self.end {
|
||||
|
@ -471,10 +471,10 @@ impl RangeMethods for Range {
|
|||
// Step 14.2.
|
||||
try!(fragment.upcast::<Node>().AppendChild(&clone));
|
||||
// Step 14.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
start_node.r(),
|
||||
let subrange = Range::new(&clone.owner_doc(),
|
||||
&start_node,
|
||||
start_offset,
|
||||
child.r(),
|
||||
&child,
|
||||
child.len());
|
||||
// Step 14.4.
|
||||
let subfragment = try!(subrange.CloneContents());
|
||||
|
@ -506,10 +506,10 @@ impl RangeMethods for Range {
|
|||
// Step 17.2.
|
||||
try!(fragment.upcast::<Node>().AppendChild(&clone));
|
||||
// Step 17.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
child.r(),
|
||||
let subrange = Range::new(&clone.owner_doc(),
|
||||
&child,
|
||||
0,
|
||||
end_node.r(),
|
||||
&end_node,
|
||||
end_offset);
|
||||
// Step 17.4.
|
||||
let subfragment = try!(subrange.CloneContents());
|
||||
|
@ -532,7 +532,7 @@ impl RangeMethods for Range {
|
|||
let end_offset = self.EndOffset();
|
||||
|
||||
// Step 1.
|
||||
let fragment = DocumentFragment::new(start_node.owner_doc().r());
|
||||
let fragment = DocumentFragment::new(&start_node.owner_doc());
|
||||
|
||||
// Step 2.
|
||||
if self.Collapsed() {
|
||||
|
@ -561,9 +561,9 @@ impl RangeMethods for Range {
|
|||
let (first_contained_child, last_contained_child, 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.
|
||||
(Root::from_ref(start_node.r()), start_offset)
|
||||
(Root::from_ref(&*start_node), start_offset)
|
||||
} else {
|
||||
// Step 14.1-2.
|
||||
let reference_node = start_node.ancestors()
|
||||
|
@ -595,10 +595,10 @@ impl RangeMethods for Range {
|
|||
// Step 16.2.
|
||||
try!(fragment.upcast::<Node>().AppendChild(&clone));
|
||||
// Step 16.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
start_node.r(),
|
||||
let subrange = Range::new(&clone.owner_doc(),
|
||||
&start_node,
|
||||
start_offset,
|
||||
child.r(),
|
||||
&child,
|
||||
child.len());
|
||||
// Step 16.4.
|
||||
let subfragment = try!(subrange.ExtractContents());
|
||||
|
@ -630,10 +630,10 @@ impl RangeMethods for Range {
|
|||
// Step 19.2.
|
||||
try!(fragment.upcast::<Node>().AppendChild(&clone));
|
||||
// Step 19.3.
|
||||
let subrange = Range::new(clone.owner_doc().r(),
|
||||
child.r(),
|
||||
let subrange = Range::new(&clone.owner_doc(),
|
||||
&child,
|
||||
0,
|
||||
end_node.r(),
|
||||
&end_node,
|
||||
end_offset);
|
||||
// Step 19.4.
|
||||
let subfragment = try!(subrange.ExtractContents());
|
||||
|
@ -643,8 +643,8 @@ impl RangeMethods for Range {
|
|||
}
|
||||
|
||||
// Step 20.
|
||||
try!(self.SetStart(new_node.r(), new_offset));
|
||||
try!(self.SetEnd(new_node.r(), new_offset));
|
||||
try!(self.SetStart(&new_node, new_offset));
|
||||
try!(self.SetEnd(&new_node, new_offset));
|
||||
|
||||
// Step 21.
|
||||
Ok(fragment)
|
||||
|
@ -682,16 +682,16 @@ impl RangeMethods for Range {
|
|||
None => return Err(Error::HierarchyRequest)
|
||||
};
|
||||
// Step 5.
|
||||
(Some(Root::from_ref(start_node.r())), parent)
|
||||
(Some(Root::from_ref(&*start_node)), parent)
|
||||
} else {
|
||||
// Steps 4-5.
|
||||
let child = start_node.ChildNodes().Item(start_offset);
|
||||
(child, Root::from_ref(start_node.r()))
|
||||
(child, Root::from_ref(&*start_node))
|
||||
};
|
||||
|
||||
// Step 6.
|
||||
try!(Node::ensure_pre_insertion_validity(node,
|
||||
parent.r(),
|
||||
&parent,
|
||||
reference_node.r()));
|
||||
|
||||
// Step 7.
|
||||
|
@ -701,7 +701,7 @@ impl RangeMethods for Range {
|
|||
Some(text) => {
|
||||
split_text = try!(text.SplitText(start_offset));
|
||||
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)
|
||||
},
|
||||
_ => reference_node
|
||||
|
@ -729,11 +729,11 @@ impl RangeMethods for Range {
|
|||
};
|
||||
|
||||
// Step 12.
|
||||
try!(Node::pre_insert(node, parent.r(), reference_node.r()));
|
||||
try!(Node::pre_insert(node, &parent, reference_node.r()));
|
||||
|
||||
// Step 13.
|
||||
if self.Collapsed() {
|
||||
self.set_end(parent.r(), new_offset);
|
||||
self.set_end(&parent, new_offset);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -765,21 +765,21 @@ impl RangeMethods for Range {
|
|||
rooted_vec!(let mut contained_children);
|
||||
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();
|
||||
while let Some(child) = next {
|
||||
if self.contains(child.r()) {
|
||||
contained_children.push(JS::from_ref(child.r()));
|
||||
if self.contains(&child) {
|
||||
contained_children.push(JS::from_ref(&*child));
|
||||
next = iter.next_skipping_children();
|
||||
} else {
|
||||
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.
|
||||
(Root::from_ref(start_node.r()), start_offset)
|
||||
(Root::from_ref(&*start_node), start_offset)
|
||||
} else {
|
||||
// Step 6.
|
||||
fn compute_reference(start_node: &Node, end_node: &Node) -> (Root<Node>, u32) {
|
||||
|
@ -793,7 +793,7 @@ impl RangeMethods for Range {
|
|||
unreachable!()
|
||||
}
|
||||
|
||||
compute_reference(start_node.r(), end_node.r())
|
||||
compute_reference(&start_node, &end_node)
|
||||
};
|
||||
|
||||
// Step 7.
|
||||
|
@ -814,8 +814,8 @@ impl RangeMethods for Range {
|
|||
}
|
||||
|
||||
// Step 10.
|
||||
self.SetStart(new_node.r(), new_offset).unwrap();
|
||||
self.SetEnd(new_node.r(), new_offset).unwrap();
|
||||
self.SetStart(&new_node, new_offset).unwrap();
|
||||
self.SetEnd(&new_node, new_offset).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -825,8 +825,8 @@ impl RangeMethods for Range {
|
|||
let start = self.StartContainer();
|
||||
let end = self.EndContainer();
|
||||
|
||||
if start.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(end.r()) && !n.is::<Text>()) ||
|
||||
end.inclusive_ancestors().any(|n| !n.is_inclusive_ancestor_of(start.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) && !n.is::<Text>()) {
|
||||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
|
@ -878,7 +878,7 @@ impl RangeMethods for Range {
|
|||
|
||||
// Step 4.
|
||||
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>);
|
||||
|
||||
while let Some(child) = iter.next() {
|
||||
|
@ -1004,7 +1004,7 @@ fn bp_position(a_node: &Node, a_offset: u32,
|
|||
// Step 3-1, 3-2.
|
||||
let mut b_ancestors = b_node.inclusive_ancestors();
|
||||
let child = b_ancestors.find(|child| {
|
||||
child.GetParentNode().unwrap().r() == a_node
|
||||
&*child.GetParentNode().unwrap() == a_node
|
||||
}).unwrap();
|
||||
// Step 3-3.
|
||||
if child.index() < a_offset {
|
||||
|
|
|
@ -163,7 +163,7 @@ impl<'a> TreeSink for Sink {
|
|||
|
||||
fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) {
|
||||
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 {
|
||||
try!(handle.r().serialize(serializer, IncludeNode));
|
||||
try!((&*handle).serialize(serializer, IncludeNode));
|
||||
}
|
||||
|
||||
if traversal_scope == IncludeNode {
|
||||
|
@ -211,7 +211,7 @@ impl<'a> Serializable for &'a Node {
|
|||
|
||||
(ChildrenOnly, NodeTypeId::Document(_)) => {
|
||||
for handle in node.children() {
|
||||
try!(handle.r().serialize(serializer, IncludeNode));
|
||||
try!((&*handle).serialize(serializer, IncludeNode));
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
|
@ -307,12 +307,11 @@ pub fn parse_html_fragment(context_node: &Node,
|
|||
output: &Node) {
|
||||
let window = window_from_node(context_node);
|
||||
let context_document = document_from_node(context_node);
|
||||
let context_document = context_document.r();
|
||||
let url = context_document.url();
|
||||
|
||||
// Step 1.
|
||||
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,
|
||||
None, None,
|
||||
DocumentSource::FromParser,
|
||||
|
@ -329,11 +328,11 @@ pub fn parse_html_fragment(context_node: &Node,
|
|||
context_elem: context_node,
|
||||
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.
|
||||
let root_element = document.GetDocumentElement().expect("no document element");
|
||||
for child in root_element.upcast::<Node>().children() {
|
||||
output.AppendChild(child.r()).unwrap();
|
||||
output.AppendChild(&child).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ impl<'a> TreeSink for Sink {
|
|||
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,
|
||||
|
|
|
@ -180,8 +180,7 @@ impl Runnable for StorageEventRunnable {
|
|||
|
||||
fn main_thread_handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
|
||||
let this = *self;
|
||||
let storage_root = this.element.root();
|
||||
let storage = storage_root.r();
|
||||
let storage = this.element.root();
|
||||
let global = storage.global();
|
||||
let ev_url = storage.get_url();
|
||||
|
||||
|
@ -191,13 +190,12 @@ impl Runnable for StorageEventRunnable {
|
|||
EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
|
||||
this.key.map(DOMString::from), this.old_value.map(DOMString::from), this.new_value.map(DOMString::from),
|
||||
DOMString::from(ev_url.to_string()),
|
||||
Some(storage)
|
||||
Some(&storage)
|
||||
);
|
||||
|
||||
let root_context = script_thread.root_browsing_context();
|
||||
for it_context in root_context.iter() {
|
||||
let it_window_root = it_context.active_window();
|
||||
let it_window = it_window_root.r();
|
||||
let it_window = it_context.active_window();
|
||||
assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url()));
|
||||
// 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.
|
||||
|
|
|
@ -37,7 +37,7 @@ impl Text {
|
|||
|
||||
pub fn Constructor(global: &GlobalScope, text: DOMString) -> Fallible<Root<Text>> {
|
||||
let document = global.as_window().Document();
|
||||
Ok(Text::new(text, document.r()))
|
||||
Ok(Text::new(text, &document))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -96,14 +96,14 @@ impl TreeWalkerMethods for TreeWalker {
|
|||
// "1. Let node be the value of the currentNode attribute."
|
||||
let mut node = self.current_node.get();
|
||||
// "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."
|
||||
match node.GetParentNode() {
|
||||
Some(n) => {
|
||||
node = n;
|
||||
// "2. If node is not null and filtering node returns FILTER_ACCEPT,
|
||||
// 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);
|
||||
return Ok(Some(node))
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ impl TreeWalkerMethods for TreeWalker {
|
|||
// "1. Let node be the value of the currentNode attribute."
|
||||
let mut node = self.current_node.get();
|
||||
// "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."
|
||||
let mut sibling_op = node.GetPreviousSibling();
|
||||
// "2. While sibling is not null, run these subsubsteps:"
|
||||
|
@ -162,7 +162,7 @@ impl TreeWalkerMethods for TreeWalker {
|
|||
// "4. If result is FILTER_ACCEPT, then
|
||||
// set the currentNode attribute to node and return node."
|
||||
loop {
|
||||
let result = try!(self.accept_node(node.r()));
|
||||
let result = try!(self.accept_node(&node));
|
||||
match result {
|
||||
NodeFilterConstants::FILTER_REJECT => break,
|
||||
_ if node.GetFirstChild().is_some() =>
|
||||
|
@ -178,7 +178,7 @@ impl TreeWalkerMethods for TreeWalker {
|
|||
sibling_op = node.GetPreviousSibling()
|
||||
}
|
||||
// "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)
|
||||
}
|
||||
// "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
|
||||
// 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);
|
||||
return Ok(Some(node))
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ impl TreeWalkerMethods for TreeWalker {
|
|||
// "1. Set node to its first child."
|
||||
node = child;
|
||||
// "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
|
||||
// set the currentNode attribute to node and return node."
|
||||
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,
|
||||
// set node to the first such node."
|
||||
// "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),
|
||||
Some(n) => {
|
||||
node = n;
|
||||
// "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
|
||||
// set the currentNode attribute to node and return node."
|
||||
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."
|
||||
// "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,
|
||||
None => return Ok(None),
|
||||
};
|
||||
|
@ -277,19 +277,19 @@ impl TreeWalker {
|
|||
// 4. Main: Repeat these substeps:
|
||||
'main: loop {
|
||||
// "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 {
|
||||
// "2. If result is FILTER_ACCEPT, then set the currentNode
|
||||
// attribute to node and return node."
|
||||
NodeFilterConstants::FILTER_ACCEPT => {
|
||||
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:"
|
||||
NodeFilterConstants::FILTER_SKIP => {
|
||||
// "1. Let child be node's first child if type is first,
|
||||
// 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."
|
||||
Some(child) => {
|
||||
node = child;
|
||||
|
@ -304,7 +304,7 @@ impl TreeWalker {
|
|||
loop {
|
||||
// "1. Let sibling be node's next sibling if type is next,
|
||||
// and node's previous sibling if type is previous."
|
||||
match next_sibling(node.r()) {
|
||||
match next_sibling(&node) {
|
||||
// "2. If sibling is not null,
|
||||
// set node to sibling and goto Main."
|
||||
Some(sibling) => {
|
||||
|
@ -318,8 +318,8 @@ impl TreeWalker {
|
|||
// or parent is currentNode attribute's value,
|
||||
// return null."
|
||||
None => return Ok(None),
|
||||
Some(ref parent) if self.is_root_node(parent.r())
|
||||
|| self.is_current_node(parent.r()) =>
|
||||
Some(ref parent) if self.is_root_node(&parent)
|
||||
|| self.is_current_node(&parent) =>
|
||||
return Ok(None),
|
||||
// "5. Otherwise, set node to parent."
|
||||
Some(parent) => node = parent
|
||||
|
@ -342,20 +342,20 @@ impl TreeWalker {
|
|||
// "1. Let node be the value of the currentNode attribute."
|
||||
let mut node = self.current_node.get();
|
||||
// "2. If node is root, return null."
|
||||
if self.is_root_node(node.r()) {
|
||||
if self.is_root_node(&node) {
|
||||
return Ok(None)
|
||||
}
|
||||
// "3. Run these substeps:"
|
||||
loop {
|
||||
// "1. Let sibling be node's next sibling if type is next,
|
||||
// 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:"
|
||||
while sibling_op.is_some() {
|
||||
// "1. Set node to sibling."
|
||||
node = sibling_op.unwrap();
|
||||
// "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
|
||||
// attribute to node and return node."
|
||||
if NodeFilterConstants::FILTER_ACCEPT == result {
|
||||
|
@ -365,13 +365,13 @@ impl TreeWalker {
|
|||
|
||||
// "4. Set sibling to node's first child if type is next,
|
||||
// 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,
|
||||
// then set sibling to node's next sibling if type is next,
|
||||
// and node's previous sibling if type is previous."
|
||||
match (result, &sibling_op) {
|
||||
(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() {
|
||||
// "4. If node is null or is root, return null."
|
||||
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."
|
||||
Some(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)
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ impl TreeWalker {
|
|||
match node.GetNextSibling() {
|
||||
None => {
|
||||
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() {
|
||||
None =>
|
||||
// This can happen if the user set the current node to somewhere
|
||||
|
@ -409,7 +409,7 @@ impl TreeWalker {
|
|||
Some(n) => candidate = n
|
||||
}
|
||||
}
|
||||
if self.is_root_node(candidate.r()) {
|
||||
if self.is_root_node(&candidate) {
|
||||
None
|
||||
} else {
|
||||
candidate.GetNextSibling()
|
||||
|
|
|
@ -21,7 +21,6 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
let node = head.upcast::<Node>();
|
||||
let first_child = node.GetFirstChild();
|
||||
let doc = node.owner_doc();
|
||||
let doc = doc.r();
|
||||
|
||||
let path = if &**path_str == "" {
|
||||
if let Ok(mut p) = resources_dir_path() {
|
||||
|
@ -46,7 +45,6 @@ pub fn load_script(head: &HTMLHeadElement) {
|
|||
_ => continue
|
||||
};
|
||||
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));
|
||||
node.InsertBefore(new_script.upcast(), first_child.r()).unwrap();
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ impl WebGLRenderingContext {
|
|||
|
||||
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::PlaceholderLoaded(_) | ImageResponse::None |
|
||||
ImageResponse::MetadataLoaded(_)
|
||||
|
@ -368,7 +368,6 @@ impl WebGLRenderingContext {
|
|||
// but we need to refactor it moving it to `HTMLCanvasElement` and support
|
||||
// WebGLContext (probably via GetPixels()).
|
||||
ImageDataOrHTMLImageElementOrHTMLCanvasElementOrHTMLVideoElement::HTMLCanvasElement(canvas) => {
|
||||
let canvas = canvas.r();
|
||||
if let Some((mut data, size)) = canvas.fetch_all_data() {
|
||||
byte_swap(&mut data);
|
||||
(data, size)
|
||||
|
|
|
@ -242,7 +242,7 @@ impl WebSocket {
|
|||
|
||||
// Step 7.
|
||||
let ws = WebSocket::new(global, resource_url.clone());
|
||||
let address = Trusted::new(ws.r());
|
||||
let address = Trusted::new(&*ws);
|
||||
|
||||
let connect_data = WebSocketConnectData {
|
||||
resource_url: resource_url.clone(),
|
||||
|
|
|
@ -81,7 +81,7 @@ impl Worker {
|
|||
let (sender, receiver) = channel();
|
||||
let closing = Arc::new(AtomicBool::new(false));
|
||||
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 {
|
||||
referrer_url: None,
|
||||
|
|
|
@ -69,7 +69,7 @@ impl XMLDocument {
|
|||
XMLDocumentBinding::Wrap);
|
||||
{
|
||||
let node = doc.upcast::<Node>();
|
||||
node.set_owner_doc(&doc.r().document);
|
||||
node.set_owner_doc(&doc.document);
|
||||
}
|
||||
doc
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
username: Option<USVString>, password: Option<USVString>) -> ErrorResult {
|
||||
// Step 1
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1111,7 +1111,7 @@ impl XMLHttpRequest {
|
|||
// Step 3, 4
|
||||
let bytes = self.response.borrow().to_vec();
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -1156,7 +1156,7 @@ impl XMLHttpRequest {
|
|||
// Step 9
|
||||
temp_doc.set_encoding(charset);
|
||||
// Step 13
|
||||
self.response_xml.set(Some(temp_doc.r()));
|
||||
self.response_xml.set(Some(&temp_doc));
|
||||
return self.response_xml.get();
|
||||
}
|
||||
|
||||
|
@ -1199,7 +1199,7 @@ impl XMLHttpRequest {
|
|||
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
||||
let document = self.new_doc(IsHTMLDocument::HTMLDocument);
|
||||
// TODO: Disable scripting while parsing
|
||||
parse_html(document.r(),
|
||||
parse_html(&document,
|
||||
DOMString::from(decoded),
|
||||
wr.get_url(),
|
||||
ParseContext::Owner(Some(wr.pipeline_id())));
|
||||
|
@ -1212,7 +1212,7 @@ impl XMLHttpRequest {
|
|||
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
||||
let document = self.new_doc(IsHTMLDocument::NonHTMLDocument);
|
||||
// TODO: Disable scripting while parsing
|
||||
parse_xml(document.r(),
|
||||
parse_xml(&document,
|
||||
DOMString::from(decoded),
|
||||
wr.get_url(),
|
||||
xml::ParseContext::Owner(Some(wr.pipeline_id())));
|
||||
|
@ -1223,7 +1223,6 @@ impl XMLHttpRequest {
|
|||
let wr = self.global();
|
||||
let win = wr.as_window();
|
||||
let doc = win.Document();
|
||||
let doc = doc.r();
|
||||
let docloader = DocumentLoader::new(&*doc.loader());
|
||||
let base = wr.get_url();
|
||||
let parsed_url = match base.join(&self.ResponseURL().0) {
|
||||
|
|
|
@ -163,8 +163,8 @@ impl FetchResponseListener for FetchContext {
|
|||
fn process_response_eof(&mut self, _response: Result<(), NetworkError>) {
|
||||
let response = self.response_object.root();
|
||||
let global = response.global();
|
||||
let cx = global.r().get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, global.r().reflector().get_jsobject().get());
|
||||
let cx = global.get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
|
||||
response.finish(mem::replace(&mut self.body, vec![]));
|
||||
// TODO
|
||||
// ... trailerObject is not supported in Servo yet.
|
||||
|
|
|
@ -1181,7 +1181,6 @@ impl ScriptThread {
|
|||
Some(browsing_context) => browsing_context.active_document(),
|
||||
None => return warn!("Message sent to closed pipeline {}.", pipeline),
|
||||
};
|
||||
let doc = doc.r();
|
||||
if doc.loader().is_blocked() {
|
||||
return;
|
||||
}
|
||||
|
@ -1189,19 +1188,19 @@ impl ScriptThread {
|
|||
doc.mut_loader().inhibit_events();
|
||||
|
||||
// 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();
|
||||
|
||||
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) {
|
||||
match doc.find_fragment_node(fragment) {
|
||||
Some(ref node) => {
|
||||
doc.set_target_element(Some(node.r()));
|
||||
self.scroll_fragment_point(pipeline_id, node.r());
|
||||
doc.set_target_element(Some(&node));
|
||||
self.scroll_fragment_point(pipeline_id, &node);
|
||||
}
|
||||
None => {
|
||||
doc.set_target_element(None);
|
||||
|
@ -1726,7 +1725,7 @@ impl ScriptThread {
|
|||
None
|
||||
};
|
||||
|
||||
let document = Document::new(window.r(),
|
||||
let document = Document::new(&window,
|
||||
Some(&browsing_context),
|
||||
Some(final_url.clone()),
|
||||
is_html_document,
|
||||
|
@ -1793,12 +1792,12 @@ impl ScriptThread {
|
|||
};
|
||||
|
||||
if is_xml {
|
||||
parse_xml(document.r(),
|
||||
parse_xml(&document,
|
||||
parse_input,
|
||||
final_url,
|
||||
xml::ParseContext::Owner(Some(incomplete.pipeline_id)));
|
||||
} else {
|
||||
parse_html(document.r(),
|
||||
parse_html(&document,
|
||||
parse_input,
|
||||
final_url,
|
||||
ParseContext::Owner(Some(incomplete.pipeline_id)));
|
||||
|
@ -1857,7 +1856,7 @@ impl ScriptThread {
|
|||
fn rebuild_and_force_reflow(&self, context: &BrowsingContext, reason: ReflowReason) {
|
||||
let document = context.active_document();
|
||||
document.dirty_all_nodes();
|
||||
let window = window_from_node(document.r());
|
||||
let window = window_from_node(&*document);
|
||||
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, reason);
|
||||
}
|
||||
|
||||
|
@ -1956,7 +1955,7 @@ impl ScriptThread {
|
|||
Some(browsing_context) => browsing_context.active_document(),
|
||||
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) => {
|
||||
|
@ -2015,7 +2014,7 @@ impl ScriptThread {
|
|||
let url = document.url();
|
||||
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -2055,15 +2054,15 @@ impl ScriptThread {
|
|||
let fragment_node = window.steal_fragment_name()
|
||||
.and_then(|name| document.find_fragment_node(&*name));
|
||||
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 => {}
|
||||
}
|
||||
|
||||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||
if size_type == WindowSizeType::Resize {
|
||||
let uievent = UIEvent::new(window.r(),
|
||||
let uievent = UIEvent::new(&window,
|
||||
DOMString::from("resize"), EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable, Some(window.r()),
|
||||
EventCancelable::NotCancelable, Some(&window),
|
||||
0i32);
|
||||
uievent.upcast::<Event>().fire(window.upcast());
|
||||
}
|
||||
|
@ -2128,7 +2127,7 @@ impl ScriptThread {
|
|||
debug!("kicking off initial reflow of {:?}", final_url);
|
||||
document.disarm_reflow_timeout();
|
||||
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);
|
||||
|
||||
// No more reflow required
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue