mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add unrooted_must_root lint for usages of JS<T> in let/for bindings
This commit is contained in:
parent
12dc54d238
commit
bded5c3703
11 changed files with 55 additions and 15 deletions
|
@ -108,8 +108,8 @@ impl Attr {
|
|||
pub fn new(window: &JSRef<Window>, local_name: Atom, value: AttrValue,
|
||||
name: Atom, namespace: Namespace,
|
||||
prefix: Option<DOMString>, owner: &JSRef<Element>) -> Temporary<Attr> {
|
||||
let attr = Attr::new_inherited(local_name, value, name, namespace, prefix, owner);
|
||||
reflect_dom_object(box attr, &Window(*window), AttrBinding::Wrap)
|
||||
reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner),
|
||||
&Window(*window), AttrBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,7 @@ pub struct CallSetup {
|
|||
|
||||
impl CallSetup {
|
||||
/// Performs the setup needed to make a call.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new<T: CallbackContainer>(callback: &T, handling: ExceptionHandling) -> CallSetup {
|
||||
let global = global_object_for_js_object(callback.callback());
|
||||
let global = global.root();
|
||||
|
|
|
@ -668,6 +668,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut
|
|||
}
|
||||
|
||||
/// Returns the global object of the realm that the given JS object was created in.
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
|
||||
unsafe {
|
||||
let global = GetGlobalForObjectCrossCompartment(obj);
|
||||
|
@ -689,6 +690,7 @@ pub fn global_object_for_js_object(obj: *mut JSObject) -> GlobalField {
|
|||
|
||||
/// Get the `JSContext` for the `JSRuntime` associated with the thread
|
||||
/// this object is on.
|
||||
#[allow(unrooted_must_root)]
|
||||
fn cx_for_dom_reflector(obj: *mut JSObject) -> *mut JSContext {
|
||||
let global = global_object_for_js_object(obj);
|
||||
let global = global.root();
|
||||
|
|
|
@ -310,8 +310,8 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn new(window: &JSRef<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> Temporary<Document> {
|
||||
let document = Document::new_inherited(window, url, doctype, content_type);
|
||||
let document = reflect_dom_object(box document, &Window(*window),
|
||||
let document = reflect_dom_object(box Document::new_inherited(window, url, doctype, content_type),
|
||||
&Window(*window),
|
||||
DocumentBinding::Wrap).root();
|
||||
|
||||
let node: &JSRef<Node> = NodeCast::from_ref(&*document);
|
||||
|
|
|
@ -220,6 +220,7 @@ pub trait LayoutElementHelpers {
|
|||
}
|
||||
|
||||
impl LayoutElementHelpers for JS<Element> {
|
||||
#[allow(unrooted_must_root)]
|
||||
unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
|
||||
if (*self.unsafe_get()).namespace != namespace::HTML {
|
||||
return false
|
||||
|
|
|
@ -55,6 +55,7 @@ impl FormData {
|
|||
}
|
||||
|
||||
impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
||||
#[allow(unrooted_must_root)]
|
||||
fn Append(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
|
||||
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
||||
self.data.deref().borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()),
|
||||
|
@ -86,7 +87,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
|||
fn Has(&self, name: DOMString) -> bool {
|
||||
self.data.deref().borrow().contains_key_equiv(&name)
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
fn Set(&self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
|
||||
let file = FileData(JS::from_rooted(&self.get_file_from_blob(value, filename)));
|
||||
self.data.deref().borrow_mut().insert(name, vec!(file));
|
||||
|
|
|
@ -29,8 +29,8 @@ impl Performance {
|
|||
}
|
||||
|
||||
pub fn new(window: &JSRef<Window>) -> Temporary<Performance> {
|
||||
let performance = Performance::new_inherited(window);
|
||||
reflect_dom_object(box performance, &Window(*window),
|
||||
reflect_dom_object(box Performance::new_inherited(window),
|
||||
&Window(*window),
|
||||
PerformanceBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ pub struct XMLHttpRequest {
|
|||
|
||||
impl XMLHttpRequest {
|
||||
pub fn new_inherited(global: &GlobalRef) -> XMLHttpRequest {
|
||||
let xhr = XMLHttpRequest {
|
||||
XMLHttpRequest {
|
||||
eventtarget: XMLHttpRequestEventTarget::new_inherited(XMLHttpRequestTypeId),
|
||||
ready_state: Traceable::new(Cell::new(Unsent)),
|
||||
timeout: Traceable::new(Cell::new(0u32)),
|
||||
|
@ -163,8 +163,7 @@ impl XMLHttpRequest {
|
|||
fetch_time: Traceable::new(Cell::new(0)),
|
||||
timeout_pinned: Traceable::new(Cell::new(false)),
|
||||
terminate_sender: Untraceable::new(RefCell::new(None)),
|
||||
};
|
||||
xhr
|
||||
}
|
||||
}
|
||||
pub fn new(global: &GlobalRef) -> Temporary<XMLHttpRequest> {
|
||||
reflect_dom_object(box XMLHttpRequest::new_inherited(global),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue