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

Side by Side Diff: include.preload.js

Issue 4759827771293696: Issue 2528 - Don't parse CSS selectors that have no comma (Closed)
Patch Set: Skip substring() as well Created May 15, 2015, 12:15 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 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 } 143 }
144 144
145 function convertSelectorsForShadowDOM(selectors) 145 function convertSelectorsForShadowDOM(selectors)
146 { 146 {
147 var result = []; 147 var result = [];
148 var prefix = "::content "; 148 var prefix = "::content ";
149 149
150 for (var i = 0; i < selectors.length; i++) 150 for (var i = 0; i < selectors.length; i++)
151 { 151 {
152 var selector = selectors[i]; 152 var selector = selectors[i];
153 if (selector.indexOf(",") == -1)
154 {
155 result.push(prefix + selector);
156 continue;
157 }
158
153 var start = 0; 159 var start = 0;
154 var sep = ""; 160 var sep = "";
155
156 for (var j = 0; j < selector.length; j++) 161 for (var j = 0; j < selector.length; j++)
157 { 162 {
158 var chr = selector[j]; 163 var chr = selector[j];
159 if (chr == "\\") 164 if (chr == "\\")
160 j++; 165 j++;
161 else if (chr == sep) 166 else if (chr == sep)
162 sep = ""; 167 sep = "";
163 else if (sep == "") 168 else if (sep == "")
164 { 169 {
165 if (chr == '"' || chr == "'") 170 if (chr == '"' || chr == "'")
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 }, true); 295 }, true);
291 296
292 return updateStylesheet; 297 return updateStylesheet;
293 } 298 }
294 299
295 if (document instanceof HTMLDocument) 300 if (document instanceof HTMLDocument)
296 { 301 {
297 checkSitekey(); 302 checkSitekey();
298 window.updateStylesheet = init(document); 303 window.updateStylesheet = init(document);
299 } 304 }
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