mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
selectors: Reformat some signatures in selectors::matching.
This commit is contained in:
parent
6a5576085c
commit
bcfe523c99
1 changed files with 76 additions and 60 deletions
|
@ -159,11 +159,13 @@ impl<'a, 'b, Impl> LocalMatchingContext<'a, 'b, Impl>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn matches_selector_list<E>(selector_list: &SelectorList<E::Impl>,
|
pub fn matches_selector_list<E>(
|
||||||
element: &E,
|
selector_list: &SelectorList<E::Impl>,
|
||||||
context: &mut MatchingContext)
|
element: &E,
|
||||||
-> bool
|
context: &mut MatchingContext,
|
||||||
where E: Element
|
) -> bool
|
||||||
|
where
|
||||||
|
E: Element
|
||||||
{
|
{
|
||||||
selector_list.0.iter().any(|selector| {
|
selector_list.0.iter().any(|selector| {
|
||||||
matches_selector(selector,
|
matches_selector(selector,
|
||||||
|
@ -176,10 +178,9 @@ pub fn matches_selector_list<E>(selector_list: &SelectorList<E::Impl>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn may_match<E>(hashes: &AncestorHashes,
|
fn may_match<E>(hashes: &AncestorHashes, bf: &BloomFilter) -> bool
|
||||||
bf: &BloomFilter)
|
where
|
||||||
-> bool
|
E: Element,
|
||||||
where E: Element,
|
|
||||||
{
|
{
|
||||||
// Check the first three hashes. Note that we can check for zero before
|
// Check the first three hashes. Note that we can check for zero before
|
||||||
// masking off the high bits, since if any of the first three hashes is
|
// masking off the high bits, since if any of the first three hashes is
|
||||||
|
@ -370,15 +371,17 @@ enum SelectorMatchingResult {
|
||||||
/// unncessary cache miss for cases when we can fast-reject with AncestorHashes
|
/// unncessary cache miss for cases when we can fast-reject with AncestorHashes
|
||||||
/// (which the caller can store inline with the selector pointer).
|
/// (which the caller can store inline with the selector pointer).
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn matches_selector<E, F>(selector: &Selector<E::Impl>,
|
pub fn matches_selector<E, F>(
|
||||||
offset: usize,
|
selector: &Selector<E::Impl>,
|
||||||
hashes: Option<&AncestorHashes>,
|
offset: usize,
|
||||||
element: &E,
|
hashes: Option<&AncestorHashes>,
|
||||||
context: &mut MatchingContext,
|
element: &E,
|
||||||
flags_setter: &mut F)
|
context: &mut MatchingContext,
|
||||||
-> bool
|
flags_setter: &mut F,
|
||||||
where E: Element,
|
) -> bool
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
where
|
||||||
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
// Use the bloom filter to fast-reject.
|
// Use the bloom filter to fast-reject.
|
||||||
if let Some(hashes) = hashes {
|
if let Some(hashes) = hashes {
|
||||||
|
@ -457,13 +460,15 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Matches a complex selector.
|
/// Matches a complex selector.
|
||||||
pub fn matches_complex_selector<E, F>(mut iter: SelectorIter<E::Impl>,
|
pub fn matches_complex_selector<E, F>(
|
||||||
element: &E,
|
mut iter: SelectorIter<E::Impl>,
|
||||||
context: &mut LocalMatchingContext<E::Impl>,
|
element: &E,
|
||||||
flags_setter: &mut F)
|
context: &mut LocalMatchingContext<E::Impl>,
|
||||||
-> bool
|
flags_setter: &mut F,
|
||||||
where E: Element,
|
) -> bool
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
where
|
||||||
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
if context.nesting_level == 0 &&
|
if context.nesting_level == 0 &&
|
||||||
|
@ -499,24 +504,30 @@ pub fn matches_complex_selector<E, F>(mut iter: SelectorIter<E::Impl>,
|
||||||
context.note_position(&iter);
|
context.note_position(&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
match matches_complex_selector_internal(iter,
|
let result = matches_complex_selector_internal(
|
||||||
element,
|
iter,
|
||||||
context,
|
element,
|
||||||
&mut RelevantLinkStatus::Looking,
|
context,
|
||||||
flags_setter) {
|
&mut RelevantLinkStatus::Looking,
|
||||||
|
flags_setter,
|
||||||
|
);
|
||||||
|
|
||||||
|
match result {
|
||||||
SelectorMatchingResult::Matched => true,
|
SelectorMatchingResult::Matched => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Impl>,
|
fn matches_complex_selector_internal<E, F>(
|
||||||
element: &E,
|
mut selector_iter: SelectorIter<E::Impl>,
|
||||||
context: &mut LocalMatchingContext<E::Impl>,
|
element: &E,
|
||||||
relevant_link: &mut RelevantLinkStatus,
|
context: &mut LocalMatchingContext<E::Impl>,
|
||||||
flags_setter: &mut F)
|
relevant_link: &mut RelevantLinkStatus,
|
||||||
-> SelectorMatchingResult
|
flags_setter: &mut F
|
||||||
where E: Element,
|
) -> SelectorMatchingResult
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
where
|
||||||
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
*relevant_link = relevant_link.examine_potential_link(element, &mut context.shared);
|
*relevant_link = relevant_link.examine_potential_link(element, &mut context.shared);
|
||||||
|
|
||||||
|
@ -614,14 +625,15 @@ fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Im
|
||||||
/// Determines whether the given element matches the given single selector.
|
/// Determines whether the given element matches the given single selector.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn matches_simple_selector<E, F>(
|
fn matches_simple_selector<E, F>(
|
||||||
selector: &Component<E::Impl>,
|
selector: &Component<E::Impl>,
|
||||||
element: &E,
|
element: &E,
|
||||||
context: &mut LocalMatchingContext<E::Impl>,
|
context: &mut LocalMatchingContext<E::Impl>,
|
||||||
relevant_link: &RelevantLinkStatus,
|
relevant_link: &RelevantLinkStatus,
|
||||||
flags_setter: &mut F)
|
flags_setter: &mut F,
|
||||||
-> bool
|
) -> bool
|
||||||
where E: Element,
|
where
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
match *selector {
|
match *selector {
|
||||||
Component::Combinator(_) => unreachable!(),
|
Component::Combinator(_) => unreachable!(),
|
||||||
|
@ -773,16 +785,18 @@ fn select_name<'a, T>(is_html: bool, local_name: &'a T, local_name_lower: &'a T)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn matches_generic_nth_child<E, F>(element: &E,
|
fn matches_generic_nth_child<E, F>(
|
||||||
context: &mut LocalMatchingContext<E::Impl>,
|
element: &E,
|
||||||
a: i32,
|
context: &mut LocalMatchingContext<E::Impl>,
|
||||||
b: i32,
|
a: i32,
|
||||||
is_of_type: bool,
|
b: i32,
|
||||||
is_from_end: bool,
|
is_of_type: bool,
|
||||||
flags_setter: &mut F)
|
is_from_end: bool,
|
||||||
-> bool
|
flags_setter: &mut F,
|
||||||
where E: Element,
|
) -> bool
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
where
|
||||||
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
if element.ignores_nth_child_selectors() {
|
if element.ignores_nth_child_selectors() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -880,8 +894,9 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn matches_first_child<E, F>(element: &E, flags_setter: &mut F) -> bool
|
fn matches_first_child<E, F>(element: &E, flags_setter: &mut F) -> bool
|
||||||
where E: Element,
|
where
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
flags_setter(element, HAS_EDGE_CHILD_SELECTOR);
|
flags_setter(element, HAS_EDGE_CHILD_SELECTOR);
|
||||||
element.prev_sibling_element().is_none()
|
element.prev_sibling_element().is_none()
|
||||||
|
@ -889,8 +904,9 @@ fn matches_first_child<E, F>(element: &E, flags_setter: &mut F) -> bool
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn matches_last_child<E, F>(element: &E, flags_setter: &mut F) -> bool
|
fn matches_last_child<E, F>(element: &E, flags_setter: &mut F) -> bool
|
||||||
where E: Element,
|
where
|
||||||
F: FnMut(&E, ElementSelectorFlags),
|
E: Element,
|
||||||
|
F: FnMut(&E, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
flags_setter(element, HAS_EDGE_CHILD_SELECTOR);
|
flags_setter(element, HAS_EDGE_CHILD_SELECTOR);
|
||||||
element.next_sibling_element().is_none()
|
element.next_sibling_element().is_none()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue