style: Remove dependency on servo_url (#31358)

In order for stylo to be a separate crate, it needs to depend on less
things from Servo. This change makes it so that stylo no longer depends
on servo_url.
This commit is contained in:
Martin Robinson 2024-02-16 12:56:35 +01:00 committed by GitHub
parent 29e1dfe1e4
commit 9a6973d629
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
42 changed files with 236 additions and 144 deletions

View file

@ -44,4 +44,5 @@ servo_url = { path = "../url" }
style = { path = "../style" }
style_traits = { workspace = true }
time = { workspace = true }
url = { workspace = true }
webrender_api = { workspace = true }

View file

@ -100,13 +100,15 @@ use style::selector_parser::{PseudoElement, SnapshotMap};
use style::servo::restyle_damage::ServoRestyleDamage;
use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards};
use style::stylesheets::{
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UserAgentStylesheets,
DocumentStyleSheet, Origin, Stylesheet, StylesheetInDocument, UrlExtraData,
UserAgentStylesheets,
};
use style::stylist::Stylist;
use style::thread_state::{self, ThreadState};
use style::traversal::DomTraversal;
use style::traversal_flags::TraversalFlags;
use style_traits::{CSSPixel, DevicePixel, SpeculativePainter};
use url::Url;
use webrender_api::{units, ColorF, HitTestFlags};
/// Information needed by the layout thread.
@ -1795,9 +1797,12 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
filename: &str,
content: &[u8],
) -> Result<DocumentStyleSheet, &'static str> {
let url = Url::parse(&format!("chrome://resources/{:?}", filename))
.ok()
.unwrap();
Ok(DocumentStyleSheet(ServoArc::new(Stylesheet::from_bytes(
content,
ServoUrl::parse(&format!("chrome://resources/{:?}", filename)).unwrap(),
url.into(),
None,
None,
Origin::UserAgent,
@ -1835,7 +1840,7 @@ fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
user_or_user_agent_stylesheets.push(DocumentStyleSheet(ServoArc::new(
Stylesheet::from_bytes(
&contents,
url.clone(),
UrlExtraData(url.get_arc()),
None,
None,
Origin::User,