diff --git a/Cargo.lock b/Cargo.lock index e9f1f372c5d..6fe4a8d20d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4569,7 +4569,6 @@ dependencies = [ "cssparser 0.25.5 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.19.8 (registry+https://github.com/rust-lang/crates.io-index)", "html5ever 0.23.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "selectors 0.21.0", "serde_json 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/tests/unit/style/Cargo.toml b/tests/unit/style/Cargo.toml index 6b378b63ee0..b339ed48c52 100644 --- a/tests/unit/style/Cargo.toml +++ b/tests/unit/style/Cargo.toml @@ -15,7 +15,6 @@ app_units = "0.7" cssparser = "0.25" euclid = "0.19" html5ever = "0.23" -parking_lot = "0.8" rayon = "1" serde_json = "1.0" selectors = {path = "../../../components/selectors"} diff --git a/tests/unit/style/lib.rs b/tests/unit/style/lib.rs index eea724d085e..ba1c8992e75 100644 --- a/tests/unit/style/lib.rs +++ b/tests/unit/style/lib.rs @@ -10,7 +10,6 @@ extern crate cssparser; extern crate euclid; #[macro_use] extern crate html5ever; -extern crate parking_lot; extern crate rayon; extern crate selectors; extern crate serde_json; diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index c6b02f37eda..d1bc0e8113f 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -2,283 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use cssparser::{self, SourceLocation}; -use html5ever::Namespace as NsAtom; -use parking_lot::RwLock; -use selectors::attr::*; -use selectors::parser::*; +use cssparser::SourceLocation; use servo_arc::Arc; -use servo_atoms::Atom; use servo_config::set_pref; use servo_url::ServoUrl; -use std::borrow::ToOwned; use std::cell::RefCell; -use std::sync::atomic::AtomicBool; use style::context::QuirksMode; use style::error_reporting::{ContextualParseError, ParseErrorReporter}; use style::media_queries::MediaList; -use style::properties::longhands; -use style::properties::{CSSWideKeyword, CustomDeclaration}; -use style::properties::{CustomDeclarationValue, Importance}; -use style::properties::{PropertyDeclaration, PropertyDeclarationBlock}; use style::shared_lock::SharedRwLock; -use style::stylesheets::{ - CssRule, CssRules, NamespaceRule, StyleRule, Stylesheet, StylesheetContents, -}; -use style::stylesheets::{Namespaces, Origin}; -use style::values::specified::PositionComponent; - -pub fn block_from(iterable: I) -> PropertyDeclarationBlock -where - I: IntoIterator, -{ - let mut block = PropertyDeclarationBlock::new(); - for (d, i) in iterable { - block.push(d, i); - } - block -} - -#[test] -fn test_parse_stylesheet() { - let css = r" - @namespace url(http://www.w3.org/1999/xhtml); - /* FIXME: only if scripting is enabled */ - input[type=hidden i] { - display: block !important; - display: none !important; - display: inline; - --a: b !important; - --a: inherit !important; - --a: c; - } - html , body /**/ { - display: none; - display: block; - } - #d1 > .ok { background: blue; } - }"; - let url = ServoUrl::parse("about::test").unwrap(); - let lock = SharedRwLock::new(); - let media = Arc::new(lock.wrap(MediaList::empty())); - let stylesheet = Stylesheet::from_str( - css, - url.clone(), - Origin::UserAgent, - media, - lock, - None, - None, - QuirksMode::NoQuirks, - 0, - ); - let mut namespaces = Namespaces::default(); - namespaces.default = Some(ns!(html)); - let expected = Stylesheet { - contents: StylesheetContents { - origin: Origin::UserAgent, - namespaces: RwLock::new(namespaces), - url_data: RwLock::new(url), - quirks_mode: QuirksMode::NoQuirks, - rules: CssRules::new( - vec![ - CssRule::Namespace(Arc::new(stylesheet.shared_lock.wrap(NamespaceRule { - prefix: None, - url: NsAtom::from("http://www.w3.org/1999/xhtml"), - source_location: SourceLocation { - line: 1, - column: 19, - }, - }))), - CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule { - selectors: SelectorList::from_vec(vec![Selector::from_vec( - vec![ - Component::DefaultNamespace(NsAtom::from( - "http://www.w3.org/1999/xhtml", - )), - Component::LocalName(LocalName { - name: local_name!("input"), - lower_name: local_name!("input"), - }), - Component::AttributeInNoNamespace { - local_name: local_name!("type"), - operator: AttrSelectorOperator::Equal, - value: "hidden".to_owned(), - case_sensitivity: ParsedCaseSensitivity::AsciiCaseInsensitive, - never_matches: false, - }, - ], - (0 << 20) + (1 << 10) + (1 << 0), - )]), - block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![ - ( - PropertyDeclaration::Display( - longhands::display::SpecifiedValue::None, - ), - Importance::Important, - ), - ( - PropertyDeclaration::Custom(CustomDeclaration { - name: Atom::from("a"), - value: CustomDeclarationValue::CSSWideKeyword( - CSSWideKeyword::Inherit, - ), - }), - Importance::Important, - ), - ]))), - source_location: SourceLocation { line: 3, column: 9 }, - }))), - CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule { - selectors: SelectorList::from_vec(vec![ - Selector::from_vec( - vec![ - Component::DefaultNamespace(NsAtom::from( - "http://www.w3.org/1999/xhtml", - )), - Component::LocalName(LocalName { - name: local_name!("html"), - lower_name: local_name!("html"), - }), - ], - (0 << 20) + (0 << 10) + (1 << 0), - ), - Selector::from_vec( - vec![ - Component::DefaultNamespace(NsAtom::from( - "http://www.w3.org/1999/xhtml", - )), - Component::LocalName(LocalName { - name: local_name!("body"), - lower_name: local_name!("body"), - }), - ], - (0 << 20) + (0 << 10) + (1 << 0), - ), - ]), - block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![( - PropertyDeclaration::Display(longhands::display::SpecifiedValue::Block), - Importance::Normal, - )]))), - source_location: SourceLocation { - line: 11, - column: 9, - }, - }))), - CssRule::Style(Arc::new(stylesheet.shared_lock.wrap(StyleRule { - selectors: SelectorList::from_vec(vec![Selector::from_vec( - vec![ - Component::DefaultNamespace(NsAtom::from( - "http://www.w3.org/1999/xhtml", - )), - Component::ID(Atom::from("d1")), - Component::Combinator(Combinator::Child), - Component::DefaultNamespace(NsAtom::from( - "http://www.w3.org/1999/xhtml", - )), - Component::Class(Atom::from("ok")), - ], - (1 << 20) + (1 << 10) + (0 << 0), - )]), - block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![ - ( - PropertyDeclaration::BackgroundColor( - longhands::background_color::SpecifiedValue::Numeric { - authored: Some("blue".to_owned().into_boxed_str()), - parsed: cssparser::RGBA::new(0, 0, 255, 255), - }, - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundPositionX( - longhands::background_position_x::SpecifiedValue(vec![ - PositionComponent::zero(), - ].into()), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundPositionY( - longhands::background_position_y::SpecifiedValue(vec![ - PositionComponent::zero(), - ].into()), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundRepeat( - longhands::background_repeat::SpecifiedValue( - vec![longhands::background_repeat::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundAttachment( - longhands::background_attachment::SpecifiedValue( - vec![longhands::background_attachment::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundImage( - longhands::background_image::SpecifiedValue( - vec![longhands::background_image::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundSize( - longhands::background_size::SpecifiedValue( - vec![longhands::background_size::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundOrigin( - longhands::background_origin::SpecifiedValue( - vec![longhands::background_origin::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ( - PropertyDeclaration::BackgroundClip( - longhands::background_clip::SpecifiedValue( - vec![longhands::background_clip::single_value - ::get_initial_specified_value()].into(), - ), - ), - Importance::Normal, - ), - ]))), - source_location: SourceLocation { - line: 15, - column: 9, - }, - }))), - ], - &stylesheet.shared_lock, - ), - source_map_url: RwLock::new(None), - source_url: RwLock::new(None), - }, - media: Arc::new(stylesheet.shared_lock.wrap(MediaList::empty())), - shared_lock: stylesheet.shared_lock.clone(), - disabled: AtomicBool::new(false), - }; - - assert_eq!(format!("{:#?}", stylesheet), format!("{:#?}", expected)); -} +use style::stylesheets::Stylesheet; +use style::stylesheets::Origin; #[derive(Debug)] struct CSSError {