mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Work around uses of #[allow(unrooted_must_root)]
Using this directive could cause rooting errors to be silently ignored, so we should avoid it as much as possible
This commit is contained in:
parent
d2a8c278ea
commit
e2c700e6ad
1 changed files with 7 additions and 10 deletions
|
@ -176,28 +176,25 @@ impl HTMLCollection {
|
||||||
|
|
||||||
impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-length
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-length
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
fn Length(self) -> u32 {
|
fn Length(self) -> u32 {
|
||||||
let Collection(ref root, ref filter) = self.collection;
|
let ref root = self.collection.0.root();
|
||||||
let root = root.root();
|
let ref filter = self.collection.1;
|
||||||
HTMLCollection::traverse(root.r())
|
HTMLCollection::traverse(root.r())
|
||||||
.filter(|element| filter.filter(element.r(), root.r()))
|
.filter(|element| filter.filter(element.r(), root.r()))
|
||||||
.count() as u32
|
.count() as u32
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
fn Item(self, index: u32) -> Option<Root<Element>> {
|
fn Item(self, index: u32) -> Option<Root<Element>> {
|
||||||
let index = index as usize;
|
let index = index as usize;
|
||||||
let Collection(ref root, ref filter) = self.collection;
|
let ref root = self.collection.0.root();
|
||||||
let root = root.root();
|
let ref filter = self.collection.1;
|
||||||
HTMLCollection::traverse(root.r())
|
HTMLCollection::traverse(root.r())
|
||||||
.filter(|element| filter.filter(element.r(), root.r()))
|
.filter(|element| filter.filter(element.r(), root.r()))
|
||||||
.nth(index)
|
.nth(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
|
// https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
|
||||||
#[allow(unrooted_must_root)]
|
|
||||||
fn NamedItem(self, key: DOMString) -> Option<Root<Element>> {
|
fn NamedItem(self, key: DOMString) -> Option<Root<Element>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if key.is_empty() {
|
if key.is_empty() {
|
||||||
|
@ -205,8 +202,8 @@ impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let Collection(ref root, ref filter) = self.collection;
|
let ref root = self.collection.0.root();
|
||||||
let root = root.root();
|
let ref filter = self.collection.1;
|
||||||
HTMLCollection::traverse(root.r())
|
HTMLCollection::traverse(root.r())
|
||||||
.filter(|element| filter.filter(element.r(), root.r()))
|
.filter(|element| filter.filter(element.r(), root.r()))
|
||||||
.find(|elem| {
|
.find(|elem| {
|
||||||
|
@ -234,8 +231,8 @@ impl<'a> HTMLCollectionMethods for &'a HTMLCollection {
|
||||||
let mut result = vec![];
|
let mut result = vec![];
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
let ref filter = self.collection.1;
|
|
||||||
let root = self.collection.0.root();
|
let root = self.collection.0.root();
|
||||||
|
let ref filter = self.collection.1;
|
||||||
let elems = HTMLCollection::traverse(root.r()).filter(|element| filter.filter(element.r(), root.r()));
|
let elems = HTMLCollection::traverse(root.r()).filter(|element| filter.filter(element.r(), root.r()));
|
||||||
for elem in elems {
|
for elem in elems {
|
||||||
// Step 2.1
|
// Step 2.1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue