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

Side by Side Diff: lib/filterComposer.js

Issue 6445129351036928: Noissue - Fixed issue where JsDoc documented module functions incorrectly (Closed)
Patch Set: Fixed syntax error Created April 18, 2015, 2:54 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 | lib/filterValidation.js » ('j') | 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 22 matching lines...) Expand all
33 return "\\" + code.toString(16) + " "; 33 return "\\" + code.toString(16) + " ";
34 34
35 return "\\" + chr; 35 return "\\" + chr;
36 } 36 }
37 37
38 /** 38 /**
39 * Escapes a token (e.g. tag, id, class or attribute) to be used in CSS selector s. 39 * Escapes a token (e.g. tag, id, class or attribute) to be used in CSS selector s.
40 * 40 *
41 * @param {string} s 41 * @param {string} s
42 * @return {string} 42 * @return {string}
43 * @static
43 */ 44 */
44 function escapeCSS(s) 45 function escapeCSS(s)
45 { 46 {
46 return s.replace(/^[\d\-]|[^\w\-\u0080-\uFFFF]/g, escapeChar); 47 return s.replace(/^[\d\-]|[^\w\-\u0080-\uFFFF]/g, escapeChar);
47 } 48 }
48 exports.escapeCSS = escapeCSS; 49 exports.escapeCSS = escapeCSS;
49 50
50 /** 51 /**
51 * Quotes a string to be used as attribute value in CSS selectors. 52 * Quotes a string to be used as attribute value in CSS selectors.
52 * 53 *
53 * @param {string} value 54 * @param {string} value
54 * @return {string} 55 * @return {string}
56 * @static
55 */ 57 */
56 function quoteCSS(value) 58 function quoteCSS(value)
57 { 59 {
58 return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"'; 60 return '"' + value.replace(/["\\\{\}\x00-\x1F\x7F]/g, escapeChar) + '"';
59 } 61 }
60 exports.quoteCSS = quoteCSS; 62 exports.quoteCSS = quoteCSS;
61 63
62 /** 64 /**
63 * Generates filters to block an element. 65 * Generates filters to block an element.
64 * @param {Object} details 66 * @param {Object} details
65 * @param {string} details.tagName The element's tag name 67 * @param {string} details.tagName The element's tag name
66 * @param {string} details.id The element's "id" attribute 68 * @param {string} details.id The element's "id" attribute
67 * @param {string} details.src The element's "src" attribute 69 * @param {string} details.src The element's "src" attribute
68 * @param {string} details.style The element's "style" attribute 70 * @param {string} details.style The element's "style" attribute
69 * @param {string[]} details.classes The classes given by the element's "class" attribute 71 * @param {string[]} details.classes The classes given by the element's "class" attribute
70 * @param {string[]} details.urls The URLs considered when loading the eleme nt 72 * @param {string[]} details.urls The URLs considered when loading the eleme nt
71 * @param {string} details.type The request type (will be ignored if there are no URLs) 73 * @param {string} details.type The request type (will be ignored if there are no URLs)
72 * @param {string} details.baseURL The URL of the document containing the ele ment 74 * @param {string} details.baseURL The URL of the document containing the ele ment
73 * @param {Page} details.page The page containing the element 75 * @param {Page} details.page The page containing the element
74 * @param {Frame} details.frame The frame containing the element 76 * @param {Frame} details.frame The frame containing the element
75 * 77 *
76 * @return {object} An object holding the list of generated filters and 78 * @return {object} An object holding the list of generated filters and
77 * the list of CSS selectors for the included element 79 * the list of CSS selectors for the included element
78 * hiding filters: {filters: [...], selectors: [...]} 80 * hiding filters: {filters: [...], selectors: [...]}
79 */ 81 */
80 function composeFilters(details) 82 exports.composeFilters = function(details)
81 { 83 {
82 let filters = []; 84 let filters = [];
83 let selectors = []; 85 let selectors = [];
84 86
85 let page = details.page; 87 let page = details.page;
86 let frame = details.frame; 88 let frame = details.frame;
87 89
88 if (!isFrameWhitelisted(page, frame, "DOCUMENT")) 90 if (!isFrameWhitelisted(page, frame, "DOCUMENT"))
89 { 91 {
90 let docDomain = extractHostFromFrame(frame); 92 let docDomain = extractHostFromFrame(frame);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (details.style && selectors.length == 0 && filters.length == 0) 136 if (details.style && selectors.length == 0 && filters.length == 0)
135 selectors.push(escapeCSS(details.tagName) + "[style=" + quoteCSS(details .style) + "]"); 137 selectors.push(escapeCSS(details.tagName) + "[style=" + quoteCSS(details .style) + "]");
136 138
137 // Add an element hiding filter for each generated CSS selector 139 // Add an element hiding filter for each generated CSS selector
138 for (let selector of selectors) 140 for (let selector of selectors)
139 filters.push(docDomain.replace(/^www\./, "") + "##" + selector); 141 filters.push(docDomain.replace(/^www\./, "") + "##" + selector);
140 } 142 }
141 } 143 }
142 144
143 return {filters: filters, selectors: selectors}; 145 return {filters: filters, selectors: selectors};
144 } 146 };
145 exports.composeFilters = composeFilters;
OLDNEW
« no previous file with comments | « no previous file | lib/filterValidation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld