Script: Change the rest of script to not rely on Deref<str> for DOMString (#39481)

This is part of the future work of implementing LazyDOMString as
outlined in issue #39479.

We use str() method or direct implementations on DOMString for these
methods. We also change some types.
This is independent of https://github.com/servo/servo/pull/39480

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 14:27:42 +02:00 committed by GitHub
parent 9713bb9e1b
commit 1e471b9b41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 219 additions and 132 deletions

View file

@ -489,7 +489,7 @@ impl ModuleTree {
module_script.set(CompileModule1(
*cx,
compile_options.ptr,
&mut transform_str_to_source_text(&module_source.source),
&mut transform_str_to_source_text(module_source.source.str()),
));
if module_script.is_null() {
@ -695,7 +695,7 @@ impl ModuleTree {
// otherwise, specifier.
let normalized_specifier = match &as_url {
Some(url) => url.as_str(),
None => &specifier,
None => specifier.str(),
};
// Step 9. Let result be a URL-or-null, initially null.
@ -768,13 +768,15 @@ impl ModuleTree {
base_url: &ServoUrl,
) -> Option<ServoUrl> {
// Step 1. If specifier starts with "/", "./", or "../", then:
if specifier.starts_with('/') || specifier.starts_with("./") || specifier.starts_with("../")
if specifier.starts_with('/') ||
specifier.starts_with_str("./") ||
specifier.starts_with_str("../")
{
// Step 1.1. Let url be the result of URL parsing specifier with baseURL.
return ServoUrl::parse_with_base(Some(base_url), specifier).ok();
return ServoUrl::parse_with_base(Some(base_url), specifier.str()).ok();
}
// Step 2. Let url be the result of URL parsing specifier (with no base URL).
ServoUrl::parse(specifier).ok()
ServoUrl::parse(specifier.str()).ok()
}
/// <https://html.spec.whatwg.org/multipage/#finding-the-first-parse-error>