OLD | NEW |
1 function splitSelector(selector) | 1 function splitSelector(selector) |
2 { | 2 { |
3 if (selector.indexOf(",") == -1) | 3 if (selector.indexOf(",") == -1) |
4 return [selector]; | 4 return [selector]; |
5 | 5 |
6 var selectors = []; | 6 var selectors = []; |
7 var start = 0; | 7 var start = 0; |
8 var level = 0; | 8 var level = 0; |
9 var sep = ""; | 9 var sep = ""; |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 selectors.push(selector.substring(start, i)); | 29 selectors.push(selector.substring(start, i)); |
30 start = i + 1; | 30 start = i + 1; |
31 } | 31 } |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 selectors.push(selector.substring(start)); | 35 selectors.push(selector.substring(start)); |
36 return selectors; | 36 return selectors; |
37 } | 37 } |
38 | 38 |
39 function CSSPropertyFilters(window, addSelectorsFunc) { | 39 function CSSPropertyFilters(window, getFiltersFunc, addSelectorsFunc) |
| 40 { |
40 this.window = window; | 41 this.window = window; |
| 42 this.getFiltersFunc = getFiltersFunc; |
41 this.addSelectorsFunc = addSelectorsFunc; | 43 this.addSelectorsFunc = addSelectorsFunc; |
42 } | 44 } |
43 | 45 |
44 CSSPropertyFilters.prototype = { | 46 CSSPropertyFilters.prototype = { |
45 stringifyStyle: function(style) | 47 stringifyStyle: function(style) |
46 { | 48 { |
47 var styles = []; | 49 var styles = []; |
48 for (var i = 0; i < style.length; i++) | 50 for (var i = 0; i < style.length; i++) |
49 { | 51 { |
50 var property = style.item(i); | 52 var property = style.item(i); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 117 |
116 onLoad: function(event) | 118 onLoad: function(event) |
117 { | 119 { |
118 var stylesheet = event.target.sheet; | 120 var stylesheet = event.target.sheet; |
119 if (stylesheet) | 121 if (stylesheet) |
120 this.addSelectors([stylesheet]); | 122 this.addSelectors([stylesheet]); |
121 }, | 123 }, |
122 | 124 |
123 load: function(callback) | 125 load: function(callback) |
124 { | 126 { |
125 ext.backgroundPage.sendMessage( | 127 this.getFiltersFunc(function(patterns) |
126 { | 128 { |
127 type: "filters.get", | 129 this.patterns = patterns; |
128 what: "cssproperties" | 130 callback(); |
129 }, | 131 }.bind(this)); |
130 function(patterns) | |
131 { | |
132 this.patterns = patterns; | |
133 callback(); | |
134 }.bind(this) | |
135 ); | |
136 }, | 132 }, |
137 | 133 |
138 apply: function() | 134 apply: function() |
139 { | 135 { |
140 if (this.patterns.length > 0) | 136 if (this.patterns.length > 0) |
141 { | 137 { |
142 var document = this.window.document; | 138 var document = this.window.document; |
143 this.addSelectors(document.styleSheets); | 139 this.addSelectors(document.styleSheets); |
144 document.addEventListener("load", this.onLoad.bind(this), true); | 140 document.addEventListener("load", this.onLoad.bind(this), true); |
145 } | 141 } |
146 } | 142 } |
147 }; | 143 }; |
OLD | NEW |