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
module Stylish.Style.Selector(
QueryableStyleSheet(..), queryableStyleSheet,
queryRules
) where
import Stylish.Style.Selector.Index
import Stylish.Style.Selector.Interpret
import Stylish.Style.Selector.Specificity
import Stylish.Style.Selector.Importance
import Stylish.Style.Selector.Common
import Stylish.Parse (StyleSheet(..))
ruleStore = ImportanceSplitter $ OrderedRuleStore (InterpretedRuleStore styleIndex) 0
data QueryableStyleSheet store = QueryableStyleSheet {
store :: store,
priority :: Int -- author vs user agent vs user styles
}
queryableStyleSheet = QueryableStyleSheet {store = ruleStore, priority = 0}
instance RuleStore s => StyleSheet (QueryableStyleSheet s) where
addRule self@(QueryableStyleSheet store priority) rule = self {
store = addStyleRule store priority $ styleRule' rule
}
queryRules (QueryableStyleSheet store _) el = lookupRules store el