style: Add an 'auto' value for the CSS 'quotes' property, and make it use language-dependent quote marks.

Differential Revision: https://phabricator.services.mozilla.com/D36429
This commit is contained in:
Jonathan Kew 2019-07-09 08:59:27 +00:00 committed by Emilio Cobos Álvarez
parent c00045b0c9
commit 6cf87d23f8
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
4 changed files with 39 additions and 25 deletions

View file

@ -104,7 +104,7 @@ pub struct QuotePair {
pub closing: crate::OwnedStr,
}
/// Specified and computed `quotes` property.
/// List of quote pairs for the specified/computed value of `quotes` property.
#[derive(
Clone,
Debug,
@ -117,23 +117,53 @@ pub struct QuotePair {
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
pub struct Quotes(
#[repr(transparent)]
pub struct QuoteList(
#[css(iterable, if_empty = "none")]
#[ignore_malloc_size_of = "Arc"]
pub crate::ArcSlice<QuotePair>,
);
/// Specified and computed `quotes` property: `auto`, `none`, or a list
/// of characters.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
pub enum Quotes {
/// list of quote pairs
QuoteList(QuoteList),
/// auto (use lang-dependent quote marks)
Auto,
}
impl Parse for Quotes {
fn parse<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Quotes, ParseError<'i>> {
if input
.try(|input| input.expect_ident_matching("auto"))
.is_ok()
{
return Ok(Quotes::Auto);
}
if input
.try(|input| input.expect_ident_matching("none"))
.is_ok()
{
return Ok(Self::default());
return Ok(Quotes::QuoteList(QuoteList::default()))
}
let mut quotes = Vec::new();
@ -150,7 +180,7 @@ impl Parse for Quotes {
}
if !quotes.is_empty() {
Ok(Quotes(crate::ArcSlice::from_iter(quotes.into_iter())))
Ok(Quotes::QuoteList(QuoteList(crate::ArcSlice::from_iter(quotes.into_iter()))))
} else {
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}