script: further use of safe to jsval (#38099)

Remove size bound from safe to jsval trait, apply to script/dom, with
the exception of windowproxy.

Second part of https://github.com/servo/servo/issues/37951

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>

*Describe the changes that this pull request makes here. This will be
the commit message.*

Testing: *Describe how this pull request is tested or why it doesn't
require tests*
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*
This commit is contained in:
Gregory Terzian 2025-07-16 21:46:10 +07:00 committed by GitHub
parent 72a9f36c43
commit b821377771
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 114 additions and 128 deletions

View file

@ -13,6 +13,7 @@ use dom_struct::dom_struct;
use js::jsapi::{Heap, JS_NewObject, JSObject};
use js::jsval::UndefinedValue;
use js::rust::{CustomAutoRooter, CustomAutoRooterGuard, HandleValue};
use script_bindings::conversions::SafeToJSValConvertible;
use crate::dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use crate::dom::bindings::codegen::Bindings::MessagePortBinding::{
@ -29,7 +30,6 @@ use crate::dom::bindings::transferable::Transferable;
use crate::dom::bindings::utils::set_dictionary_property;
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::js::conversions::ToJSValConvertible;
use crate::script_runtime::{CanGc, JSContext as SafeJSContext};
#[dom_struct]
@ -219,9 +219,7 @@ impl MessagePort {
// Let message be OrdinaryObjectCreate(null).
rooted!(in(*cx) let mut message = unsafe { JS_NewObject(*cx, ptr::null()) });
rooted!(in(*cx) let mut type_string = UndefinedValue());
unsafe {
type_.to_jsval(*cx, type_string.handle_mut());
}
type_.safe_to_jsval(cx, type_string.handle_mut());
// Perform ! CreateDataProperty(message, "type", type).
unsafe {
@ -244,9 +242,7 @@ impl MessagePort {
// Run the message port post message steps providing targetPort, message, and options.
rooted!(in(*cx) let mut message_val = UndefinedValue());
unsafe {
message.to_jsval(*cx, message_val.handle_mut());
}
message.safe_to_jsval(cx, message_val.handle_mut());
self.post_message_impl(cx, message_val.handle(), transfer)
}
}