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

@ -6,16 +6,16 @@ use std::cell::RefCell;
use cssparser::SourceLocation;
use servo_arc::Arc;
use servo_url::ServoUrl;
use style::context::QuirksMode;
use style::error_reporting::{ContextualParseError, ParseErrorReporter};
use style::media_queries::MediaList;
use style::shared_lock::SharedRwLock;
use style::stylesheets::{AllowImportRules, Origin, Stylesheet};
use style::stylesheets::{AllowImportRules, Origin, Stylesheet, UrlExtraData};
use url::Url;
#[derive(Debug)]
struct CSSError {
pub url: ServoUrl,
pub url: Arc<Url>,
pub line: u32,
pub column: u32,
pub message: String,
@ -60,9 +60,14 @@ impl TestingErrorReporter {
}
impl ParseErrorReporter for TestingErrorReporter {
fn report_error(&self, url: &ServoUrl, location: SourceLocation, error: ContextualParseError) {
fn report_error(
&self,
url: &UrlExtraData,
location: SourceLocation,
error: ContextualParseError,
) {
self.errors.borrow_mut().push(CSSError {
url: url.clone(),
url: url.0.clone(),
line: location.line,
column: location.column,
message: error.to_string(),
@ -88,14 +93,14 @@ fn test_report_error_stylesheet() {
@supports (color: green) and invalid and (margin: 0) {}
@keyframes foo { from invalid {} to { margin: 0 invalid 0; } }
";
let url = ServoUrl::parse("about::test").unwrap();
let url = Url::parse("about::test").unwrap();
let error_reporter = TestingErrorReporter::new();
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(
css,
url.clone(),
url.clone().into(),
Origin::UserAgent,
media,
lock,
@ -134,7 +139,7 @@ fn test_report_error_stylesheet() {
),
]);
assert_eq!(error_reporter.errors.borrow()[0].url, url);
assert_eq!(*error_reporter.errors.borrow()[0].url, url);
}
#[test]
@ -146,14 +151,14 @@ fn test_no_report_unrecognized_vendor_properties() {
-moz-background-color: red;
}
";
let url = ServoUrl::parse("about::test").unwrap();
let url = Url::parse("about::test").unwrap();
let error_reporter = TestingErrorReporter::new();
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
Stylesheet::from_str(
css,
url,
url.into(),
Origin::UserAgent,
media,
lock,
@ -182,12 +187,12 @@ fn test_source_map_url() {
];
for test in tests {
let url = ServoUrl::parse("about::test").unwrap();
let url = Url::parse("about::test").unwrap();
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(
test.0,
url.clone(),
url.into(),
Origin::UserAgent,
media,
lock,
@ -210,12 +215,12 @@ fn test_source_url() {
];
for test in tests {
let url = ServoUrl::parse("about::test").unwrap();
let url = Url::parse("about::test").unwrap();
let lock = SharedRwLock::new();
let media = Arc::new(lock.wrap(MediaList::empty()));
let stylesheet = Stylesheet::from_str(
test.0,
url.clone(),
url.into(),
Origin::UserAgent,
media,
lock,