mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
stylo: Support system colors
MozReview-Commit-ID: HUfTdcMRoEx
This commit is contained in:
parent
d309782461
commit
6b9a6806b8
7 changed files with 720 additions and 1 deletions
|
@ -132,6 +132,7 @@ impl ToComputedValue for specified::Color {
|
|||
let pres_context = unsafe { &*context.device.pres_context };
|
||||
match *self {
|
||||
specified::Color::RGBA(rgba) => rgba,
|
||||
specified::Color::System(system) => to_rgba(system.to_computed_value(context)),
|
||||
specified::Color::CurrentColor => context.inherited_style.get_color().clone_color(),
|
||||
specified::Color::MozDefaultColor => to_rgba(pres_context.mDefaultColor),
|
||||
specified::Color::MozDefaultBackgroundColor => to_rgba(pres_context.mBackgroundColor),
|
||||
|
|
|
@ -24,6 +24,7 @@ mod servo {
|
|||
mod gecko {
|
||||
use cssparser::{Color as CSSParserColor, Parser, RGBA};
|
||||
use parser::{Parse, ParserContext};
|
||||
use properties::longhands::color::SystemColor;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
|
@ -35,7 +36,8 @@ mod gecko {
|
|||
CurrentColor,
|
||||
/// A specific RGBA color
|
||||
RGBA(RGBA),
|
||||
|
||||
/// A system color
|
||||
System(SystemColor),
|
||||
/// -moz-default-color
|
||||
MozDefaultColor,
|
||||
/// -moz-default-background-color
|
||||
|
@ -57,6 +59,8 @@ mod gecko {
|
|||
CSSParserColor::CurrentColor => Ok(Color::CurrentColor),
|
||||
CSSParserColor::RGBA(x) => Ok(Color::RGBA(x)),
|
||||
}
|
||||
} else if let Ok(system) = input.try(SystemColor::parse) {
|
||||
Ok(Color::System(system))
|
||||
} else {
|
||||
let ident = input.expect_ident()?;
|
||||
match_ignore_ascii_case! { &ident,
|
||||
|
@ -77,6 +81,7 @@ mod gecko {
|
|||
// Standard values:
|
||||
Color::CurrentColor => CSSParserColor::CurrentColor.to_css(dest),
|
||||
Color::RGBA(rgba) => rgba.to_css(dest),
|
||||
Color::System(system) => system.to_css(dest),
|
||||
|
||||
// Non-standard values:
|
||||
Color::MozDefaultColor => dest.write_str("-moz-default-color"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue