mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Format script component
This commit is contained in:
parent
2ca7a13473
commit
c37a345dc9
357 changed files with 25485 additions and 18076 deletions
|
@ -31,9 +31,7 @@ pub struct NodeIterator {
|
|||
}
|
||||
|
||||
impl NodeIterator {
|
||||
fn new_inherited(root_node: &Node,
|
||||
what_to_show: u32,
|
||||
filter: Filter) -> NodeIterator {
|
||||
fn new_inherited(root_node: &Node, what_to_show: u32, filter: Filter) -> NodeIterator {
|
||||
NodeIterator {
|
||||
reflector_: Reflector::new(),
|
||||
root_node: Dom::from_ref(root_node),
|
||||
|
@ -45,22 +43,28 @@ impl NodeIterator {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new_with_filter(document: &Document,
|
||||
root_node: &Node,
|
||||
what_to_show: u32,
|
||||
filter: Filter) -> DomRoot<NodeIterator> {
|
||||
reflect_dom_object(Box::new(NodeIterator::new_inherited(root_node, what_to_show, filter)),
|
||||
document.window(),
|
||||
NodeIteratorBinding::Wrap)
|
||||
pub fn new_with_filter(
|
||||
document: &Document,
|
||||
root_node: &Node,
|
||||
what_to_show: u32,
|
||||
filter: Filter,
|
||||
) -> DomRoot<NodeIterator> {
|
||||
reflect_dom_object(
|
||||
Box::new(NodeIterator::new_inherited(root_node, what_to_show, filter)),
|
||||
document.window(),
|
||||
NodeIteratorBinding::Wrap,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new(document: &Document,
|
||||
root_node: &Node,
|
||||
what_to_show: u32,
|
||||
node_filter: Option<Rc<NodeFilter>>) -> DomRoot<NodeIterator> {
|
||||
pub fn new(
|
||||
document: &Document,
|
||||
root_node: &Node,
|
||||
what_to_show: u32,
|
||||
node_filter: Option<Rc<NodeFilter>>,
|
||||
) -> DomRoot<NodeIterator> {
|
||||
let filter = match node_filter {
|
||||
None => Filter::None,
|
||||
Some(jsfilter) => Filter::Callback(jsfilter)
|
||||
Some(jsfilter) => Filter::Callback(jsfilter),
|
||||
};
|
||||
NodeIterator::new_with_filter(document, root_node, what_to_show, filter)
|
||||
}
|
||||
|
@ -189,7 +193,6 @@ impl NodeIteratorMethods for NodeIterator {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
impl NodeIterator {
|
||||
// https://dom.spec.whatwg.org/#concept-node-filter
|
||||
fn accept_node(&self, node: &Node) -> Fallible<u16> {
|
||||
|
@ -201,7 +204,7 @@ impl NodeIterator {
|
|||
let n = node.NodeType() - 1;
|
||||
// Step 3.
|
||||
if (self.what_to_show & (1 << n)) == 0 {
|
||||
return Ok(NodeFilterConstants::FILTER_SKIP)
|
||||
return Ok(NodeFilterConstants::FILTER_SKIP);
|
||||
}
|
||||
|
||||
match self.filter {
|
||||
|
@ -216,14 +219,13 @@ impl NodeIterator {
|
|||
self.active.set(false);
|
||||
// Step 8.
|
||||
result
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(JSTraceable)]
|
||||
pub enum Filter {
|
||||
None,
|
||||
Callback(Rc<NodeFilter>)
|
||||
Callback(Rc<NodeFilter>),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue