mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Expand var() references in single_value_to_css
This is a temporary step needed to support Gecko's getKeyframes() API until we implement bug 1391537. It only takes effect when a ComputedValues object is supplied and only for longhand declarations.
This commit is contained in:
parent
87206bd68e
commit
4f53ca2e39
3 changed files with 33 additions and 7 deletions
|
@ -2562,7 +2562,9 @@ extern "C" {
|
|||
pub fn Servo_DeclarationBlock_SerializeOneValue(declarations:
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
property: nsCSSPropertyID,
|
||||
buffer: *mut nsAString);
|
||||
buffer: *mut nsAString,
|
||||
computed_values:
|
||||
ServoStyleContextBorrowedOrNull);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DeclarationBlock_Count(declarations:
|
||||
|
|
|
@ -518,13 +518,35 @@ impl PropertyDeclarationBlock {
|
|||
}
|
||||
|
||||
/// Take a declaration block known to contain a single property and serialize it.
|
||||
pub fn single_value_to_css<W>(&self, property: &PropertyId, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
pub fn single_value_to_css<W>(
|
||||
&self,
|
||||
property: &PropertyId,
|
||||
dest: &mut W,
|
||||
computed_values: Option<&ComputedValues>,
|
||||
) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
match property.as_shorthand() {
|
||||
Err(_longhand_or_custom) => {
|
||||
if self.declarations.len() == 1 {
|
||||
self.declarations[0].0.to_css(dest)
|
||||
let declaration = &self.declarations[0].0;
|
||||
// If we have a longhand declaration with variables, those variables will be
|
||||
// stored as unparsed values. As a temporary measure to produce sensible results
|
||||
// in Gecko's getKeyframes() implementation for CSS animations, if
|
||||
// |computed_values| is supplied, we use it to expand such variable
|
||||
// declarations. This will be fixed properly in Gecko bug 1391537.
|
||||
match (declaration, computed_values) {
|
||||
(&PropertyDeclaration::WithVariables(id, ref unparsed),
|
||||
Some(ref computed_values)) => unparsed
|
||||
.substitute_variables(
|
||||
id,
|
||||
&computed_values.custom_properties(),
|
||||
QuirksMode::NoQuirks,
|
||||
)
|
||||
.to_css(dest),
|
||||
(ref d, _) => d.to_css(dest),
|
||||
}
|
||||
} else {
|
||||
Err(fmt::Error)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue