script: Feature-gate all crown support. (#35055)

* script: Feature-gate all crown support.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* script: Use cfg(crown) instead of a cargo feature.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-01-18 16:36:15 -05:00 committed by GitHub
parent 1bd34a5781
commit 875e387004
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
223 changed files with 442 additions and 417 deletions

View file

@ -41,7 +41,7 @@ use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
use crate::script_thread::ScriptThread;
#[dom_struct]
#[crown::unrooted_must_root_lint::allow_unrooted_in_rc]
#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_in_rc)]
pub(crate) struct Promise {
reflector: Reflector,
/// Since Promise values are natively reference counted without the knowledge of
@ -105,7 +105,8 @@ impl Promise {
Promise::new_with_js_promise(self.reflector().get_jsobject(), cx)
}
#[allow(unsafe_code, crown::unrooted_must_root)]
#[allow(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn new_with_js_promise(obj: HandleObject, cx: SafeJSContext) -> Rc<Promise> {
unsafe {
assert!(IsPromiseObject(obj));
@ -146,7 +147,8 @@ impl Promise {
}
}
#[allow(crown::unrooted_must_root, unsafe_code)]
#[allow(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn new_resolved(
global: &GlobalScope,
cx: SafeJSContext,
@ -162,7 +164,8 @@ impl Promise {
}
}
#[allow(crown::unrooted_must_root, unsafe_code)]
#[allow(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn new_rejected(
global: &GlobalScope,
cx: SafeJSContext,
@ -192,7 +195,8 @@ impl Promise {
self.resolve(cx, v.handle());
}
#[allow(crown::unrooted_must_root, unsafe_code)]
#[allow(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn resolve(&self, cx: SafeJSContext, value: HandleValue) {
unsafe {
if !ResolvePromise(*cx, self.promise_obj(), value) {
@ -226,7 +230,8 @@ impl Promise {
self.reject(cx, v.handle());
}
#[allow(crown::unrooted_must_root, unsafe_code)]
#[allow(unsafe_code)]
#[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn reject(&self, cx: SafeJSContext, value: HandleValue) {
unsafe {
if !RejectPromise(*cx, self.promise_obj(), value) {