mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace LengthOrNone by a specific type for the perspective property
This was its only use, and it was bugged: AFAIK this didn't properly clamp animated values below 0.
This commit is contained in:
parent
4a98fa70bf
commit
260e05320c
11 changed files with 88 additions and 32 deletions
|
@ -24,6 +24,7 @@ use values::computed::{NonNegativeLength, NonNegativeLengthOrPercentage, NonNega
|
|||
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
|
||||
use values::generics::{CounterStyleOrNone, NonNegative};
|
||||
use values::generics::basic_shape::ShapeRadius;
|
||||
use values::generics::box_::Perspective;
|
||||
use values::generics::gecko::ScrollSnapPoint;
|
||||
use values::generics::grid::{TrackBreadth, TrackKeyword};
|
||||
|
||||
|
@ -422,6 +423,27 @@ impl GeckoStyleCoordConvertible for ScrollSnapPoint<LengthOrPercentage> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<L> GeckoStyleCoordConvertible for Perspective<L>
|
||||
where
|
||||
L: GeckoStyleCoordConvertible,
|
||||
{
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
Perspective::None => coord.set_value(CoordDataValue::None),
|
||||
Perspective::Length(ref l) => l.to_gecko_style_coord(coord),
|
||||
};
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
use gecko_bindings::structs::root::nsStyleUnit;
|
||||
|
||||
if coord.unit() == nsStyleUnit::eStyleUnit_None {
|
||||
return Some(Perspective::None);
|
||||
}
|
||||
Some(Perspective::Length(L::from_gecko_style_coord(coord)?))
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a given RGBA value to `nscolor`.
|
||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||
((rgba.alpha as u32) << 24) |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue