mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Refactor the selector parser to make implementing ::part() easier.
::slotted() is already weird in the sense that it supports a pseudo-element afterwards (so ::slotted(*)::before is valid for example). ::part() is weirder because you are supposed to allow stuff like ::part(foo):hover, ::part(foo):hover::before, etc. In order to avoid making the already-complex parse_compound_selector more complex, shuffle stuff so that we pass the progress of our current compound selector around, and is the parsing code for each selector which decides whether it's ok to parse at the given point. Differential Revision: https://phabricator.services.mozilla.com/D27158
This commit is contained in:
parent
498a163cdf
commit
09d497db3d
3 changed files with 191 additions and 193 deletions
|
@ -11,7 +11,7 @@
|
|||
use crate::gecko_bindings::structs::{self, PseudoStyleType};
|
||||
use crate::properties::longhands::display::computed_value::T as Display;
|
||||
use crate::properties::{ComputedValues, PropertyFlags};
|
||||
use crate::selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
|
||||
use crate::selector_parser::{PseudoElementCascadeType, SelectorImpl};
|
||||
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
|
||||
use crate::string_cache::Atom;
|
||||
use crate::values::serialize_atom_identifier;
|
||||
|
@ -30,6 +30,7 @@ impl ::selectors::parser::PseudoElement for PseudoElement {
|
|||
// ::slotted() should support all tree-abiding pseudo-elements, see
|
||||
// https://drafts.csswg.org/css-scoping/#slotted-pseudo
|
||||
// https://drafts.csswg.org/css-pseudo-4/#treelike
|
||||
#[inline]
|
||||
fn valid_after_slotted(&self) -> bool {
|
||||
matches!(
|
||||
*self,
|
||||
|
@ -40,12 +41,9 @@ impl ::selectors::parser::PseudoElement for PseudoElement {
|
|||
)
|
||||
}
|
||||
|
||||
fn supports_pseudo_class(&self, pseudo_class: &NonTSPseudoClass) -> bool {
|
||||
if !self.supports_user_action_state() {
|
||||
return false;
|
||||
}
|
||||
|
||||
return pseudo_class.is_safe_user_action_state();
|
||||
#[inline]
|
||||
fn accepts_state_pseudo_classes(&self) -> bool {
|
||||
self.supports_user_action_state()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue