style: Basic implementation of Custom Highlight API

Added WebIDL interfaces as per spec, added some necessary changes to support maplike and setlike structures to be accessed from C++.

Added `::highlight(foo)` pseudo element to CSS engine.

Implemented Highlight as new kind of `Selection` using `HighlightType::eHighlight`. This implies Selections being added/removed during runtime (one `Selection` object per highlight identifier), therefore a dynamic container for highlight `Selection` objects was added to `nsFrameSelection`. Also, the painting code queries the highlight style for highlight Selections.

Implementation is currently hidden behind a pref `dom.customHighlightAPI.enabled`.

Differential Revision: https://phabricator.services.mozilla.com/D164203
This commit is contained in:
Jan-Niklas Jaeschke 2023-01-27 11:42:18 +00:00 committed by Martin Robinson
parent 29c6094c80
commit 896aac5e4a
5 changed files with 65 additions and 5 deletions

View file

@ -2920,6 +2920,7 @@ pub mod tests {
pub enum PseudoElement {
Before,
After,
Highlight(String),
}
impl parser::PseudoElement for PseudoElement {
@ -2973,6 +2974,11 @@ pub mod tests {
match *self {
PseudoElement::Before => dest.write_str("::before"),
PseudoElement::After => dest.write_str("::after"),
PseudoElement::Highlight(ref name) => {
dest.write_str("::highlight(")?;
serialize_identifier(&name, dest)?;
dest.write_char(')')
},
}
}
}
@ -3133,6 +3139,23 @@ pub mod tests {
)
}
fn parse_functional_pseudo_element<'t>(
&self,
name: CowRcStr<'i>,
parser: &mut CssParser<'i, 't>,
) -> Result<PseudoElement, SelectorParseError<'i>> {
match_ignore_ascii_case! {&name,
"highlight" => return Ok(PseudoElement::Highlight(parser.expect_ident()?.as_ref().to_owned())),
_ => {}
}
Err(
parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(
name,
)),
)
}
fn default_namespace(&self) -> Option<DummyAtom> {
self.default_ns.clone()
}
@ -3660,6 +3683,8 @@ pub mod tests {
)]))
);
assert!(parse("::highlight(foo)").is_ok());
assert!(parse("::slotted()").is_err());
assert!(parse("::slotted(div)").is_ok());
assert!(parse("::slotted(div).foo").is_err());