mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Make resolutions more like the rest of the CSS values.
Bug: 1460655 Reviewed-by: xidorn MozReview-Commit-ID: 3Gt8VX1KhjC
This commit is contained in:
parent
2688588538
commit
2f18b67ce1
5 changed files with 128 additions and 50 deletions
|
@ -56,6 +56,7 @@ pub use self::inherited_box::{ImageOrientation, Orientation};
|
|||
#[cfg(feature = "gecko")]
|
||||
pub use self::gecko::ScrollSnapPoint;
|
||||
pub use self::rect::LengthOrNumberRect;
|
||||
pub use self::resolution::Resolution;
|
||||
pub use super::{Auto, Either, None_};
|
||||
pub use super::specified::{BorderStyle, TextDecorationLine};
|
||||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage};
|
||||
|
@ -105,6 +106,7 @@ pub mod outline;
|
|||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
pub mod resolution;
|
||||
pub mod svg;
|
||||
pub mod table;
|
||||
pub mod text;
|
||||
|
|
48
components/style/values/computed/resolution.rs
Normal file
48
components/style/values/computed/resolution.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Resolution values:
|
||||
//!
|
||||
//! https://drafts.csswg.org/css-values/#resolution
|
||||
|
||||
use std::fmt::{self, Write};
|
||||
use style_traits::{CssWriter, ToCss};
|
||||
use values::computed::{Context, ToComputedValue};
|
||||
use values::specified;
|
||||
use values::CSSFloat;
|
||||
|
||||
/// A computed `<resolution>`.
|
||||
pub struct Resolution(CSSFloat);
|
||||
|
||||
impl Resolution {
|
||||
/// Returns this resolution value as dppx.
|
||||
#[inline]
|
||||
pub fn dppx(&self) -> CSSFloat {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::Resolution {
|
||||
type ComputedValue = Resolution;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue {
|
||||
Resolution(self.to_dppx())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||
specified::Resolution::Dppx(computed.dppx())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Resolution {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
self.dppx().to_css(dest)?;
|
||||
dest.write_str("dppx")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue