mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Unbox a bunch of color properties.
This builds on https://github.com/servo/rust-cssparser/pull/118.
This commit is contained in:
parent
e394334739
commit
0c102e2350
37 changed files with 185 additions and 195 deletions
|
@ -510,18 +510,21 @@ impl Interpolate for RGBA {
|
|||
val.max(0.).min(1.)
|
||||
}
|
||||
|
||||
let alpha = clamp(try!(self.alpha.interpolate(&other.alpha, progress)));
|
||||
let alpha = clamp(try!(self.alpha_f32().interpolate(&other.alpha_f32(), progress)));
|
||||
if alpha == 0. {
|
||||
Ok(RGBA { red: 0., green: 0., blue: 0., alpha: 0. })
|
||||
Ok(RGBA::transparent())
|
||||
} else {
|
||||
Ok(RGBA { red: clamp(try!((self.red * self.alpha).interpolate(&(other.red * other.alpha), progress))
|
||||
* 1. / alpha),
|
||||
green: clamp(try!((self.green * self.alpha).interpolate(&(other.green * other.alpha), progress))
|
||||
* 1. / alpha),
|
||||
blue: clamp(try!((self.blue * self.alpha).interpolate(&(other.blue * other.alpha), progress))
|
||||
* 1. / alpha),
|
||||
alpha: alpha
|
||||
})
|
||||
// NB: We rely on RGBA::from_floats clamping already.
|
||||
let red = try!((self.red_f32() * self.alpha_f32())
|
||||
.interpolate(&(other.red_f32() * other.alpha_f32()), progress))
|
||||
* 1. / alpha;
|
||||
let green = try!((self.green_f32() * self.alpha_f32())
|
||||
.interpolate(&(other.green_f32() * other.alpha_f32()), progress))
|
||||
* 1. / alpha;
|
||||
let blue = try!((self.blue_f32() * self.alpha_f32())
|
||||
.interpolate(&(other.blue_f32() * other.alpha_f32()), progress))
|
||||
* 1. / alpha;
|
||||
Ok(RGBA::from_floats(red, green, blue, alpha))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -756,9 +759,7 @@ impl Interpolate for TextShadowList {
|
|||
offset_x: Au(0),
|
||||
offset_y: Au(0),
|
||||
blur_radius: Au(0),
|
||||
color: CSSParserColor::RGBA(RGBA {
|
||||
red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0
|
||||
})
|
||||
color: CSSParserColor::RGBA(RGBA::transparent()),
|
||||
};
|
||||
|
||||
let max_len = cmp::max(self.0.len(), other.0.len());
|
||||
|
@ -793,9 +794,7 @@ impl Interpolate for BoxShadowList {
|
|||
offset_y: Au(0),
|
||||
spread_radius: Au(0),
|
||||
blur_radius: Au(0),
|
||||
color: CSSParserColor::RGBA(RGBA {
|
||||
red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0
|
||||
}),
|
||||
color: CSSParserColor::RGBA(RGBA::transparent()),
|
||||
inset: false,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue