mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Handle 'color: currentColor'
This commit is contained in:
parent
cb340df79c
commit
96dce99e8f
1 changed files with 38 additions and 10 deletions
|
@ -53,7 +53,7 @@ pub mod longhands {
|
||||||
pub use super::*;
|
pub use super::*;
|
||||||
pub use std;
|
pub use std;
|
||||||
|
|
||||||
<%def name="longhand(name, inherited=False, no_super=False)">
|
<%def name="raw_longhand(name, inherited=False, no_super=False)">
|
||||||
<%
|
<%
|
||||||
property = Longhand(name)
|
property = Longhand(name)
|
||||||
THIS_STYLE_STRUCT_LONGHANDS.append(property)
|
THIS_STYLE_STRUCT_LONGHANDS.append(property)
|
||||||
|
@ -69,6 +69,22 @@ pub mod longhands {
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
<%def name="longhand(name, inherited=False, no_super=False)">
|
||||||
|
<%self:raw_longhand name="${name}" inherited="${inherited}">
|
||||||
|
${caller.body()}
|
||||||
|
pub fn parse_declared(input: &[ComponentValue])
|
||||||
|
-> Option<DeclaredValue<SpecifiedValue>> {
|
||||||
|
match CSSWideKeyword::parse(input) {
|
||||||
|
Some(keyword) => Some(CSSWideKeyword(keyword)),
|
||||||
|
None => match parse(input) {
|
||||||
|
Some(value) => Some(SpecifiedValue(value)),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:raw_longhand>
|
||||||
|
</%def>
|
||||||
|
|
||||||
<%def name="single_component_value(name, inherited=False)">
|
<%def name="single_component_value(name, inherited=False)">
|
||||||
<%self:longhand name="${name}" inherited="${inherited}">
|
<%self:longhand name="${name}" inherited="${inherited}">
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
|
@ -257,9 +273,24 @@ pub mod longhands {
|
||||||
|
|
||||||
${new_style_struct("Color")}
|
${new_style_struct("Color")}
|
||||||
|
|
||||||
${predefined_type("color", "CSSColor",
|
<%self:raw_longhand name="color" inherited="True">
|
||||||
"RGBA(RGBA { red: 0., green: 0., blue: 0., alpha: 1. }) /* black */",
|
pub use to_computed_value = std::util::id;
|
||||||
inherited=True)}
|
pub type SpecifiedValue = RGBA;
|
||||||
|
pub type ComputedValue = SpecifiedValue;
|
||||||
|
#[inline] pub fn get_initial_value() -> ComputedValue {
|
||||||
|
RGBA { red: 0., green: 0., blue: 0., alpha: 1. } /* black */
|
||||||
|
}
|
||||||
|
pub fn parse_declared(input: &[ComponentValue]) -> Option<DeclaredValue<SpecifiedValue>> {
|
||||||
|
match CSSWideKeyword::parse(input) {
|
||||||
|
Some(keyword) => Some(CSSWideKeyword(keyword)),
|
||||||
|
None => match one_component_value(input).chain(Color::parse) {
|
||||||
|
Some(RGBA(rgba)) => Some(SpecifiedValue(rgba)),
|
||||||
|
Some(CurrentColor) => Some(CSSWideKeyword(Inherit)),
|
||||||
|
None => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%self:raw_longhand>
|
||||||
|
|
||||||
// CSS 2.1, Section 15 - Fonts
|
// CSS 2.1, Section 15 - Fonts
|
||||||
|
|
||||||
|
@ -675,13 +706,10 @@ impl PropertyDeclaration {
|
||||||
match name.to_ascii_lower().as_slice() {
|
match name.to_ascii_lower().as_slice() {
|
||||||
% for property in LONGHANDS:
|
% for property in LONGHANDS:
|
||||||
"${property.name}" => result_list.push(${property.ident}_declaration(
|
"${property.name}" => result_list.push(${property.ident}_declaration(
|
||||||
match CSSWideKeyword::parse(value) {
|
match longhands::${property.ident}::parse_declared(value) {
|
||||||
Some(keyword) => CSSWideKeyword(keyword),
|
Some(value) => value,
|
||||||
None => match longhands::${property.ident}::parse(value) {
|
|
||||||
Some(value) => SpecifiedValue(value),
|
|
||||||
None => return false,
|
None => return false,
|
||||||
}
|
}
|
||||||
}
|
|
||||||
)),
|
)),
|
||||||
% endfor
|
% endfor
|
||||||
% for shorthand in SHORTHANDS:
|
% for shorthand in SHORTHANDS:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue