diff options
223 files changed, 442 insertions, 417 deletions
diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index 2d9dac7bd1b..27c591f56b8 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -13,7 +13,7 @@ pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream { } let attributes = quote! { #[derive(deny_public_fields::DenyPublicFields, domobject_derive::DomObject, JSTraceable, MallocSizeOf)] - #[crown::unrooted_must_root_lint::must_root] + #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[repr(C)] }; diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index c9db4b52034..2934bfec419 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -13,6 +13,7 @@ name = "script" path = "lib.rs" [features] +crown = ['js/crown'] debugmozjs = ['js/debugmozjs'] jitspew = ['js/jitspew'] profilemozjs = ['js/profilemozjs'] @@ -23,6 +24,9 @@ refcell_backtrace = ["accountable-refcell"] webxr = ["webxr-api"] webgpu = [] +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(crown)'] } + [build-dependencies] phf_codegen = "0.11" phf_shared = "0.11" @@ -72,7 +76,7 @@ image = { workspace = true } indexmap = { workspace = true } ipc-channel = { workspace = true } itertools = { workspace = true } -js = { package = "mozjs", git = "https://github.com/servo/mozjs", features = ["crown"] } +js = { package = "mozjs", git = "https://github.com/servo/mozjs" } jstraceable_derive = { path = "../jstraceable_derive" } keyboard-types = { workspace = true } libc = { workspace = true } diff --git a/components/script/animations.rs b/components/script/animations.rs index 09a0eb4b8eb..ec430eb374a 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -37,7 +37,7 @@ use crate::script_runtime::CanGc; /// The set of animations for a document. #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Animations { /// The map of nodes to their animation states. #[no_trace] diff --git a/components/script/body.rs b/components/script/body.rs index 5f02a599e77..e8e72913df9 100644 --- a/components/script/body.rs +++ b/components/script/body.rs @@ -267,7 +267,7 @@ impl TransmitBodyConnectHandler { /// The handler of read promises of body streams used in /// <https://fetch.spec.whatwg.org/#concept-request-transmit-body>. #[derive(Clone, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct TransmitBodyPromiseHandler { #[ignore_malloc_size_of = "Channels are hard"] #[no_trace] @@ -605,7 +605,7 @@ impl Callback for ConsumeBodyPromiseRejectionHandler { impl js::gc::Rootable for ConsumeBodyPromiseHandler {} #[derive(Clone, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] /// The promise handler used to consume the body, /// <https://fetch.spec.whatwg.org/#concept-body-consume-body> struct ConsumeBodyPromiseHandler { @@ -645,7 +645,7 @@ impl ConsumeBodyPromiseHandler { impl Callback for ConsumeBodyPromiseHandler { /// Continuing Step 4 of <https://fetch.spec.whatwg.org/#concept-body-consume-body> /// Step 3 of <https://fetch.spec.whatwg.org/#concept-read-all-bytes-from-readablestream>. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn callback(&self, cx: JSContext, v: HandleValue, _realm: InRealm, can_gc: CanGc) { let stream = self .stream @@ -711,7 +711,7 @@ impl Callback for ConsumeBodyPromiseHandler { } // https://fetch.spec.whatwg.org/#concept-body-consume-body -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn consume_body<T: BodyMixin + DomObject>( object: &T, body_type: BodyType, diff --git a/components/script/canvas_state.rs b/components/script/canvas_state.rs index 6f9aa99b567..46a1c864fc1 100644 --- a/components/script/canvas_state.rs +++ b/components/script/canvas_state.rs @@ -60,7 +60,7 @@ use crate::dom::textmetrics::TextMetrics; use crate::script_runtime::CanGc; use crate::unpremultiplytable::UNPREMULTIPLY_TABLE; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Clone, JSTraceable, MallocSizeOf)] #[allow(dead_code)] pub(crate) enum CanvasFillOrStrokeStyle { @@ -79,7 +79,7 @@ impl CanvasFillOrStrokeStyle { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Clone, JSTraceable, MallocSizeOf)] pub(crate) struct CanvasContextState { global_alpha: f64, @@ -138,7 +138,7 @@ impl CanvasContextState { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct CanvasState { #[ignore_malloc_size_of = "Defined in ipc-channel"] @@ -959,7 +959,7 @@ impl CanvasState { self.send_canvas_2d_msg(Canvas2dMsg::SaveContext); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://html.spec.whatwg.org/multipage/#dom-context-2d-restore pub(crate) fn restore(&self) { let mut saved_states = self.saved_states.borrow_mut(); diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 5635cbcfd0d..fdf9c991bd2 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -216,7 +216,7 @@ pub(crate) fn handle_get_attribute_style( reply.send(Some(msg)).unwrap(); } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn handle_get_stylesheet_style( documents: &DocumentCollection, pipeline: PipelineId, @@ -263,7 +263,7 @@ pub(crate) fn handle_get_stylesheet_style( reply.send(msg).unwrap(); } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn handle_get_selectors( documents: &DocumentCollection, pipeline: PipelineId, diff --git a/components/script/document_collection.rs b/components/script/document_collection.rs index 66563b55513..846efe1d44d 100644 --- a/components/script/document_collection.rs +++ b/components/script/document_collection.rs @@ -18,7 +18,7 @@ use crate::dom::window::Window; /// This is stored as a mapping of [`PipelineId`] to [`Document`], but for updating the /// rendering, [`Document`]s should be processed in order via [`Self::documents_in_order`]. #[derive(JSTraceable)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct DocumentCollection { map: HashMapTracedValues<PipelineId, Dom<Document>>, } @@ -92,7 +92,7 @@ impl DocumentCollection { } impl Default for DocumentCollection { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn default() -> Self { Self { map: HashMapTracedValues::new(), @@ -100,7 +100,7 @@ impl Default for DocumentCollection { } } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) struct DocumentsIter<'a> { iter: hash_map::Iter<'a, PipelineId, Dom<Document>>, } diff --git a/components/script/document_loader.rs b/components/script/document_loader.rs index f4f6970f6d5..e73a793ce6a 100644 --- a/components/script/document_loader.rs +++ b/components/script/document_loader.rs @@ -30,7 +30,7 @@ pub(crate) enum LoadType { /// created via DocumentLoader::fetch_async) are always removed by the time /// that the owner is destroyed. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct LoadBlocker { /// The document whose load event is blocked by this object existing. doc: Dom<Document>, diff --git a/components/script/dom/abstractrange.rs b/components/script/dom/abstractrange.rs index 80cd64a0df5..dd5d36c1958 100644 --- a/components/script/dom/abstractrange.rs +++ b/components/script/dom/abstractrange.rs @@ -94,7 +94,7 @@ impl AbstractRangeMethods<crate::DomTypeHolder> for AbstractRange { } #[derive(DenyPublicFields, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct BoundaryPoint { node: MutDom<Node>, offset: Cell<u32>, @@ -123,7 +123,7 @@ impl BoundaryPoint { } } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl PartialOrd for BoundaryPoint { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { bp_position( @@ -135,7 +135,7 @@ impl PartialOrd for BoundaryPoint { } } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl PartialEq for BoundaryPoint { fn eq(&self, other: &Self) -> bool { self.node.get() == other.node.get() && self.offset.get() == other.offset.get() diff --git a/components/script/dom/analysernode.rs b/components/script/dom/analysernode.rs index 6d447e0a9f6..7af43192b19 100644 --- a/components/script/dom/analysernode.rs +++ b/components/script/dom/analysernode.rs @@ -37,7 +37,7 @@ pub(crate) struct AnalyserNode { } impl AnalyserNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, @@ -100,7 +100,7 @@ impl AnalyserNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/audiobuffer.rs b/components/script/dom/audiobuffer.rs index 1fbdc771f2e..80b704e8c23 100644 --- a/components/script/dom/audiobuffer.rs +++ b/components/script/dom/audiobuffer.rs @@ -59,7 +59,7 @@ pub(crate) struct AudioBuffer { } impl AudioBuffer { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( number_of_channels: u32, length: u32, @@ -98,7 +98,7 @@ impl AudioBuffer { ) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/audiobuffersourcenode.rs b/components/script/dom/audiobuffersourcenode.rs index 72b857a727f..03941fb9e15 100644 --- a/components/script/dom/audiobuffersourcenode.rs +++ b/components/script/dom/audiobuffersourcenode.rs @@ -43,7 +43,7 @@ pub(crate) struct AudioBufferSourceNode { } impl AudioBufferSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -105,7 +105,7 @@ impl AudioBufferSourceNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/audiocontext.rs b/components/script/dom/audiocontext.rs index 20987944d8e..cc0480cf84a 100644 --- a/components/script/dom/audiocontext.rs +++ b/components/script/dom/audiocontext.rs @@ -47,7 +47,7 @@ pub(crate) struct AudioContext { } impl AudioContext { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://webaudio.github.io/web-audio-api/#AudioContext-constructors fn new_inherited( options: &AudioContextOptions, @@ -82,7 +82,7 @@ impl AudioContext { }) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/audiodestinationnode.rs b/components/script/dom/audiodestinationnode.rs index 908303085a5..1238bb0c51a 100644 --- a/components/script/dom/audiodestinationnode.rs +++ b/components/script/dom/audiodestinationnode.rs @@ -38,7 +38,7 @@ impl AudioDestinationNode { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, context: &BaseAudioContext, diff --git a/components/script/dom/audiolistener.rs b/components/script/dom/audiolistener.rs index 2baf410d6c0..abc3b948fb3 100644 --- a/components/script/dom/audiolistener.rs +++ b/components/script/dom/audiolistener.rs @@ -153,7 +153,7 @@ impl AudioListener { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, context: &BaseAudioContext, diff --git a/components/script/dom/audioparam.rs b/components/script/dom/audioparam.rs index 3b3b65d55ee..bb536d24995 100644 --- a/components/script/dom/audioparam.rs +++ b/components/script/dom/audioparam.rs @@ -66,7 +66,8 @@ impl AudioParam { } } - #[allow(crown::unrooted_must_root, clippy::too_many_arguments)] + #[allow(clippy::too_many_arguments)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, context: &BaseAudioContext, diff --git a/components/script/dom/audioscheduledsourcenode.rs b/components/script/dom/audioscheduledsourcenode.rs index d29c188c476..6db1af0a3b7 100644 --- a/components/script/dom/audioscheduledsourcenode.rs +++ b/components/script/dom/audioscheduledsourcenode.rs @@ -26,7 +26,7 @@ pub(crate) struct AudioScheduledSourceNode { } impl AudioScheduledSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( node_type: AudioNodeInit, context: &BaseAudioContext, diff --git a/components/script/dom/baseaudiocontext.rs b/components/script/dom/baseaudiocontext.rs index c16156e42ca..75d6a9354a6 100644 --- a/components/script/dom/baseaudiocontext.rs +++ b/components/script/dom/baseaudiocontext.rs @@ -112,7 +112,7 @@ pub(crate) struct BaseAudioContext { } impl BaseAudioContext { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( options: BaseAudioContextOptions, pipeline_id: PipelineId, @@ -196,9 +196,9 @@ impl BaseAudioContext { /// does not take a list of promises to fulfill. Callers cannot just pop /// the front list off of `in_flight_resume_promises_queue` and later fulfill /// the promises because that would mean putting - /// `#[allow(crown::unrooted_must_root)]` on even more functions, potentially + /// `#[cfg_attr(crown, allow(crown::unrooted_must_root))]` on even more functions, potentially /// hiding actual safety bugs. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn fulfill_in_flight_resume_promises<F>(&self, f: F) where F: FnOnce(), diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index 22aa6ea3e9c..cc52fb9f8e4 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -41,7 +41,7 @@ pub(crate) enum ExceptionHandling { /// A common base class for representing IDL callback function and /// callback interface types. #[derive(JSTraceable)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct CallbackObject { /// The underlying `JSObject`. callback: Heap<*mut JSObject>, @@ -62,7 +62,7 @@ pub(crate) struct CallbackObject { } impl CallbackObject { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // These are used by the bindings and do not need `default()` functions. #[allow(clippy::new_without_default)] fn new() -> CallbackObject { @@ -128,14 +128,14 @@ pub(crate) trait CallbackContainer { /// A common base class for representing IDL callback function types. #[derive(JSTraceable, PartialEq)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct CallbackFunction { object: CallbackObject, } impl CallbackFunction { /// Create a new `CallbackFunction` for this object. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // These are used by the bindings and do not need `default()` functions. #[allow(clippy::new_without_default)] pub(crate) fn new() -> CallbackFunction { @@ -158,7 +158,7 @@ impl CallbackFunction { /// A common base class for representing IDL callback interface types. #[derive(JSTraceable, PartialEq)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct CallbackInterface { object: CallbackObject, } @@ -260,7 +260,7 @@ pub(crate) struct CallSetup { impl CallSetup { /// Performs the setup needed to make a call. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new<T: CallbackContainer>( callback: &T, handling: ExceptionHandling, diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index e9ee8617187..8eb1ce2ce69 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2725,8 +2725,11 @@ def DomTypes(descriptors, descriptorProvider, dictionaries, callbacks, typedefs, traits += [f"crate::dom::bindings::codegen::Bindings::{namespace}::{iface_name}Methods<Self>"] isPromise = firstCap(iface_name) == "Promise" elements += [ - CGGeneric(" #[crown::unrooted_must_root_lint::must_root]\n"), - CGGeneric(" #[crown::unrooted_must_root_lint::allow_unrooted_in_rc]\n" if isPromise else ""), + CGGeneric(" #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]\n"), + CGGeneric( + " #[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_in_rc)]\n" + if isPromise else "" + ), CGGeneric(f" type {firstCap(iface_name)}: {' + '.join(traits)};\n") ] elements += [CGGeneric("}\n")] @@ -3017,7 +3020,8 @@ class CGWrapMethod(CGAbstractMethod): Argument('CanGc', '_can_gc')] retval = f'DomRoot<{descriptor.concreteType}>' CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, - pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]']) + pub=True, unsafe=True, + extra_decorators=['#[cfg_attr(crown, allow(crown::unrooted_must_root))]']) def definition_body(self): unforgeable = CopyLegacyUnforgeablePropertiesToInstance(self.descriptor) @@ -3109,7 +3113,8 @@ class CGWrapGlobalMethod(CGAbstractMethod): Argument(f"Box<{descriptor.concreteType}>", 'object')] retval = f'DomRoot<{descriptor.concreteType}>' CGAbstractMethod.__init__(self, descriptor, 'Wrap', retval, args, - pub=True, unsafe=True, extra_decorators=['#[allow(crown::unrooted_must_root)]']) + pub=True, unsafe=True, + extra_decorators=['#[cfg_attr(crown, allow(crown::unrooted_must_root))]']) self.properties = properties def definition_body(self): @@ -7037,7 +7042,7 @@ class CGDictionary(CGThing): default = "" mustRoot = "" if self.membersNeedTracing(): - mustRoot = "#[crown::unrooted_must_root_lint::must_root]\n" + mustRoot = "#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]\n" # We can't unconditionally derive Default here, because union types can have unique # default values provided for each usage. Instead, whenever possible we re-use the empty() @@ -7628,8 +7633,8 @@ class CGCallback(CGClass): constructors=self.getConstructors(), methods=realMethods, decorators="#[derive(JSTraceable, PartialEq)]\n" - "#[allow(crown::unrooted_must_root)]\n" - "#[crown::unrooted_must_root_lint::allow_unrooted_interior]") + "#[cfg_attr(crown, allow(crown::unrooted_must_root))]\n" + "#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)]") def getConstructors(self): return [ClassConstructor( diff --git a/components/script/dom/bindings/inheritance.rs b/components/script/dom/bindings/inheritance.rs index 7c5ca4f7a27..f226dbb617b 100644 --- a/components/script/dom/bindings/inheritance.rs +++ b/components/script/dom/bindings/inheritance.rs @@ -55,7 +55,7 @@ pub(crate) trait Castable: IDLInterface + DomObject + Sized { #[allow(missing_docs)] pub(crate) trait HasParent { - #[crown::unrooted_must_root_lint::must_root] + #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] type Parent; fn as_parent(&self) -> &Self::Parent; } diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index d3f55012534..f0da94443db 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -83,7 +83,7 @@ impl TrustedPromise { /// Create a new `TrustedPromise` instance from an existing DOM object. The object will /// be prevented from being GCed for the duration of the resulting `TrustedPromise` object's /// lifetime. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(promise: Rc<Promise>) -> TrustedPromise { LIVE_REFERENCES.with(|r| { let r = r.borrow(); @@ -133,7 +133,7 @@ impl TrustedPromise { } /// A task which will reject the promise. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn reject_task(self, error: Error) -> impl TaskOnce { let this = self; task!(reject_promise: move || { @@ -143,7 +143,7 @@ impl TrustedPromise { } /// A task which will resolve the promise. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn resolve_task<T>(self, value: T) -> impl TaskOnce where T: ToJSValConvertible + Send, @@ -160,7 +160,7 @@ impl TrustedPromise { /// shared among threads for use in asynchronous operations. The underlying /// DOM object is guaranteed to live at least as long as the last outstanding /// `Trusted<T>` instance. -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] #[derive(MallocSizeOf)] pub(crate) struct Trusted<T: DomObject> { /// A pointer to the Rust DOM object of type T, but void to allow @@ -226,7 +226,7 @@ impl<T: DomObject> Clone for Trusted<T> { /// The set of live, pinned DOM objects that are currently prevented /// from being garbage collected due to outstanding references. -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) struct LiveDOMReferences { // keyed on pointer to Rust DOM object reflectable_table: RefCell<HashMap<*const libc::c_void, Weak<TrustedReference>>>, @@ -250,7 +250,7 @@ impl LiveDOMReferences { }); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn addref_promise(&self, promise: Rc<Promise>) { let mut table = self.promise_table.borrow_mut(); table.entry(&*promise).or_default().push(promise) @@ -301,7 +301,7 @@ fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) { } /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) { trace!("tracing live refcounted references"); LIVE_REFERENCES.with(|r| { diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index eb15172aaaa..5fd200e4220 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -43,16 +43,16 @@ where } /// A struct to store a reference to the reflector of a DOM object. -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] #[derive(MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] // If you're renaming or moving this field, update the path in plugins::reflector as well pub(crate) struct Reflector { #[ignore_malloc_size_of = "defined and measured in rust-mozjs"] object: Heap<*mut JSObject>, } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl PartialEq for Reflector { fn eq(&self, other: &Reflector) -> bool { self.object.get() == other.object.get() diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index b182c917b98..142e981120c 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -43,8 +43,8 @@ use crate::dom::bindings::trace::{trace_reflector, JSTraceable}; use crate::dom::node::Node; /// A rooted value. -#[allow(crown::unrooted_must_root)] -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] pub(crate) struct Root<T: StableTraceObject> { /// The value to root. value: T, @@ -59,7 +59,7 @@ where /// Create a new stack-bounded root for the provided value. /// It cannot outlive its associated `RootCollection`, and it gives /// out references which cannot outlive this new `Root`. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) unsafe fn new(value: T) -> Self { unsafe fn add_to_root_list(object: *const dyn JSTraceable) -> *const RootCollection { assert_in_script(); @@ -99,7 +99,7 @@ where // The JSTraceable impl for Reflector doesn't actually do anything, // so we need this shenanigan to actually trace the reflector of the // T pointer in Dom<T>. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] struct ReflectorStackRoot(Reflector); unsafe impl JSTraceable for ReflectorStackRoot { unsafe fn trace(&self, tracer: *mut JSTracer) { @@ -118,7 +118,7 @@ where // The JSTraceable impl for Reflector doesn't actually do anything, // so we need this shenanigan to actually trace the reflector of the // T pointer in Dom<T>. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] struct MaybeUnreflectedStackRoot<T>(T); unsafe impl<T> JSTraceable for MaybeUnreflectedStackRoot<T> where @@ -197,7 +197,7 @@ impl<T: DomObject> DomRoot<T> { /// /// This should never be used to create on-stack values. Instead these values should always /// end up as members of other DOM objects. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn as_traced(&self) -> Dom<T> { Dom::from_ref(self) } @@ -335,7 +335,7 @@ where /// on the stack, the `Dom<T>` can point to freed memory. /// /// This should only be used as a field in other DOM objects. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Dom<T> { ptr: ptr::NonNull<T>, } @@ -364,7 +364,7 @@ impl<T> Dom<T> { impl<T: DomObject> Dom<T> { /// Create a `Dom<T>` from a `&T` - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn from_ref(obj: &T) -> Dom<T> { assert_in_script(); Dom { @@ -403,7 +403,7 @@ unsafe impl<T: DomObject> JSTraceable for Dom<T> { } /// A traced reference to a DOM object that may not be reflected yet. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct MaybeUnreflectedDom<T> { ptr: ptr::NonNull<T>, } @@ -412,7 +412,7 @@ impl<T> MaybeUnreflectedDom<T> where T: DomObject, { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) unsafe fn from_box(value: Box<T>) -> Self { Self { ptr: Box::leak(value).into(), @@ -444,7 +444,7 @@ where /// An unrooted reference to a DOM object for use in layout. `Layout*Helpers` /// traits must be implemented on this. -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] pub(crate) struct LayoutDom<'dom, T> { value: &'dom T, } @@ -533,7 +533,7 @@ impl<T> Hash for LayoutDom<'_, T> { impl<T> Clone for Dom<T> { #[inline] - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn clone(&self) -> Self { assert_in_script(); Dom { ptr: self.ptr } @@ -566,7 +566,7 @@ impl LayoutDom<'_, Node> { /// /// This should only be used as a field in other DOM objects; see warning /// on `Dom<T>`. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable)] pub(crate) struct MutDom<T: DomObject> { val: UnsafeCell<Dom<T>>, @@ -629,7 +629,7 @@ pub(crate) fn assert_in_layout() { /// /// This should only be used as a field in other DOM objects; see warning /// on `Dom<T>`. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable)] pub(crate) struct MutNullableDom<T: DomObject> { ptr: UnsafeCell<Option<Dom<T>>>, @@ -663,14 +663,14 @@ impl<T: DomObject> MutNullableDom<T> { /// Retrieve a copy of the inner optional `Dom<T>` as `LayoutDom<T>`. /// For use by layout, which can't use safe types like Temporary. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) unsafe fn get_inner_as_layout(&self) -> Option<LayoutDom<T>> { assert_in_layout(); (*self.ptr.get()).as_ref().map(|js| js.to_layout()) } /// Get a rooted value out of this object - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn get(&self) -> Option<DomRoot<T>> { assert_in_script(); unsafe { ptr::read(self.ptr.get()).map(|o| DomRoot::from_ref(&*o)) } @@ -705,7 +705,7 @@ impl<T: DomObject> PartialEq<Option<&T>> for MutNullableDom<T> { } impl<T: DomObject> Default for MutNullableDom<T> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn default() -> MutNullableDom<T> { assert_in_script(); MutNullableDom { @@ -727,7 +727,7 @@ impl<T: DomObject> MallocSizeOf for MutNullableDom<T> { /// /// This should only be used as a field in other DOM objects; see warning /// on `Dom<T>`. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct DomOnceCell<T: DomObject> { ptr: OnceCell<Dom<T>>, } @@ -738,7 +738,7 @@ where { /// Retrieve a copy of the current inner value. If it is `None`, it is /// initialized with the result of `cb` first. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn init_once<F>(&self, cb: F) -> &T where F: FnOnce() -> DomRoot<T>, @@ -749,7 +749,7 @@ where } impl<T: DomObject> Default for DomOnceCell<T> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn default() -> DomOnceCell<T> { assert_in_script(); DomOnceCell { @@ -765,7 +765,7 @@ impl<T: DomObject> MallocSizeOf for DomOnceCell<T> { } } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] unsafe impl<T: DomObject> JSTraceable for DomOnceCell<T> { unsafe fn trace(&self, trc: *mut JSTracer) { if let Some(ptr) = self.ptr.get() { diff --git a/components/script/dom/bindings/settings_stack.rs b/components/script/dom/bindings/settings_stack.rs index 66d408cce2f..28e48ea4d93 100644 --- a/components/script/dom/bindings/settings_stack.rs +++ b/components/script/dom/bindings/settings_stack.rs @@ -21,7 +21,7 @@ enum StackEntryKind { Entry, } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] #[derive(JSTraceable)] struct StackEntry { global: Dom<GlobalScope>, diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index b94dba3fc7d..926bb49109f 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -116,7 +116,7 @@ unsafe impl<T> CustomTraceable for Sender<T> { /// /// SAFETY: Inner type must not impl JSTraceable #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] -#[crown::trace_in_no_trace_lint::must_not_have_traceable] +#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable)] pub(crate) struct NoTrace<T>(pub(crate) T); impl<T: Display> Display for NoTrace<T> { @@ -146,7 +146,7 @@ impl<T: MallocSizeOf> MallocSizeOf for NoTrace<T> { /// HashMap wrapper, that has non-jsmanaged keys /// /// Not all methods are reexposed, but you can access inner type via .0 -#[crown::trace_in_no_trace_lint::must_not_have_traceable(0)] +#[cfg_attr(crown, crown::trace_in_no_trace_lint::must_not_have_traceable(0))] #[derive(Clone, Debug)] pub(crate) struct HashMapTracedValues<K, V, S = RandomState>(pub(crate) HashMap<K, V, S>); @@ -289,7 +289,7 @@ pub(crate) fn trace_jsval(tracer: *mut JSTracer, description: &str, val: &Heap<J } /// Trace the `JSObject` held by `reflector`. -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn trace_reflector(tracer: *mut JSTracer, description: &str, reflector: &Reflector) { trace!("tracing reflector {}", description); trace_object(tracer, description, reflector.rootable()) @@ -490,7 +490,7 @@ where /// If you have GC things like *mut JSObject or JSVal, use rooted!. /// If you have an arbitrary number of DomObjects to root, use rooted_vec!. /// If you know what you're doing, use this. -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] pub(crate) struct RootedTraceableBox<T: JSTraceable + 'static>(js::gc::RootedTraceableBox<T>); unsafe impl<T: JSTraceable + 'static> JSTraceable for RootedTraceableBox<T> { diff --git a/components/script/dom/bindings/weakref.rs b/components/script/dom/bindings/weakref.rs index 949da64b987..4e92d9f8bc6 100644 --- a/components/script/dom/bindings/weakref.rs +++ b/components/script/dom/bindings/weakref.rs @@ -33,14 +33,14 @@ use crate::dom::bindings::trace::JSTraceable; pub(crate) const DOM_WEAK_SLOT: u32 = 1; /// A weak reference to a JS-managed DOM object. -#[allow(crown::unrooted_must_root)] -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] pub(crate) struct WeakRef<T: WeakReferenceable> { ptr: ptr::NonNull<WeakBox<T>>, } /// The inner box of weak references, public for the finalization in codegen. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct WeakBox<T: WeakReferenceable> { /// The reference count. When it reaches zero, the `value` field should /// have already been set to `None`. The pointee contributes one to the count. @@ -218,7 +218,7 @@ unsafe impl<T: WeakReferenceable> JSTraceable for MutableWeakRef<T> { /// A vector of weak references. On tracing, the vector retains /// only references which still point to live objects. -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] #[derive(MallocSizeOf)] pub(crate) struct WeakRefVec<T: WeakReferenceable> { vec: Vec<WeakRef<T>>, @@ -268,7 +268,7 @@ impl<T: WeakReferenceable> DerefMut for WeakRefVec<T> { /// An entry of a vector of weak references. Passed to the closure /// given to `WeakRefVec::update`. -#[crown::unrooted_must_root_lint::allow_unrooted_interior] +#[cfg_attr(crown, crown::unrooted_must_root_lint::allow_unrooted_interior)] pub(crate) struct WeakRefEntry<'a, T: WeakReferenceable> { vec: &'a mut WeakRefVec<T>, index: &'a mut usize, diff --git a/components/script/dom/biquadfilternode.rs b/components/script/dom/biquadfilternode.rs index 160c7279cae..63f7f0d612c 100644 --- a/components/script/dom/biquadfilternode.rs +++ b/components/script/dom/biquadfilternode.rs @@ -41,7 +41,7 @@ pub(crate) struct BiquadFilterNode { } impl BiquadFilterNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -123,7 +123,7 @@ impl BiquadFilterNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index d57772a523b..183e62a5ba1 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -59,7 +59,7 @@ impl Blob { dom_blob } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited(blob_impl: &BlobImpl) -> Blob { Blob { reflector_: Reflector::new(), diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index bcffa8493d2..42b18974b5f 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -118,7 +118,7 @@ impl<T> BluetoothContext<T> where T: AsyncBluetoothListener + DomObject, { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn response(&mut self, response: BluetoothResponseResult, can_gc: CanGc) { let promise = self.promise.take().expect("bt promise is missing").root(); @@ -753,7 +753,7 @@ impl PermissionAlgorithm for Bluetooth { // NOTE: Step 3. is in BluetoothPermissionResult's `handle_response` function. } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://webbluetoothcg.github.io/web-bluetooth/#revoke-bluetooth-access fn permission_revoke( _descriptor: &BluetoothPermissionDescriptor, diff --git a/components/script/dom/bluetoothdevice.rs b/components/script/dom/bluetoothdevice.rs index 2906260f93f..46043313c39 100644 --- a/components/script/dom/bluetoothdevice.rs +++ b/components/script/dom/bluetoothdevice.rs @@ -35,7 +35,7 @@ use crate::dom::promise::Promise; use crate::realms::InRealm; use crate::script_runtime::CanGc; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] struct AttributeInstanceMap { service_map: DomRefCell<HashMap<String, Dom<BluetoothRemoteGATTService>>>, @@ -194,7 +194,7 @@ impl BluetoothDevice { } // https://webbluetoothcg.github.io/web-bluetooth/#clean-up-the-disconnected-device - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn clean_up_disconnected_device(&self, can_gc: CanGc) { // Step 1. self.get_gatt().set_connected(false); @@ -230,7 +230,7 @@ impl BluetoothDevice { } // https://webbluetoothcg.github.io/web-bluetooth/#garbage-collect-the-connection - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn garbage_collect_the_connection(&self) -> ErrorResult { // Step 1: TODO: Check if other systems using this device. diff --git a/components/script/dom/bluetoothpermissionresult.rs b/components/script/dom/bluetoothpermissionresult.rs index d5817e7c901..ec408edb85a 100644 --- a/components/script/dom/bluetoothpermissionresult.rs +++ b/components/script/dom/bluetoothpermissionresult.rs @@ -35,7 +35,7 @@ pub(crate) struct BluetoothPermissionResult { } impl BluetoothPermissionResult { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(status: &PermissionStatus) -> BluetoothPermissionResult { let result = BluetoothPermissionResult { status: PermissionStatus::new_inherited(status.get_query()), @@ -76,7 +76,7 @@ impl BluetoothPermissionResult { self.status.State() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn set_devices(&self, devices: Vec<Dom<BluetoothDevice>>) { *self.devices.borrow_mut() = devices; } diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index b91680545df..34f6d27fc3d 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -167,7 +167,7 @@ impl CanvasRenderingContext2DMethods<crate::DomTypeHolder> for CanvasRenderingCo self.canvas_state.save() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://html.spec.whatwg.org/multipage/#dom-context-2d-restore fn Restore(&self) { self.canvas_state.restore() diff --git a/components/script/dom/channelmergernode.rs b/components/script/dom/channelmergernode.rs index a22d36eae91..9f027b60e21 100644 --- a/components/script/dom/channelmergernode.rs +++ b/components/script/dom/channelmergernode.rs @@ -27,7 +27,7 @@ pub(crate) struct ChannelMergerNode { } impl ChannelMergerNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, @@ -66,7 +66,7 @@ impl ChannelMergerNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/channelsplitternode.rs b/components/script/dom/channelsplitternode.rs index 97f881113d9..ca7f0074669 100644 --- a/components/script/dom/channelsplitternode.rs +++ b/components/script/dom/channelsplitternode.rs @@ -26,7 +26,7 @@ pub(crate) struct ChannelSplitterNode { } impl ChannelSplitterNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( _: &Window, context: &BaseAudioContext, @@ -68,7 +68,7 @@ impl ChannelSplitterNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index e1bcd13c7f1..3d00194d2cf 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -31,7 +31,7 @@ const MAX_LOG_DEPTH: usize = 10; const MAX_LOG_CHILDREN: usize = 15; /// <https://developer.mozilla.org/en-US/docs/Web/API/Console> -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Console; impl Console { diff --git a/components/script/dom/constantsourcenode.rs b/components/script/dom/constantsourcenode.rs index 63ee0ac5dcb..a252aa75c4c 100644 --- a/components/script/dom/constantsourcenode.rs +++ b/components/script/dom/constantsourcenode.rs @@ -30,7 +30,7 @@ pub(crate) struct ConstantSourceNode { } impl ConstantSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -72,7 +72,7 @@ impl ConstantSourceNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index da63e604e60..e15ed81658d 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -34,7 +34,7 @@ impl CSSFontFaceRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index f70e6182fd1..80ff03fc900 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -37,7 +37,7 @@ impl CSSImportRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index 36b14e96df6..95122bc901f 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -40,7 +40,7 @@ impl CSSKeyframeRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index f7fa24940f7..906bb0274e1 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -44,7 +44,7 @@ impl CSSKeyframesRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/csslayerblockrule.rs b/components/script/dom/csslayerblockrule.rs index b9db7dbd406..278a20bdbc9 100644 --- a/components/script/dom/csslayerblockrule.rs +++ b/components/script/dom/csslayerblockrule.rs @@ -40,7 +40,7 @@ impl CSSLayerBlockRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/csslayerstatementrule.rs b/components/script/dom/csslayerstatementrule.rs index df14579ee61..bc18819f72f 100644 --- a/components/script/dom/csslayerstatementrule.rs +++ b/components/script/dom/csslayerstatementrule.rs @@ -38,7 +38,7 @@ impl CSSLayerStatementRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index a4f48554cdd..0ef09de7f5a 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -38,7 +38,7 @@ impl CSSMediaRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index 4285df722f3..75cc6bad415 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -35,7 +35,7 @@ impl CSSNamespaceRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssrule.rs b/components/script/dom/cssrule.rs index 5cbc002114d..52d10e75b1f 100644 --- a/components/script/dom/cssrule.rs +++ b/components/script/dom/cssrule.rs @@ -38,7 +38,7 @@ pub(crate) struct CSSRule { } impl CSSRule { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited(parent_stylesheet: &CSSStyleSheet) -> CSSRule { CSSRule { reflector_: Reflector::new(), diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 6420982973c..b21429d2355 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -53,7 +53,7 @@ pub(crate) enum RulesSource { } impl CSSRuleList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, rules: RulesSource, @@ -82,7 +82,7 @@ impl CSSRuleList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index c91ec72da68..de4077449d8 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -43,7 +43,7 @@ pub(crate) struct CSSStyleDeclaration { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum CSSStyleOwner { Element(Dom<Element>), CSSRule( @@ -215,7 +215,7 @@ fn remove_property(decls: &mut PropertyDeclarationBlock, id: &PropertyId) -> boo } impl CSSStyleDeclaration { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( owner: CSSStyleOwner, pseudo: Option<PseudoElement>, @@ -229,7 +229,7 @@ impl CSSStyleDeclaration { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &Window, owner: CSSStyleOwner, diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index f0052fda1ef..32ce8c53964 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -45,7 +45,7 @@ impl CSSStyleRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index 0212ea16e99..ec48647f162 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -50,7 +50,7 @@ impl CSSStyleSheet { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, owner: &Element, diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index f387daba95e..01936bc031d 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -37,7 +37,7 @@ impl CSSSupportsRule { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 9ca7b756e06..e9ca7113ed1 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -334,7 +334,8 @@ fn get_callback( } impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistry { - #[allow(unsafe_code, crown::unrooted_must_root)] + #[allow(unsafe_code)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] /// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define> fn Define( &self, @@ -973,7 +974,7 @@ pub(crate) fn try_upgrade_element(element: &Element) { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum CustomElementReaction { Upgrade(#[ignore_malloc_size_of = "Rc"] Rc<CustomElementDefinition>), Callback( @@ -1028,7 +1029,7 @@ enum BackupElementQueueFlag { /// <https://html.spec.whatwg.org/multipage/#custom-element-reactions-stack> #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct CustomElementReactionStack { stack: DomRefCell<Vec<ElementQueue>>, backup_queue: ElementQueue, @@ -1233,7 +1234,7 @@ impl CustomElementReactionStack { /// <https://html.spec.whatwg.org/multipage/#element-queue> #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct ElementQueue { queue: DomRefCell<VecDeque<Dom<Element>>>, } diff --git a/components/script/dom/defaultteereadrequest.rs b/components/script/dom/defaultteereadrequest.rs index 2abf5de3cdc..d54f5885605 100644 --- a/components/script/dom/defaultteereadrequest.rs +++ b/components/script/dom/defaultteereadrequest.rs @@ -24,7 +24,7 @@ use crate::microtask::Microtask; use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) struct DefaultTeeReadRequestMicrotask { #[ignore_malloc_size_of = "mozjs"] chunk: Box<Heap<JSVal>>, @@ -60,7 +60,7 @@ pub(crate) struct DefaultTeeReadRequest { } impl DefaultTeeReadRequest { #[allow(clippy::too_many_arguments)] - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( stream: &ReadableStream, branch_1: &ReadableStream, diff --git a/components/script/dom/defaultteeunderlyingsource.rs b/components/script/dom/defaultteeunderlyingsource.rs index 565659d7bae..269cba5cc91 100644 --- a/components/script/dom/defaultteeunderlyingsource.rs +++ b/components/script/dom/defaultteeunderlyingsource.rs @@ -59,7 +59,7 @@ pub(crate) struct DefaultTeeUnderlyingSource { impl DefaultTeeUnderlyingSource { #[allow(clippy::too_many_arguments)] #[allow(clippy::redundant_allocation)] - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( reader: &ReadableStreamDefaultReader, stream: &ReadableStream, @@ -106,7 +106,7 @@ impl DefaultTeeUnderlyingSource { /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaulttee> /// Let pullAlgorithm be the following steps: - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn pull_algorithm(&self, can_gc: CanGc) -> Option<Result<Rc<Promise>, Error>> { // If reading is true, if self.reading.get() { diff --git a/components/script/dom/dissimilaroriginlocation.rs b/components/script/dom/dissimilaroriginlocation.rs index dd108e5b2ad..3e2b84c9ae2 100644 --- a/components/script/dom/dissimilaroriginlocation.rs +++ b/components/script/dom/dissimilaroriginlocation.rs @@ -29,7 +29,7 @@ pub(crate) struct DissimilarOriginLocation { } impl DissimilarOriginLocation { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(window: &DissimilarOriginWindow) -> DissimilarOriginLocation { DissimilarOriginLocation { reflector: Reflector::new(), diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 8263d3f15ef..6efd7c83b59 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -240,7 +240,7 @@ pub(crate) enum IsHTMLDocument { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] enum FocusTransaction { /// No focus operation is in effect. NotInTransaction, @@ -3152,7 +3152,7 @@ impl Document { self.webgpu_contexts.clone() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] #[cfg(feature = "webgpu")] pub(crate) fn update_rendering_of_webgpu_canvases(&self) { self.webgpu_contexts @@ -4178,7 +4178,7 @@ impl Document { /// Add a stylesheet owned by `owner` to the list of document sheets, in the /// correct tree position. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { let stylesheets = &mut *self.stylesheets.borrow_mut(); let insertion_point = stylesheets @@ -4215,7 +4215,7 @@ impl Document { } /// Remove a stylesheet owned by `owner` from the list of document sheets. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn remove_stylesheet(&self, owner: &Element, stylesheet: &Arc<Stylesheet>) { let cloned_stylesheet = stylesheet.clone(); self.window @@ -4241,7 +4241,7 @@ impl Document { }) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn drain_pending_restyles(&self) -> Vec<(TrustedNodeAddress, PendingRestyle)> { self.pending_restyles .borrow_mut() @@ -5878,7 +5878,7 @@ impl AnimationFrameCallback { } #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct PendingInOrderScriptVec { scripts: DomRefCell<VecDeque<PendingScript>>, } @@ -5916,7 +5916,7 @@ impl PendingInOrderScriptVec { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct PendingScript { element: Dom<HTMLScriptElement>, // TODO(sagudev): could this be all no_trace? diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs index 29713ee0d50..4b0e8478368 100644 --- a/components/script/dom/documentorshadowroot.rs +++ b/components/script/dom/documentorshadowroot.rs @@ -29,7 +29,7 @@ use crate::script_runtime::CanGc; use crate::stylesheet_set::StylesheetSetRef; #[derive(Clone, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct StyleSheetInDocument { #[ignore_malloc_size_of = "Arc"] #[no_trace] @@ -82,7 +82,7 @@ impl ::style::stylesheets::StylesheetInDocument for StyleSheetInDocument { } // https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-the-documentorshadowroot-mixin -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct DocumentOrShadowRoot { window: Dom<Window>, @@ -218,7 +218,7 @@ impl DocumentOrShadowRoot { } /// Remove a stylesheet owned by `owner` from the list of document sheets. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn remove_stylesheet( owner: &Element, s: &Arc<Stylesheet>, @@ -239,7 +239,7 @@ impl DocumentOrShadowRoot { /// Add a stylesheet owned by `owner` to the list of document sheets, in the /// correct tree position. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn add_stylesheet( owner: &Element, mut stylesheets: StylesheetSetRef<StyleSheetInDocument>, diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index 7499d7fbaae..a2382e4faa7 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -38,7 +38,7 @@ impl DocumentType { system_id: system_id.unwrap_or_default(), } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( name: DOMString, public_id: Option<DOMString>, diff --git a/components/script/dom/dommatrix.rs b/components/script/dom/dommatrix.rs index f84f3b500d4..f5491e8cefe 100644 --- a/components/script/dom/dommatrix.rs +++ b/components/script/dom/dommatrix.rs @@ -38,7 +38,7 @@ impl DOMMatrix { Self::new_with_proto(global, None, is2D, matrix, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, diff --git a/components/script/dom/dommatrixreadonly.rs b/components/script/dom/dommatrixreadonly.rs index fb6e6fbf48b..13e581356bf 100644 --- a/components/script/dom/dommatrixreadonly.rs +++ b/components/script/dom/dommatrixreadonly.rs @@ -55,7 +55,7 @@ impl DOMMatrixReadOnly { Self::new_with_proto(global, None, is2D, matrix, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index 40ebd42f036..1748b7e6f68 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -74,7 +74,7 @@ impl DOMRectMethods<crate::DomTypeHolder> for DOMRect { } // https://drafts.fxtf.org/geometry/#dom-domrect-fromrect - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMRect> { let rect = create_a_domrectreadonly_from_the_dictionary(other); diff --git a/components/script/dom/domrectreadonly.rs b/components/script/dom/domrectreadonly.rs index f9e71db51ba..bdad365b55e 100644 --- a/components/script/dom/domrectreadonly.rs +++ b/components/script/dom/domrectreadonly.rs @@ -89,7 +89,7 @@ impl DOMRectReadOnlyMethods<crate::DomTypeHolder> for DOMRectReadOnly { } // https://drafts.fxtf.org/geometry/#dom-domrectreadonly-fromrect - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn FromRect(global: &GlobalScope, other: &DOMRectInit) -> DomRoot<DOMRectReadOnly> { let dom_rect = create_a_domrectreadonly_from_the_dictionary(other); @@ -158,7 +158,7 @@ impl DOMRectReadOnlyMethods<crate::DomTypeHolder> for DOMRectReadOnly { } /// <https://drafts.fxtf.org/geometry/#ref-for-create-a-domrectreadonly-from-the-dictionary> -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(super) fn create_a_domrectreadonly_from_the_dictionary(other: &DOMRectInit) -> DOMRectReadOnly { // NOTE: We trivially combine all three steps into one diff --git a/components/script/dom/dynamicmoduleowner.rs b/components/script/dom/dynamicmoduleowner.rs index 1ad75a2323f..820c5fc5432 100644 --- a/components/script/dom/dynamicmoduleowner.rs +++ b/components/script/dom/dynamicmoduleowner.rs @@ -31,7 +31,7 @@ pub(crate) struct DynamicModuleOwner { } impl DynamicModuleOwner { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(promise: Rc<Promise>, id: DynamicModuleId) -> Self { DynamicModuleOwner { reflector_: Reflector::new(), @@ -40,7 +40,7 @@ impl DynamicModuleOwner { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, promise: Rc<Promise>, diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index df22722e1d5..166b9707e31 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -4462,7 +4462,7 @@ impl ElementPerformFullscreenEnter { } impl TaskOnce for ElementPerformFullscreenEnter { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn run_once(self) { let element = self.element.root(); let promise = self.promise.root(); @@ -4507,7 +4507,7 @@ impl ElementPerformFullscreenExit { } impl TaskOnce for ElementPerformFullscreenExit { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn run_once(self) { let element = self.element.root(); let document = element.owner_document(); diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index 05a58274414..dbcb973da59 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -95,7 +95,7 @@ pub(crate) struct Event { /// An element on an [event path](https://dom.spec.whatwg.org/#event-path) #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct EventPathSegment { /// <https://dom.spec.whatwg.org/#event-path-invocation-target> invocation_target: Dom<EventTarget>, @@ -211,7 +211,7 @@ impl Event { } /// <https://dom.spec.whatwg.org/#concept-event-path-append> - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn append_to_path( &self, invocation_target: &EventTarget, diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index f3f78fe2c7f..780cadbfa1f 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -31,7 +31,7 @@ pub(crate) struct File { } impl File { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(blob_impl: &BlobImpl, name: DOMString, modified: Option<SystemTime>) -> File { File { blob: Blob::new_inherited(blob_impl), @@ -51,7 +51,7 @@ impl File { Self::new_with_proto(global, None, blob_impl, name, modified, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, diff --git a/components/script/dom/filelist.rs b/components/script/dom/filelist.rs index f3e077aa3fe..232ffcad14b 100644 --- a/components/script/dom/filelist.rs +++ b/components/script/dom/filelist.rs @@ -21,7 +21,7 @@ pub(crate) struct FileList { } impl FileList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(files: Vec<Dom<File>>) -> FileList { FileList { reflector_: Reflector::new(), @@ -29,7 +29,7 @@ impl FileList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(window: &Window, files: Vec<DomRoot<File>>) -> DomRoot<FileList> { reflect_dom_object( Box::new(FileList::new_inherited( diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index d8c2de5a561..2dce36757eb 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -104,7 +104,7 @@ impl FormDataMethods<crate::DomTypeHolder> for FormData { .push((NoTrace(LocalName::from(name.0)), datum)); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://xhr.spec.whatwg.org/#dom-formdata-append fn Append_(&self, name: USVString, blob: &Blob, filename: Option<USVString>) { let datum = FormDatum { @@ -188,7 +188,7 @@ impl FormDataMethods<crate::DomTypeHolder> for FormData { )); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://xhr.spec.whatwg.org/#dom-formdata-set fn Set_(&self, name: USVString, blob: &Blob, filename: Option<USVString>) { let file = self.create_an_entry(blob, filename, CanGc::note()); diff --git a/components/script/dom/gainnode.rs b/components/script/dom/gainnode.rs index 31184925616..937c7bc242f 100644 --- a/components/script/dom/gainnode.rs +++ b/components/script/dom/gainnode.rs @@ -31,7 +31,7 @@ pub(crate) struct GainNode { } impl GainNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -74,7 +74,7 @@ impl GainNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/gamepadbuttonlist.rs b/components/script/dom/gamepadbuttonlist.rs index caf25661184..1689711d1ee 100644 --- a/components/script/dom/gamepadbuttonlist.rs +++ b/components/script/dom/gamepadbuttonlist.rs @@ -19,7 +19,7 @@ pub(crate) struct GamepadButtonList { } impl GamepadButtonList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(list: &[&GamepadButton]) -> GamepadButtonList { GamepadButtonList { reflector_: Reflector::new(), diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index e9b1cbcbda5..22edc0bbcdf 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -447,7 +447,7 @@ enum BlobResult { /// Data representing a message-port managed by this global. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct ManagedMessagePort { /// The DOM port. dom_port: Dom<MessagePort>, @@ -467,7 +467,7 @@ pub(crate) struct ManagedMessagePort { /// State representing whether this global is currently managing broadcast channels. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum BroadcastChannelState { /// The broadcast-channel router id for this global, and a queue of managed channels. /// Step 9, "sort destinations" @@ -484,7 +484,7 @@ pub(crate) enum BroadcastChannelState { /// State representing whether this global is currently managing messageports. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum MessagePortState { /// The message-port router id for this global, and a map of managed ports. Managed( diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index b3e5563bdd4..af019fb88c5 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -61,7 +61,7 @@ impl HTMLAnchorElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index b8b668f94e0..145916281f6 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -258,7 +258,7 @@ impl HTMLAreaElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index 44258d73f66..6377d5519ea 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -36,7 +36,7 @@ impl HTMLAudioElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 24957bd1e94..55403787154 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -35,7 +35,7 @@ impl HTMLBaseElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 3a15d4c3afa..d3e540f562f 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -40,7 +40,7 @@ impl HTMLBodyElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs index 4f299c832c7..2d5167b115b 100644 --- a/components/script/dom/htmlbrelement.rs +++ b/components/script/dom/htmlbrelement.rs @@ -28,7 +28,7 @@ impl HTMLBRElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 62bd6a964de..e3e43f2796f 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -69,7 +69,7 @@ impl HTMLButtonElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index ad153affc00..aee09ee4dd2 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -105,7 +105,7 @@ impl EncodedImageType { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Clone, JSTraceable, MallocSizeOf)] pub(crate) enum CanvasContext { Placeholder(Dom<OffscreenCanvasRenderingContext2D>), @@ -140,7 +140,7 @@ impl HTMLCanvasElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 4b3ad216e19..4ba65b405ed 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -69,7 +69,7 @@ pub(crate) struct HTMLCollection { } impl HTMLCollection { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( root: &Node, filter: Box<dyn CollectionFilter + 'static>, @@ -99,7 +99,7 @@ impl HTMLCollection { Self::new(window, root, Box::new(NoFilter)) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, root: &Node, diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs index 101bf713810..260b3e53ea3 100644 --- a/components/script/dom/htmldataelement.rs +++ b/components/script/dom/htmldataelement.rs @@ -30,7 +30,7 @@ impl HTMLDataElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index efa20a67604..51fc9280ad8 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -32,7 +32,7 @@ impl HTMLDataListElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 5e24031b823..00fb8aa21f4 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -39,7 +39,7 @@ impl HTMLDetailsElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index 078f47ad1fc..3839fe77575 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -36,7 +36,7 @@ impl HTMLDialogElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs index d355caca58e..6e09069ad19 100644 --- a/components/script/dom/htmldirectoryelement.rs +++ b/components/script/dom/htmldirectoryelement.rs @@ -28,7 +28,7 @@ impl HTMLDirectoryElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs index afaacef03e3..0582ff4b629 100644 --- a/components/script/dom/htmldivelement.rs +++ b/components/script/dom/htmldivelement.rs @@ -30,7 +30,7 @@ impl HTMLDivElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs index d13b6de1601..4198b840f27 100644 --- a/components/script/dom/htmldlistelement.rs +++ b/components/script/dom/htmldlistelement.rs @@ -28,7 +28,7 @@ impl HTMLDListElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 070522d216e..346b15ef009 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -87,7 +87,7 @@ impl HTMLElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs index e7b217a6d28..3d822d067c1 100644 --- a/components/script/dom/htmlembedelement.rs +++ b/components/script/dom/htmlembedelement.rs @@ -28,7 +28,7 @@ impl HTMLEmbedElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 28187c14da6..c9e0daf66e5 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -53,7 +53,7 @@ impl HTMLFieldSetElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index bc96d8b2ea4..e7af77812fc 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -42,7 +42,7 @@ impl HTMLFontElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index a4f62f94093..cae5c4d5963 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -131,7 +131,7 @@ impl HTMLFormElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs index f0e61f74e22..3bebcf677ca 100644 --- a/components/script/dom/htmlframeelement.rs +++ b/components/script/dom/htmlframeelement.rs @@ -28,7 +28,7 @@ impl HTMLFrameElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs index 83c97387c94..9ec694ba6af 100644 --- a/components/script/dom/htmlframesetelement.rs +++ b/components/script/dom/htmlframesetelement.rs @@ -31,7 +31,7 @@ impl HTMLFrameSetElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index 95b05732cb3..686007dc53d 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -35,7 +35,7 @@ impl HTMLHeadElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index 0f3d92e4d4e..a26f57d44a0 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -41,7 +41,7 @@ impl HTMLHeadingElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 298cf008a74..2707c4ebabf 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -35,7 +35,7 @@ impl HTMLHRElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs index f2fac7b1c67..fe4e4c828d8 100644 --- a/components/script/dom/htmlhtmlelement.rs +++ b/components/script/dom/htmlhtmlelement.rs @@ -30,7 +30,7 @@ impl HTMLHtmlElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( localName: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index ff58bc67b72..8bf9c6590d4 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -468,7 +468,7 @@ impl HTMLIFrameElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 1cbce12ebad..f8b4ba5d354 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -144,7 +144,7 @@ enum ImageRequestPhase { Current, } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct ImageRequest { state: State, #[no_trace] @@ -1324,7 +1324,7 @@ impl HTMLImageElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 9de33dcaa72..e8844084c68 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -369,7 +369,7 @@ impl HTMLInputElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, @@ -2104,7 +2104,7 @@ impl HTMLInputElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn selection(&self) -> TextControlSelection<Self> { TextControlSelection::new(self, &self.textinput) } diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index a7025d678d6..378bf1a6ed9 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -43,7 +43,7 @@ impl HTMLLabelElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index d0f551122e3..62ce3efebe4 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -37,7 +37,7 @@ impl HTMLLegendElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index 9d9e8d073c7..22a0e50eaca 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -33,7 +33,7 @@ impl HTMLLIElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index c676c048846..50d5e274c85 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -130,7 +130,7 @@ impl HTMLLinkElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, @@ -155,7 +155,7 @@ impl HTMLLinkElement { // FIXME(emilio): These methods are duplicated with // HTMLStyleElement::set_stylesheet. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn set_stylesheet(&self, s: Arc<Stylesheet>) { let stylesheets_owner = self.stylesheet_list_owner(); if let Some(ref s) = *self.stylesheet.borrow() { diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs index ee89c4c4da9..3f4a4356117 100644 --- a/components/script/dom/htmlmapelement.rs +++ b/components/script/dom/htmlmapelement.rs @@ -30,7 +30,7 @@ impl HTMLMapElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 60604c6c2df..b836f414496 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -301,7 +301,7 @@ impl VideoFrameRenderer for MediaFrameRenderer { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] enum SrcObject { MediaStream(Dom<MediaStream>), @@ -309,7 +309,7 @@ enum SrcObject { } impl From<MediaStreamOrBlob> for SrcObject { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn from(src_object: MediaStreamOrBlob) -> SrcObject { match src_object { MediaStreamOrBlob::Blob(blob) => SrcObject::Blob(Dom::from_ref(&*blob)), @@ -1199,9 +1199,9 @@ impl HTMLMediaElement { /// does not take a list of promises to fulfill. Callers cannot just pop /// the front list off of `in_flight_play_promises_queue` and later fulfill /// the promises because that would mean putting - /// `#[allow(crown::unrooted_must_root)]` on even more functions, potentially + /// `#[cfg_attr(crown, allow(crown::unrooted_must_root))]` on even more functions, potentially /// hiding actual safety bugs. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn fulfill_in_flight_play_promises<F>(&self, f: F) where F: FnOnce(), diff --git a/components/script/dom/htmlmenuelement.rs b/components/script/dom/htmlmenuelement.rs index 2caa6a884e6..00d0447ef25 100644 --- a/components/script/dom/htmlmenuelement.rs +++ b/components/script/dom/htmlmenuelement.rs @@ -29,7 +29,7 @@ impl HTMLMenuElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index bff3b9757a2..84a7a9d294b 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -66,7 +66,7 @@ impl HTMLMetaElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs index a86abf6ab51..596a792f2b5 100644 --- a/components/script/dom/htmlmeterelement.rs +++ b/components/script/dom/htmlmeterelement.rs @@ -39,7 +39,7 @@ impl HTMLMeterElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs index f4a0d7ab33d..8bcd7cdc6f7 100644 --- a/components/script/dom/htmlmodelement.rs +++ b/components/script/dom/htmlmodelement.rs @@ -28,7 +28,7 @@ impl HTMLModElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index c06ba9c33c7..e0d9de1d113 100644 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -50,7 +50,7 @@ impl HTMLObjectElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs index 993d4cb534f..3b5851833c6 100644 --- a/components/script/dom/htmlolistelement.rs +++ b/components/script/dom/htmlolistelement.rs @@ -28,7 +28,7 @@ impl HTMLOListElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index a54a3de95e7..e3f2f3f1996 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -43,7 +43,7 @@ impl HTMLOptGroupElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index fbf66afbe2f..b42a51d7ca1 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -66,7 +66,7 @@ impl HTMLOptionElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 70c60d212b7..443e98a2c42 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -47,7 +47,7 @@ impl HTMLOutputElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index b8e23285c32..bf910d56263 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -28,7 +28,7 @@ impl HTMLParagraphElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs index 6bed543251a..d3f5abffbc2 100644 --- a/components/script/dom/htmlparamelement.rs +++ b/components/script/dom/htmlparamelement.rs @@ -28,7 +28,7 @@ impl HTMLParamElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlpictureelement.rs b/components/script/dom/htmlpictureelement.rs index 0eac2af24ce..50062fee5ce 100644 --- a/components/script/dom/htmlpictureelement.rs +++ b/components/script/dom/htmlpictureelement.rs @@ -28,7 +28,7 @@ impl HTMLPictureElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs index 2e14491472f..17575c2c4c0 100644 --- a/components/script/dom/htmlpreelement.rs +++ b/components/script/dom/htmlpreelement.rs @@ -33,7 +33,7 @@ impl HTMLPreElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs index 487415ffc6a..13aedb6b37f 100644 --- a/components/script/dom/htmlprogresselement.rs +++ b/components/script/dom/htmlprogresselement.rs @@ -36,7 +36,7 @@ impl HTMLProgressElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs index b0adf962e87..dc46c96ea43 100644 --- a/components/script/dom/htmlquoteelement.rs +++ b/components/script/dom/htmlquoteelement.rs @@ -30,7 +30,7 @@ impl HTMLQuoteElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index c76075a93aa..1aaa0119760 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -209,7 +209,7 @@ impl HTMLScriptElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index b3efa6da21d..227048b7f46 100644 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -92,7 +92,7 @@ impl HTMLSelectElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index 6dac11e1510..34949fa38ce 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -37,7 +37,7 @@ impl HTMLSourceElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs index bbf3c459042..4563477dc8c 100644 --- a/components/script/dom/htmlspanelement.rs +++ b/components/script/dom/htmlspanelement.rs @@ -28,7 +28,7 @@ impl HTMLSpanElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 8d8b7d8492e..5160918640c 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -64,7 +64,7 @@ impl HTMLStyleElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, @@ -143,7 +143,7 @@ impl HTMLStyleElement { } // FIXME(emilio): This is duplicated with HTMLLinkElement::set_stylesheet. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn set_stylesheet(&self, s: Arc<Stylesheet>) { let stylesheets_owner = self.stylesheet_list_owner(); if let Some(ref s) = *self.stylesheet.borrow() { diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs index a684b740627..b6bae5a7485 100644 --- a/components/script/dom/htmltablecaptionelement.rs +++ b/components/script/dom/htmltablecaptionelement.rs @@ -29,7 +29,7 @@ impl HTMLTableCaptionElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index cc9f5252bf9..dc32f57e87a 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -43,7 +43,7 @@ impl HTMLTableCellElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs index c7857089d23..047b164cd34 100644 --- a/components/script/dom/htmltablecolelement.rs +++ b/components/script/dom/htmltablecolelement.rs @@ -38,7 +38,7 @@ impl HTMLTableColElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 05666f7831e..5cee96dba37 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -39,7 +39,7 @@ pub(crate) struct HTMLTableElement { tbodies: MutNullableDom<HTMLCollection>, } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] #[derive(JSTraceable, MallocSizeOf)] struct TableRowFilter { sections: Vec<Dom<Node>>, @@ -70,7 +70,7 @@ impl HTMLTableElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 41564100e05..4ad32a38947 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -45,7 +45,7 @@ impl HTMLTableRowElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index ffdc1e928b1..ed3b5fc04a5 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -39,7 +39,7 @@ impl HTMLTableSectionElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 8ce3119af1f..9a69c2c27f8 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -38,7 +38,7 @@ impl HTMLTemplateElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index fe0c822aa48..e660e3e4d93 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -170,7 +170,7 @@ impl HTMLTextAreaElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, @@ -454,7 +454,7 @@ impl HTMLTextAreaElement { self.value_dirty.set(false); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn selection(&self) -> TextControlSelection<Self> { TextControlSelection::new(self, &self.textinput) } diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs index ebb63c6cfb6..8f2ce66f636 100644 --- a/components/script/dom/htmltimeelement.rs +++ b/components/script/dom/htmltimeelement.rs @@ -30,7 +30,7 @@ impl HTMLTimeElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index 5eea0d278fe..6b6b3504e13 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -37,7 +37,7 @@ impl HTMLTitleElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs index 37be6865e21..3ba9a9deb0b 100644 --- a/components/script/dom/htmlulistelement.rs +++ b/components/script/dom/htmlulistelement.rs @@ -30,7 +30,7 @@ impl HTMLUListElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs index a286c601ffc..1f51ea6cfa4 100644 --- a/components/script/dom/htmlunknownelement.rs +++ b/components/script/dom/htmlunknownelement.rs @@ -28,7 +28,7 @@ impl HTMLUnknownElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index d8668dcc859..2147580928b 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -82,7 +82,7 @@ impl HTMLVideoElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/iirfilternode.rs b/components/script/dom/iirfilternode.rs index cf50c47bc5e..e057536997b 100644 --- a/components/script/dom/iirfilternode.rs +++ b/components/script/dom/iirfilternode.rs @@ -35,7 +35,7 @@ pub(crate) struct IIRFilterNode { } impl IIRFilterNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( _window: &Window, context: &BaseAudioContext, @@ -77,7 +77,7 @@ impl IIRFilterNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 7fc18260890..0d659839e53 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -682,7 +682,7 @@ macro_rules! impl_performance_entry_struct( } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(global: &GlobalScope, name: DOMString, start_time: CrossProcessInstant, diff --git a/components/script/dom/mediaelementaudiosourcenode.rs b/components/script/dom/mediaelementaudiosourcenode.rs index d56ba30422b..7d612a7a26d 100644 --- a/components/script/dom/mediaelementaudiosourcenode.rs +++ b/components/script/dom/mediaelementaudiosourcenode.rs @@ -28,7 +28,7 @@ pub(crate) struct MediaElementAudioSourceNode { } impl MediaElementAudioSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( context: &AudioContext, media_element: &HTMLMediaElement, @@ -63,7 +63,7 @@ impl MediaElementAudioSourceNode { Self::new_with_proto(window, None, context, media_element, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index d28e15d643b..09dea6183eb 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -30,7 +30,7 @@ pub(crate) struct MediaList { } impl MediaList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( parent_stylesheet: &CSSStyleSheet, media_queries: Arc<Locked<StyleMediaList>>, @@ -42,7 +42,7 @@ impl MediaList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, parent_stylesheet: &CSSStyleSheet, diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs index 679188f02c3..d2049273c15 100644 --- a/components/script/dom/mediasession.rs +++ b/components/script/dom/mediasession.rs @@ -50,7 +50,7 @@ pub(crate) struct MediaSession { } impl MediaSession { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited() -> MediaSession { MediaSession { reflector_: Reflector::new(), diff --git a/components/script/dom/mediastreamaudiodestinationnode.rs b/components/script/dom/mediastreamaudiodestinationnode.rs index 29a3a19a6f4..7e48d8df08b 100644 --- a/components/script/dom/mediastreamaudiodestinationnode.rs +++ b/components/script/dom/mediastreamaudiodestinationnode.rs @@ -29,7 +29,7 @@ pub(crate) struct MediaStreamAudioDestinationNode { } impl MediaStreamAudioDestinationNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( context: &AudioContext, options: &AudioNodeOptions, @@ -65,7 +65,7 @@ impl MediaStreamAudioDestinationNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/mediastreamaudiosourcenode.rs b/components/script/dom/mediastreamaudiosourcenode.rs index f3eb95f7a5d..b60dbea377e 100644 --- a/components/script/dom/mediastreamaudiosourcenode.rs +++ b/components/script/dom/mediastreamaudiosourcenode.rs @@ -27,7 +27,7 @@ pub(crate) struct MediaStreamAudioSourceNode { } impl MediaStreamAudioSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( context: &AudioContext, stream: &MediaStream, @@ -60,7 +60,7 @@ impl MediaStreamAudioSourceNode { Self::new_with_proto(window, None, context, stream, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/mediastreamtrackaudiosourcenode.rs b/components/script/dom/mediastreamtrackaudiosourcenode.rs index cb58f58ee66..f8bb9717682 100644 --- a/components/script/dom/mediastreamtrackaudiosourcenode.rs +++ b/components/script/dom/mediastreamtrackaudiosourcenode.rs @@ -26,7 +26,7 @@ pub(crate) struct MediaStreamTrackAudioSourceNode { } impl MediaStreamTrackAudioSourceNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( context: &AudioContext, track: &MediaStreamTrack, @@ -53,7 +53,7 @@ impl MediaStreamTrackAudioSourceNode { Self::new_with_proto(window, None, context, track, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index c6dc0f3abd2..0ed757614e8 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -28,7 +28,7 @@ use crate::dom::serviceworker::ServiceWorker; use crate::dom::windowproxy::WindowProxy; use crate::script_runtime::{CanGc, JSContext}; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] enum SrcObject { WindowProxy(Dom<WindowProxy>), @@ -37,7 +37,7 @@ enum SrcObject { } impl From<&WindowProxyOrMessagePortOrServiceWorker> for SrcObject { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn from(src_object: &WindowProxyOrMessagePortOrServiceWorker) -> SrcObject { match src_object { WindowProxyOrMessagePortOrServiceWorker::WindowProxy(blob) => { diff --git a/components/script/dom/mutationrecord.rs b/components/script/dom/mutationrecord.rs index 3b4195bd01c..a8289cd2c30 100644 --- a/components/script/dom/mutationrecord.rs +++ b/components/script/dom/mutationrecord.rs @@ -28,7 +28,7 @@ pub(crate) struct MutationRecord { } impl MutationRecord { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn attribute_mutated( target: &Node, attribute_name: &LocalName, diff --git a/components/script/dom/navigationpreloadmanager.rs b/components/script/dom/navigationpreloadmanager.rs index ff8fea3a6b8..25129cd0166 100644 --- a/components/script/dom/navigationpreloadmanager.rs +++ b/components/script/dom/navigationpreloadmanager.rs @@ -34,7 +34,7 @@ impl NavigationPreloadManager { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, registration: &ServiceWorkerRegistration, diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 3925c532a5c..3518e3d9b7f 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1833,7 +1833,7 @@ impl Node { Node::new_(NodeFlags::empty(), Some(doc)) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_document_node() -> Node { Node::new_( NodeFlags::IS_IN_A_DOCUMENT_TREE | NodeFlags::IS_CONNECTED, @@ -1841,7 +1841,7 @@ impl Node { ) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_(flags: NodeFlags, doc: Option<&Document>) -> Node { Node { eventtarget: EventTarget::new_inherited(), @@ -3355,7 +3355,7 @@ pub(crate) trait NodeTraits { fn containing_shadow_root(&self) -> Option<DomRoot<ShadowRoot>>; /// Get the stylesheet owner for this node: either the [`Document`] or the [`ShadowRoot`] /// of the node. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn stylesheet_list_owner(&self) -> StyleSheetListOwner; } @@ -3376,7 +3376,7 @@ impl<T: DerivedFrom<Node> + DomObject> NodeTraits for T { Node::containing_shadow_root(self.upcast()) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn stylesheet_list_owner(&self) -> StyleSheetListOwner { self.containing_shadow_root() .map(|shadow_root| StyleSheetListOwner::ShadowRoot(Dom::from_ref(&*shadow_root))) diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 0900996a611..2e0e0f73eb6 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -20,7 +20,7 @@ use crate::dom::window::Window; use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum NodeListType { Simple(Vec<Dom<Node>>), Children(ChildrenList), @@ -37,7 +37,7 @@ pub(crate) struct NodeList { } impl NodeList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited(list_type: NodeListType) -> NodeList { NodeList { reflector_: Reflector::new(), @@ -45,7 +45,7 @@ impl NodeList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(window: &Window, list_type: NodeListType) -> DomRoot<NodeList> { reflect_dom_object( Box::new(NodeList::new_inherited(list_type)), @@ -152,7 +152,7 @@ impl NodeList { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct ChildrenList { node: Dom<Node>, #[ignore_malloc_size_of = "Defined in rust-mozjs"] @@ -362,7 +362,7 @@ impl ChildrenList { // and it's possible that tracking label moves would end up no faster // than recalculating labels. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct LabelsList { element: Dom<HTMLElement>, } @@ -395,7 +395,7 @@ pub(crate) enum RadioListMode { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct RadioList { form: Dom<HTMLFormElement>, mode: RadioListMode, @@ -422,7 +422,7 @@ impl RadioList { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct ElementsByNameList { document: Dom<Document>, name: DOMString, diff --git a/components/script/dom/offlineaudiocontext.rs b/components/script/dom/offlineaudiocontext.rs index 55047da46b8..f93c40ff87c 100644 --- a/components/script/dom/offlineaudiocontext.rs +++ b/components/script/dom/offlineaudiocontext.rs @@ -44,7 +44,7 @@ pub(crate) struct OfflineAudioContext { } impl OfflineAudioContext { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( channel_count: u32, length: u32, @@ -69,7 +69,7 @@ impl OfflineAudioContext { }) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/offscreencanvas.rs b/components/script/dom/offscreencanvas.rs index 41b862ce118..00ca2b63bc5 100644 --- a/components/script/dom/offscreencanvas.rs +++ b/components/script/dom/offscreencanvas.rs @@ -25,7 +25,7 @@ use crate::dom::htmlcanvaselement::HTMLCanvasElement; use crate::dom::offscreencanvasrenderingcontext2d::OffscreenCanvasRenderingContext2D; use crate::script_runtime::{CanGc, JSContext}; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Clone, JSTraceable, MallocSizeOf)] pub(crate) enum OffscreenCanvasContext { OffscreenContext2d(Dom<OffscreenCanvasRenderingContext2D>), diff --git a/components/script/dom/offscreencanvasrenderingcontext2d.rs b/components/script/dom/offscreencanvasrenderingcontext2d.rs index 67dae84012a..c0a0ee984b1 100644 --- a/components/script/dom/offscreencanvasrenderingcontext2d.rs +++ b/components/script/dom/offscreencanvasrenderingcontext2d.rs @@ -210,7 +210,7 @@ impl OffscreenCanvasRenderingContext2DMethods<crate::DomTypeHolder> self.canvas_state.save() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://html.spec.whatwg.org/multipage/#dom-context-2d-restore fn Restore(&self) { self.canvas_state.restore() diff --git a/components/script/dom/oscillatornode.rs b/components/script/dom/oscillatornode.rs index c05a95fdd69..2660bdc8958 100644 --- a/components/script/dom/oscillatornode.rs +++ b/components/script/dom/oscillatornode.rs @@ -40,7 +40,7 @@ pub(crate) struct OscillatorNode { } impl OscillatorNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -97,7 +97,7 @@ impl OscillatorNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs index b971bbbd35f..8e2bbdc1fe8 100644 --- a/components/script/dom/paintworkletglobalscope.rs +++ b/components/script/dom/paintworkletglobalscope.rs @@ -453,7 +453,7 @@ pub(crate) enum PaintWorkletTask { /// This type is dangerous, because it contains uboxed `Heap<JSVal>` values, /// which can't be moved. #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct PaintDefinition { #[ignore_malloc_size_of = "mozjs"] class_constructor: Heap<JSVal>, @@ -493,7 +493,7 @@ impl PaintDefinition { impl PaintWorkletGlobalScopeMethods<crate::DomTypeHolder> for PaintWorkletGlobalScope { #[allow(unsafe_code)] - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] /// <https://drafts.css-houdini.org/css-paint-api/#dom-paintworkletglobalscope-registerpaint> fn RegisterPaint(&self, name: DOMString, paint_ctor: Rc<VoidFunction>) -> Fallible<()> { let name = Atom::from(name); diff --git a/components/script/dom/pannernode.rs b/components/script/dom/pannernode.rs index 4ebcf4abc6b..30693ff89cd 100644 --- a/components/script/dom/pannernode.rs +++ b/components/script/dom/pannernode.rs @@ -58,7 +58,7 @@ pub(crate) struct PannerNode { } impl PannerNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -190,7 +190,7 @@ impl PannerNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/performanceentry.rs b/components/script/dom/performanceentry.rs index 8c3fb3e1120..8b7cf95c469 100644 --- a/components/script/dom/performanceentry.rs +++ b/components/script/dom/performanceentry.rs @@ -45,7 +45,7 @@ impl PerformanceEntry { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, name: DOMString, diff --git a/components/script/dom/performanceobserver.rs b/components/script/dom/performanceobserver.rs index a3093ed9815..db7454938db 100644 --- a/components/script/dom/performanceobserver.rs +++ b/components/script/dom/performanceobserver.rs @@ -74,7 +74,7 @@ impl PerformanceObserver { Self::new_with_proto(global, None, callback, entries, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &GlobalScope, proto: Option<HandleObject>, diff --git a/components/script/dom/performanceobserverentrylist.rs b/components/script/dom/performanceobserverentrylist.rs index 71e97fdb925..36adbf8da0d 100644 --- a/components/script/dom/performanceobserverentrylist.rs +++ b/components/script/dom/performanceobserverentrylist.rs @@ -28,7 +28,7 @@ impl PerformanceObserverEntryList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, entries: PerformanceEntryList, diff --git a/components/script/dom/performancepainttiming.rs b/components/script/dom/performancepainttiming.rs index 0e556f3c13c..d7b2b14e57f 100644 --- a/components/script/dom/performancepainttiming.rs +++ b/components/script/dom/performancepainttiming.rs @@ -41,7 +41,7 @@ impl PerformancePaintTiming { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, metric_type: ProgressiveWebMetricType, diff --git a/components/script/dom/performanceresourcetiming.rs b/components/script/dom/performanceresourcetiming.rs index 02e703fcdab..972ca1e8ad9 100644 --- a/components/script/dom/performanceresourcetiming.rs +++ b/components/script/dom/performanceresourcetiming.rs @@ -114,7 +114,7 @@ impl PerformanceResourceTiming { } //TODO fetch start should be in RFT - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn from_resource_timing( url: ServoUrl, initiator_type: InitiatorType, diff --git a/components/script/dom/permissions.rs b/components/script/dom/permissions.rs index 8efa1b09765..1d7c8e63698 100644 --- a/components/script/dom/permissions.rs +++ b/components/script/dom/permissions.rs @@ -30,7 +30,7 @@ use crate::script_runtime::{CanGc, JSContext}; pub(crate) trait PermissionAlgorithm { type Descriptor; - #[crown::unrooted_must_root_lint::must_root] + #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] type Status; fn create_descriptor( cx: JSContext, diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs index 41c40fce556..bf475e95ceb 100644 --- a/components/script/dom/promise.rs +++ b/components/script/dom/promise.rs @@ -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) { diff --git a/components/script/dom/promiserejectionevent.rs b/components/script/dom/promiserejectionevent.rs index 432f1be7fdb..593e5a4e7b0 100644 --- a/components/script/dom/promiserejectionevent.rs +++ b/components/script/dom/promiserejectionevent.rs @@ -35,7 +35,7 @@ pub(crate) struct PromiseRejectionEvent { } impl PromiseRejectionEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited() -> Self { PromiseRejectionEvent { event: Event::new_inherited(), @@ -65,7 +65,7 @@ impl PromiseRejectionEvent { ) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] #[allow(clippy::too_many_arguments)] fn new_with_proto( global: &GlobalScope, diff --git a/components/script/dom/radionodelist.rs b/components/script/dom/radionodelist.rs index b47a38f0d4f..e63e9f25930 100644 --- a/components/script/dom/radionodelist.rs +++ b/components/script/dom/radionodelist.rs @@ -25,14 +25,14 @@ pub(crate) struct RadioNodeList { } impl RadioNodeList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(list_type: NodeListType) -> RadioNodeList { RadioNodeList { node_list: NodeList::new_inherited(list_type), } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(window: &Window, list_type: NodeListType) -> DomRoot<RadioNodeList> { reflect_dom_object( Box::new(RadioNodeList::new_inherited(list_type)), diff --git a/components/script/dom/raredata.rs b/components/script/dom/raredata.rs index cbcb2934c42..d9b087d3b63 100644 --- a/components/script/dom/raredata.rs +++ b/components/script/dom/raredata.rs @@ -21,7 +21,7 @@ use crate::dom::window::LayoutValue; // storage. #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct NodeRareData { /// The shadow root the node belongs to. /// This is None if the node is not in a shadow tree or @@ -34,7 +34,7 @@ pub(crate) struct NodeRareData { } #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct ElementRareData { /// <https://dom.spec.whatwg.org/#dom-element-shadowroot> /// The ShadowRoot this element is host of. diff --git a/components/script/dom/readablestream.rs b/components/script/dom/readablestream.rs index 2121894ffdf..a99ae33c799 100644 --- a/components/script/dom/readablestream.rs +++ b/components/script/dom/readablestream.rs @@ -90,7 +90,7 @@ pub(crate) enum ReadableStreamState { /// <https://streams.spec.whatwg.org/#readablestream-controller> #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum ControllerType { /// <https://streams.spec.whatwg.org/#readablebytestreamcontroller> Byte(MutNullableDom<ReadableByteStreamController>), @@ -100,7 +100,7 @@ pub(crate) enum ControllerType { /// <https://streams.spec.whatwg.org/#readablestream-readerr> #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum ReaderType { /// <https://streams.spec.whatwg.org/#readablestreambyobreader> #[allow(clippy::upper_case_acronyms)] @@ -110,7 +110,7 @@ pub(crate) enum ReaderType { } /// <https://streams.spec.whatwg.org/#create-readable-stream> -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] fn create_readable_stream( global: &GlobalScope, underlying_source_type: UnderlyingSourceType, @@ -181,7 +181,7 @@ pub(crate) struct ReadableStream { } impl ReadableStream { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] /// <https://streams.spec.whatwg.org/#initialize-readable-stream> fn new_inherited(controller: ControllerType) -> ReadableStream { let reader = match &controller { @@ -198,7 +198,7 @@ impl ReadableStream { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( global: &GlobalScope, proto: Option<SafeHandleObject>, @@ -252,7 +252,7 @@ impl ReadableStream { /// Build a stream backed by a Rust underlying source. /// Note: external sources are always paired with a default controller. - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_with_external_underlying_source( global: &GlobalScope, source: UnderlyingSourceType, @@ -555,7 +555,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#readable-stream-fulfill-read-request> - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn fulfill_read_request(&self, chunk: SafeHandleValue, done: bool) { // step 1 - Assert: ! ReadableStreamHasDefaultReader(stream) is true. assert!(self.has_default_reader()); @@ -676,7 +676,7 @@ impl ReadableStream { result_promise } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn set_reader(&self, new_reader: Option<ReaderType>) { match (&self.reader, new_reader) { (ReaderType::Default(ref reader), Some(ReaderType::Default(new_reader))) => { @@ -698,7 +698,7 @@ impl ReadableStream { } /// <https://streams.spec.whatwg.org/#abstract-opdef-readablestreamdefaulttee> - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn default_tee( &self, clone_for_branch_2: bool, diff --git a/components/script/dom/readablestreamdefaultcontroller.rs b/components/script/dom/readablestreamdefaultcontroller.rs index 22e724360d8..1b627a90558 100644 --- a/components/script/dom/readablestreamdefaultcontroller.rs +++ b/components/script/dom/readablestreamdefaultcontroller.rs @@ -37,7 +37,7 @@ use crate::script_runtime::{CanGc, JSContext, JSContext as SafeJSContext}; /// The fulfillment handler for /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed> #[derive(Clone, JSTraceable, MallocSizeOf)] -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] struct PullAlgorithmFulfillmentHandler { #[ignore_malloc_size_of = "Trusted are hard"] controller: Trusted<ReadableStreamDefaultController>, @@ -66,7 +66,7 @@ impl Callback for PullAlgorithmFulfillmentHandler { /// The rejection handler for /// <https://streams.spec.whatwg.org/#readable-stream-default-controller-call-pull-if-needed> #[derive(Clone, JSTraceable, MallocSizeOf)] -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] struct PullAlgorithmRejectionHandler { #[ignore_malloc_size_of = "Trusted are hard"] controller: Trusted<ReadableStreamDefaultController>, @@ -86,7 +86,7 @@ impl Callback for PullAlgorithmRejectionHandler { /// The fulfillment handler for /// <https://streams.spec.whatwg.org/#dom-underlyingsource-start> #[derive(Clone, JSTraceable, MallocSizeOf)] -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] struct StartAlgorithmFulfillmentHandler { #[ignore_malloc_size_of = "Trusted are hard"] controller: Trusted<ReadableStreamDefaultController>, @@ -109,7 +109,7 @@ impl Callback for StartAlgorithmFulfillmentHandler { /// The rejection handler for /// <https://streams.spec.whatwg.org/#dom-underlyingsource-start> #[derive(Clone, JSTraceable, MallocSizeOf)] -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] struct StartAlgorithmRejectionHandler { #[ignore_malloc_size_of = "Trusted are hard"] controller: Trusted<ReadableStreamDefaultController>, @@ -128,7 +128,7 @@ impl Callback for StartAlgorithmRejectionHandler { /// <https://streams.spec.whatwg.org/#value-with-size> #[derive(JSTraceable)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct ValueWithSize { value: Box<Heap<JSVal>>, size: f64, @@ -136,7 +136,7 @@ pub(crate) struct ValueWithSize { /// <https://streams.spec.whatwg.org/#value-with-size> #[derive(JSTraceable)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum EnqueuedValue { /// A value enqueued from Rust. Native(Box<[u8]>), @@ -193,7 +193,7 @@ fn is_non_negative_number(value: &EnqueuedValue) -> bool { /// <https://streams.spec.whatwg.org/#queue-with-sizes> #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct QueueWithSizes { #[ignore_malloc_size_of = "EnqueuedValue::Js"] queue: VecDeque<EnqueuedValue>, @@ -213,7 +213,7 @@ impl QueueWithSizes { } /// <https://streams.spec.whatwg.org/#enqueue-value-with-size> - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn enqueue_value_with_size(&mut self, value: EnqueuedValue) -> Result<(), Error> { // If ! IsNonNegativeNumber(size) is false, throw a RangeError exception. if !is_non_negative_number(&value) { @@ -300,7 +300,7 @@ pub(crate) struct ReadableStreamDefaultController { } impl ReadableStreamDefaultController { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( global: &GlobalScope, underlying_source_type: UnderlyingSourceType, @@ -326,7 +326,7 @@ impl ReadableStreamDefaultController { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, underlying_source: UnderlyingSourceType, diff --git a/components/script/dom/readablestreamdefaultreader.rs b/components/script/dom/readablestreamdefaultreader.rs index d5259543200..9a5283b1baa 100644 --- a/components/script/dom/readablestreamdefaultreader.rs +++ b/components/script/dom/readablestreamdefaultreader.rs @@ -91,7 +91,7 @@ impl ReadRequest { /// The rejection handler for /// <https://streams.spec.whatwg.org/#readable-stream-tee> #[derive(Clone, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct ClosedPromiseRejectionHandler { branch_1_controller: Dom<ReadableStreamDefaultController>, branch_2_controller: Dom<ReadableStreamDefaultController>, diff --git a/components/script/dom/readablestreamgenericreader.rs b/components/script/dom/readablestreamgenericreader.rs index 65b851e7bcf..c39335a3b85 100644 --- a/components/script/dom/readablestreamgenericreader.rs +++ b/components/script/dom/readablestreamgenericreader.rs @@ -22,7 +22,7 @@ use crate::script_runtime::CanGc; /// <https://streams.spec.whatwg.org/#readablestreamgenericreader> pub(crate) trait ReadableStreamGenericReader { /// <https://streams.spec.whatwg.org/#readable-stream-reader-generic-initialize> - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn generic_initialize( &self, global: &GlobalScope, diff --git a/components/script/dom/response.rs b/components/script/dom/response.rs index bfe7b1af198..5094d042996 100644 --- a/components/script/dom/response.rs +++ b/components/script/dom/response.rs @@ -458,7 +458,7 @@ impl Response { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn finish(&self) { if let Some(body) = self.body_stream.get() { body.controller_close_native(); diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs index 5b5f8f353bd..c9140b3bc03 100644 --- a/components/script/dom/rtcdatachannel.rs +++ b/components/script/dom/rtcdatachannel.rs @@ -55,7 +55,7 @@ pub(crate) struct RTCDataChannel { } impl RTCDataChannel { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( peer_connection: &RTCPeerConnection, label: USVString, diff --git a/components/script/dom/rtctrackevent.rs b/components/script/dom/rtctrackevent.rs index d90e3fa2d0d..d452b16406d 100644 --- a/components/script/dom/rtctrackevent.rs +++ b/components/script/dom/rtctrackevent.rs @@ -26,7 +26,7 @@ pub(crate) struct RTCTrackEvent { } impl RTCTrackEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(track: &MediaStreamTrack) -> RTCTrackEvent { RTCTrackEvent { event: Event::new_inherited(), diff --git a/components/script/dom/serviceworker.rs b/components/script/dom/serviceworker.rs index 0568bb40938..9f2187226ab 100644 --- a/components/script/dom/serviceworker.rs +++ b/components/script/dom/serviceworker.rs @@ -166,7 +166,7 @@ impl ServiceWorkerMethods<crate::DomTypeHolder> for ServiceWorker { } impl TaskOnce for SimpleWorkerErrorHandler<ServiceWorker> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn run_once(self) { ServiceWorker::dispatch_simple_error(self.addr, CanGc::note()); } diff --git a/components/script/dom/serviceworkercontainer.rs b/components/script/dom/serviceworkercontainer.rs index 2028c21960a..ffb904de2d4 100644 --- a/components/script/dom/serviceworkercontainer.rs +++ b/components/script/dom/serviceworkercontainer.rs @@ -44,7 +44,7 @@ impl ServiceWorkerContainer { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(global: &GlobalScope) -> DomRoot<ServiceWorkerContainer> { let client = Client::new(global.as_window()); let container = ServiceWorkerContainer::new_inherited(&client); diff --git a/components/script/dom/serviceworkerregistration.rs b/components/script/dom/serviceworkerregistration.rs index 2f1318f2d8d..0e6b80b1e3b 100644 --- a/components/script/dom/serviceworkerregistration.rs +++ b/components/script/dom/serviceworkerregistration.rs @@ -63,7 +63,7 @@ impl ServiceWorkerRegistration { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, scope: ServoUrl, diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index 8c80068ef83..98ca1fbb3b0 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![allow(crown::unrooted_must_root)] +#![cfg_attr(crown, allow(crown::unrooted_must_root))] use std::borrow::Cow; use std::cell::{Cell, Ref, RefCell, RefMut}; @@ -205,7 +205,7 @@ fn create_buffer_queue(mut buffers: VecDeque<SendTendril<UTF8>>) -> BufferQueue // |_____________| |_______________| // #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Tokenizer { document: Dom<Document>, #[ignore_malloc_size_of = "Defined in std"] @@ -693,7 +693,7 @@ impl Sink { } } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl TreeSink for Sink { type Output = Self; fn finish(self) -> Self { diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index a7fad312af5..624063d20dc 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![allow(crown::unrooted_must_root)] +#![cfg_attr(crown, allow(crown::unrooted_must_root))] use std::cell::Cell; use std::io; @@ -33,7 +33,7 @@ use crate::dom::servoparser::{ParsingAlgorithm, Sink}; use crate::script_runtime::CanGc; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>>, @@ -110,7 +110,7 @@ unsafe impl CustomTraceable for HtmlTokenizer<TreeBuilder<Dom<Node>, Sink>> { impl HtmlTracer for Tracer { type Handle = Dom<Node>; - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn trace_handle(&self, node: &Dom<Node>) { unsafe { node.trace(self.0); diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index fe9719f5569..99e862b71c1 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -441,7 +441,7 @@ impl ServoParser { self.script_nesting_level() > 0 && !self.aborted.get() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(document: &Document, tokenizer: Tokenizer, kind: ParserKind) -> Self { ServoParser { reflector: Reflector::new(), @@ -461,7 +461,7 @@ impl ServoParser { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new(document: &Document, tokenizer: Tokenizer, kind: ParserKind) -> DomRoot<Self> { reflect_dom_object( Box::new(ServoParser::new_inherited(document, tokenizer, kind)), @@ -709,7 +709,7 @@ enum ParserKind { } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] enum Tokenizer { Html(self::html::Tokenizer), AsyncHtml(self::async_html::Tokenizer), @@ -1062,7 +1062,7 @@ pub(crate) struct FragmentContext<'a> { pub(crate) form_elem: Option<&'a Node>, } -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] fn insert( parent: &Node, reference_child: Option<&Node>, @@ -1103,7 +1103,7 @@ fn insert( } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Sink { #[no_trace] base_url: ServoUrl, @@ -1128,7 +1128,7 @@ impl Sink { impl TreeSink for Sink { type Output = Self; - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn finish(self) -> Self { self } @@ -1139,12 +1139,12 @@ impl TreeSink for Sink { where Self: 'a; - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn get_document(&self) -> Dom<Node> { Dom::from_ref(self.document.upcast()) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn get_template_contents(&self, target: &Dom<Node>) -> Dom<Node> { let template = target .downcast::<HTMLTemplateElement>() @@ -1166,7 +1166,7 @@ impl TreeSink for Sink { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn create_element( &self, name: QualName, @@ -1188,7 +1188,7 @@ impl TreeSink for Sink { Dom::from_ref(element.upcast()) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn create_comment(&self, text: StrTendril) -> Dom<Node> { let comment = Comment::new( DOMString::from(String::from(text)), @@ -1199,7 +1199,7 @@ impl TreeSink for Sink { Dom::from_ref(comment.upcast()) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn create_pi(&self, target: StrTendril, data: StrTendril) -> Dom<Node> { let doc = &*self.document; let pi = ProcessingInstruction::new( @@ -1241,7 +1241,7 @@ impl TreeSink for Sink { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn append_before_sibling(&self, sibling: &Dom<Node>, new_node: NodeOrText<Dom<Node>>) { let parent = sibling .GetParentNode() @@ -1269,12 +1269,12 @@ impl TreeSink for Sink { self.document.set_quirks_mode(mode); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn append(&self, parent: &Dom<Node>, child: NodeOrText<Dom<Node>>) { insert(parent, None, child, self.parsing_algorithm, CanGc::note()); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn append_based_on_parent_node( &self, elem: &Dom<Node>, diff --git a/components/script/dom/servoparser/prefetch.rs b/components/script/dom/servoparser/prefetch.rs index 835cdc1d1f3..5e394816f44 100644 --- a/components/script/dom/servoparser/prefetch.rs +++ b/components/script/dom/servoparser/prefetch.rs @@ -25,7 +25,7 @@ use crate::script_module::ScriptFetchOptions; use crate::stylesheet_loader::stylesheet_fetch_request; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in html5ever"] inner: HtmlTokenizer<PrefetchSink>, diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index 43248988094..35c86d2ba4b 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![allow(crown::unrooted_must_root)] +#![cfg_attr(crown, allow(crown::unrooted_must_root))] use std::cell::Cell; @@ -21,7 +21,7 @@ use crate::dom::node::Node; use crate::dom::servoparser::{ParsingAlgorithm, Sink}; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct Tokenizer { #[ignore_malloc_size_of = "Defined in xml5ever"] inner: XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>>, @@ -68,7 +68,7 @@ unsafe impl CustomTraceable for XmlTokenizer<XmlTreeBuilder<Dom<Node>, Sink>> { impl XmlTracer for Tracer { type Handle = Dom<Node>; - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn trace_handle(&self, node: &Dom<Node>) { unsafe { node.trace(self.0); diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index da0d010c7f8..c3911b35642 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -62,7 +62,7 @@ pub(crate) struct ShadowRoot { } impl ShadowRoot { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( host: &Element, document: &Document, @@ -130,7 +130,7 @@ impl ShadowRoot { /// Add a stylesheet owned by `owner` to the list of shadow root sheets, in the /// correct tree position. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn add_stylesheet(&self, owner: &Element, sheet: Arc<Stylesheet>) { let stylesheets = &mut self.author_styles.borrow_mut().stylesheets; let insertion_point = stylesheets @@ -151,7 +151,7 @@ impl ShadowRoot { } /// Remove a stylesheet owned by `owner` from the list of shadow root sheets. - #[allow(crown::unrooted_must_root)] // Owner needs to be rooted already necessarily. + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // Owner needs to be rooted already necessarily. pub(crate) fn remove_stylesheet(&self, owner: &Element, s: &Arc<Stylesheet>) { DocumentOrShadowRoot::remove_stylesheet( owner, diff --git a/components/script/dom/stereopannernode.rs b/components/script/dom/stereopannernode.rs index 12a578a8fce..e9f31a5ae42 100644 --- a/components/script/dom/stereopannernode.rs +++ b/components/script/dom/stereopannernode.rs @@ -31,7 +31,7 @@ pub(crate) struct StereoPannerNode { } impl StereoPannerNode { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( window: &Window, context: &BaseAudioContext, @@ -83,7 +83,7 @@ impl StereoPannerNode { Self::new_with_proto(window, None, context, options, can_gc) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_with_proto( window: &Window, proto: Option<HandleObject>, diff --git a/components/script/dom/stylesheet.rs b/components/script/dom/stylesheet.rs index be5de8ae4c2..747395ff27f 100644 --- a/components/script/dom/stylesheet.rs +++ b/components/script/dom/stylesheet.rs @@ -22,7 +22,7 @@ pub(crate) struct StyleSheet { } impl StyleSheet { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new_inherited( type_: DOMString, href: Option<DOMString>, diff --git a/components/script/dom/stylesheetlist.rs b/components/script/dom/stylesheetlist.rs index 5315cb06360..f7e05de38d6 100644 --- a/components/script/dom/stylesheetlist.rs +++ b/components/script/dom/stylesheetlist.rs @@ -17,7 +17,7 @@ use crate::dom::stylesheet::StyleSheet; use crate::dom::window::Window; use crate::script_runtime::CanGc; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) enum StyleSheetListOwner { Document(Dom<Document>), @@ -74,7 +74,7 @@ pub(crate) struct StyleSheetList { } impl StyleSheetList { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(doc_or_sr: StyleSheetListOwner) -> StyleSheetList { StyleSheetList { reflector_: Reflector::new(), @@ -82,7 +82,7 @@ impl StyleSheetList { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new(window: &Window, doc_or_sr: StyleSheetListOwner) -> DomRoot<StyleSheetList> { reflect_dom_object( Box::new(StyleSheetList::new_inherited(doc_or_sr)), diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index 50f4eb0e957..2438854b3b0 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -38,7 +38,7 @@ impl SVGSVGElement { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( local_name: LocalName, prefix: Option<Prefix>, diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 0677623ea36..91fb0b8ba67 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -970,12 +970,12 @@ impl TestBindingMethods<crate::DomTypeHolder> for TestBinding { Record::new() } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn ReturnResolvedPromise(&self, cx: SafeJSContext, v: HandleValue) -> Fallible<Rc<Promise>> { Promise::new_resolved(&self.global(), cx, v) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn ReturnRejectedPromise(&self, cx: SafeJSContext, v: HandleValue) -> Fallible<Rc<Promise>> { Promise::new_rejected(&self.global(), cx, v) } @@ -992,7 +992,7 @@ impl TestBindingMethods<crate::DomTypeHolder> for TestBinding { p.reject_error(Error::Type(s.0)); } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn ResolvePromiseDelayed(&self, p: &Promise, value: DOMString, delay: u64) { let promise = p.duplicate(); let cb = TestBindingCallback { @@ -1160,7 +1160,7 @@ pub(crate) struct TestBindingCallback { } impl TestBindingCallback { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn invoke(self) { self.promise.root().resolve_native(&self.value); } diff --git a/components/script/dom/testbindingmaplike.rs b/components/script/dom/testbindingmaplike.rs index 81da08748c7..d055c68e12e 100644 --- a/components/script/dom/testbindingmaplike.rs +++ b/components/script/dom/testbindingmaplike.rs @@ -87,7 +87,7 @@ impl TestBindingMaplikeMethods<crate::DomTypeHolder> for TestBindingMaplike { // this error is wrong because if we inline Self::Key and Self::Value all errors are gone // TODO: FIX THIS -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl Maplike for TestBindingMaplike { type Key = DOMString; type Value = i32; diff --git a/components/script/dom/testbindingsetlike.rs b/components/script/dom/testbindingsetlike.rs index b3a8c4b450a..d6fb9e05fd7 100644 --- a/components/script/dom/testbindingsetlike.rs +++ b/components/script/dom/testbindingsetlike.rs @@ -61,7 +61,7 @@ impl TestBindingSetlikeMethods<crate::DomTypeHolder> for TestBindingSetlike { // this error is wrong because if we inline Self::Key and Self::Value all errors are gone // TODO: FIX THIS -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl Setlike for TestBindingSetlike { type Key = DOMString; diff --git a/components/script/dom/testns.rs b/components/script/dom/testns.rs index 96dcf37aad0..04a758bd121 100644 --- a/components/script/dom/testns.rs +++ b/components/script/dom/testns.rs @@ -4,5 +4,5 @@ // check-tidy: no specs after this line -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct TestNS(()); diff --git a/components/script/dom/trackevent.rs b/components/script/dom/trackevent.rs index a93bd5da619..b36adc83f80 100644 --- a/components/script/dom/trackevent.rs +++ b/components/script/dom/trackevent.rs @@ -23,7 +23,7 @@ use crate::dom::videotrack::VideoTrack; use crate::dom::window::Window; use crate::script_runtime::CanGc; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] enum MediaTrack { Video(Dom<VideoTrack>), @@ -38,7 +38,8 @@ pub(crate) struct TrackEvent { } impl TrackEvent { - #[allow(crown::unrooted_must_root, non_snake_case)] + #[allow(non_snake_case)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(track: &Option<VideoTrackOrAudioTrackOrTextTrack>) -> TrackEvent { let media_track = match track { Some(VideoTrackOrAudioTrackOrTextTrack::VideoTrack(VideoTrack)) => { diff --git a/components/script/dom/underlyingsourcecontainer.rs b/components/script/dom/underlyingsourcecontainer.rs index 603c6a1a88a..9486a9e9edc 100644 --- a/components/script/dom/underlyingsourcecontainer.rs +++ b/components/script/dom/underlyingsourcecontainer.rs @@ -26,7 +26,7 @@ use crate::script_runtime::CanGc; /// the JavaScript object representing the underlying source. /// The other variants are native sources in Rust. #[derive(JSTraceable)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) enum UnderlyingSourceType { /// Facilitate partial integration with sources /// that are currently read into memory. @@ -68,7 +68,7 @@ pub(crate) struct UnderlyingSourceContainer { } impl UnderlyingSourceContainer { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(underlying_source_type: UnderlyingSourceType) -> UnderlyingSourceContainer { UnderlyingSourceContainer { reflector_: Reflector::new(), @@ -76,7 +76,7 @@ impl UnderlyingSourceContainer { } } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( global: &GlobalScope, underlying_source_type: UnderlyingSourceType, diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs index 4100e230493..31db2848fc6 100644 --- a/components/script/dom/vertexarrayobject.rs +++ b/components/script/dom/vertexarrayobject.rs @@ -16,7 +16,7 @@ use crate::dom::webglbuffer::WebGLBuffer; use crate::dom::webglrenderingcontext::{Operation, WebGLRenderingContext}; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct VertexArrayObject { context: Dom<WebGLRenderingContext>, #[no_trace] @@ -261,7 +261,7 @@ impl Drop for VertexArrayObject { } #[derive(Clone, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct VertexAttribData { pub(crate) enabled_as_array: bool, pub(crate) size: u8, @@ -275,7 +275,7 @@ pub(crate) struct VertexAttribData { } impl Default for VertexAttribData { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn default() -> Self { Self { enabled_as_array: false, diff --git a/components/script/dom/visibilitystateentry.rs b/components/script/dom/visibilitystateentry.rs index c39fd23b2d9..9667f65cd0e 100644 --- a/components/script/dom/visibilitystateentry.rs +++ b/components/script/dom/visibilitystateentry.rs @@ -25,7 +25,7 @@ pub(crate) struct VisibilityStateEntry { } impl VisibilityStateEntry { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( state: DocumentVisibilityState, timestamp: CrossProcessInstant, diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs index ba4c8e09f38..d57c579f2aa 100644 --- a/components/script/dom/webgl2renderingcontext.rs +++ b/components/script/dom/webgl2renderingcontext.rs @@ -69,7 +69,7 @@ use crate::dom::window::Window; use crate::js::conversions::ToJSValConvertible; use crate::script_runtime::{CanGc, JSContext}; -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] struct IndexedBinding { buffer: MutNullableDom<WebGLBuffer>, @@ -171,7 +171,7 @@ impl WebGL2RenderingContext { }) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, canvas: &HTMLCanvasElementOrOffscreenCanvas, diff --git a/components/script/dom/webgl_extensions/extension.rs b/components/script/dom/webgl_extensions/extension.rs index 0c59a7dbf82..cb71336ec96 100644 --- a/components/script/dom/webgl_extensions/extension.rs +++ b/components/script/dom/webgl_extensions/extension.rs @@ -15,7 +15,7 @@ pub(crate) trait WebGLExtension: Sized where Self::Extension: DomObject + JSTraceable, { - #[crown::unrooted_must_root_lint::must_root] + #[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] type Extension; /// Creates the DOM object of the WebGL extension. diff --git a/components/script/dom/webgl_extensions/extensions.rs b/components/script/dom/webgl_extensions/extensions.rs index fa0b4c17bc7..ea62973d55d 100644 --- a/components/script/dom/webgl_extensions/extensions.rs +++ b/components/script/dom/webgl_extensions/extensions.rs @@ -164,7 +164,7 @@ impl WebGLExtensionFeatures { } /// Handles the list of implemented, supported and enabled WebGL extensions. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct WebGLExtensions { extensions: DomRefCell<HashMap<String, Box<dyn WebGLExtensionWrapper>>>, diff --git a/components/script/dom/webgl_extensions/wrapper.rs b/components/script/dom/webgl_extensions/wrapper.rs index 1d1957f10ec..1b7a71e3e21 100644 --- a/components/script/dom/webgl_extensions/wrapper.rs +++ b/components/script/dom/webgl_extensions/wrapper.rs @@ -28,7 +28,7 @@ pub(crate) trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf { fn name(&self) -> &'static str; } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct TypedWebGLExtensionWrapper<T: WebGLExtension> { extension: MutNullableDom<T::Extension>, diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs index b3faf613a1c..48d8842fd12 100644 --- a/components/script/dom/webglframebuffer.rs +++ b/components/script/dom/webglframebuffer.rs @@ -39,7 +39,7 @@ fn log2(n: u32) -> u32 { 31 - n.leading_zeros() } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Clone, JSTraceable, MallocSizeOf)] enum WebGLFramebufferAttachment { Renderbuffer(Dom<WebGLRenderbuffer>), diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 1ca324baaab..ffceccce4f1 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -281,7 +281,7 @@ impl WebGLRenderingContext { }) } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn new( window: &Window, canvas: &HTMLCanvasElementOrOffscreenCanvas, @@ -4878,7 +4878,7 @@ capabilities! { STENCIL_TEST, } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] pub(crate) struct Textures { active_unit: Cell<u32>, @@ -4958,7 +4958,7 @@ impl Textures { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(Default, JSTraceable, MallocSizeOf)] struct TextureUnit { tex_2d: MutNullableDom<WebGLTexture>, diff --git a/components/script/dom/webgltexture.rs b/components/script/dom/webgltexture.rs index cd1d20a67fc..450e6461aee 100644 --- a/components/script/dom/webgltexture.rs +++ b/components/script/dom/webgltexture.rs @@ -37,7 +37,7 @@ pub(crate) enum TexParameterValue { // Textures generated for WebXR are owned by the WebXR device, not by the WebGL thread // so the GL texture should not be deleted when the texture is garbage collected. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] enum WebGLTextureOwner { WebGL, diff --git a/components/script/dom/webgpu/gpu.rs b/components/script/dom/webgpu/gpu.rs index ebc183380be..473005d6b1b 100644 --- a/components/script/dom/webgpu/gpu.rs +++ b/components/script/dom/webgpu/gpu.rs @@ -58,7 +58,7 @@ struct WGPUResponse<T: AsyncWGPUListener + DomObject> { } impl<T: AsyncWGPUListener + DomObject> WGPUResponse<T> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn response(self, response: WebGPUResponse, can_gc: CanGc) { let promise = self.trusted.root(); self.receiver diff --git a/components/script/dom/webgpu/gpusupportedfeatures.rs b/components/script/dom/webgpu/gpusupportedfeatures.rs index a32ed75490d..f07b173f5ca 100644 --- a/components/script/dom/webgpu/gpusupportedfeatures.rs +++ b/components/script/dom/webgpu/gpusupportedfeatures.rs @@ -140,7 +140,7 @@ pub(crate) fn gpu_to_wgt_feature(feature: GPUFeatureName) -> Option<Features> { } // this error is wrong because if we inline Self::Key and Self::Value all errors are gone -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl Setlike for GPUSupportedFeatures { type Key = DOMString; diff --git a/components/script/dom/webgpu/wgsllanguagefeatures.rs b/components/script/dom/webgpu/wgsllanguagefeatures.rs index 9519e2b6c84..9b370e0b710 100644 --- a/components/script/dom/webgpu/wgsllanguagefeatures.rs +++ b/components/script/dom/webgpu/wgsllanguagefeatures.rs @@ -55,7 +55,7 @@ impl WGSLLanguageFeaturesMethods<crate::DomTypeHolder> for WGSLLanguageFeatures } // this error is wrong because if we inline Self::Key and Self::Value all errors are gone -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] impl Setlike for WGSLLanguageFeatures { type Key = DOMString; diff --git a/components/script/dom/webxr/xrinputsourceevent.rs b/components/script/dom/webxr/xrinputsourceevent.rs index 1e381b13a54..47bb32263a2 100644 --- a/components/script/dom/webxr/xrinputsourceevent.rs +++ b/components/script/dom/webxr/xrinputsourceevent.rs @@ -30,7 +30,7 @@ pub(crate) struct XRInputSourceEvent { } impl XRInputSourceEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(frame: &XRFrame, source: &XRInputSource) -> XRInputSourceEvent { XRInputSourceEvent { event: Event::new_inherited(), diff --git a/components/script/dom/webxr/xrinputsourceschangeevent.rs b/components/script/dom/webxr/xrinputsourceschangeevent.rs index 1e2057b0c72..3d00e2984a6 100644 --- a/components/script/dom/webxr/xrinputsourceschangeevent.rs +++ b/components/script/dom/webxr/xrinputsourceschangeevent.rs @@ -36,7 +36,7 @@ pub(crate) struct XRInputSourcesChangeEvent { } impl XRInputSourcesChangeEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(session: &XRSession) -> XRInputSourcesChangeEvent { XRInputSourcesChangeEvent { event: Event::new_inherited(), diff --git a/components/script/dom/webxr/xrreferencespaceevent.rs b/components/script/dom/webxr/xrreferencespaceevent.rs index cce439c3757..1269f953172 100644 --- a/components/script/dom/webxr/xrreferencespaceevent.rs +++ b/components/script/dom/webxr/xrreferencespaceevent.rs @@ -30,7 +30,7 @@ pub(crate) struct XRReferenceSpaceEvent { } impl XRReferenceSpaceEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited( space: &XRReferenceSpace, transform: Option<&XRRigidTransform>, diff --git a/components/script/dom/webxr/xrsessionevent.rs b/components/script/dom/webxr/xrsessionevent.rs index 98f5ce710b8..0485559bcf9 100644 --- a/components/script/dom/webxr/xrsessionevent.rs +++ b/components/script/dom/webxr/xrsessionevent.rs @@ -26,7 +26,7 @@ pub(crate) struct XRSessionEvent { } impl XRSessionEvent { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn new_inherited(session: &XRSession) -> XRSessionEvent { XRSessionEvent { event: Event::new_inherited(), diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index 9c3525c9aa3..34e4cd5a900 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -306,7 +306,7 @@ impl WorkerMethods<crate::DomTypeHolder> for Worker { } impl TaskOnce for SimpleWorkerErrorHandler<Worker> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn run_once(self) { Worker::dispatch_simple_error(self.addr, CanGc::note()); } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 80654a9826a..7db2123e36e 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -414,7 +414,7 @@ impl WorkerGlobalScopeMethods<crate::DomTypeHolder> for WorkerGlobalScope { p } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] // https://fetch.spec.whatwg.org/#fetch-method fn Fetch( &self, diff --git a/components/script/dom/worklet.rs b/components/script/dom/worklet.rs index efa2f34aa62..752aa4e5e9e 100644 --- a/components/script/dom/worklet.rs +++ b/components/script/dom/worklet.rs @@ -428,7 +428,7 @@ struct WorkletThreadInit { } /// A thread for executing worklets. -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] struct WorkletThread { /// Which role the thread is currently playing role: WorkletThreadRole, @@ -467,7 +467,7 @@ unsafe impl JSTraceable for WorkletThread { impl WorkletThread { /// Spawn a new worklet thread, returning the channel to send it control messages. #[allow(unsafe_code)] - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn spawn( role: WorkletThreadRole, init: WorkletThreadInit, diff --git a/components/script/fetch.rs b/components/script/fetch.rs index de8c546971b..e7236e6319f 100644 --- a/components/script/fetch.rs +++ b/components/script/fetch.rs @@ -127,7 +127,8 @@ fn request_init_from_request(request: NetTraitsRequest) -> RequestBuilder { } /// <https://fetch.spec.whatwg.org/#fetch-method> -#[allow(crown::unrooted_must_root, non_snake_case)] +#[allow(non_snake_case)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub(crate) fn Fetch( global: &GlobalScope, input: RequestInfo, @@ -204,7 +205,7 @@ impl FetchResponseListener for FetchContext { // TODO } - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn process_response( &mut self, _: RequestId, diff --git a/components/script/iframe_collection.rs b/components/script/iframe_collection.rs index ada71128e87..a573f438fd8 100644 --- a/components/script/iframe_collection.rs +++ b/components/script/iframe_collection.rs @@ -21,7 +21,7 @@ use crate::dom::types::Document; use crate::script_thread::with_script_thread; #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct IFrame { pub(crate) element: Dom<HTMLIFrameElement>, #[no_trace] @@ -29,7 +29,7 @@ pub(crate) struct IFrame { } #[derive(Default, JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct IFrameCollection { /// The version of the [`Document`] that this collection refers to. When the versions /// do not match, the collection will need to be rebuilt. diff --git a/components/script/lib.rs b/components/script/lib.rs index 7c70825cb39..c005f56c168 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -2,13 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![feature(register_tool)] +#![cfg_attr(crown, feature(register_tool))] #![deny(unsafe_code)] #![doc = "The script crate contains all matters DOM."] // Register the linter `crown`, which is the Servo-specific linter for the script // crate. Issue a warning if `crown` is not being used to compile, but not when // building rustdoc or running clippy. -#![register_tool(crown)] +#![cfg_attr(crown, register_tool(crown))] #![cfg_attr(any(doc, clippy), allow(unknown_lints))] #![deny(crown_is_not_used)] diff --git a/components/script/script_module.rs b/components/script/script_module.rs index adc805cd86f..c6f18733bc1 100644 --- a/components/script/script_module.rs +++ b/components/script/script_module.rs @@ -1593,7 +1593,7 @@ pub(crate) fn fetch_external_module_script( } #[derive(JSTraceable, MallocSizeOf)] -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] pub(crate) struct DynamicModuleList { requests: Vec<RootedTraceableBox<DynamicModule>>, @@ -1627,7 +1627,7 @@ impl DynamicModuleList { } } -#[crown::unrooted_must_root_lint::must_root] +#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)] #[derive(JSTraceable, MallocSizeOf)] struct DynamicModule { #[ignore_malloc_size_of = "Rc is hard"] diff --git a/components/script/script_runtime.rs b/components/script/script_runtime.rs index 910e1ba0ef7..fd3074d0b0c 100644 --- a/components/script/script_runtime.rs +++ b/components/script/script_runtime.rs @@ -283,7 +283,8 @@ unsafe extern "C" fn enqueue_promise_job( result } -#[allow(unsafe_code, crown::unrooted_must_root)] +#[allow(unsafe_code)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] /// <https://html.spec.whatwg.org/multipage/#the-hostpromiserejectiontracker-implementation> unsafe extern "C" fn promise_rejection_tracker( cx: *mut RawJSContext, @@ -416,7 +417,8 @@ unsafe extern "C" fn content_security_policy_allows( allowed } -#[allow(unsafe_code, crown::unrooted_must_root)] +#[allow(unsafe_code)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] /// <https://html.spec.whatwg.org/multipage/#notify-about-rejected-promises> pub(crate) fn notify_about_rejected_promises(global: &GlobalScope) { let cx = GlobalScope::get_cx(); diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 08ce5fa7540..5224332f330 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -192,7 +192,7 @@ unsafe_no_jsmanaged_fields!(TaskQueue<MainThreadScriptMsg>); #[derive(JSTraceable)] // ScriptThread instances are rooted on creation, so this is okay -#[allow(crown::unrooted_must_root)] +#[cfg_attr(crown, allow(crown::unrooted_must_root))] pub struct ScriptThread { /// <https://html.spec.whatwg.org/multipage/#last-render-opportunity-time> last_render_opportunity_time: DomRefCell<Option<Instant>>, @@ -385,7 +385,7 @@ impl<'a> ScriptMemoryFailsafe<'a> { } impl Drop for ScriptMemoryFailsafe<'_> { - #[allow(crown::unrooted_must_root)] + #[cfg_attr(crown, allow(crown::unrooted_must_root))] fn drop(&mut self) { if let Some(owner) = self.owner { for (_, document) in owner.documents.borrow().iter() { diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 98376e1ae8a..0b0706b22fa 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -13,6 +13,7 @@ path = "lib.rs" crate-type = ["rlib"] [features] +crown = ["script/crown"] debugmozjs = ["script/debugmozjs"] jitspew = ["script/jitspew"] js_backtrace = ["script/js_backtrace"] diff --git a/ports/servoshell/Cargo.toml b/ports/servoshell/Cargo.toml index 835c854ecfd..1de0d8cdc4a 100644 --- a/ports/servoshell/Cargo.toml +++ b/ports/servoshell/Cargo.toml @@ -36,6 +36,7 @@ OriginalFilename = "servo.exe" ProductName = "Servo" [features] +crown = ["libservo/crown"] debugmozjs = ["libservo/debugmozjs"] default = ["max_log_level", "webdriver", "webxr", "webgpu"] jitspew = ["libservo/jitspew"] diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 59b36e8f688..ca026f07758 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -797,6 +797,8 @@ class CommandBase(object): if command == 'rustc': args += ["--lib", "--crate-type=cdylib"] + features = [] + if use_crown: if 'CARGO_BUILD_RUSTC' in env: current_rustc = env['CARGO_BUILD_RUSTC'] @@ -805,6 +807,7 @@ class CommandBase(object): f'already set to `{current_rustc}` in the parent environment.\n' 'These options conflict, please specify only one of them.') sys.exit(1) + features += ["crown"] env['CARGO_BUILD_RUSTC'] = 'crown' # Changing `RUSTC` or `CARGO_BUILD_RUSTC` does not cause `cargo check` to # recheck files with the new compiler. `cargo build` is not affected and @@ -814,7 +817,7 @@ class CommandBase(object): env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " --cfg=crown" if "-p" not in cargo_args: # We're building specific package, that may not have features - features = list(self.features) + features += list(self.features) if self.enable_media: features.append("media-gstreamer") if self.config["build"]["debug-mozjs"] or debug_mozjs: |