use css_lexer::Span;
use css_parse::Comparison;
use crate::{CssAtomSet, traits::declaration_metadata::PropertyGroup};
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum FeatureType {
Media,
Container,
}
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum FeatureEvaluator {
Length,
Integer,
Number,
Ratio,
Resolution,
Keyword,
Boolean,
}
#[derive(Debug, Clone)]
pub enum RangedForm {
Bare,
Exact { value: Span },
LegacyMin { value: Span },
LegacyMax { value: Span },
Left { comparison: Comparison, value: Span },
Right { value: Span, comparison: Comparison },
Range { left: Span, left_cmp: Comparison, right_cmp: Comparison, right: Span },
}
#[derive(Debug, Clone)]
pub enum ConditionalFeature {
Plain {
name: CssAtomSet,
value: Option<Span>,
},
Ranged {
name: CssAtomSet,
form: RangedForm,
},
}
impl ConditionalFeature {
pub fn name(&self) -> CssAtomSet {
match self {
Self::Plain { name, .. } | Self::Ranged { name, .. } => *name,
}
}
}
pub trait FeatureMetadata: Sized {
fn feature_type() -> FeatureType {
FeatureType::Media
}
fn evaluator() -> FeatureEvaluator {
FeatureEvaluator::Keyword
}
fn property_group() -> PropertyGroup {
PropertyGroup::none()
}
fn feature_metadata(&self) -> ConditionalFeature;
}