mirror of
https://github.com/servo/servo.git
synced 2025-06-21 07:38:59 +01:00
Properly set default direction of prefixed linear gradients
The default linear gradient direction is `to bottom`. This correspondes to `top` keyword in prefixed linear gradients. We should preserve the default value.
This commit is contained in:
parent
19cbea23a8
commit
a0c1eb5109
3 changed files with 17 additions and 7 deletions
|
@ -78,10 +78,13 @@ pub type ColorStop = GenericColorStop<RGBA, LengthOrPercentage>;
|
||||||
pub type MozImageRect = GenericMozImageRect<NumberOrPercentage, ComputedUrl>;
|
pub type MozImageRect = GenericMozImageRect<NumberOrPercentage, ComputedUrl>;
|
||||||
|
|
||||||
impl GenericLineDirection for LineDirection {
|
impl GenericLineDirection for LineDirection {
|
||||||
fn points_downwards(&self) -> bool {
|
fn points_downwards(&self, compat_mode: CompatMode) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
LineDirection::Angle(angle) => angle.radians() == PI,
|
LineDirection::Angle(angle) => angle.radians() == PI,
|
||||||
LineDirection::Vertical(Y::Bottom) => true,
|
LineDirection::Vertical(Y::Bottom)
|
||||||
|
if compat_mode == CompatMode::Modern => true,
|
||||||
|
LineDirection::Vertical(Y::Top)
|
||||||
|
if compat_mode != CompatMode::Modern => true,
|
||||||
LineDirection::Corner(..) => false,
|
LineDirection::Corner(..) => false,
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
LineDirection::MozPosition(_, _) => false,
|
LineDirection::MozPosition(_, _) => false,
|
||||||
|
|
|
@ -230,7 +230,8 @@ impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
|
||||||
dest.write_str(self.kind.label())?;
|
dest.write_str(self.kind.label())?;
|
||||||
dest.write_str("-gradient(")?;
|
dest.write_str("-gradient(")?;
|
||||||
let mut skip_comma = match self.kind {
|
let mut skip_comma = match self.kind {
|
||||||
GradientKind::Linear(ref direction) if direction.points_downwards() => true,
|
GradientKind::Linear(ref direction)
|
||||||
|
if direction.points_downwards(self.compat_mode) => true,
|
||||||
GradientKind::Linear(ref direction) => {
|
GradientKind::Linear(ref direction) => {
|
||||||
direction.to_css(dest, self.compat_mode)?;
|
direction.to_css(dest, self.compat_mode)?;
|
||||||
false
|
false
|
||||||
|
@ -287,7 +288,7 @@ impl<D, L, LoP, P, A> GradientKind<D, L, LoP, P, A> {
|
||||||
/// The direction of a linear gradient.
|
/// The direction of a linear gradient.
|
||||||
pub trait LineDirection {
|
pub trait LineDirection {
|
||||||
/// Whether this direction points towards, and thus can be omitted.
|
/// Whether this direction points towards, and thus can be omitted.
|
||||||
fn points_downwards(&self) -> bool;
|
fn points_downwards(&self, compat_mode: CompatMode) -> bool;
|
||||||
|
|
||||||
/// Serialises this direction according to the compatibility mode.
|
/// Serialises this direction according to the compatibility mode.
|
||||||
fn to_css<W>(&self, dest: &mut W, compat_mode: CompatMode) -> fmt::Result
|
fn to_css<W>(&self, dest: &mut W, compat_mode: CompatMode) -> fmt::Result
|
||||||
|
|
|
@ -526,7 +526,10 @@ impl GradientKind {
|
||||||
input.expect_comma()?;
|
input.expect_comma()?;
|
||||||
d
|
d
|
||||||
} else {
|
} else {
|
||||||
LineDirection::Vertical(Y::Bottom)
|
match *compat_mode {
|
||||||
|
CompatMode::Modern => LineDirection::Vertical(Y::Bottom),
|
||||||
|
_ => LineDirection::Vertical(Y::Top),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
Ok(GenericGradientKind::Linear(direction))
|
Ok(GenericGradientKind::Linear(direction))
|
||||||
}
|
}
|
||||||
|
@ -615,10 +618,13 @@ impl GradientKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GenericsLineDirection for LineDirection {
|
impl GenericsLineDirection for LineDirection {
|
||||||
fn points_downwards(&self) -> bool {
|
fn points_downwards(&self, compat_mode: CompatMode) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
LineDirection::Angle(ref angle) => angle.radians() == PI,
|
LineDirection::Angle(ref angle) => angle.radians() == PI,
|
||||||
LineDirection::Vertical(Y::Bottom) => true,
|
LineDirection::Vertical(Y::Bottom)
|
||||||
|
if compat_mode == CompatMode::Modern => true,
|
||||||
|
LineDirection::Vertical(Y::Top)
|
||||||
|
if compat_mode != CompatMode::Modern => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue