-
-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Rc<CssRule>>, | ||
parent_stylesheet: Option<Rc<CSSStyleSheet>>, | ||
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type CssRuleList = vec<CssRule>; | ||
|
||
impl CssRuleList { | ||
fn item(&self, idx: usize) -> Option<&CssRule> { | ||
self.get(idx) | ||
} | ||
|
||
fn length(&self) -> usize { | ||
self.len() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
struct StyleSheetList { | ||
item: vec<StyleSheet> | ||
} |