mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
style: Add simple parsing and matching support for :has
Parsing is behind a config value `layout.css.has-selectors.enabled`. This change does not support p:has(> a) combinators, but will handle them gracefully, just not matching on them. Differential Revision: https://phabricator.services.mozilla.com/D149515
This commit is contained in:
parent
dcdf9f33d5
commit
3d0cf4dbf9
8 changed files with 85 additions and 10 deletions
|
@ -305,6 +305,11 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
true
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn parse_has(&self) -> bool {
|
||||
static_prefs::pref!("layout.css.has-selector.enabled")
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn parse_part(&self) -> bool {
|
||||
true
|
||||
|
|
|
@ -1844,6 +1844,18 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn first_element_child(&self) -> Option<Self> {
|
||||
let mut child = self.as_node().first_child();
|
||||
while let Some(child_node) = child {
|
||||
if let Some(el) = child_node.as_element() {
|
||||
return Some(el);
|
||||
}
|
||||
child = child_node.next_sibling();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
debug_assert!(!flags.is_empty());
|
||||
self.set_flags(selector_flags_to_node_flags(flags));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue