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

@ -9,6 +9,7 @@ use style::context::QuirksMode;
use style::parser::ParserContext;
use style::stylesheets::{CssRuleType, Origin};
use style_traits::{ParseError, ParsingMode};
use url::Url;
fn parse<T, F>(f: F, s: &'static str) -> Result<T, ParseError<'static>>
where
@ -22,10 +23,10 @@ fn parse_input<'i: 't, 't, T, F>(f: F, input: &'t mut ParserInput<'i>) -> Result
where
F: Fn(&ParserContext, &mut Parser<'i, 't>) -> Result<T, ParseError<'i>>,
{
let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap();
let url_data = Url::parse("http://localhost").unwrap().into();
let context = ParserContext::new(
Origin::Author,
&url,
&url_data,
Some(CssRuleType::Style),
ParsingMode::DEFAULT,
QuirksMode::NoQuirks,

View file

@ -4,10 +4,10 @@
use cssparser::{Parser, ParserInput, ToCss};
use selectors::parser::SelectorList;
use servo_url::ServoUrl;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::{Namespaces, Origin};
use style_traits::ParseError;
use url::Url;
fn parse_selector<'i, 't>(
input: &mut Parser<'i, 't>,
@ -15,11 +15,11 @@ fn parse_selector<'i, 't>(
let mut ns = Namespaces::default();
ns.prefixes
.insert("svg".into(), style::Namespace::new(ns!(svg)));
let dummy_url = ServoUrl::parse("about:blank").unwrap();
let dummy_url_data = Url::parse("about:blank").unwrap().into();
let parser = SelectorParser {
stylesheet_origin: Origin::UserAgent,
namespaces: &ns,
url_data: &dummy_url,
url_data: &dummy_url_data,
for_supports_rule: false,
};
SelectorList::parse(&parser, input)