mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Allow calc() in GeckoStyleCoordConvertible
This commit is contained in:
parent
67bcb96cea
commit
8fddc46020
1 changed files with 16 additions and 6 deletions
|
@ -56,6 +56,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_auto(&mut self) {
|
fn set_auto(&mut self) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Auto;
|
self.mUnit = nsStyleUnit::eStyleUnit_Auto;
|
||||||
unsafe { *self.mValue.mInt.as_mut() = 0; }
|
unsafe { *self.mValue.mInt.as_mut() = 0; }
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_normal(&mut self) {
|
fn set_normal(&mut self) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Normal;
|
self.mUnit = nsStyleUnit::eStyleUnit_Normal;
|
||||||
unsafe { *self.mValue.mInt.as_mut() = 0; }
|
unsafe { *self.mValue.mInt.as_mut() = 0; }
|
||||||
}
|
}
|
||||||
|
@ -76,6 +78,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_coord(&mut self, val: Au) {
|
fn set_coord(&mut self, val: Au) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Coord;
|
self.mUnit = nsStyleUnit::eStyleUnit_Coord;
|
||||||
unsafe { *self.mValue.mInt.as_mut() = val.0; }
|
unsafe { *self.mValue.mInt.as_mut() = val.0; }
|
||||||
}
|
}
|
||||||
|
@ -91,6 +94,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_int(&mut self, val: i32) {
|
fn set_int(&mut self, val: i32) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Integer;
|
self.mUnit = nsStyleUnit::eStyleUnit_Integer;
|
||||||
unsafe { *self.mValue.mInt.as_mut() = val; }
|
unsafe { *self.mValue.mInt.as_mut() = val; }
|
||||||
}
|
}
|
||||||
|
@ -106,6 +110,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_enum(&mut self, val: i32) {
|
fn set_enum(&mut self, val: i32) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Enumerated;
|
self.mUnit = nsStyleUnit::eStyleUnit_Enumerated;
|
||||||
unsafe { *self.mValue.mInt.as_mut() = val; }
|
unsafe { *self.mValue.mInt.as_mut() = val; }
|
||||||
}
|
}
|
||||||
|
@ -121,6 +126,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_percent(&mut self, val: f32) {
|
fn set_percent(&mut self, val: f32) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Percent;
|
self.mUnit = nsStyleUnit::eStyleUnit_Percent;
|
||||||
unsafe { *self.mValue.mFloat.as_mut() = val; }
|
unsafe { *self.mValue.mFloat.as_mut() = val; }
|
||||||
}
|
}
|
||||||
|
@ -136,6 +142,7 @@ impl StyleCoordHelpers for nsStyleCoord {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn set_factor(&mut self, val: f32) {
|
fn set_factor(&mut self, val: f32) {
|
||||||
|
unsafe { self.mValue.reset(&mut self.mUnit)};
|
||||||
self.mUnit = nsStyleUnit::eStyleUnit_Factor;
|
self.mUnit = nsStyleUnit::eStyleUnit_Factor;
|
||||||
unsafe { *self.mValue.mFloat.as_mut() = val; }
|
unsafe { *self.mValue.mFloat.as_mut() = val; }
|
||||||
}
|
}
|
||||||
|
@ -157,6 +164,7 @@ pub trait GeckoStyleCoordConvertible : Sized {
|
||||||
|
|
||||||
impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||||
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
||||||
|
unsafe { union.reset(unit) };
|
||||||
match *self {
|
match *self {
|
||||||
LengthOrPercentage::Length(au) => {
|
LengthOrPercentage::Length(au) => {
|
||||||
*unit = nsStyleUnit::eStyleUnit_Coord;
|
*unit = nsStyleUnit::eStyleUnit_Coord;
|
||||||
|
@ -166,7 +174,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||||
*unit = nsStyleUnit::eStyleUnit_Percent;
|
*unit = nsStyleUnit::eStyleUnit_Percent;
|
||||||
unsafe { *union.mFloat.as_mut() = p; }
|
unsafe { *union.mFloat.as_mut() = p; }
|
||||||
},
|
},
|
||||||
LengthOrPercentage::Calc(_) => unimplemented!(),
|
LengthOrPercentage::Calc(calc) => unsafe {union.set_calc_value(unit, calc.into()) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +185,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||||
nsStyleUnit::eStyleUnit_Percent
|
nsStyleUnit::eStyleUnit_Percent
|
||||||
=> Some(LengthOrPercentage::Percentage(unsafe { *union.mFloat.as_ref() })),
|
=> Some(LengthOrPercentage::Percentage(unsafe { *union.mFloat.as_ref() })),
|
||||||
nsStyleUnit::eStyleUnit_Calc
|
nsStyleUnit::eStyleUnit_Calc
|
||||||
=> unimplemented!(),
|
=> Some(LengthOrPercentage::Calc(unsafe { union.get_calc().into()})),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,6 +193,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentage {
|
||||||
|
|
||||||
impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
||||||
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
||||||
|
unsafe { union.reset(unit) };
|
||||||
match *self {
|
match *self {
|
||||||
LengthOrPercentageOrAuto::Length(au) => {
|
LengthOrPercentageOrAuto::Length(au) => {
|
||||||
*unit = nsStyleUnit::eStyleUnit_Coord;
|
*unit = nsStyleUnit::eStyleUnit_Coord;
|
||||||
|
@ -198,7 +207,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
||||||
*unit = nsStyleUnit::eStyleUnit_Auto;
|
*unit = nsStyleUnit::eStyleUnit_Auto;
|
||||||
unsafe { *union.mInt.as_mut() = 0; }
|
unsafe { *union.mInt.as_mut() = 0; }
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrAuto::Calc(_) => unimplemented!(),
|
LengthOrPercentageOrAuto::Calc(calc) => unsafe {union.set_calc_value(unit, calc.into()) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +220,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
||||||
nsStyleUnit::eStyleUnit_Percent
|
nsStyleUnit::eStyleUnit_Percent
|
||||||
=> Some(LengthOrPercentageOrAuto::Percentage(unsafe { *union.mFloat.as_ref() })),
|
=> Some(LengthOrPercentageOrAuto::Percentage(unsafe { *union.mFloat.as_ref() })),
|
||||||
nsStyleUnit::eStyleUnit_Calc
|
nsStyleUnit::eStyleUnit_Calc
|
||||||
=> unimplemented!(),
|
=> Some(LengthOrPercentageOrAuto::Calc(unsafe { union.get_calc().into()})),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,6 +228,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
|
||||||
|
|
||||||
impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
||||||
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
||||||
|
unsafe { union.reset(unit) };
|
||||||
match *self {
|
match *self {
|
||||||
LengthOrPercentageOrNone::Length(au) => {
|
LengthOrPercentageOrNone::Length(au) => {
|
||||||
*unit = nsStyleUnit::eStyleUnit_Coord;
|
*unit = nsStyleUnit::eStyleUnit_Coord;
|
||||||
|
@ -232,7 +242,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
||||||
*unit = nsStyleUnit::eStyleUnit_None;
|
*unit = nsStyleUnit::eStyleUnit_None;
|
||||||
unsafe { *union.mInt.as_mut() = 0; }
|
unsafe { *union.mInt.as_mut() = 0; }
|
||||||
},
|
},
|
||||||
LengthOrPercentageOrNone::Calc(_) => unimplemented!(),
|
LengthOrPercentageOrNone::Calc(calc) => unsafe { union.set_calc_value(unit, calc.into()) },
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +255,7 @@ impl GeckoStyleCoordConvertible for LengthOrPercentageOrNone {
|
||||||
nsStyleUnit::eStyleUnit_Percent
|
nsStyleUnit::eStyleUnit_Percent
|
||||||
=> Some(LengthOrPercentageOrNone::Percentage(unsafe { *union.mFloat.as_ref() })),
|
=> Some(LengthOrPercentageOrNone::Percentage(unsafe { *union.mFloat.as_ref() })),
|
||||||
nsStyleUnit::eStyleUnit_Calc
|
nsStyleUnit::eStyleUnit_Calc
|
||||||
=> unimplemented!(),
|
=> Some(LengthOrPercentageOrNone::Calc(unsafe { union.get_calc().into()})),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue