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

Side by Side Diff: lib/elemHide.js

Issue 5697079653433344: Issue 340 - Element hiding reports NS_ERROR_NOT_AVAILABLE to error console (Closed)
Patch Set: Created April 16, 2014, 12:47 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 246
247 TimeLine.leave("ElemHide.apply() done (no file changes)"); 247 TimeLine.leave("ElemHide.apply() done (no file changes)");
248 return; 248 return;
249 } 249 }
250 250
251 IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e) 251 IO.writeToFile(styleURL.file, this._generateCSSContent(), function(e)
252 { 252 {
253 TimeLine.enter("ElemHide.apply() write callback"); 253 TimeLine.enter("ElemHide.apply() write callback");
254 this._applying = false; 254 this._applying = false;
255 255
256 if (e && e.result == Cr.NS_ERROR_NOT_AVAILABLE) 256 // _generateCSSContent is throwing NS_ERROR_NOT_AVAILABLE to indicate that
257 IO.removeFile(styleURL.file, function(e2) {}); 257 // there are no filters. If that exception is passed through XPCOM we will
258 // see a proper exception here, otherwise a number.
259 let noFilters = (e == Cr.NS_ERROR_NOT_AVAILABLE || (e && e.result == Cr.NS _ERROR_NOT_AVAILABLE));
260 if (noFilters)
261 {
262 e = null;
263 IO.removeFile(styleURL.file, function(e) {});
264 }
258 else if (e) 265 else if (e)
259 Cu.reportError(e); 266 Cu.reportError(e);
260 267
261 if (this._needsApply) 268 if (this._needsApply)
262 { 269 {
263 this._needsApply = false; 270 this._needsApply = false;
264 this.apply(); 271 this.apply();
265 } 272 }
266 else if (!e || e.result == Cr.NS_ERROR_NOT_AVAILABLE) 273 else if (!e)
267 { 274 {
268 ElemHide.isDirty = false; 275 ElemHide.isDirty = false;
269 276
270 ElemHide.unapply(); 277 ElemHide.unapply();
271 TimeLine.log("ElemHide.unapply() finished"); 278 TimeLine.log("ElemHide.unapply() finished");
272 279
273 if (!e) 280 if (!noFilters)
274 { 281 {
275 try 282 try
276 { 283 {
277 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetSe rvice.USER_SHEET); 284 Utils.styleService.loadAndRegisterSheet(styleURL, Ci.nsIStyleSheetSe rvice.USER_SHEET);
278 ElemHide.applied = true; 285 ElemHide.applied = true;
279 } 286 }
280 catch (e) 287 catch (e)
281 { 288 {
282 Cu.reportError(e); 289 Cu.reportError(e);
283 } 290 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 let filter = filterByKey[key]; 401 let filter = filterByKey[key];
395 if (specificOnly && (!filter.domains || filter.domains[""])) 402 if (specificOnly && (!filter.domains || filter.domains[""]))
396 continue; 403 continue;
397 404
398 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) 405 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain))
399 result.push(filter.selector); 406 result.push(filter.selector);
400 } 407 }
401 return result; 408 return result;
402 } 409 }
403 }; 410 };
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