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

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

Issue 29340588: Issue 3879 - CSS property filters ignore third-party stylesheets in Chrome but not in Firefox (Closed)
Patch Set: Removed debugging statement Created April 19, 2016, 2:33 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 var value = style.getPropertyValue(property); 51 var value = style.getPropertyValue(property);
52 var priority = style.getPropertyPriority(property); 52 var priority = style.getPropertyPriority(property);
53 styles.push(property + ": " + value + (priority ? " !" + priority : "") + ";"); 53 styles.push(property + ": " + value + (priority ? " !" + priority : "") + ";");
54 } 54 }
55 styles.sort(); 55 styles.sort();
56 return styles.join(" "); 56 return styles.join(" ");
57 }, 57 },
58 58
59 findSelectors: function(stylesheet, selectors) 59 findSelectors: function(stylesheet, selectors)
60 { 60 {
61 try
Sebastian Noack 2016/04/19 14:47:01 I guess we should move this logic to a seperate fu
Wladimir Palant 2016/04/19 15:07:42 Done.
62 {
63 // Explicitly ignore third-party stylesheets to ensure consistent behavior
64 // between Firefox and Chrome.
65 if (stylesheet.href &&
Sebastian Noack 2016/04/19 14:47:01 This check seems to be redundant as we catch the e
Wladimir Palant 2016/04/19 15:07:42 I don't really like intentionally running into exc
66 new URL(stylesheet.href).origin != this.window.location.origin)
67 {
Sebastian Noack 2016/04/19 14:47:01 Nit: Redundant braces.
Wladimir Palant 2016/04/19 15:07:42 Not redundant, actually required for readability s
68 return;
69 }
70 }
71 catch (e)
72 {
73 // An invalid URL, can be ignored.
74 }
75
61 var rules = stylesheet.cssRules; 76 var rules = stylesheet.cssRules;
62 if (!rules) 77 if (!rules)
63 return; 78 return;
64 79
65 for (var i = 0; i < rules.length; i++) 80 for (var i = 0; i < rules.length; i++)
66 { 81 {
67 var rule = rules[i]; 82 var rule = rules[i];
68 if (rule.type != rule.STYLE_RULE) 83 if (rule.type != rule.STYLE_RULE)
69 continue; 84 continue;
70 85
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 apply: function() 135 apply: function()
121 { 136 {
122 if (this.patterns.length > 0) 137 if (this.patterns.length > 0)
123 { 138 {
124 var document = this.window.document; 139 var document = this.window.document;
125 this.addSelectors(document.styleSheets); 140 this.addSelectors(document.styleSheets);
126 document.addEventListener("load", this.onLoad.bind(this), true); 141 document.addEventListener("load", this.onLoad.bind(this), true);
127 } 142 }
128 } 143 }
129 }; 144 };
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