mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Bug 1364412: Store full selectors in the Rule object. r=bholley
MozReview-Commit-ID: EKLKxNCghLD Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
10560ae043
commit
dd38740ece
2 changed files with 19 additions and 27 deletions
|
@ -42,10 +42,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
|
|||
let guard = shared_lock.read();
|
||||
let rule = locked.read_with(&guard);
|
||||
rule.selectors.0.iter().map(|s| {
|
||||
Rule::new(s.inner.clone(),
|
||||
locked.clone(),
|
||||
i,
|
||||
s.specificity)
|
||||
Rule::new(s.clone(), locked.clone(), i)
|
||||
}).collect()
|
||||
}).collect(), shared_lock)
|
||||
}
|
||||
|
@ -175,22 +172,22 @@ fn test_rule_ordering_same_specificity() {
|
|||
#[test]
|
||||
fn test_get_id_name() {
|
||||
let (rules_list, _) = get_mock_rules(&[".intro", "#top"]);
|
||||
assert_eq!(stylist::get_id_name(&rules_list[0][0].selector), None);
|
||||
assert_eq!(stylist::get_id_name(&rules_list[1][0].selector), Some(Atom::from("top")));
|
||||
assert_eq!(stylist::get_id_name(&rules_list[0][0].selector.inner), None);
|
||||
assert_eq!(stylist::get_id_name(&rules_list[1][0].selector.inner), Some(Atom::from("top")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_class_name() {
|
||||
let (rules_list, _) = get_mock_rules(&[".intro.foo", "#top"]);
|
||||
assert_eq!(stylist::get_class_name(&rules_list[0][0].selector), Some(Atom::from("foo")));
|
||||
assert_eq!(stylist::get_class_name(&rules_list[1][0].selector), None);
|
||||
assert_eq!(stylist::get_class_name(&rules_list[0][0].selector.inner), Some(Atom::from("foo")));
|
||||
assert_eq!(stylist::get_class_name(&rules_list[1][0].selector.inner), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_local_name() {
|
||||
let (rules_list, _) = get_mock_rules(&["img.foo", "#top", "IMG", "ImG"]);
|
||||
let check = |i: usize, names: Option<(&str, &str)>| {
|
||||
assert!(stylist::get_local_name(&rules_list[i][0].selector)
|
||||
assert!(stylist::get_local_name(&rules_list[i][0].selector.inner)
|
||||
== names.map(|(name, lower_name)| LocalNameSelector {
|
||||
name: LocalName::from(name),
|
||||
lower_name: LocalName::from(lower_name) }))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue