mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
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>
This commit is contained in:
parent
9eeb602f7a
commit
5e9de2cb61
70 changed files with 809 additions and 753 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue