stylo: Don't serialize default position on -moz- prefixed linear gradient

Normally, we should not serialize if the line direction points downwards. Unprefixed and
-webkit- prefixed syntaxes use only Keyword enum for line direction and we check them already.
But -moz- prefixed linear gradients can store position too. Therefore it's stored inside
`LineDirection::MozPosition` and we should check that for consistency between other gradients.
This commit is contained in:
Nazım Can Altınova 2017-09-28 22:26:25 +03:00
parent 056c085119
commit dfd12d78c6
2 changed files with 35 additions and 1 deletions

View file

@ -626,6 +626,32 @@ impl GenericsLineDirection for LineDirection {
if compat_mode == CompatMode::Modern => true,
LineDirection::Vertical(Y::Top)
if compat_mode != CompatMode::Modern => true,
#[cfg(feature = "gecko")]
LineDirection::MozPosition(Some(LegacyPosition {
horizontal: ref x,
vertical: ref y,
}), None) => {
use values::computed::Percentage as ComputedPercentage;
use values::specified::transform::OriginComponent;
// `50% 0%` is the default value for line direction.
// These percentage values can also be keywords.
let x = match *x {
OriginComponent::Center => true,
OriginComponent::Length(LengthOrPercentage::Percentage(ComputedPercentage(val))) => {
val == 0.5
},
_ => false,
};
let y = match *y {
OriginComponent::Side(Y::Top) => true,
OriginComponent::Length(LengthOrPercentage::Percentage(ComputedPercentage(val))) => {
val == 0.0
},
_ => false,
};
x && y
},
_ => false,
}
}