Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/cssProperties.js

Issue 29340895: Issue 3998 - cssProperties.js content script shouldn't assume that messaging will automatically kno… (Closed)
Patch Set: Created April 27, 2016, 5:18 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld