Further changes required by Servo

This commit is contained in:
Oriol Brufau 2023-05-31 12:17:20 +02:00
parent 04282ff04c
commit 07dbd9d637
5 changed files with 26 additions and 23 deletions

View file

@ -4,6 +4,7 @@
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;
@ -14,10 +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 parser = SelectorParser {
stylesheet_origin: Origin::UserAgent,
namespaces: &ns,
url_data: None,
url_data: &dummy_url,
};
SelectorList::parse(&parser, input)
}

View file

@ -8,6 +8,7 @@ use euclid::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};
@ -24,6 +25,7 @@ use style::thread_state::{self, ThreadState};
/// 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 shared_lock = SharedRwLock::new();
(
css_selectors
@ -31,7 +33,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
.enumerate()
.map(|(i, selectors)| {
let selectors =
SelectorParser::parse_author_origin_no_namespace(selectors).unwrap();
SelectorParser::parse_author_origin_no_namespace(selectors, dummy_url).unwrap();
let locked = Arc::new(shared_lock.wrap(StyleRule {
selectors: selectors,
@ -64,10 +66,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();
selectors
.iter()
.map(|x| {
SelectorParser::parse_author_origin_no_namespace(x)
SelectorParser::parse_author_origin_no_namespace(x, dummy_url)
.unwrap()
.0
.into_iter()