mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add 'fallback' descriptor to @counter-style
This commit is contained in:
parent
e27de3842d
commit
0ba5cae707
3 changed files with 32 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
|||
//!
|
||||
//! [counter-style]: https://drafts.csswg.org/css-counter-styles/
|
||||
|
||||
use Atom;
|
||||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, Token};
|
||||
use cssparser::{serialize_string, serialize_identifier};
|
||||
#[cfg(feature = "gecko")] use gecko::rules::CounterStyleDescriptors;
|
||||
|
@ -148,6 +149,10 @@ counter_style_descriptors! {
|
|||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
||||
"pad" pad / eCSSCounterDesc_Pad: Pad = Pad(0, Symbol::String("".to_owned()));
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-fallback
|
||||
"fallback" fallback / eCSSCounterDesc_Fallback: Fallback =
|
||||
Fallback(CustomIdent(Atom::from("decimal")));
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-system
|
||||
|
@ -358,3 +363,19 @@ impl ToCss for Pad {
|
|||
self.1.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-fallback
|
||||
#[derive(Debug)]
|
||||
pub struct Fallback(pub CustomIdent);
|
||||
|
||||
impl Parse for Fallback {
|
||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
parse_counter_style_name(input).map(Fallback)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Fallback {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.0.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,3 +221,9 @@ impl ToNsCssValue for counter_style::Pad {
|
|||
//nscssvalue.set_pair(min_length, pad_with);
|
||||
}
|
||||
}
|
||||
|
||||
impl ToNsCssValue for counter_style::Fallback {
|
||||
fn convert(&self, nscssvalue: &mut nsCSSValue) {
|
||||
nscssvalue.set_ident_from_atom(&self.0 .0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,6 +124,11 @@ impl nsCSSValue {
|
|||
self.set_string_from_atom_internal(s, nsCSSUnit::eCSSUnit_String)
|
||||
}
|
||||
|
||||
/// Set to a ident value from the given atom
|
||||
pub fn set_ident_from_atom(&mut self, s: &Atom) {
|
||||
self.set_string_from_atom_internal(s, nsCSSUnit::eCSSUnit_Ident)
|
||||
}
|
||||
|
||||
/// Set to an identifier value
|
||||
pub fn set_ident(&mut self, s: &str) {
|
||||
self.set_string_internal(s, nsCSSUnit::eCSSUnit_Ident)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue