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