mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: [css-nesting] Do a first pass at parsing nested rules mixed with declarations
Plumb everything up. This factors out declaration and rule parsing so we share the code with the regular declaration parser. This could be made a bit nicer in the future. We need to decide what to do for @page and @keyframe (it seems conditional rules inside ought to work, but that's not so easy because per spec we create a nested style rule). But this is a first pass that passes a good chunk of the tests. There are other fixups to cssom, and I think some of the tests we fail are actually wrong... Differential Revision: https://phabricator.services.mozilla.com/D178266
This commit is contained in:
parent
b92440ef7c
commit
7c4ec6e9cc
13 changed files with 523 additions and 286 deletions
|
@ -392,6 +392,11 @@ enum ParseRelative {
|
|||
}
|
||||
|
||||
impl<Impl: SelectorImpl> SelectorList<Impl> {
|
||||
/// Returns a selector list with a single `&`
|
||||
pub fn ampersand() -> Self {
|
||||
Self(smallvec::smallvec![Selector::ampersand()])
|
||||
}
|
||||
|
||||
/// Parse a comma-separated list of Selectors.
|
||||
/// <https://drafts.csswg.org/selectors/#grouping>
|
||||
///
|
||||
|
@ -647,6 +652,18 @@ pub struct Selector<Impl: SelectorImpl>(
|
|||
);
|
||||
|
||||
impl<Impl: SelectorImpl> Selector<Impl> {
|
||||
/// See Arc::mark_as_intentionally_leaked
|
||||
pub fn mark_as_intentionally_leaked(&self) {
|
||||
self.0.with_arc(|a| a.mark_as_intentionally_leaked())
|
||||
}
|
||||
|
||||
fn ampersand() -> Self {
|
||||
Self(ThinArc::from_header_and_iter(SpecificityAndFlags {
|
||||
specificity: 0,
|
||||
flags: SelectorFlags::HAS_PARENT,
|
||||
}, std::iter::once(Component::ParentSelector)))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn specificity(&self) -> u32 {
|
||||
self.0.header.header.specificity()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue