mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #16780 - canaltinova:shorthand-aliases, r=emilio
Add comments to shorthand alias logic that explains the interesting bahavior <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because they are just comments and variable name change. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16780) <!-- Reviewable:end -->
This commit is contained in:
commit
121662aa57
3 changed files with 13 additions and 6 deletions
|
@ -482,7 +482,7 @@ impl ToCss for PropertyDeclarationBlock {
|
|||
// Substeps 7 and 8
|
||||
// We need to check the shorthand whether it's an alias property or not.
|
||||
// If it's an alias property, it should be serialized like its longhand.
|
||||
if shorthand.flags().contains(ALIAS_PROPERTY) {
|
||||
if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) {
|
||||
append_serialization::<_, Cloned<slice::Iter< _>>, _>(
|
||||
dest,
|
||||
&property,
|
||||
|
|
|
@ -484,8 +484,8 @@ bitflags! {
|
|||
/// This property has values that can establish a containing block for
|
||||
/// absolutely positioned elements.
|
||||
const ABSPOS_CB = 1 << 2,
|
||||
/// This property(shorthand) is an alias of another property.
|
||||
const ALIAS_PROPERTY = 1 << 3,
|
||||
/// This shorthand property is an alias of another property.
|
||||
const SHORTHAND_ALIAS_PROPERTY = 1 << 3,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1263,7 +1263,10 @@ impl ToCss for PropertyDeclaration {
|
|||
PropertyDeclaration::WithVariables(_, ref with_variables) => {
|
||||
// https://drafts.csswg.org/css-variables/#variables-in-shorthands
|
||||
match with_variables.from_shorthand {
|
||||
Some(shorthand) if shorthand.flags().contains(ALIAS_PROPERTY) =>
|
||||
// Normally, we shouldn't be printing variables here if they came from
|
||||
// shorthands. But we should allow properties that came from shorthand
|
||||
// aliases. That also matches with the Gecko behavior.
|
||||
Some(shorthand) if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) =>
|
||||
dest.write_str(&*with_variables.css)?,
|
||||
None => dest.write_str(&*with_variables.css)?,
|
||||
_ => {},
|
||||
|
@ -1345,7 +1348,11 @@ impl PropertyDeclaration {
|
|||
Some(&*with_variables.css)
|
||||
} else { None }
|
||||
} else {
|
||||
if shorthand.flags().contains(ALIAS_PROPERTY) {
|
||||
// Normally, longhand property that doesn't come from a shorthand
|
||||
// should return None here. But we return Some to longhands if they
|
||||
// came from a shorthand alias. Because for example, we should be able to
|
||||
// get -moz-transform's value from transform.
|
||||
if shorthand.flags().contains(SHORTHAND_ALIAS_PROPERTY) {
|
||||
return Some(&*with_variables.css);
|
||||
}
|
||||
None
|
||||
|
|
|
@ -327,7 +327,7 @@ macro_rules! try_parse_one {
|
|||
|
||||
<%helpers:shorthand name="-moz-transform" products="gecko"
|
||||
sub_properties="transform"
|
||||
flags="ALIAS_PROPERTY"
|
||||
flags="SHORTHAND_ALIAS_PROPERTY"
|
||||
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
|
||||
use properties::longhands::transform;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue