mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Support max-{width,height} in geckolib.
This commit is contained in:
parent
04f976bfb2
commit
84ef0de160
2 changed files with 22 additions and 1 deletions
|
@ -362,6 +362,7 @@ impl Debug for ${style_struct.gecko_ffi_name} {
|
||||||
predefined_types = {
|
predefined_types = {
|
||||||
"LengthOrPercentage": impl_style_coord,
|
"LengthOrPercentage": impl_style_coord,
|
||||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||||
|
"LengthOrPercentageOrNone": impl_style_coord,
|
||||||
"Number": impl_simple,
|
"Number": impl_simple,
|
||||||
"Opacity": impl_simple,
|
"Opacity": impl_simple,
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use cssparser::RGBA;
|
use cssparser::RGBA;
|
||||||
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
|
use gecko_style_structs::{nsStyleUnion, nsStyleUnit};
|
||||||
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||||
|
|
||||||
pub trait ToGeckoStyleCoord {
|
pub trait ToGeckoStyleCoord {
|
||||||
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion);
|
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion);
|
||||||
|
@ -46,6 +46,26 @@ impl ToGeckoStyleCoord for LengthOrPercentageOrAuto {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToGeckoStyleCoord for LengthOrPercentageOrNone {
|
||||||
|
fn to_gecko_style_coord(&self, unit: &mut nsStyleUnit, union: &mut nsStyleUnion) {
|
||||||
|
match *self {
|
||||||
|
LengthOrPercentageOrNone::Length(au) => {
|
||||||
|
*unit = nsStyleUnit::eStyleUnit_Coord;
|
||||||
|
unsafe { *union.mInt.as_mut() = au.0; }
|
||||||
|
},
|
||||||
|
LengthOrPercentageOrNone::Percentage(p) => {
|
||||||
|
*unit = nsStyleUnit::eStyleUnit_Percent;
|
||||||
|
unsafe { *union.mFloat.as_mut() = p; }
|
||||||
|
},
|
||||||
|
LengthOrPercentageOrNone::None => {
|
||||||
|
*unit = nsStyleUnit::eStyleUnit_None;
|
||||||
|
unsafe { *union.mInt.as_mut() = 0; }
|
||||||
|
},
|
||||||
|
LengthOrPercentageOrNone::Calc(_) => unimplemented!(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
pub fn convert_rgba_to_nscolor(rgba: &RGBA) -> u32 {
|
||||||
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
(((rgba.alpha * 255.0).round() as u32) << 24) |
|
||||||
(((rgba.blue * 255.0).round() as u32) << 16) |
|
(((rgba.blue * 255.0).round() as u32) << 16) |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue