diff --git a/src/css3/cssom/cssrule.rs b/src/css3/cssom/cssrule.rs new file mode 100644 index 000000000..8556b7cdc --- /dev/null +++ b/src/css3/cssom/cssrule.rs @@ -0,0 +1,62 @@ +pub enum CssRuleType { + UnknownRule = 0, + StyleRule = 1, + CharsetRule = 2, // Obsolete + ImportRule = 3, + MediaRule = 4, + FontFaceRule = 5, + PageRule = 6, + KeyframesRule = 7, + KeyframeRule = 8, + MarginRule = 9, // Obsolete + NamespaceRule = 10, + CounterStyleRule = 11, + SupportsRule = 12, + DocumentRule = 13, // Obsolete + FontFeatureValuesRule = 14, + ViewportRule = 15, // Obsolete + RegionStyleRule = 16, // Obsolete +} + +pub struct CssStyleRule { +} + +pub enum CssTypeRuleType { + StyleRule(CssStyleRule), + CharsetRule(CssCharsetRule), + ImportRule(CssImportRule), + MediaRule(CssMediaRule), + FontFaceRule(CssFontFaceRule), + PageRule(CssPageRule), + KeyframesRule(CssKeyframesRule), + KeyframeRule(CssKeyframeRule), + MarginRule(CssMarginRule), + NamespaceRule(CssNamespaceRule), + CounterStyleRule(CssCounterStyleRule), + SupportsRule(CssSupportsRule), + DocumentRule(CssDocumentRule), + FontFeatureValuesRule(CssFontFeatureValuesRule), + ViewportRule(CssViewportRule), + RegionStyleRule(CssRegionStyleRule), +} + +struct CssRule { + text: String, + parent_rule: Option>, + parent_stylesheet: Option>, + type_: CssRuleType, +} + +struct CssGroupingRule { + css_rules: CssRuleList, +} + +impl CssGroupingRule { + pub fn delete_rule(&mut self, idx: usize) { + self.css_rules.remove(idx); + } + + pub fn insert_rule(&mut self, idx: usize, rule: CssRule) { + self.css_rules.insert(idx, rule); + } +} \ No newline at end of file diff --git a/src/css3/cssom/cssrule_list.rs b/src/css3/cssom/cssrule_list.rs new file mode 100644 index 000000000..43f5868fe --- /dev/null +++ b/src/css3/cssom/cssrule_list.rs @@ -0,0 +1,11 @@ +type CssRuleList = vec; + +impl CssRuleList { + fn item(&self, idx: usize) -> Option<&CssRule> { + self.get(idx) + } + + fn length(&self) -> usize { + self.len() + } +} \ No newline at end of file diff --git a/src/css3/cssom/stylesheet.rs b/src/css3/cssom/stylesheet.rs new file mode 100644 index 000000000..9d4b8bdb4 --- /dev/null +++ b/src/css3/cssom/stylesheet.rs @@ -0,0 +1,32 @@ +struct CSSStyleSheet { + rules: CssRuleList +} + +impl CSSStyleSheet { + pub fn new() -> Self { + Self { + rules: vec![] + } + } + + pub fn delete_rule(&mut self, idx: usize) { + self.rules.remove(idx); + } + + pub fn insert_rule(&mut self, idx: usize, rule: CssRule) { + self.rules.insert(idx, rule); + } + + pub fn replace_async(&mut self, idx: usize, rule: CssRule) { + self.rules[idx] = rule; + } + + pub fn replace(&mut self, idx: usize, rule: CssRule) { + self.rules[idx] = rule; + } + + // CSSOM: + // property: rules obsolete + // method: addRule() obsolete + // method: removeRule() obsolete +} \ No newline at end of file diff --git a/src/css3/cssom/stylesheet_list.rs b/src/css3/cssom/stylesheet_list.rs new file mode 100644 index 000000000..24f6450a2 --- /dev/null +++ b/src/css3/cssom/stylesheet_list.rs @@ -0,0 +1,3 @@ +struct StyleSheetList { + item: vec +} \ No newline at end of file