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

Delta Between Two Patch Sets: include.preload.js

Issue 4759827771293696: Issue 2528 - Don't parse CSS selectors that have no comma (Closed)
Left Patch Set: Created May 15, 2015, 11:32 a.m.
Right 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:
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 /* 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 160 var sep = "";
155 if (selector.indexOf(",") != -1) 161 for (var j = 0; j < selector.length; j++)
156 { 162 {
157 var sep = ""; 163 var chr = selector[j];
158 164 if (chr == "\\")
159 for (var j = 0; j < selector.length; j++) 165 j++;
160 { 166 else if (chr == sep)
161 var chr = selector[j]; 167 sep = "";
162 if (chr == "\\") 168 else if (sep == "")
163 j++; 169 {
164 else if (chr == sep) 170 if (chr == '"' || chr == "'")
165 sep = ""; 171 sep = chr;
166 else if (sep == "") 172 else if (chr == ",")
167 { 173 {
168 if (chr == '"' || chr == "'") 174 result.push(prefix + selector.substring(start, j));
169 sep = chr; 175 start = j + 1;
170 else if (chr == ",")
171 {
172 result.push(prefix + selector.substring(start, j));
173 start = j + 1;
174 }
175 } 176 }
176 } 177 }
177 } 178 }
178 179
179 result.push(prefix + selector.substring(start)); 180 result.push(prefix + selector.substring(start));
180 } 181 }
181 182
182 return result; 183 return result;
183 } 184 }
184 185
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 }, true); 295 }, true);
295 296
296 return updateStylesheet; 297 return updateStylesheet;
297 } 298 }
298 299
299 if (document instanceof HTMLDocument) 300 if (document instanceof HTMLDocument)
300 { 301 {
301 checkSitekey(); 302 checkSitekey();
302 window.updateStylesheet = init(document); 303 window.updateStylesheet = init(document);
303 } 304 }
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