mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
stylo: support background-size
This commit is contained in:
parent
f787e8ed65
commit
04c5d05727
3 changed files with 107 additions and 2 deletions
|
@ -14,7 +14,7 @@ use gecko_bindings::structs::nsStyleCoord_CalcValue;
|
|||
use gecko_bindings::sugar::refptr::HasArcFFI;
|
||||
use properties::ComputedValues;
|
||||
use stylesheets::Stylesheet;
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
|
||||
unsafe impl HasArcFFI for Stylesheet {
|
||||
type FFIType = RawServoStyleSheet;
|
||||
|
@ -70,6 +70,29 @@ impl From<LengthOrPercentage> for nsStyleCoord_CalcValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl LengthOrPercentageOrAuto {
|
||||
pub fn to_calc_value(&self) -> Option<nsStyleCoord_CalcValue> {
|
||||
match *self {
|
||||
LengthOrPercentageOrAuto::Length(au) => {
|
||||
Some(nsStyleCoord_CalcValue {
|
||||
mLength: au.0,
|
||||
mPercent: 0.0,
|
||||
mHasPercent: false,
|
||||
})
|
||||
},
|
||||
LengthOrPercentageOrAuto::Percentage(pc) => {
|
||||
Some(nsStyleCoord_CalcValue {
|
||||
mLength: 0,
|
||||
mPercent: pc,
|
||||
mHasPercent: true,
|
||||
})
|
||||
},
|
||||
LengthOrPercentageOrAuto::Calc(calc) => Some(calc.into()),
|
||||
LengthOrPercentageOrAuto::Auto => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<nsStyleCoord_CalcValue> for LengthOrPercentage {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> LengthOrPercentage {
|
||||
match (other.mHasPercent, other.mLength) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue