net: Simplify FetchResponseListener and move it to script (#40461)

`FetchReponseListener` has traditionally lived in `net` even though it
is only used in `script` currently. Because of the two way dependency,
it has also use a lot of templating to implement something pretty basic
(call methods on a trait object).

This change moves the trait to `script` and removes several levels of
templating, making the code quite a bit shorter and easier to
understand.

This change is preparation for fixing #22550 and implementing
off-the-main-thread CSS parsing.

Testing: This should not change any behavior so is covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson
2025-11-06 15:44:01 +01:00
committed by GitHub
parent bdcae320fd
commit 8f6edca4dd
23 changed files with 174 additions and 286 deletions

View File

@@ -19,10 +19,7 @@ use net_traits::request::{
CorsSettings, CredentialsMode, Destination, InsecureRequestsPolicy, ParserMetadata,
RequestBuilder, RequestId,
};
use net_traits::{
FetchMetadata, FetchResponseListener, Metadata, NetworkError, ResourceFetchTiming,
ResourceTimingType,
};
use net_traits::{FetchMetadata, Metadata, NetworkError, ResourceFetchTiming, ResourceTimingType};
use script_bindings::domstring::BytesView;
use servo_url::{ImmutableOrigin, ServoUrl};
use style::attr::AttrValue;
@@ -64,7 +61,7 @@ use crate::dom::trustedscripturl::TrustedScriptURL;
use crate::dom::virtualmethods::VirtualMethods;
use crate::dom::window::Window;
use crate::fetch::create_a_potential_cors_request;
use crate::network_listener::{self, PreInvoke, ResourceTimingListener};
use crate::network_listener::{self, FetchResponseListener, ResourceTimingListener};
use crate::realms::enter_realm;
use crate::script_module::{
ImportMap, ModuleOwner, ScriptFetchOptions, fetch_external_module_script,
@@ -513,8 +510,6 @@ impl ResourceTimingListener for ClassicContext {
}
}
impl PreInvoke for ClassicContext {}
/// Steps 1-2 of <https://html.spec.whatwg.org/multipage/#fetch-a-classic-script>
// This function is also used to prefetch a script in `script::dom::servoparser::prefetch`.
#[allow(clippy::too_many_arguments)]