OLD | NEW |
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 }, | 352 }, |
353 | 353 |
354 setData: function(screenshot) | 354 setData: function(screenshot) |
355 { | 355 { |
356 let canvas = E("screenshotCanvas"); | 356 let canvas = E("screenshotCanvas"); |
357 | 357 |
358 // Do not resize canvas any more (no idea why Gecko requires both to be set) | 358 // Do not resize canvas any more (no idea why Gecko requires both to be set) |
359 canvas.parentNode.style.MozBoxAlign = "center"; | 359 canvas.parentNode.style.MozBoxAlign = "center"; |
360 canvas.parentNode.align = "center"; | 360 canvas.parentNode.align = "center"; |
361 | 361 |
362 // Init canvas settings | |
363 let context = canvas.getContext("2d"); | 362 let context = canvas.getContext("2d"); |
364 context.fillStyle = "rgb(0, 0, 0)"; | |
365 context.strokeStyle = "rgba(255, 0, 0, 0.7)"; | |
366 context.lineWidth = 3; | |
367 context.lineJoin = "round"; | |
368 | |
369 this._canvas = canvas; | 363 this._canvas = canvas; |
370 this._context = context; | 364 this._context = context; |
371 | 365 |
372 if (screenshot) | 366 let drawScreenshot = new Promise((resolve, reject) => { |
373 { | 367 if (screenshot) |
374 let image = new Image(); | 368 { |
375 image.src = screenshot; | 369 let image = new Image(); |
376 image.addEventListener("load", () => { | 370 image.src = screenshot; |
377 canvas.width = image.width + this.imageOffset * 2; | 371 image.addEventListener("load", () => { |
378 canvas.height = image.height + this.imageOffset * 2; | 372 canvas.width = image.width + this.imageOffset * 2; |
379 context.drawImage(image, this.imageOffset, this.imageOffset); | 373 canvas.height = image.height + this.imageOffset * 2; |
380 }); | 374 context.drawImage(image, this.imageOffset, this.imageOffset); |
381 } | 375 resolve(); |
| 376 }); |
| 377 } |
| 378 else |
| 379 resolve(); |
| 380 }); |
| 381 |
| 382 drawScreenshot.then(() => { |
| 383 // Init canvas settings, this has to be done after the canvas size is set |
| 384 context.fillStyle = "rgb(0, 0, 0)"; |
| 385 context.strokeStyle = "rgba(255, 0, 0, 0.7)"; |
| 386 context.lineWidth = 3; |
| 387 context.lineJoin = "round"; |
| 388 }); |
382 }, | 389 }, |
383 | 390 |
384 get enabled() | 391 get enabled() |
385 { | 392 { |
386 return this._enabled | 393 return this._enabled |
387 }, | 394 }, |
388 set enabled(enabled) | 395 set enabled(enabled) |
389 { | 396 { |
390 if (this._enabled == enabled) | 397 if (this._enabled == enabled) |
391 return; | 398 return; |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 | 1560 |
1554 function censorURL(url) | 1561 function censorURL(url) |
1555 { | 1562 { |
1556 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); | 1563 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); |
1557 } | 1564 } |
1558 | 1565 |
1559 function encodeHTML(str) | 1566 function encodeHTML(str) |
1560 { | 1567 { |
1561 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); | 1568 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); |
1562 } | 1569 } |
OLD | NEW |