mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Fix handling of all
shorthand with var() functions
This commit is contained in:
parent
42813bc813
commit
66c357feef
1 changed files with 11 additions and 42 deletions
|
@ -215,43 +215,6 @@ pub mod shorthands {
|
|||
<% data.declare_shorthand("all",
|
||||
[p.name for p in data.longhands if p.name not in ['direction', 'unicode-bidi']],
|
||||
spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand") %>
|
||||
pub mod all {
|
||||
use cssparser::Parser;
|
||||
use parser::ParserContext;
|
||||
use properties::{SourcePropertyDeclaration, AllShorthand, ShorthandId, UnparsedValue};
|
||||
use stylearc::Arc;
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
|
||||
pub fn parse_into<'i, 't>(declarations: &mut SourcePropertyDeclaration,
|
||||
context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<(), ParseError<'i>> {
|
||||
// This function is like the parse() that is generated by
|
||||
// helpers:shorthand, but since the only values for the 'all'
|
||||
// shorthand when not just a single CSS-wide keyword is one
|
||||
// with variable references, we can make this function a
|
||||
// little simpler.
|
||||
//
|
||||
// FIXME(heycam) Try to share code with the helpers:shorthand
|
||||
// definition.
|
||||
input.look_for_var_functions();
|
||||
let start = input.position();
|
||||
while let Ok(_) = input.next() {} // Look for var()
|
||||
if input.seen_var_functions() {
|
||||
input.reset(start);
|
||||
let (first_token_type, css) =
|
||||
::custom_properties::parse_non_custom_with_var(input)?;
|
||||
declarations.all_shorthand = AllShorthand::WithVariables(Arc::new(UnparsedValue {
|
||||
css: css.into_owned(),
|
||||
first_token_type: first_token_type,
|
||||
url_data: context.url_data.clone(),
|
||||
from_shorthand: Some(ShorthandId::All),
|
||||
}));
|
||||
Ok(())
|
||||
} else {
|
||||
Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A module with all the code related to animated properties.
|
||||
|
@ -863,11 +826,13 @@ impl ShorthandId {
|
|||
context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<(), ParseError<'i>> {
|
||||
match *self {
|
||||
% for shorthand in data.shorthands:
|
||||
% for shorthand in data.shorthands_except_all():
|
||||
ShorthandId::${shorthand.camel_case} => {
|
||||
shorthands::${shorthand.ident}::parse_into(declarations, context, input)
|
||||
}
|
||||
% endfor
|
||||
// 'all' accepts no value other than CSS-wide keywords
|
||||
ShorthandId::All => Err(StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1603,10 +1568,14 @@ impl PropertyDeclaration {
|
|||
url_data: context.url_data.clone(),
|
||||
from_shorthand: Some(id),
|
||||
});
|
||||
for &longhand in id.longhands() {
|
||||
declarations.push(
|
||||
PropertyDeclaration::WithVariables(longhand, unparsed.clone())
|
||||
)
|
||||
if id == ShorthandId::All {
|
||||
declarations.all_shorthand = AllShorthand::WithVariables(unparsed)
|
||||
} else {
|
||||
for &longhand in id.longhands() {
|
||||
declarations.push(
|
||||
PropertyDeclaration::WithVariables(longhand, unparsed.clone())
|
||||
)
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue