Clean up the cast calls

This commit is contained in:
Anthony Ramine 2015-10-07 14:55:02 +02:00
parent 13ea3ac413
commit 68014af78e
66 changed files with 412 additions and 718 deletions

View file

@ -43,7 +43,7 @@ impl Range {
}
pub fn new_with_doc(document: &Document) -> Root<Range> {
let root = document.upcast::<Node>();
let root = document.upcast();
Range::new(document, root, 0, root, 0)
}
@ -369,7 +369,7 @@ impl RangeMethods for Range {
let text = text.SubstringData(start_offset, end_offset - start_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 4.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 4.4
return Ok(fragment);
}
@ -389,12 +389,12 @@ impl RangeMethods for Range {
let text = text.SubstringData(start_offset, start_node.len() - start_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 13.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
} else {
// Step 14.1.
let clone = child.CloneNode(false);
// Step 14.2.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 14.3.
let subrange = Range::new(clone.owner_doc().r(),
start_node.r(),
@ -404,7 +404,7 @@ impl RangeMethods for Range {
// Step 14.4.
let subfragment = try!(subrange.CloneContents());
// Step 14.5.
try!(clone.AppendChild(subfragment.upcast::<Node>()));
try!(clone.AppendChild(subfragment.upcast()));
}
}
@ -413,7 +413,7 @@ impl RangeMethods for Range {
// Step 15.1.
let clone = child.CloneNode(true);
// Step 15.2.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
}
if let Some(child) = last_contained_child {
@ -426,12 +426,12 @@ impl RangeMethods for Range {
let text = text.SubstringData(0, end_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 16.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
} else {
// Step 17.1.
let clone = child.CloneNode(false);
// Step 17.2.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 17.3.
let subrange = Range::new(clone.owner_doc().r(),
child.r(),
@ -441,7 +441,7 @@ impl RangeMethods for Range {
// Step 17.4.
let subfragment = try!(subrange.CloneContents());
// Step 17.5.
try!(clone.AppendChild(subfragment.upcast::<Node>()));
try!(clone.AppendChild(subfragment.upcast()));
}
}
@ -477,7 +477,7 @@ impl RangeMethods for Range {
let text = end_data.SubstringData(start_offset, end_offset - start_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 4.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 4.4.
try!(end_data.ReplaceData(start_offset,
end_offset - start_offset,
@ -513,7 +513,7 @@ impl RangeMethods for Range {
start_node.len() - start_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 15.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 15.4.
try!(start_data.ReplaceData(start_offset,
start_node.len() - start_offset,
@ -522,7 +522,7 @@ impl RangeMethods for Range {
// Step 16.1.
let clone = child.CloneNode(false);
// Step 16.2.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 16.3.
let subrange = Range::new(clone.owner_doc().r(),
start_node.r(),
@ -532,13 +532,13 @@ impl RangeMethods for Range {
// Step 16.4.
let subfragment = try!(subrange.ExtractContents());
// Step 16.5.
try!(clone.AppendChild(subfragment.upcast::<Node>()));
try!(clone.AppendChild(subfragment.upcast()));
}
}
// Step 17.
for child in contained_children {
try!(fragment.upcast::<Node>().AppendChild(child.r()));
try!(fragment.upcast::<Node>().AppendChild(&child));
}
if let Some(child) = last_contained_child {
@ -550,14 +550,14 @@ impl RangeMethods for Range {
let text = end_data.SubstringData(0, end_offset);
clone.downcast::<CharacterData>().unwrap().SetData(text.unwrap());
// Step 18.3.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 18.4.
try!(end_data.ReplaceData(0, end_offset, "".to_owned()));
} else {
// Step 19.1.
let clone = child.CloneNode(false);
// Step 19.2.
try!(fragment.upcast::<Node>().AppendChild(clone.r()));
try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 19.3.
let subrange = Range::new(clone.owner_doc().r(),
child.r(),
@ -567,7 +567,7 @@ impl RangeMethods for Range {
// Step 19.4.
let subfragment = try!(subrange.ExtractContents());
// Step 19.5.
try!(clone.AppendChild(subfragment.upcast::<Node>()));
try!(clone.AppendChild(subfragment.upcast()));
}
}
@ -697,7 +697,7 @@ impl RangeMethods for Range {
try!(self.InsertNode(new_parent));
// Step 6.
let _ = try!(new_parent.AppendChild(fragment.upcast::<Node>()));
try!(new_parent.AppendChild(fragment.upcast()));
// Step 7.
self.SelectNode(new_parent)