mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Add unrooted_must_root lint for enums and structs containing JS<T>, as well as functions with JS<T> in their parameter list
For safe wrappers over JS<T> (eg Temporary<T>) use #[allow(unrooted_must_root)]. For all other types containing a #[must_root] value, annotate the type with #[must_root] to ensure that it is never used unrooted
This commit is contained in:
parent
13ae369dec
commit
12dc54d238
22 changed files with 101 additions and 4 deletions
|
@ -11,18 +11,21 @@ use dom::node::{Node, NodeHelpers};
|
|||
use dom::window::Window;
|
||||
|
||||
#[deriving(Encodable)]
|
||||
#[must_root]
|
||||
pub enum NodeListType {
|
||||
Simple(Vec<JS<Node>>),
|
||||
Children(JS<Node>)
|
||||
}
|
||||
|
||||
#[deriving(Encodable)]
|
||||
#[must_root]
|
||||
pub struct NodeList {
|
||||
list_type: NodeListType,
|
||||
reflector_: Reflector,
|
||||
}
|
||||
|
||||
impl NodeList {
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new_inherited(list_type: NodeListType) -> NodeList {
|
||||
NodeList {
|
||||
list_type: list_type,
|
||||
|
@ -30,6 +33,7 @@ impl NodeList {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(window: &JSRef<Window>,
|
||||
list_type: NodeListType) -> Temporary<NodeList> {
|
||||
reflect_dom_object(box NodeList::new_inherited(list_type),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue