style: Allow disabling invalidation-based querySelector from C++

Rust compile times are hard.

MozReview-Commit-ID: 9Xhtf7f3Vzv
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-10-30 19:23:59 +01:00
parent afb09536f9
commit f32f09656b
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 32 additions and 2 deletions

View file

@ -512,11 +512,21 @@ where
});
}
/// Whether the invalidation machinery should be used for this query.
#[derive(PartialEq)]
pub enum MayUseInvalidation {
/// We may use it if we deem it useful.
Yes,
/// Don't use it.
No,
}
/// <https://dom.spec.whatwg.org/#dom-parentnode-queryselector>
pub fn query_selector<E, Q>(
root: E::ConcreteNode,
selector_list: &SelectorList<E::Impl>,
results: &mut Q::Output,
may_use_invalidation: MayUseInvalidation,
)
where
E: TElement,
@ -561,6 +571,7 @@ where
// A selector with a combinator needs to have a length of at least 3: A
// simple selector, a combinator, and another simple selector.
let invalidation_may_be_useful =
may_use_invalidation == MayUseInvalidation::Yes &&
selector_list.0.iter().any(|s| s.len() > 2);
if root_element.is_some() || !invalidation_may_be_useful {