mirror of
https://github.com/servo/servo.git
synced 2025-08-12 00:45:33 +01:00
style: Serialize a bunch of image properties with Servo.
I had to fix the conversion for BackgroundSize too, hopefully we can simplify all this using cbindgen in the future instead of CalcValue. Differential Revision: https://phabricator.services.mozilla.com/D7580
This commit is contained in:
parent
0d5d5a9c82
commit
7345af613a
4 changed files with 63 additions and 19 deletions
|
@ -17,7 +17,7 @@ use gecko_bindings::sugar::ns_style_coord::{CoordData, CoordDataMut, CoordDataVa
|
|||
use std::f32::consts::PI;
|
||||
use stylesheets::{Origin, RulesMutateError};
|
||||
use values::computed::{Angle, CalcLengthOrPercentage, Gradient, Image};
|
||||
use values::computed::{Integer, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
use values::computed::{Integer, LengthOrPercentage, LengthOrPercentageOrAuto, NonNegativeLengthOrPercentageOrAuto};
|
||||
use values::computed::{Percentage, TextAlign};
|
||||
use values::computed::image::LineDirection;
|
||||
use values::computed::url::ComputedImageUrl;
|
||||
|
@ -106,6 +106,26 @@ impl From<nsStyleCoord_CalcValue> for LengthOrPercentageOrAuto {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(emilio): A lot of these impl From should probably become explicit or
|
||||
// disappear as we move more stuff to cbindgen.
|
||||
impl From<nsStyleCoord_CalcValue> for NonNegativeLengthOrPercentageOrAuto {
|
||||
fn from(other: nsStyleCoord_CalcValue) -> Self {
|
||||
use values::generics::NonNegative;
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
NonNegative(if other.mLength < 0 || other.mPercent < 0. {
|
||||
LengthOrPercentageOrAuto::Calc(
|
||||
CalcLengthOrPercentage::with_clamping_mode(
|
||||
Au(other.mLength).into(),
|
||||
if other.mHasPercent { Some(Percentage(other.mPercent)) } else { None },
|
||||
AllowedNumericType::NonNegative,
|
||||
)
|
||||
)
|
||||
} else {
|
||||
other.into()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Angle> for CoordDataValue {
|
||||
fn from(reference: Angle) -> Self {
|
||||
match reference {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue