mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Implement css(dimension) and derive ToCss for a bunch of stuff.
For css(dimension), it'd be nice to derive(Parse) too, I think...
This commit is contained in:
parent
1b533f9bdc
commit
4927786d90
10 changed files with 98 additions and 153 deletions
|
@ -29,7 +29,7 @@ use style_traits::{CSSPixel, DevicePixel};
|
|||
use style_traits::{ToCss, ParseError, StyleParseErrorKind};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use stylesheets::Origin;
|
||||
use values::{CSSFloat, CustomIdent, serialize_dimension};
|
||||
use values::{CSSFloat, CustomIdent};
|
||||
use values::computed::{self, ToComputedValue};
|
||||
use values::computed::font::FontSize;
|
||||
use values::specified::Length;
|
||||
|
@ -262,7 +262,8 @@ impl PartialEq for Expression {
|
|||
}
|
||||
|
||||
/// A resolution.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
#[css(dimension)]
|
||||
pub enum Resolution {
|
||||
/// Dots per inch.
|
||||
Dpi(CSSFloat),
|
||||
|
@ -303,18 +304,6 @@ impl Resolution {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for Resolution {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
Resolution::Dpi(v) => serialize_dimension(v, "dpi", dest),
|
||||
Resolution::Dppx(v) => serialize_dimension(v, "dppx", dest),
|
||||
Resolution::Dpcm(v) => serialize_dimension(v, "dpcm", dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A value found or expected in a media expression.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum MediaExpressionValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue