Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serialization of namespace and universal selectors #16890

Merged
merged 2 commits into from May 17, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Move "is universal" logic from stylist.rs to selectors/parser.rs

  • Loading branch information
SimonSapin committed May 16, 2017
commit 685b9efed645871877ad83ae3f3e51f9ca9af94d
@@ -182,6 +182,18 @@ pub struct Selector<Impl: SelectorImpl> {
pub specificity: u32,
}

impl<Impl: SelectorImpl> Selector<Impl> {
/// Whether this selector (pseudo-element part excluded) matches every element.
///
/// Used for "pre-computed" pseudo-elements in components/style/stylist.rs
pub fn is_universal(&self) -> bool {
self.inner.complex.iter_raw().all(|c| matches!(*c,
Component::ExplicitUniversalType |
Component::ExplicitAnyNamespace
))
}
}

pub trait SelectorMethods {
type Impl: SelectorImpl;

@@ -1366,20 +1366,9 @@ impl SelectorMap<Rule> {

let mut rules_list = vec![];
for rule in self.other.iter() {
let mut iter = rule.selector.inner.complex.iter_raw();
match iter.next() {
None => {}
Some(&Component::ExplicitUniversalType) => match iter.next() {
None => {}
Some(&Component::ExplicitAnyNamespace) => match iter.next() {
None => {}
_ => continue
},
_ => continue
},
_ => continue
if rule.selector.is_universal() {
rules_list.push(rule.to_applicable_declaration_block(cascade_level))
}
rules_list.push(rule.to_applicable_declaration_block(cascade_level))
}

sort_by_key(&mut rules_list,
@@ -212,9 +212,9 @@ fn test_insert() {
#[test]
fn test_get_universal_rules() {
thread_state::initialize(thread_state::LAYOUT);
let (map, shared_lock) = get_mock_map(&["*|*", "#foo > *|*", ".klass", "#id"]);
let (map, shared_lock) = get_mock_map(&["*|*", "#foo > *|*", "*|* > *|*", ".klass", "#id"]);

let decls = map.get_universal_rules(CascadeLevel::UserNormal);

assert_eq!(decls.len(), 1);
assert_eq!(decls.len(), 1, "{:?}", decls);
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.