oak_css/parser/
element_type.rs1use crate::lexer::CssTokenType;
2use oak_core::{ElementType, UniversalElementRole};
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9pub enum CssElementType {
10 SourceFile,
12 RuleSet,
14 SelectorList,
16 Selector,
18 DeclarationBlock,
20 Declaration,
22 Property,
24 Value,
26 AtRule,
28 MediaQuery,
30 Function,
32 Url,
34 CalcExpression,
36}
37
38impl ElementType for CssElementType {
39 type Role = UniversalElementRole;
40
41 fn role(&self) -> Self::Role {
42 match self {
43 Self::SourceFile => UniversalElementRole::Root,
44 Self::RuleSet => UniversalElementRole::Container,
45 Self::SelectorList => UniversalElementRole::Detail,
46 Self::DeclarationBlock => UniversalElementRole::Container,
47 Self::Declaration => UniversalElementRole::Statement,
48 _ => UniversalElementRole::None,
49 }
50 }
51}
52
53impl From<CssTokenType> for CssElementType {
54 fn from(token: CssTokenType) -> Self {
55 match token {
56 _ => Self::SourceFile, }
58 }
59}