aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-11 14:13:48 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-11 14:13:48 +0530
commit5adf36231e739f57dc7d1d85b37fb2a47b8f5d74 (patch)
tree8ea2bce2a10dd080c61061647669ad55af50e90d /components/script
parent5aa62b3621f4793c559f6c7eb77e06259b0a00ea (diff)
parent3f95e4c8e13ac1253f662804229e3b37c85894b6 (diff)
downloadservo-5adf36231e739f57dc7d1d85b37fb2a47b8f5d74.tar.gz
servo-5adf36231e739f57dc7d1d85b37fb2a47b8f5d74.zip
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 -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/js.rs6
-rw-r--r--components/script/dom/node.rs36
-rw-r--r--components/script/dom/xmldocument.rs7
3 files changed, 20 insertions, 29 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 1736758e739..d171715d474 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -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> {
fn drop(&mut self) {
unsafe {
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 99648369357..748b7b8249e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -1166,34 +1166,20 @@ impl Iterator for PrecedingNodeIterator {
Some(current) => current,
};
- if self.root == current {
- self.current = None;
- return None
- }
-
- let node = current;
- if let Some(previous_sibling) = node.GetPreviousSibling() {
+ self.current = if self.root == current {
+ None
+ } else if let Some(previous_sibling) = current.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()
+ None
+ } else if let Some(last_child) = previous_sibling.descending_last_children().last() {
+ Some(last_child)
+ } else {
+ Some(previous_sibling)
}
-
- self.current = Some(previous_sibling);
- return node.GetPreviousSibling()
+ } else {
+ current.GetParentNode()
};
-
- if let Some(parent_node) = node.GetParentNode() {
- self.current = Some(parent_node);
- return node.GetParentNode()
- }
-
- self.current = None;
- None
+ self.current.clone()
}
}
diff --git a/components/script/dom/xmldocument.rs b/components/script/dom/xmldocument.rs
index 8f614a0442c..9d156682fa2 100644
--- a/components/script/dom/xmldocument.rs
+++ b/components/script/dom/xmldocument.rs
@@ -4,7 +4,6 @@
use document_loader::DocumentLoader;
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::global::GlobalRef;
use dom::bindings::inheritance::Castable;
@@ -77,16 +76,16 @@ impl XMLDocument {
impl XMLDocumentMethods for XMLDocument {
// https://html.spec.whatwg.org/multipage/#dom-document-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
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
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)
}
}