Auto merge of #10516 - Ms2ger:cleanup, r=nox

Various cleanup.

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10516)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-04-11 14:13:48 +05:30
commit 5adf36231e
3 changed files with 20 additions and 29 deletions

View file

@ -606,6 +606,12 @@ impl<T: Reflectable> PartialEq for Root<T> {
} }
} }
impl<T: Reflectable> Clone for Root<T> {
fn clone(&self) -> Root<T> {
Root::from_ref(&*self)
}
}
impl<T: Reflectable> Drop for Root<T> { impl<T: Reflectable> Drop for Root<T> {
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {

View file

@ -1166,34 +1166,20 @@ impl Iterator for PrecedingNodeIterator {
Some(current) => current, Some(current) => current,
}; };
if self.root == current { self.current = if self.root == current {
self.current = None;
return None
}
let node = current;
if let Some(previous_sibling) = node.GetPreviousSibling() {
if self.root == previous_sibling {
self.current = None;
return None
}
if let Some(last_child) = previous_sibling.descending_last_children().last() {
self.current = Some(last_child);
return previous_sibling.descending_last_children().last()
}
self.current = Some(previous_sibling);
return node.GetPreviousSibling()
};
if let Some(parent_node) = node.GetParentNode() {
self.current = Some(parent_node);
return node.GetParentNode()
}
self.current = None;
None None
} else if let Some(previous_sibling) = current.GetPreviousSibling() {
if self.root == previous_sibling {
None
} else if let Some(last_child) = previous_sibling.descending_last_children().last() {
Some(last_child)
} else {
Some(previous_sibling)
}
} else {
current.GetParentNode()
};
self.current.clone()
} }
} }

View file

@ -4,7 +4,6 @@
use document_loader::DocumentLoader; use document_loader::DocumentLoader;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods}; use dom::bindings::codegen::Bindings::XMLDocumentBinding::{self, XMLDocumentMethods};
use dom::bindings::global::GlobalRef; use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable; use dom::bindings::inheritance::Castable;
@ -77,16 +76,16 @@ impl XMLDocument {
impl XMLDocumentMethods for XMLDocument { impl XMLDocumentMethods for XMLDocument {
// https://html.spec.whatwg.org/multipage/#dom-document-location // https://html.spec.whatwg.org/multipage/#dom-document-location
fn GetLocation(&self) -> Option<Root<Location>> { fn GetLocation(&self) -> Option<Root<Location>> {
self.document.GetLocation() self.upcast::<Document>().GetLocation()
} }
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names // https://html.spec.whatwg.org/multipage/#dom-tree-accessors:supported-property-names
fn SupportedPropertyNames(&self) -> Vec<DOMString> { fn SupportedPropertyNames(&self) -> Vec<DOMString> {
self.document.SupportedPropertyNames() self.upcast::<Document>().SupportedPropertyNames()
} }
// https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter // https://html.spec.whatwg.org/multipage/#dom-tree-accessors:dom-document-nameditem-filter
fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString, found: &mut bool) -> *mut JSObject { fn NamedGetter(&self, _cx: *mut JSContext, name: DOMString, found: &mut bool) -> *mut JSObject {
self.document.NamedGetter(_cx, name, found) self.upcast::<Document>().NamedGetter(_cx, name, found)
} }
} }