aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/document.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2014-12-04 11:38:54 +0100
committerMs2ger <ms2ger@gmail.com>2014-12-04 11:38:54 +0100
commitd22964792adce78cc166de3528d0ef3bff5f7d1a (patch)
tree4258bb1a128d37ca70f48320b757e202a11b1497 /components/script/dom/document.rs
parent2ce4c6c52971383e492cb1b4754f100874a2713e (diff)
downloadservo-d22964792adce78cc166de3528d0ef3bff5f7d1a.tar.gz
servo-d22964792adce78cc166de3528d0ef3bff5f7d1a.zip
Cleanup Document::SetBody.
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r--components/script/dom/document.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 53c8e78e513..f7cd7f9435e 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -821,21 +821,21 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body
fn SetBody(self, new_body: Option<JSRef<HTMLElement>>) -> ErrorResult {
// Step 1.
- match new_body {
- Some(ref htmlelem) => {
- let node: JSRef<Node> = NodeCast::from_ref(*htmlelem);
- match node.type_id() {
- ElementNodeTypeId(HTMLBodyElementTypeId) | ElementNodeTypeId(HTMLFrameSetElementTypeId) => {}
- _ => return Err(HierarchyRequest)
- }
- }
- None => return Err(HierarchyRequest)
+ let new_body = match new_body {
+ Some(new_body) => new_body,
+ None => return Err(HierarchyRequest),
+ };
+
+ let node: JSRef<Node> = NodeCast::from_ref(new_body);
+ match node.type_id() {
+ ElementNodeTypeId(HTMLBodyElementTypeId) |
+ ElementNodeTypeId(HTMLFrameSetElementTypeId) => {}
+ _ => return Err(HierarchyRequest)
}
// Step 2.
let old_body = self.GetBody().root();
- //FIXME: covariant lifetime workaround. do not judge.
- if old_body.as_ref().map(|body| body.deref()) == new_body.as_ref().map(|a| &*a) {
+ if old_body.as_ref().map(|body| **body) == Some(new_body) {
return Ok(());
}
@@ -844,8 +844,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
// Step 4.
None => return Err(HierarchyRequest),
Some(ref root) => {
- let new_body_unwrapped = new_body.unwrap();
- let new_body: JSRef<Node> = NodeCast::from_ref(new_body_unwrapped);
+ let new_body: JSRef<Node> = NodeCast::from_ref(new_body);
let root: JSRef<Node> = NodeCast::from_ref(**root);
match old_body {