mirror of
https://github.com/servo/servo.git
synced 2025-08-15 18:35:33 +01:00
Format component of style_traits
This commit is contained in:
parent
81655a9a99
commit
a2fc2ae517
4 changed files with 121 additions and 64 deletions
|
@ -28,7 +28,10 @@ define_css_keyword_enum! {
|
|||
///
|
||||
/// <https://drafts.csswg.org/css-device-adapt/#viewport-desc>
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, MallocSizeOf))]
|
||||
#[cfg_attr(
|
||||
feature = "servo",
|
||||
derive(Deserialize, Serialize, MallocSizeOf)
|
||||
)]
|
||||
pub struct ViewportConstraints {
|
||||
/// Width and height:
|
||||
/// * https://drafts.csswg.org/css-device-adapt/#width-desc
|
||||
|
@ -43,7 +46,7 @@ pub struct ViewportConstraints {
|
|||
/// <https://drafts.csswg.org/css-device-adapt/#user-zoom-desc>
|
||||
pub user_zoom: UserZoom,
|
||||
/// <https://drafts.csswg.org/css-device-adapt/#orientation-desc>
|
||||
pub orientation: Orientation
|
||||
pub orientation: Orientation,
|
||||
}
|
||||
|
||||
impl ToCss for ViewportConstraints {
|
||||
|
@ -93,7 +96,8 @@ pub enum Zoom {
|
|||
|
||||
impl ToCss for Zoom {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
where
|
||||
W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
Zoom::Number(number) => number.to_css(dest),
|
||||
|
@ -101,7 +105,7 @@ impl ToCss for Zoom {
|
|||
Zoom::Percentage(percentage) => {
|
||||
(percentage * 100.).to_css(dest)?;
|
||||
dest.write_char('%')
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,16 +125,16 @@ impl Zoom {
|
|||
// argument, and pass ParsingMode owned by the ParserContext to
|
||||
// is_ok() instead of using ParsingMode::DEFAULT directly.
|
||||
// In order to do so, we might want to move these stuff into style::stylesheets::viewport_rule.
|
||||
Token::Percentage { unit_value, .. } if NonNegative.is_ok(ParsingMode::DEFAULT, unit_value) => {
|
||||
Token::Percentage { unit_value, .. }
|
||||
if NonNegative.is_ok(ParsingMode::DEFAULT, unit_value) =>
|
||||
{
|
||||
Ok(Zoom::Percentage(unit_value))
|
||||
}
|
||||
},
|
||||
Token::Number { value, .. } if NonNegative.is_ok(ParsingMode::DEFAULT, value) => {
|
||||
Ok(Zoom::Number(value))
|
||||
}
|
||||
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => {
|
||||
Ok(Zoom::Auto)
|
||||
}
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone()))
|
||||
},
|
||||
Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") => Ok(Zoom::Auto),
|
||||
ref t => Err(location.new_unexpected_token_error(t.clone())),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +145,7 @@ impl Zoom {
|
|||
match *self {
|
||||
Zoom::Number(number) => Some(number as f32),
|
||||
Zoom::Percentage(percentage) => Some(percentage as f32),
|
||||
Zoom::Auto => None
|
||||
Zoom::Auto => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue