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

Delta Between Two Patch Sets: lib/content/elemHideEmulation.js

Issue 29859558: Issue 6741 - Use ES2015 classes in lib/content/elemHideEmulation.js (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Aug. 20, 2018, 5:55 p.m.
Right Patch Set: Initialize properties with default values first Created Aug. 21, 2018, 3:44 a.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 yield [prefix + this._selector, subtree]; 262 yield [prefix + this._selector, subtree];
263 } 263 }
264 } 264 }
265 265
266 const incompletePrefixRegexp = /[\s>+~]$/; 266 const incompletePrefixRegexp = /[\s>+~]$/;
267 267
268 class HasSelector 268 class HasSelector
269 { 269 {
270 constructor(selectors) 270 constructor(selectors)
271 { 271 {
272 this.dependsOnDOM = true;
273
272 this._innerSelectors = selectors; 274 this._innerSelectors = selectors;
273 this.dependsOnDOM = true;
hub 2018/08/20 19:51:21 I'd feel better if the properties that have a defa
Manish Jethani 2018/08/21 03:45:30 OK, that makes sense. Done.
274 } 275 }
275 276
276 get dependsOnStyles() 277 get dependsOnStyles()
277 { 278 {
278 return this._innerSelectors.some(selector => selector.dependsOnStyles); 279 return this._innerSelectors.some(selector => selector.dependsOnStyles);
279 } 280 }
280 281
281 get dependsOnCharacterData() 282 get dependsOnCharacterData()
282 { 283 {
283 return this._innerSelectors.some( 284 return this._innerSelectors.some(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 testInfo.lastProcessedElements.add(element); 339 testInfo.lastProcessedElements.add(element);
339 } 340 }
340 } 341 }
341 } 342 }
342 } 343 }
343 344
344 class ContainsSelector 345 class ContainsSelector
345 { 346 {
346 constructor(textContent) 347 constructor(textContent)
347 { 348 {
348 this._regexp = makeRegExpParameter(textContent);
349 this.dependsOnDOM = true; 349 this.dependsOnDOM = true;
350 this.dependsOnCharacterData = true; 350 this.dependsOnCharacterData = true;
hub 2018/08/20 19:51:21 same here.
Manish Jethani 2018/08/21 03:45:30 Done.
351
352 this._regexp = makeRegExpParameter(textContent);
351 } 353 }
352 354
353 *getSelectors(prefix, subtree, styles, targets) 355 *getSelectors(prefix, subtree, styles, targets)
354 { 356 {
355 for (let element of this.getElements(prefix, subtree, styles, targets)) 357 for (let element of this.getElements(prefix, subtree, styles, targets))
356 yield [makeSelector(element), subtree]; 358 yield [makeSelector(element), subtree];
357 } 359 }
358 360
359 *getElements(prefix, subtree, styles, targets) 361 *getElements(prefix, subtree, styles, targets)
360 { 362 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 testInfo.lastProcessedElements.add(element); 397 testInfo.lastProcessedElements.add(element);
396 } 398 }
397 } 399 }
398 } 400 }
399 } 401 }
400 402
401 class PropsSelector 403 class PropsSelector
402 { 404 {
403 constructor(propertyExpression) 405 constructor(propertyExpression)
404 { 406 {
407 this.dependsOnStyles = true;
408 this.dependsOnDOM = true;
409
405 let regexpString; 410 let regexpString;
406 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && 411 if (propertyExpression.length >= 2 && propertyExpression[0] == "/" &&
407 propertyExpression[propertyExpression.length - 1] == "/") 412 propertyExpression[propertyExpression.length - 1] == "/")
408 { 413 {
409 regexpString = propertyExpression.slice(1, -1) 414 regexpString = propertyExpression.slice(1, -1)
410 .replace("\\7B ", "{").replace("\\7D ", "}"); 415 .replace("\\7B ", "{").replace("\\7D ", "}");
411 } 416 }
412 else 417 else
413 regexpString = filterToRegExp(propertyExpression); 418 regexpString = filterToRegExp(propertyExpression);
414 419
415 this._regexp = new RegExp(regexpString, "i"); 420 this._regexp = new RegExp(regexpString, "i");
416
417 this.dependsOnStyles = true;
418 this.dependsOnDOM = true;
hub 2018/08/20 19:51:21 and here.
Manish Jethani 2018/08/21 03:45:30 Done.
419 } 421 }
420 422
421 *findPropsSelectors(styles, prefix, regexp) 423 *findPropsSelectors(styles, prefix, regexp)
422 { 424 {
423 for (let style of styles) 425 for (let style of styles)
424 if (regexp.test(style.style)) 426 if (regexp.test(style.style))
425 for (let subSelector of style.subSelectors) 427 for (let subSelector of style.subSelectors)
426 { 428 {
427 if (subSelector.startsWith("*") && 429 if (subSelector.startsWith("*") &&
428 !incompletePrefixRegexp.test(prefix)) 430 !incompletePrefixRegexp.test(prefix))
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 characterData: shouldObserveCharacterData(this.patterns), 971 characterData: shouldObserveCharacterData(this.patterns),
970 subtree: true 972 subtree: true
971 } 973 }
972 ); 974 );
973 this.document.addEventListener("load", this.onLoad.bind(this), true); 975 this.document.addEventListener("load", this.onLoad.bind(this), true);
974 } 976 }
975 } 977 }
976 } 978 }
977 979
978 exports.ElemHideEmulation = ElemHideEmulation; 980 exports.ElemHideEmulation = ElemHideEmulation;
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