mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Implement parsing/serialization of text-emphasis-color and text-emphasis
This commit is contained in:
parent
61431b7fd6
commit
852fdca1c5
2 changed files with 68 additions and 0 deletions
|
@ -866,6 +866,11 @@ ${helpers.single_keyword("text-align-last",
|
||||||
computed_value::T::None
|
computed_value::T::None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||||
|
SpecifiedValue::None
|
||||||
|
}
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedValue {
|
impl ToComputedValue for SpecifiedValue {
|
||||||
type ComputedValue = computed_value::T;
|
type ComputedValue = computed_value::T;
|
||||||
|
|
||||||
|
@ -985,6 +990,12 @@ ${helpers.single_keyword("text-align-last",
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-text-decor-3/#text-emphasis-color-property
|
||||||
|
${helpers.predefined_type("text-emphasis-color", "CSSColor",
|
||||||
|
"::cssparser::Color::CurrentColor",
|
||||||
|
products="gecko",animatable=True,
|
||||||
|
complex_color=True, need_clone=True)}
|
||||||
|
|
||||||
// TODO(pcwalton): `full-width`
|
// TODO(pcwalton): `full-width`
|
||||||
${helpers.single_keyword("text-transform",
|
${helpers.single_keyword("text-transform",
|
||||||
"none capitalize uppercase lowercase",
|
"none capitalize uppercase lowercase",
|
||||||
|
|
|
@ -21,3 +21,60 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/css-text-decor-3/#text-emphasis-property
|
||||||
|
<%helpers:shorthand name="text-emphasis" products="gecko" sub_properties="text-emphasis-color
|
||||||
|
text-emphasis-style">
|
||||||
|
use properties::longhands::{text_emphasis_color, text_emphasis_style};
|
||||||
|
|
||||||
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
|
let mut color = None;
|
||||||
|
let mut style = None;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if color.is_none() {
|
||||||
|
if let Ok(value) = input.try(|input| text_emphasis_color::parse(context, input)) {
|
||||||
|
color = Some(value);
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if style.is_none() {
|
||||||
|
if let Ok(value) = input.try(|input| text_emphasis_style::parse(context, input)) {
|
||||||
|
style = Some(value);
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if color.is_some() || style.is_some() {
|
||||||
|
if style.is_none() {
|
||||||
|
style = Some(text_emphasis_style::get_initial_specified_value());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Longhands {
|
||||||
|
text_emphasis_color: color,
|
||||||
|
text_emphasis_style: style,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> LonghandsToSerialize<'a> {
|
||||||
|
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
let mut style_present = false;
|
||||||
|
if let DeclaredValue::Value(ref value) = *self.text_emphasis_style {
|
||||||
|
style_present = true;
|
||||||
|
try!(value.to_css(dest));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let DeclaredValue::Value(ref color) = *self.text_emphasis_color {
|
||||||
|
if style_present {
|
||||||
|
try!(write!(dest, " "));
|
||||||
|
}
|
||||||
|
try!(color.to_css(dest));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%helpers:shorthand>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue