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

Delta Between Two Patch Sets: chrome/content/cssProperties.js

Issue 29317059: Issue 2395 - Added content script for CSS property filters (Closed)
Left Patch Set: Added missing this. Created Oct. 24, 2015, 6:31 p.m.
Right Patch Set: Make function to add CSS selectors configurable in the constructor Created Nov. 13, 2015, 1:16 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 function CSSPropertyFilters(window) { 1 function CSSPropertyFilters(window, addSelectorsFunc) {
2 this.window = window; 2 this.window = window;
3 this.addSelectorsFunc = addSelectorsFunc;
3 this.load(this.apply.bind(this)); 4 this.load(this.apply.bind(this));
4 } 5 }
5 6
6 CSSPropertyFilters.prototype = { 7 CSSPropertyFilters.prototype = {
7 stringifyStyle: function(style) 8 stringifyStyle: function(style)
8 { 9 {
9 var styles = []; 10 var styles = [];
10 for (var i = 0; i < style.length; i++) 11 for (var i = 0; i < style.length; i++)
11 { 12 {
12 var property = style.item(i); 13 var property = style.item(i);
(...skipping 30 matching lines...) Expand all
43 selectors.push(pattern.prefix + rule.selectorText + pattern.suffix); 44 selectors.push(pattern.prefix + rule.selectorText + pattern.suffix);
44 } 45 }
45 } 46 }
46 }, 47 },
47 48
48 addSelectors: function(stylesheets) 49 addSelectors: function(stylesheets)
49 { 50 {
50 var selectors = []; 51 var selectors = [];
51 for (var i = 0; i < stylesheets.length; i++) 52 for (var i = 0; i < stylesheets.length; i++)
52 this.findSelectors(stylesheets[i], selectors); 53 this.findSelectors(stylesheets[i], selectors);
53 addElemHideSelectors(selectors); 54 this.addSelectorsFunc(selectors);
54 }, 55 },
55 56
56 onLoad: function(event) 57 onLoad: function(event)
57 { 58 {
58 var stylesheet = event.target.sheet; 59 var stylesheet = event.target.sheet;
59 if (stylesheet) 60 if (stylesheet)
60 this.addSelectors([stylesheet]); 61 this.addSelectors([stylesheet]);
61 }, 62 },
62 63
63 load: function(callback) 64 load: function(callback)
64 { 65 {
65 ext.backgroundPage.sendMessage( 66 ext.backgroundPage.sendMessage(
66 { 67 {
67 type: "filters.get", 68 type: "filters.get",
68 what: "cssproperties" 69 what: "cssproperties"
kzar 2015/11/02 20:30:56 We need to pass the domain here as well, according
Wladimir Palant 2015/11/05 13:10:04 Actually, I don't think we do - sender.frame.url s
kzar 2015/11/05 14:35:32 OK I've updated the description for #2396 accordin
69 }, 70 },
70 function(patterns) 71 function(patterns)
71 { 72 {
72 this.patterns = patterns; 73 this.patterns = patterns;
73 callback(); 74 callback();
74 }.bind(this) 75 }.bind(this)
75 ); 76 );
76 }, 77 },
77 78
78 apply: function() 79 apply: function()
79 { 80 {
80 if (this.patterns.length > 0) 81 if (this.patterns.length > 0)
81 { 82 {
82 var document = this.window.document; 83 var document = this.window.document;
83 this.addSelectors(document.styleSheets); 84 this.addSelectors(document.styleSheets);
84 document.addEventListener("load", this.onLoad.bind(this), true); 85 document.addEventListener("load", this.onLoad.bind(this), true);
85 } 86 }
86 } 87 }
87 }; 88 };
88
89 if (typeof window == "object")
90 new CSSPropertyFilters(window);
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld