diff --git a/Cargo.lock b/Cargo.lock index 85388f972..4151b98c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5325,8 +5325,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09975d3195f34dce9c7b381cb0f00c3c13381d4d3735c0f1a9c894b283b302ab" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "bitflags 2.9.4", "cssparser", @@ -5456,9 +5455,8 @@ dependencies = [ [[package]] name = "servo_arc" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "204ea332803bd95a0b60388590d59cf6468ec9becf626e2451f1d26a1d972de4" +version = "0.4.2" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "serde", "stable_deref_trait", @@ -5742,8 +5740,7 @@ dependencies = [ [[package]] name = "stylo" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff45c788bcb0230aff156dce747d4d0d7f793f525764fd6690d51bbfe1f5bbd5" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "app_units", "arrayvec", @@ -5800,8 +5797,7 @@ dependencies = [ [[package]] name = "stylo_atoms" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d6ff15e6ed626c331663555af48b8f21bc46f729f45711597143dc1bf50fb5" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "string_cache", "string_cache_codegen", @@ -5810,14 +5806,12 @@ dependencies = [ [[package]] name = "stylo_config" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebdb6722cde5d2660928c63e07b3afbef1be8376e2b247e96e381ba5e99db33a" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" [[package]] name = "stylo_derive" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1724b911e0775fb9379dc629b1c3647fed991f90ddb865f74a2a26f7b030777" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "darling 0.20.11", "proc-macro2", @@ -5829,8 +5823,7 @@ dependencies = [ [[package]] name = "stylo_dom" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c0101ada15990fee6269257538cbcbc6f01462dc4b22d6f820edb6a4427e82" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "bitflags 2.9.4", "stylo_malloc_size_of", @@ -5839,8 +5832,7 @@ dependencies = [ [[package]] name = "stylo_malloc_size_of" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8185a7a3cf0716c475ad113b494c276acf534b518dd41ee47ad5aba4af6690e" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "app_units", "cssparser", @@ -5857,8 +5849,7 @@ dependencies = [ [[package]] name = "stylo_static_prefs" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca4c89da4ab6ac0beda8b03db38216967c99f1f7287a0f3b0f366b45d34ac7c4" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" [[package]] name = "stylo_taffy" @@ -5872,8 +5863,7 @@ dependencies = [ [[package]] name = "stylo_traits" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58034d08877fb80a5496301fde9111bc57e761f4a78045222af30ce95ec150f" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "app_units", "bitflags 2.9.4", @@ -6243,8 +6233,7 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "to_shmem" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb61262d1e7e4cc777e40cb2f101d5fa51f3eeac50c3a7355b2027b9274baa35" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "cssparser", "servo_arc", @@ -6257,8 +6246,7 @@ dependencies = [ [[package]] name = "to_shmem_derive" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba1f5563024b63bb6acb4558452d9ba737518c1d11fcc1861febe98d1e31cf4" +source = "git+https://github.com/servo/stylo?rev=e272be8#e272be8e5320da67ef514592d56908859b0fbaec" dependencies = [ "darling 0.20.11", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 87bab1cfa..31a471a92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,12 +43,12 @@ mini-dxn = { path = "./packages/mini-dxn", default-features = false } debug_timer = { version = "0.1.2", path = "./packages/debug_timer" } # Servo dependencies -style = { version = "0.8", package = "stylo" } -style_traits = { version = "0.8", package = "stylo_traits" } -style_atoms = { version = "0.8", package = "stylo_atoms" } -style_config = { version = "0.8", package = "stylo_config" } -style_dom = { version = "0.8", package = "stylo_dom" } -selectors = { version = "0.32", package = "selectors" } +style = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "stylo" } +style_traits = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "stylo_traits" } +style_atoms = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "stylo_atoms" } +style_config = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "stylo_config" } +style_dom = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "stylo_dom" } +selectors = { git = "https://github.com/servo/stylo", rev = "e272be8", package = "selectors" } cssparser = { version = "0.35" } # HTML5ever dependencies diff --git a/packages/blitz-dom/src/net.rs b/packages/blitz-dom/src/net.rs index 371b8df1d..cefb4bc0b 100644 --- a/packages/blitz-dom/src/net.rs +++ b/packages/blitz-dom/src/net.rs @@ -1,16 +1,14 @@ use selectors::context::QuirksMode; -use std::{io::Cursor, sync::Arc, sync::atomic::AtomicBool}; +use std::{io::Cursor, sync::Arc}; use style::{ font_face::{FontFaceSourceFormat, FontFaceSourceFormatKeyword, Source}, media_queries::MediaList, - parser::ParserContext, servo_arc::Arc as ServoArc, shared_lock::SharedRwLock, shared_lock::{Locked, SharedRwLockReadGuard}, stylesheets::{ - AllowImportRules, CssRule, CssRules, DocumentStyleSheet, ImportRule, Origin, Stylesheet, - StylesheetContents, StylesheetInDocument, StylesheetLoader as ServoStylesheetLoader, - UrlExtraData, + AllowImportRules, CssRule, DocumentStyleSheet, ImportRule, Origin, Stylesheet, + StylesheetInDocument, StylesheetLoader as ServoStylesheetLoader, UrlExtraData, import_rule::{ImportLayer, ImportSheet, ImportSupportsCondition}, }, values::{CssUrl, SourceLocation}, @@ -49,7 +47,6 @@ impl ServoStylesheetLoader for StylesheetLoader { &self, url: CssUrl, location: SourceLocation, - context: &ParserContext, lock: &SharedRwLock, media: ServoArc>, supports: Option, @@ -65,76 +62,74 @@ impl ServoStylesheetLoader for StylesheetLoader { })); } - let sheet = ServoArc::new(Stylesheet { - contents: StylesheetContents::from_data( - CssRules::new(Vec::new(), lock), - context.stylesheet_origin, - context.url_data.clone(), - context.quirks_mode, - ), - media, - shared_lock: lock.clone(), - disabled: AtomicBool::new(false), - }); - - let stylesheet = ImportSheet::new(sheet.clone()); let import = ImportRule { url, - stylesheet, + stylesheet: ImportSheet::new_pending(), supports, layer, source_location: location, }; - struct StylesheetLoaderInner { - loader: StylesheetLoader, - read_lock: SharedRwLock, - url: ServoArc, - sheet: ServoArc, - provider: SharedProvider, - } - impl NetHandler for StylesheetLoaderInner { - fn bytes( - self: Box, - doc_id: usize, - bytes: Bytes, - callback: SharedCallback, - ) { - let Ok(css) = std::str::from_utf8(&bytes) else { - callback.call(doc_id, Err(Some(String::from("Invalid UTF8")))); - return; - }; - - // NOTE(Nico): I don't *think* external stylesheets should have HTML entities escaped - // let escaped_css = html_escape::decode_html_entities(css); - Stylesheet::update_from_str( - &self.sheet, - css, - UrlExtraData(self.url), - Some(&self.loader), - None, - AllowImportRules::Yes, - ); - fetch_font_face(doc_id, &self.sheet, &self.provider, &self.read_lock.read()); - callback.call(doc_id, Ok(Resource::None)) - } - } - let url = import.url.url().unwrap(); + let url = import.url.url().unwrap().clone(); + let import = ServoArc::new(lock.wrap(import)); self.1.fetch( self.0, Request::get(url.as_ref().clone()), Box::new(StylesheetLoaderInner { url: url.clone(), loader: self.clone(), - read_lock: lock.clone(), - sheet: sheet.clone(), + lock: lock.clone(), + media, + import_rule: import.clone(), provider: self.1.clone(), }), ); - ServoArc::new(lock.wrap(import)) + import } } + +struct StylesheetLoaderInner { + loader: StylesheetLoader, + lock: SharedRwLock, + url: ServoArc, + media: ServoArc>, + import_rule: ServoArc>, + provider: SharedProvider, +} + +impl NetHandler for StylesheetLoaderInner { + fn bytes(self: Box, doc_id: usize, bytes: Bytes, callback: SharedCallback) { + let Ok(css) = std::str::from_utf8(&bytes) else { + callback.call(doc_id, Err(Some(String::from("Invalid UTF8")))); + return; + }; + + // NOTE(Nico): I don't *think* external stylesheets should have HTML entities escaped + // let escaped_css = html_escape::decode_html_entities(css); + + let sheet = ServoArc::new(Stylesheet::from_str( + css, + UrlExtraData(self.url), + Origin::Author, + self.media.clone(), + self.lock.clone(), + Some(&self.loader), + None, // error_reporter + QuirksMode::NoQuirks, + AllowImportRules::Yes, + )); + + // Fetch @font-face fonts + fetch_font_face(doc_id, &sheet, &self.provider, &self.lock.read()); + + let mut guard = self.lock.write(); + self.import_rule.write_with(&mut guard).stylesheet = ImportSheet::Sheet(sheet); + + callback.call(doc_id, Ok(Resource::None)) + } +} + impl NetHandler for CssHandler { fn bytes(self: Box, doc_id: usize, bytes: Bytes, callback: SharedCallback) { let Ok(css) = std::str::from_utf8(&bytes) else { @@ -152,12 +147,13 @@ impl NetHandler for CssHandler { ServoArc::new(self.guard.wrap(MediaList::empty())), self.guard.clone(), Some(&StylesheetLoader(doc_id, self.provider.clone())), - None, + None, // error_reporter QuirksMode::NoQuirks, AllowImportRules::Yes, ); - let read_guard = self.guard.read(); - fetch_font_face(doc_id, &sheet, &self.provider, &read_guard); + + // Fetch @font-face fonts + fetch_font_face(doc_id, &sheet, &self.provider, &self.guard.read()); callback.call( doc_id,