stylo: Support pixel and percent presentation attributes

This commit is contained in:
Manish Goregaokar 2017-02-12 16:02:29 -08:00 committed by Manish Goregaokar
parent 31945c287f
commit 5cc0fa5ec2
3 changed files with 129 additions and 8 deletions

View file

@ -40,6 +40,13 @@ impl Importance {
}
}
impl Default for Importance {
#[inline]
fn default() -> Self {
Importance::Normal
}
}
/// Overridden declarations are skipped.
#[derive(Debug, PartialEq, Clone)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]

View file

@ -368,6 +368,13 @@ pub enum Length {
Calc(Box<CalcLengthOrPercentage>, AllowedNumericType),
}
impl From<NoCalcLength> for Length {
#[inline]
fn from(len: NoCalcLength) -> Self {
Length::NoCalc(len)
}
}
impl HasViewportPercentage for Length {
fn has_viewport_percentage(&self) -> bool {
match *self {
@ -938,6 +945,20 @@ impl From<Length> for LengthOrPercentage {
}
}
impl From<NoCalcLength> for LengthOrPercentage {
#[inline]
fn from(len: NoCalcLength) -> Self {
LengthOrPercentage::Length(len)
}
}
impl From<Percentage> for LengthOrPercentage {
#[inline]
fn from(pc: Percentage) -> Self {
LengthOrPercentage::Percentage(pc)
}
}
impl HasViewportPercentage for LengthOrPercentage {
fn has_viewport_percentage(&self) -> bool {
match *self {
@ -1043,6 +1064,21 @@ pub enum LengthOrPercentageOrAuto {
Calc(Box<CalcLengthOrPercentage>),
}
impl From<NoCalcLength> for LengthOrPercentageOrAuto {
#[inline]
fn from(len: NoCalcLength) -> Self {
LengthOrPercentageOrAuto::Length(len)
}
}
impl From<Percentage> for LengthOrPercentageOrAuto {
#[inline]
fn from(pc: Percentage) -> Self {
LengthOrPercentageOrAuto::Percentage(pc)
}
}
impl HasViewportPercentage for LengthOrPercentageOrAuto {
fn has_viewport_percentage(&self) -> bool {
match *self {