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

Unified Diff: chrome/content/cssProperties.js

Issue 29340901: Issue 4000 - cssProperties.js content script should report matching filters (Closed)
Patch Set: Created April 27, 2016, 5:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/content/cssProperties.js
===================================================================
--- a/chrome/content/cssProperties.js
+++ b/chrome/content/cssProperties.js
@@ -66,17 +66,17 @@ CSSPropertyFilters.prototype = {
}
catch (e)
{
// Invalid URL, assume that it is first-party.
return true;
}
},
- findSelectors: function(stylesheet, selectors)
+ findSelectors: function(stylesheet, selectors, filters)
{
// Explicitly ignore third-party stylesheets to ensure consistent behavior
// between Firefox and Chrome.
if (!this.isSameOrigin(stylesheet))
return;
var rules = stylesheet.cssRules;
if (!rules)
@@ -97,27 +97,29 @@ CSSPropertyFilters.prototype = {
if (typeof regexp == "string")
regexp = pattern.regexp = new RegExp(regexp);
if (regexp.test(style))
{
var subSelectors = splitSelector(rule.selectorText);
for (var k = 0; k < subSelectors.length; k++)
selectors.push(pattern.prefix + subSelectors[k] + pattern.suffix);
+ filters[pattern.text] = true;
}
}
}
},
addSelectors: function(stylesheets)
{
var selectors = [];
+ var filters = {};
for (var i = 0; i < stylesheets.length; i++)
- this.findSelectors(stylesheets[i], selectors);
- this.addSelectorsFunc(selectors);
+ this.findSelectors(stylesheets[i], selectors, filters);
+ this.addSelectorsFunc(selectors, Object.keys(filters));
},
onLoad: function(event)
{
var stylesheet = event.target.sheet;
if (stylesheet)
this.addSelectors([stylesheet]);
},
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld