Skip to content

Commit

Permalink
Auto merge of #16780 - canaltinova:shorthand-aliases, r=emilio
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo committed May 9, 2017
2 parents 8bc20ee + 936fa7c commit 121662a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/style/properties/declaration_block.rs
Expand Up @@ -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,
Expand Down
15 changes: 11 additions & 4 deletions components/style/properties/properties.mako.rs
Expand Up @@ -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,
}
}

Expand Down Expand Up @@ -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)?,
_ => {},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/shorthand/box.mako.rs
Expand Up @@ -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;

Expand Down

0 comments on commit 121662a

Please sign in to comment.