mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add support for background-position in geckolib.
This commit is contained in:
parent
11ad48f8e3
commit
77e57aab5b
2 changed files with 58 additions and 2 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use gecko_bindings::structs::nsStyleCoord_CalcValue;
|
||||
use values::computed::CalcLengthOrPercentage;
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
|
||||
|
||||
impl From<CalcLengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: CalcLengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
|
@ -34,3 +34,35 @@ impl From<nsStyleCoord_CalcValue> for CalcLengthOrPercentage {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LengthOrPercentage> for nsStyleCoord_CalcValue {
|
||||
fn from(other: LengthOrPercentage) -> nsStyleCoord_CalcValue {
|
||||
match other {
|
||||
LengthOrPercentage::Length(au) => {
|
||||
nsStyleCoord_CalcValue {
|
||||
mLength: au.0,
|
||||
mPercent: 0.0,
|
||||
mHasPercent: false,
|
||||
}
|
||||
},
|
||||
LengthOrPercentage::Percentage(pc) => {
|
||||
nsStyleCoord_CalcValue {
|
||||
mLength: 0,
|
||||
mPercent: pc,
|
||||
mHasPercent: true,
|
||||
}
|
||||
},
|
||||
LengthOrPercentage::Calc(calc) => calc.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<nsStyleCoord_CalcValue> for LengthOrPercentage {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> LengthOrPercentage {
|
||||
match (other.mHasPercent, other.mLength) {
|
||||
(false, _) => LengthOrPercentage::Length(Au(other.mLength)),
|
||||
(true, 0) => LengthOrPercentage::Percentage(other.mPercent),
|
||||
_ => LengthOrPercentage::Calc(other.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue