lewp_css/domain/properties/
does_not_have_importance.rs

1// This file is part of css. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT. No part of predicator, including this file, may be copied, modified, propagated, or distributed except according to the terms contained in the COPYRIGHT file.
2// Copyright © 2017 The developers of css. See the COPYRIGHT file in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/css/master/COPYRIGHT.
3
4use {
5    super::{HasImportance, Importance},
6    crate::CustomParseError,
7    cssparser::{ParseError, ToCss},
8    std::fmt,
9};
10
11/// A type representing that !important can not be present in a property declaration
12#[derive(Default, Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
13pub struct DoesNotHaveImportance;
14
15impl ToCss for DoesNotHaveImportance {
16    #[inline(always)]
17    fn to_css<W: fmt::Write>(&self, _dest: &mut W) -> fmt::Result {
18        Ok(())
19    }
20}
21
22impl HasImportance for DoesNotHaveImportance {
23    #[inline(always)]
24    fn validateParsedImportance<'i>(
25        importance: Importance,
26    ) -> Result<Self, ParseError<'i, CustomParseError<'i>>> {
27        if importance.isImportant() {
28            Err(ParseError::from(
29                CustomParseError::ImportantIsNotAllowedInKeyframePropertyDeclarationValues,
30            ))
31        } else {
32            Ok(DoesNotHaveImportance)
33        }
34    }
35
36    /// Return whether this is an important declaration.
37    #[inline(always)]
38    fn isImportant(&self) -> bool {
39        false
40    }
41}