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

@ -7,7 +7,6 @@ use euclid::{Scale, Size2D};
use selectors::parser::{AncestorHashes, Selector};
use servo_arc::Arc;
use servo_atoms::Atom;
use servo_url::ServoUrl;
use style::context::QuirksMode;
use style::media_queries::{Device, MediaType};
use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock};
@ -19,11 +18,12 @@ use style::stylist::{
needs_revalidation_for_testing, ContainerConditionId, LayerId, Rule, Stylist,
};
use style::thread_state::{self, ThreadState};
use url::Url;
/// Helper method to get some Rules from selector strings.
/// Each sublist of the result contains the Rules for one StyleRule.
fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
let dummy_url = &ServoUrl::parse("about:blank").unwrap();
let dummy_url_data = Url::parse("about:blank").unwrap().into();
let shared_lock = SharedRwLock::new();
(
css_selectors
@ -31,7 +31,8 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
.enumerate()
.map(|(i, selectors)| {
let selectors =
SelectorParser::parse_author_origin_no_namespace(selectors, dummy_url).unwrap();
SelectorParser::parse_author_origin_no_namespace(selectors, &dummy_url_data)
.unwrap();
let locked = Arc::new(shared_lock.wrap(StyleRule {
selectors: selectors,
@ -66,11 +67,11 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
}
fn parse_selectors(selectors: &[&str]) -> Vec<Selector<SelectorImpl>> {
let dummy_url = &ServoUrl::parse("about:blank").unwrap();
let dummy_url_data = Url::parse("about:blank").unwrap().into();
selectors
.iter()
.map(|x| {
SelectorParser::parse_author_origin_no_namespace(x, dummy_url)
SelectorParser::parse_author_origin_no_namespace(x, &dummy_url_data)
.unwrap()
.0
.into_iter()