diff options
author | Delan Azabani <dazabani@igalia.com> | 2025-01-30 19:15:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-30 11:15:35 +0000 |
commit | 5e9de2cb61fbfd82b27343bf03439838458b9848 (patch) | |
tree | 64574624cda94237bbfc443a29b792229fde0ee2 /components/script/stylesheet_loader.rs | |
parent | 9eeb602f7afca502753bb8211ab646c952951761 (diff) | |
download | servo-5e9de2cb61fbfd82b27343bf03439838458b9848.tar.gz servo-5e9de2cb61fbfd82b27343bf03439838458b9848.zip |
Include `WebViewId` into EmbedderMsg variants where possible (#35211)
`EmbedderMsg` was previously paired with an implicit
`Option<WebViewId>`, even though almost all variants were either always
`Some` or always `None`, depending on whether there was a `WebView
involved.
This patch adds the `WebViewId` to as many `EmbedderMsg` variants as
possible, so we can call their associated `WebView` delegate methods
without needing to check and unwrap the `Option`. In many cases, this
required more changes to plumb through the `WebViewId`.
Notably, all `Request`s now explicitly need a `WebView` or not, in order
to ensure that it is passed when appropriate.
Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/script/stylesheet_loader.rs')
-rw-r--r-- | components/script/stylesheet_loader.rs | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 8f6f83390e3..2a61bb0d993 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -5,17 +5,16 @@ use std::io::{Read, Seek, Write}; use std::sync::atomic::AtomicBool; -use base::id::PipelineId; use cssparser::SourceLocation; use encoding_rs::UTF_8; use mime::{self, Mime}; -use net_traits::request::{CorsSettings, Destination, Referrer, RequestBuilder, RequestId}; +use net_traits::request::{CorsSettings, Destination, RequestId}; use net_traits::{ FetchMetadata, FetchResponseListener, FilteredMetadata, Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, ResourceTimingType, }; use servo_arc::Arc; -use servo_url::{ImmutableOrigin, ServoUrl}; +use servo_url::ServoUrl; use style::media_queries::MediaList; use style::parser::ParserContext; use style::shared_lock::{Locked, SharedRwLock}; @@ -343,39 +342,24 @@ impl StylesheetLoader<'_> { document.increment_script_blocking_stylesheet_count(); } - let request = stylesheet_fetch_request( + // https://html.spec.whatwg.org/multipage/#default-fetch-and-process-the-linked-resource + let request = create_a_potential_cors_request( + Some(document.webview_id()), url.clone(), + Destination::Style, cors_setting, - document.origin().immutable().clone(), - self.elem.global().pipeline_id(), + None, self.elem.global().get_referrer(), - referrer_policy, - integrity_metadata, - ); - let request = document.prepare_request(request); + ) + .origin(document.origin().immutable().clone()) + .pipeline_id(Some(self.elem.global().pipeline_id())) + .referrer_policy(referrer_policy) + .integrity_metadata(integrity_metadata); document.fetch(LoadType::Stylesheet(url), request, context); } } -// This function is also used to prefetch a stylesheet in `script::dom::servoparser::prefetch`. -// https://html.spec.whatwg.org/multipage/#default-fetch-and-process-the-linked-resource -pub(crate) fn stylesheet_fetch_request( - url: ServoUrl, - cors_setting: Option<CorsSettings>, - origin: ImmutableOrigin, - pipeline_id: PipelineId, - referrer: Referrer, - referrer_policy: ReferrerPolicy, - integrity_metadata: String, -) -> RequestBuilder { - create_a_potential_cors_request(url, Destination::Style, cors_setting, None, referrer) - .origin(origin) - .pipeline_id(Some(pipeline_id)) - .referrer_policy(referrer_policy) - .integrity_metadata(integrity_metadata) -} - impl StyleStylesheetLoader for StylesheetLoader<'_> { /// Request a stylesheet after parsing a given `@import` rule, and return /// the constructed `@import` rule. |