mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Move LengthOrNumber to style/values and implement GeckoStyleCoordConvertible
This commit is contained in:
parent
9a2ef2e6ef
commit
7720fe4d9c
7 changed files with 131 additions and 90 deletions
|
@ -10,8 +10,8 @@ use gecko_bindings::structs::{NS_RADIUS_CLOSEST_SIDE, NS_RADIUS_FARTHEST_SIDE};
|
|||
use gecko_bindings::structs::nsStyleCoord;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataValue};
|
||||
use std::cmp::max;
|
||||
use values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use values::computed::Angle;
|
||||
use values::computed::{LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{LengthOrPercentageOrNone, Angle};
|
||||
use values::computed::basic_shape::ShapeRadius;
|
||||
|
||||
pub trait StyleCoordHelpers {
|
||||
|
@ -108,6 +108,24 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
|||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for LengthOrNumber {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
let value = match *self {
|
||||
LengthOrNumber::Length(au) => CoordDataValue::Coord(au.0),
|
||||
LengthOrNumber::Number(number) => CoordDataValue::Factor(number),
|
||||
};
|
||||
coord.set_value(value);
|
||||
}
|
||||
|
||||
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
|
||||
match coord.as_value() {
|
||||
CoordDataValue::Coord(coord) => Some(LengthOrNumber::Length(Au(coord))),
|
||||
CoordDataValue::Factor(f) => Some(LengthOrNumber::Number(f)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GeckoStyleCoordConvertible for ShapeRadius {
|
||||
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
|
||||
match *self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue