Script: Change script/dom/{bluetooth,canvas,html} to not rely on Deref<str> for DOMString (#39480)

This is part of the future work of implementing LazyDOMString as
outlined in https://github.com/servo/servo/issues/39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>


Testing: This is essentially just renaming a method and a type and
should not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
This commit is contained in:
Narfinger 2025-09-25 17:53:21 +02:00 committed by GitHub
parent 1e471b9b41
commit a4c8ffe753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 97 additions and 95 deletions

View file

@ -707,7 +707,7 @@ impl HTMLScriptElement {
global,
element,
InlineCheckType::Script,
&text,
text.str(),
)
{
warn!("Blocking inline script due to CSP");
@ -751,14 +751,13 @@ impl HTMLScriptElement {
let module_credentials_mode = match script_type {
ScriptType::Classic => CredentialsMode::CredentialsSameOrigin,
ScriptType::Module | ScriptType::ImportMap => reflect_cross_origin_attribute(element)
.map_or(
CredentialsMode::CredentialsSameOrigin,
|attr| match &*attr {
.map_or(CredentialsMode::CredentialsSameOrigin, |attr| {
match attr.str() {
"use-credentials" => CredentialsMode::Include,
"anonymous" => CredentialsMode::CredentialsSameOrigin,
_ => CredentialsMode::CredentialsSameOrigin,
},
),
}
}),
};
// Step 24. Let cryptographic nonce be el's [[CryptographicNonce]] internal slot's value.
@ -1385,7 +1384,7 @@ impl HTMLScriptElementMethods<crate::DomTypeHolder> for HTMLScriptElement {
)?;
element.set_attribute(
local_name,
AttrValue::String(value.as_ref().to_owned()),
AttrValue::String(value.str().to_owned()),
can_gc,
);
Ok(())