mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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:
parent
c00045b0c9
commit
6cf87d23f8
4 changed files with 39 additions and 25 deletions
|
@ -7,28 +7,12 @@
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use crate::values::specified::list::ListStyleType;
|
pub use crate::values::specified::list::ListStyleType;
|
||||||
pub use crate::values::specified::list::MozListReversed;
|
pub use crate::values::specified::list::MozListReversed;
|
||||||
pub use crate::values::specified::list::{QuotePair, Quotes};
|
pub use crate::values::specified::list::Quotes;
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref INITIAL_QUOTES: crate::ArcSlice<QuotePair> = crate::ArcSlice::from_iter_leaked(
|
|
||||||
vec![
|
|
||||||
QuotePair {
|
|
||||||
opening: "\u{201c}".to_owned().into(),
|
|
||||||
closing: "\u{201d}".to_owned().into(),
|
|
||||||
},
|
|
||||||
QuotePair {
|
|
||||||
opening: "\u{2018}".to_owned().into(),
|
|
||||||
closing: "\u{2019}".to_owned().into(),
|
|
||||||
},
|
|
||||||
]
|
|
||||||
.into_iter()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Quotes {
|
impl Quotes {
|
||||||
/// Initial value for `quotes`.
|
/// Initial value for `quotes`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn get_initial_value() -> Quotes {
|
pub fn get_initial_value() -> Quotes {
|
||||||
Quotes(INITIAL_QUOTES.clone())
|
Quotes::Auto
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageO
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::list::ListStyleType;
|
pub use self::list::ListStyleType;
|
||||||
pub use self::list::MozListReversed;
|
pub use self::list::MozListReversed;
|
||||||
pub use self::list::{QuotePair, Quotes};
|
pub use self::list::Quotes;
|
||||||
pub use self::motion::{OffsetPath, OffsetRotate};
|
pub use self::motion::{OffsetPath, OffsetRotate};
|
||||||
pub use self::outline::OutlineStyle;
|
pub use self::outline::OutlineStyle;
|
||||||
pub use self::percentage::{NonNegativePercentage, Percentage};
|
pub use self::percentage::{NonNegativePercentage, Percentage};
|
||||||
|
|
|
@ -104,7 +104,7 @@ pub struct QuotePair {
|
||||||
pub closing: crate::OwnedStr,
|
pub closing: crate::OwnedStr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Specified and computed `quotes` property.
|
/// List of quote pairs for the specified/computed value of `quotes` property.
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
Debug,
|
Debug,
|
||||||
|
@ -117,23 +117,53 @@ pub struct QuotePair {
|
||||||
ToResolvedValue,
|
ToResolvedValue,
|
||||||
ToShmem,
|
ToShmem,
|
||||||
)]
|
)]
|
||||||
#[repr(C)]
|
#[repr(transparent)]
|
||||||
pub struct Quotes(
|
pub struct QuoteList(
|
||||||
#[css(iterable, if_empty = "none")]
|
#[css(iterable, if_empty = "none")]
|
||||||
#[ignore_malloc_size_of = "Arc"]
|
#[ignore_malloc_size_of = "Arc"]
|
||||||
pub crate::ArcSlice<QuotePair>,
|
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 {
|
impl Parse for Quotes {
|
||||||
fn parse<'i, 't>(
|
fn parse<'i, 't>(
|
||||||
_: &ParserContext,
|
_: &ParserContext,
|
||||||
input: &mut Parser<'i, 't>,
|
input: &mut Parser<'i, 't>,
|
||||||
) -> Result<Quotes, ParseError<'i>> {
|
) -> Result<Quotes, ParseError<'i>> {
|
||||||
|
if input
|
||||||
|
.try(|input| input.expect_ident_matching("auto"))
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
return Ok(Quotes::Auto);
|
||||||
|
}
|
||||||
|
|
||||||
if input
|
if input
|
||||||
.try(|input| input.expect_ident_matching("none"))
|
.try(|input| input.expect_ident_matching("none"))
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
return Ok(Self::default());
|
return Ok(Quotes::QuoteList(QuoteList::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut quotes = Vec::new();
|
let mut quotes = Vec::new();
|
||||||
|
@ -150,7 +180,7 @@ impl Parse for Quotes {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !quotes.is_empty() {
|
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 {
|
} else {
|
||||||
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ pub use self::length::{NonNegativeLengthPercentage, NonNegativeLengthPercentageO
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use self::list::ListStyleType;
|
pub use self::list::ListStyleType;
|
||||||
pub use self::list::MozListReversed;
|
pub use self::list::MozListReversed;
|
||||||
pub use self::list::{QuotePair, Quotes};
|
pub use self::list::Quotes;
|
||||||
pub use self::motion::{OffsetPath, OffsetRotate};
|
pub use self::motion::{OffsetPath, OffsetRotate};
|
||||||
pub use self::outline::OutlineStyle;
|
pub use self::outline::OutlineStyle;
|
||||||
pub use self::percentage::Percentage;
|
pub use self::percentage::Percentage;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue