mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Change LengthOrPercentage to make use of NoCalcLength
This commit is contained in:
parent
377a23df50
commit
590c9579f0
10 changed files with 61 additions and 60 deletions
|
@ -454,18 +454,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
font_family)])))));
|
font_family)])))));
|
||||||
}
|
}
|
||||||
|
|
||||||
let font_size = if let Some(this) = self.downcast::<HTMLFontElement>() {
|
let font_size = self.downcast::<HTMLFontElement>().and_then(|this| this.get_size());
|
||||||
this.get_size()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(font_size) = font_size {
|
if let Some(font_size) = font_size {
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
PropertyDeclaration::FontSize(
|
PropertyDeclaration::FontSize(
|
||||||
DeclaredValue::Value(
|
DeclaredValue::Value(
|
||||||
font_size::SpecifiedValue(
|
font_size::SpecifiedValue(font_size.into())))))
|
||||||
LengthOrPercentage::Length(font_size))))))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() {
|
let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() {
|
||||||
|
|
|
@ -236,8 +236,7 @@ impl MediaExpressionValue {
|
||||||
nsMediaFeature_ValueType::eLength => {
|
nsMediaFeature_ValueType::eLength => {
|
||||||
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
|
debug_assert!(css_value.mUnit == nsCSSUnit::eCSSUnit_Pixel);
|
||||||
let pixels = css_value.float_unchecked();
|
let pixels = css_value.float_unchecked();
|
||||||
Some(MediaExpressionValue::Length(
|
Some(MediaExpressionValue::Length(specified::Length::from_px(pixels)))
|
||||||
specified::Length::Absolute(Au::from_f32_px(pixels))))
|
|
||||||
}
|
}
|
||||||
nsMediaFeature_ValueType::eInteger => {
|
nsMediaFeature_ValueType::eInteger => {
|
||||||
let i = css_value.integer_unchecked();
|
let i = css_value.integer_unchecked();
|
||||||
|
|
|
@ -1761,7 +1761,7 @@ ${helpers.single_keyword("transform-style",
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use values::HasViewportPercentage;
|
use values::HasViewportPercentage;
|
||||||
use values::specified::{Length, LengthOrPercentage, Percentage};
|
use values::specified::{NoCalcLength, LengthOrPercentage, Percentage};
|
||||||
|
|
||||||
pub mod computed_value {
|
pub mod computed_value {
|
||||||
use properties::animated_properties::Interpolate;
|
use properties::animated_properties::Interpolate;
|
||||||
|
@ -1799,7 +1799,7 @@ ${helpers.single_keyword("transform-style",
|
||||||
pub struct SpecifiedValue {
|
pub struct SpecifiedValue {
|
||||||
horizontal: LengthOrPercentage,
|
horizontal: LengthOrPercentage,
|
||||||
vertical: LengthOrPercentage,
|
vertical: LengthOrPercentage,
|
||||||
depth: Length,
|
depth: NoCalcLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToCss for computed_value::T {
|
impl ToCss for computed_value::T {
|
||||||
|
@ -1836,7 +1836,7 @@ ${helpers.single_keyword("transform-style",
|
||||||
Ok(SpecifiedValue {
|
Ok(SpecifiedValue {
|
||||||
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
horizontal: result.horizontal.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||||
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
vertical: result.vertical.unwrap_or(LengthOrPercentage::Percentage(Percentage(0.5))),
|
||||||
depth: result.depth.unwrap_or(Length::zero()),
|
depth: result.depth.unwrap_or(NoCalcLength::zero()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -613,7 +613,7 @@ ${helpers.predefined_type("opacity",
|
||||||
pub struct OriginParseResult {
|
pub struct OriginParseResult {
|
||||||
pub horizontal: Option<specified::LengthOrPercentage>,
|
pub horizontal: Option<specified::LengthOrPercentage>,
|
||||||
pub vertical: Option<specified::LengthOrPercentage>,
|
pub vertical: Option<specified::LengthOrPercentage>,
|
||||||
pub depth: Option<specified::Length>
|
pub depth: Option<specified::NoCalcLength>
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<OriginParseResult,()> {
|
pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<OriginParseResult,()> {
|
||||||
|
|
|
@ -363,10 +363,10 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
LengthOrPercentage::Length(Length::NoCalc(NoCalcLength::FontRelative(value))) => {
|
LengthOrPercentage::Length(NoCalcLength::FontRelative(value)) => {
|
||||||
value.to_computed_value(context, /* use inherited */ true)
|
value.to_computed_value(context, /* use inherited */ true)
|
||||||
}
|
}
|
||||||
LengthOrPercentage::Length(Length::NoCalc(NoCalcLength::ServoCharacterWidth(value))) => {
|
LengthOrPercentage::Length(NoCalcLength::ServoCharacterWidth(value)) => {
|
||||||
value.to_computed_value(context.inherited_style().get_font().clone_font_size())
|
value.to_computed_value(context.inherited_style().get_font().clone_font_size())
|
||||||
}
|
}
|
||||||
LengthOrPercentage::Length(ref l) => {
|
LengthOrPercentage::Length(ref l) => {
|
||||||
|
@ -397,11 +397,10 @@ ${helpers.single_keyword("font-variant-caps",
|
||||||
input.try(specified::LengthOrPercentage::parse_non_negative)
|
input.try(specified::LengthOrPercentage::parse_non_negative)
|
||||||
.or_else(|()| {
|
.or_else(|()| {
|
||||||
let ident = try!(input.expect_ident());
|
let ident = try!(input.expect_ident());
|
||||||
specified::Length::from_str(&ident as &str)
|
NoCalcLength::from_str(&ident as &str)
|
||||||
.ok_or(())
|
.ok_or(())
|
||||||
.map(specified::LengthOrPercentage::Length)
|
.map(specified::LengthOrPercentage::Length)
|
||||||
})
|
}).map(SpecifiedValue)
|
||||||
.map(SpecifiedValue)
|
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,6 @@
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
use values::specified::{BorderWidth, Length};
|
use values::specified::{BorderWidth, Length};
|
||||||
use app_units::Au;
|
|
||||||
|
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut width = None;
|
let mut width = None;
|
||||||
|
|
|
@ -299,7 +299,6 @@ impl ToComputedValue for InsetRect {
|
||||||
/// the keywords are folded into the percentages
|
/// the keywords are folded into the percentages
|
||||||
fn serialize_basicshape_position<W>(position: &Position, dest: &mut W)
|
fn serialize_basicshape_position<W>(position: &Position, dest: &mut W)
|
||||||
-> fmt::Result where W: fmt::Write {
|
-> fmt::Result where W: fmt::Write {
|
||||||
use values::specified::Length;
|
|
||||||
use values::specified::position::Keyword;
|
use values::specified::position::Keyword;
|
||||||
|
|
||||||
// keyword-percentage pairs can be folded into a single percentage
|
// keyword-percentage pairs can be folded into a single percentage
|
||||||
|
@ -327,7 +326,7 @@ fn serialize_basicshape_position<W>(position: &Position, dest: &mut W)
|
||||||
// 0 length should be replaced with 0%
|
// 0 length should be replaced with 0%
|
||||||
fn replace_with_percent(input: LengthOrPercentage) -> LengthOrPercentage {
|
fn replace_with_percent(input: LengthOrPercentage) -> LengthOrPercentage {
|
||||||
match input {
|
match input {
|
||||||
LengthOrPercentage::Length(ref l) if l == &Length::zero() => {
|
LengthOrPercentage::Length(ref l) if l.is_zero() => {
|
||||||
LengthOrPercentage::Percentage(Percentage(0.0))
|
LengthOrPercentage::Percentage(Percentage(0.0))
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -323,7 +323,13 @@ impl NoCalcLength {
|
||||||
NoCalcLength::Absolute(Au(0))
|
NoCalcLength::Absolute(Au(0))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an absolute length from a px values.
|
#[inline]
|
||||||
|
/// Checks whether the length value is zero.
|
||||||
|
pub fn is_zero(&self) -> bool {
|
||||||
|
*self == NoCalcLength::Absolute(Au(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get an absolute length from a px value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_px(px_value: CSSFloat) -> NoCalcLength {
|
pub fn from_px(px_value: CSSFloat) -> NoCalcLength {
|
||||||
NoCalcLength::Absolute(Au((px_value * AU_PER_PX) as i32))
|
NoCalcLength::Absolute(Au((px_value * AU_PER_PX) as i32))
|
||||||
|
@ -337,7 +343,7 @@ impl NoCalcLength {
|
||||||
#[derive(Clone, PartialEq, Debug)]
|
#[derive(Clone, PartialEq, Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub enum Length {
|
pub enum Length {
|
||||||
/// The `NoCalcLength` type that cannot parse `calc`
|
/// The internal length type that cannot parse `calc`
|
||||||
NoCalc(NoCalcLength),
|
NoCalc(NoCalcLength),
|
||||||
/// A calc expression.
|
/// A calc expression.
|
||||||
///
|
///
|
||||||
|
@ -428,8 +434,7 @@ impl Length {
|
||||||
match try!(input.next()) {
|
match try!(input.next()) {
|
||||||
Token::Dimension(ref value, ref unit) if context.is_ok(value.value) =>
|
Token::Dimension(ref value, ref unit) if context.is_ok(value.value) =>
|
||||||
Length::parse_dimension(value.value, unit),
|
Length::parse_dimension(value.value, unit),
|
||||||
Token::Number(ref value) if value.value == 0. =>
|
Token::Number(ref value) if value.value == 0. => Ok(Length::zero()),
|
||||||
Ok(Length::zero()),
|
|
||||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") =>
|
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") =>
|
||||||
input.parse_nested_block(|input| {
|
input.parse_nested_block(|input| {
|
||||||
CalcLengthOrPercentage::parse_length(input, context)
|
CalcLengthOrPercentage::parse_length(input, context)
|
||||||
|
@ -443,7 +448,7 @@ impl Length {
|
||||||
Length::parse_internal(input, AllowedNumericType::NonNegative)
|
Length::parse_internal(input, AllowedNumericType::NonNegative)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get an absolute length from a px values.
|
/// Get an absolute length from a px value.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_px(px_value: CSSFloat) -> Length {
|
pub fn from_px(px_value: CSSFloat) -> Length {
|
||||||
Length::NoCalc(NoCalcLength::from_px(px_value))
|
Length::NoCalc(NoCalcLength::from_px(px_value))
|
||||||
|
@ -490,7 +495,7 @@ pub struct CalcProductNode {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum CalcValueNode {
|
pub enum CalcValueNode {
|
||||||
Length(LengthInternal),
|
Length(NoCalcLength),
|
||||||
Angle(Angle),
|
Angle(Angle),
|
||||||
Time(Time),
|
Time(Time),
|
||||||
Percentage(CSSFloat),
|
Percentage(CSSFloat),
|
||||||
|
@ -583,7 +588,7 @@ impl CalcLengthOrPercentage {
|
||||||
(Token::Number(ref value), _) => Ok(CalcValueNode::Number(value.value)),
|
(Token::Number(ref value), _) => Ok(CalcValueNode::Number(value.value)),
|
||||||
(Token::Dimension(ref value, ref unit), CalcUnit::Length) |
|
(Token::Dimension(ref value, ref unit), CalcUnit::Length) |
|
||||||
(Token::Dimension(ref value, ref unit), CalcUnit::LengthOrPercentage) => {
|
(Token::Dimension(ref value, ref unit), CalcUnit::LengthOrPercentage) => {
|
||||||
LengthInternal::parse_dimension(value.value, unit).map(CalcValueNode::Length)
|
NoCalcLength::parse_dimension(value.value, unit).map(CalcValueNode::Length)
|
||||||
}
|
}
|
||||||
(Token::Dimension(ref value, ref unit), CalcUnit::Angle) => {
|
(Token::Dimension(ref value, ref unit), CalcUnit::Angle) => {
|
||||||
Angle::parse_dimension(value.value, unit).map(CalcValueNode::Angle)
|
Angle::parse_dimension(value.value, unit).map(CalcValueNode::Angle)
|
||||||
|
@ -899,11 +904,20 @@ impl Parse for Percentage {
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum LengthOrPercentage {
|
pub enum LengthOrPercentage {
|
||||||
Length(Length),
|
Length(NoCalcLength),
|
||||||
Percentage(Percentage),
|
Percentage(Percentage),
|
||||||
Calc(Box<CalcLengthOrPercentage>),
|
Calc(Box<CalcLengthOrPercentage>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Length> for LengthOrPercentage {
|
||||||
|
fn from(len: Length) -> LengthOrPercentage {
|
||||||
|
match len {
|
||||||
|
Length::NoCalc(l) => LengthOrPercentage::Length(l),
|
||||||
|
Length::Calc(l, _) => LengthOrPercentage::Calc(l),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl HasViewportPercentage for LengthOrPercentage {
|
impl HasViewportPercentage for LengthOrPercentage {
|
||||||
fn has_viewport_percentage(&self) -> bool {
|
fn has_viewport_percentage(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
|
@ -924,10 +938,9 @@ impl ToCss for LengthOrPercentage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl LengthOrPercentage {
|
impl LengthOrPercentage {
|
||||||
#[inline]
|
|
||||||
/// Returns a `zero` length.
|
/// Returns a `zero` length.
|
||||||
pub fn zero() -> LengthOrPercentage {
|
pub fn zero() -> LengthOrPercentage {
|
||||||
LengthOrPercentage::Length(Length::zero())
|
LengthOrPercentage::Length(NoCalcLength::zero())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_internal(input: &mut Parser, context: AllowedNumericType)
|
fn parse_internal(input: &mut Parser, context: AllowedNumericType)
|
||||||
|
@ -935,11 +948,11 @@ impl LengthOrPercentage {
|
||||||
{
|
{
|
||||||
match try!(input.next()) {
|
match try!(input.next()) {
|
||||||
Token::Dimension(ref value, ref unit) if context.is_ok(value.value) =>
|
Token::Dimension(ref value, ref unit) if context.is_ok(value.value) =>
|
||||||
Length::parse_dimension(value.value, unit).map(LengthOrPercentage::Length),
|
NoCalcLength::parse_dimension(value.value, unit).map(LengthOrPercentage::Length),
|
||||||
Token::Percentage(ref value) if context.is_ok(value.unit_value) =>
|
Token::Percentage(ref value) if context.is_ok(value.unit_value) =>
|
||||||
Ok(LengthOrPercentage::Percentage(Percentage(value.unit_value))),
|
Ok(LengthOrPercentage::Percentage(Percentage(value.unit_value))),
|
||||||
Token::Number(ref value) if value.value == 0. =>
|
Token::Number(ref value) if value.value == 0. =>
|
||||||
Ok(LengthOrPercentage::Length(Length::zero())),
|
Ok(LengthOrPercentage::zero()),
|
||||||
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
|
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
|
||||||
let calc = try!(input.parse_nested_block(CalcLengthOrPercentage::parse_length_or_percentage));
|
let calc = try!(input.parse_nested_block(CalcLengthOrPercentage::parse_length_or_percentage));
|
||||||
Ok(LengthOrPercentage::Calc(Box::new(calc)))
|
Ok(LengthOrPercentage::Calc(Box::new(calc)))
|
||||||
|
|
|
@ -198,8 +198,8 @@ impl NoViewportPercentage for BorderRadiusSize {}
|
||||||
impl BorderRadiusSize {
|
impl BorderRadiusSize {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn zero() -> BorderRadiusSize {
|
pub fn zero() -> BorderRadiusSize {
|
||||||
let zero = LengthOrPercentage::Length(Length::default());
|
let zero = LengthOrPercentage::Length(NoCalcLength::zero());
|
||||||
BorderRadiusSize(Size2D::new(zero.clone(), zero))
|
BorderRadiusSize(Size2D::new(zero.clone(), zero))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
@ -292,11 +292,11 @@ pub fn parse_border_radius(context: &ParserContext, input: &mut Parser) -> Resul
|
||||||
input.try(|i| BorderRadiusSize::parse(context, i)).or_else(|_| {
|
input.try(|i| BorderRadiusSize::parse(context, i)).or_else(|_| {
|
||||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||||
"thin" => Ok(BorderRadiusSize::circle(
|
"thin" => Ok(BorderRadiusSize::circle(
|
||||||
LengthOrPercentage::Length(Length::from_px(1.)))),
|
LengthOrPercentage::Length(NoCalcLength::from_px(1.)))),
|
||||||
"medium" => Ok(BorderRadiusSize::circle(
|
"medium" => Ok(BorderRadiusSize::circle(
|
||||||
LengthOrPercentage::Length(Length::from_px(3.)))),
|
LengthOrPercentage::Length(NoCalcLength::from_px(3.)))),
|
||||||
"thick" => Ok(BorderRadiusSize::circle(
|
"thick" => Ok(BorderRadiusSize::circle(
|
||||||
LengthOrPercentage::Length(Length::from_px(5.)))),
|
LengthOrPercentage::Length(NoCalcLength::from_px(5.)))),
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -606,10 +606,7 @@ impl Shadow {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser, disable_spread_and_inset: bool) -> Result<Shadow, ()> {
|
pub fn parse(context: &ParserContext, input: &mut Parser, disable_spread_and_inset: bool) -> Result<Shadow, ()> {
|
||||||
let length_count = if disable_spread_and_inset { 3 } else { 4 };
|
let length_count = if disable_spread_and_inset { 3 } else { 4 };
|
||||||
let mut lengths = [Length::default(),
|
let mut lengths = [Length::zero(), Length::zero(), Length::zero(), Length::zero()];
|
||||||
Length::default(),
|
|
||||||
Length::default(),
|
|
||||||
Length::default()];
|
|
||||||
let mut lengths_parsed = false;
|
let mut lengths_parsed = false;
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut inset = false;
|
let mut inset = false;
|
||||||
|
@ -661,7 +658,7 @@ impl Shadow {
|
||||||
offset_x: lengths[0].take(),
|
offset_x: lengths[0].take(),
|
||||||
offset_y: lengths[1].take(),
|
offset_y: lengths[1].take(),
|
||||||
blur_radius: lengths[2].take(),
|
blur_radius: lengths[2].take(),
|
||||||
spread_radius: if disable_spread_and_inset { Length::default() } else { lengths[3].take() },
|
spread_radius: if disable_spread_and_inset { Length::zero() } else { lengths[3].take() },
|
||||||
color: color,
|
color: color,
|
||||||
inset: inset,
|
inset: inset,
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
pub use std::sync::Arc;
|
pub use std::sync::Arc;
|
||||||
pub use style::computed_values::display::T::inline_block;
|
pub use style::computed_values::display::T::inline_block;
|
||||||
pub use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance, PropertyId};
|
pub use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance, PropertyId};
|
||||||
pub use style::values::specified::{BorderStyle, BorderWidth, CSSColor, Length};
|
pub use style::values::specified::{BorderStyle, BorderWidth, CSSColor, Length, NoCalcLength};
|
||||||
pub use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
|
pub use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
|
||||||
pub use style::properties::longhands::outline_color::computed_value::T as ComputedColor;
|
pub use style::properties::longhands::outline_color::computed_value::T as ComputedColor;
|
||||||
pub use style::values::RGBA;
|
pub use style::values::RGBA;
|
||||||
|
@ -23,7 +23,7 @@ fn property_declaration_block_should_serialize_correctly() {
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
|
|
||||||
(PropertyDeclaration::MinHeight(
|
(PropertyDeclaration::MinHeight(
|
||||||
DeclaredValue::Value(LengthOrPercentage::Length(Length::from_px(20f32)))),
|
DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(20f32)))),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
|
|
||||||
(PropertyDeclaration::Height(
|
(PropertyDeclaration::Height(
|
||||||
|
@ -178,8 +178,8 @@ mod shorthand_serialization {
|
||||||
fn padding_should_serialize_correctly() {
|
fn padding_should_serialize_correctly() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let px_10 = DeclaredValue::Value(LengthOrPercentage::Length(Length::from_px(10f32)));
|
let px_10 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(10f32)));
|
||||||
let px_15 = DeclaredValue::Value(LengthOrPercentage::Length(Length::from_px(15f32)));
|
let px_15 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(15f32)));
|
||||||
properties.push(PropertyDeclaration::PaddingTop(px_10.clone()));
|
properties.push(PropertyDeclaration::PaddingTop(px_10.clone()));
|
||||||
properties.push(PropertyDeclaration::PaddingRight(px_15.clone()));
|
properties.push(PropertyDeclaration::PaddingRight(px_15.clone()));
|
||||||
properties.push(PropertyDeclaration::PaddingBottom(px_10));
|
properties.push(PropertyDeclaration::PaddingBottom(px_10));
|
||||||
|
@ -637,7 +637,7 @@ mod shorthand_serialization {
|
||||||
let font_variant = DeclaredValue::Value(FontVariant::normal);
|
let font_variant = DeclaredValue::Value(FontVariant::normal);
|
||||||
let font_weight = DeclaredValue::Value(FontWeight::Bolder);
|
let font_weight = DeclaredValue::Value(FontWeight::Bolder);
|
||||||
let font_size = DeclaredValue::Value(FontSizeContainer(
|
let font_size = DeclaredValue::Value(FontSizeContainer(
|
||||||
LengthOrPercentage::Length(Length::from_px(4f32)))
|
LengthOrPercentage::Length(NoCalcLength::from_px(4f32)))
|
||||||
);
|
);
|
||||||
let font_stretch = DeclaredValue::Value(FontStretch::expanded);
|
let font_stretch = DeclaredValue::Value(FontStretch::expanded);
|
||||||
let line_height = DeclaredValue::Value(LineHeight::Number(3f32));
|
let line_height = DeclaredValue::Value(LineHeight::Number(3f32));
|
||||||
|
@ -718,14 +718,14 @@ mod shorthand_serialization {
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(7f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(7f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let position_y = single_vec_value_typedef!(position_y,
|
let position_y = single_vec_value_typedef!(position_y,
|
||||||
VerticalPosition {
|
VerticalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(4f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(4f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -778,14 +778,14 @@ mod shorthand_serialization {
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(7f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(7f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let position_y = single_vec_value_typedef!(position_y,
|
let position_y = single_vec_value_typedef!(position_y,
|
||||||
VerticalPosition {
|
VerticalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(4f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(4f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -837,14 +837,14 @@ mod shorthand_serialization {
|
||||||
let position_x = single_vec_value_typedef!(position_x,
|
let position_x = single_vec_value_typedef!(position_x,
|
||||||
HorizontalPosition {
|
HorizontalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(0f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(0f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let position_y = single_vec_value_typedef!(position_y,
|
let position_y = single_vec_value_typedef!(position_y,
|
||||||
VerticalPosition {
|
VerticalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(0f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(0f32))),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -922,11 +922,11 @@ mod shorthand_serialization {
|
||||||
Position {
|
Position {
|
||||||
horizontal: HorizontalPosition {
|
horizontal: HorizontalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(7f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(7f32))),
|
||||||
},
|
},
|
||||||
vertical: VerticalPosition {
|
vertical: VerticalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(4f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(4f32))),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -976,11 +976,11 @@ mod shorthand_serialization {
|
||||||
Position {
|
Position {
|
||||||
horizontal: HorizontalPosition {
|
horizontal: HorizontalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(7f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(7f32))),
|
||||||
},
|
},
|
||||||
vertical: VerticalPosition {
|
vertical: VerticalPosition {
|
||||||
keyword: None,
|
keyword: None,
|
||||||
position: Some(LengthOrPercentage::Length(Length::from_px(4f32))),
|
position: Some(LengthOrPercentage::Length(NoCalcLength::from_px(4f32))),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue