mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
style: Minor restyle_hints.rs code reorganization.
This commit is contained in:
parent
74ea8ce3ed
commit
90b3691f82
1 changed files with 30 additions and 31 deletions
|
@ -636,30 +636,27 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
-> bool
|
-> bool
|
||||||
where F: FnMut(&Self, ElementSelectorFlags),
|
where F: FnMut(&Self, ElementSelectorFlags),
|
||||||
{
|
{
|
||||||
// :moz-any is quite special, because we need to keep matching as a
|
// Some pseudo-classes need special handling to evaluate them against
|
||||||
// snapshot.
|
// the snapshot.
|
||||||
#[cfg(feature = "gecko")]
|
match *pseudo_class {
|
||||||
{
|
#[cfg(feature = "gecko")]
|
||||||
use selectors::matching::matches_complex_selector;
|
NonTSPseudoClass::MozAny(ref selectors) => {
|
||||||
if let NonTSPseudoClass::MozAny(ref selectors) = *pseudo_class {
|
use selectors::matching::matches_complex_selector;
|
||||||
return selectors.iter().any(|s| {
|
return selectors.iter().any(|s| {
|
||||||
matches_complex_selector(s, 0, self, context, _setter)
|
matches_complex_selector(s, 0, self, context, _setter)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// :dir needs special handling. It's implemented in terms of state
|
// :dir is implemented in terms of state flags, but which state flag
|
||||||
// flags, but which state flag it maps to depends on the argument to
|
// it maps to depends on the argument to :dir. That means we can't
|
||||||
// :dir. That means we can't just add its state flags to the
|
// just add its state flags to the NonTSPseudoClass, because if we
|
||||||
// NonTSPseudoClass, because if we added all of them there, and tested
|
// added all of them there, and tested via intersects() here, we'd
|
||||||
// via intersects() here, we'd get incorrect behavior for :not(:dir())
|
// get incorrect behavior for :not(:dir()) cases.
|
||||||
// cases.
|
//
|
||||||
//
|
// FIXME(bz): How can I set this up so once Servo adds :dir()
|
||||||
// FIXME(bz): How can I set this up so once Servo adds :dir() support we
|
// support we don't forget to update this code?
|
||||||
// don't forget to update this code?
|
#[cfg(feature = "gecko")]
|
||||||
#[cfg(feature = "gecko")]
|
NonTSPseudoClass::Dir(ref s) => {
|
||||||
{
|
|
||||||
if let NonTSPseudoClass::Dir(ref s) = *pseudo_class {
|
|
||||||
let selector_flag = dir_selector_to_state(s);
|
let selector_flag = dir_selector_to_state(s);
|
||||||
if selector_flag.is_empty() {
|
if selector_flag.is_empty() {
|
||||||
// :dir() with some random argument; does not match.
|
// :dir() with some random argument; does not match.
|
||||||
|
@ -671,16 +668,18 @@ impl<'a, E> Element for ElementWrapper<'a, E>
|
||||||
};
|
};
|
||||||
return state.contains(selector_flag);
|
return state.contains(selector_flag);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// For :link and :visited, we don't actually want to test the element
|
// For :link and :visited, we don't actually want to test the element
|
||||||
// state directly. Instead, we use the `relevant_link` to determine if
|
// state directly. Instead, we use the `relevant_link` to determine if
|
||||||
// they match.
|
// they match.
|
||||||
if *pseudo_class == NonTSPseudoClass::Link {
|
NonTSPseudoClass::Link => {
|
||||||
return relevant_link.is_unvisited(self, context)
|
return relevant_link.is_unvisited(self, context);
|
||||||
}
|
}
|
||||||
if *pseudo_class == NonTSPseudoClass::Visited {
|
NonTSPseudoClass::Visited => {
|
||||||
return relevant_link.is_visited(self, context)
|
return relevant_link.is_visited(self, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let flag = pseudo_class.state_flag();
|
let flag = pseudo_class.state_flag();
|
||||||
|
@ -821,11 +820,11 @@ fn is_attr_selector(sel: &Component<SelectorImpl>) -> bool {
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
/// The aspects of an selector which are sensitive.
|
/// The characteristics that a selector is sensitive to.
|
||||||
pub struct Sensitivities {
|
pub struct Sensitivities {
|
||||||
/// The states which are sensitive.
|
/// The states which the selector is sensitive to.
|
||||||
pub states: ElementState,
|
pub states: ElementState,
|
||||||
/// Whether attributes are sensitive.
|
/// Whether the selector is sensitive to attributes.
|
||||||
pub attrs: bool,
|
pub attrs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue