Consistently use Dom in native promise handlers (#37226)

Use `Dom` instead of `DomRoot` for fields of
`TransmitBodyPromiseRejectionHandler` to reduce redundant work by GC,
according to discussion in
https://github.com/servo/servo/issues/33604#issuecomment-2931524400

Fixes: #33604

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This commit is contained in:
Euclid Ye 2025-06-03 15:41:34 +08:00 committed by GitHub
parent 8d086b9fe5
commit 56c0ad8420
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -249,7 +249,7 @@ impl TransmitBodyConnectHandler {
let rejection_handler = Box::new(TransmitBodyPromiseRejectionHandler { let rejection_handler = Box::new(TransmitBodyPromiseRejectionHandler {
bytes_sender, bytes_sender,
stream: rooted_stream, stream: Dom::from_ref(&rooted_stream.clone()),
control_sender, control_sender,
}); });
@ -321,11 +321,12 @@ impl Callback for TransmitBodyPromiseHandler {
/// The handler of read promises rejection of body streams used in /// The handler of read promises rejection of body streams used in
/// <https://fetch.spec.whatwg.org/#concept-request-transmit-body>. /// <https://fetch.spec.whatwg.org/#concept-request-transmit-body>.
#[derive(Clone, JSTraceable, MallocSizeOf)] #[derive(Clone, JSTraceable, MallocSizeOf)]
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
struct TransmitBodyPromiseRejectionHandler { struct TransmitBodyPromiseRejectionHandler {
#[ignore_malloc_size_of = "Channels are hard"] #[ignore_malloc_size_of = "Channels are hard"]
#[no_trace] #[no_trace]
bytes_sender: IpcSender<BodyChunkResponse>, bytes_sender: IpcSender<BodyChunkResponse>,
stream: DomRoot<ReadableStream>, stream: Dom<ReadableStream>,
#[ignore_malloc_size_of = "Channels are hard"] #[ignore_malloc_size_of = "Channels are hard"]
#[no_trace] #[no_trace]
control_sender: IpcSender<BodyChunkRequest>, control_sender: IpcSender<BodyChunkRequest>,