-
Notifications
You must be signed in to change notification settings - Fork 5
/
rule.go
46 lines (40 loc) · 886 Bytes
/
rule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package css
type RuleType int
const (
STYLE_RULE RuleType = iota
CHARSET_RULE
IMPORT_RULE
MEDIA_RULE
FONT_FACE_RULE
PAGE_RULE
KEYFRAMES_RULE
WEBKIT_KEYFRAMES_RULE
COUNTER_STYLE_RULE
)
var ruleTypeNames = map[RuleType]string{
STYLE_RULE: "",
MEDIA_RULE: "@media",
CHARSET_RULE: "@charset",
IMPORT_RULE: "@import",
FONT_FACE_RULE: "@font-face",
PAGE_RULE: "@page",
KEYFRAMES_RULE: "@keyframes",
WEBKIT_KEYFRAMES_RULE: "@-webkit-keyframes",
COUNTER_STYLE_RULE: "@counter-style",
}
func (rt RuleType) Text() string {
return ruleTypeNames[rt]
}
type CSSRule struct {
Type RuleType
Style CSSStyleRule
Rules []*CSSRule
}
func NewRule(ruleType RuleType) *CSSRule {
r := &CSSRule{
Type: ruleType,
}
r.Style.Styles = make([]*CSSStyleDeclaration, 0)
r.Rules = make([]*CSSRule, 0)
return r
}