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 if (screenshot) |
373 { | 367 { |
374 let image = new Image(); | 368 canvas.width = screenshot.width + this.imageOffset * 2; |
375 image.src = screenshot; | 369 canvas.height = screenshot.height + this.imageOffset * 2; |
376 image.addEventListener("load", () => { | 370 context.putImageData(screenshot, this.imageOffset, this.imageOffset); |
377 canvas.width = image.width + this.imageOffset * 2; | |
378 canvas.height = image.height + this.imageOffset * 2; | |
379 context.drawImage(image, this.imageOffset, this.imageOffset); | |
380 }); | |
381 } | 371 } |
| 372 |
| 373 // Init canvas settings |
| 374 context.fillStyle = "rgb(0, 0, 0)"; |
| 375 context.strokeStyle = "rgba(255, 0, 0, 0.7)"; |
| 376 context.lineWidth = 3; |
| 377 context.lineJoin = "round"; |
382 }, | 378 }, |
383 | 379 |
384 get enabled() | 380 get enabled() |
385 { | 381 { |
386 return this._enabled | 382 return this._enabled |
387 }, | 383 }, |
388 set enabled(enabled) | 384 set enabled(enabled) |
389 { | 385 { |
390 if (this._enabled == enabled) | 386 if (this._enabled == enabled) |
391 return; | 387 return; |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 | 1549 |
1554 function censorURL(url) | 1550 function censorURL(url) |
1555 { | 1551 { |
1556 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); | 1552 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); |
1557 } | 1553 } |
1558 | 1554 |
1559 function encodeHTML(str) | 1555 function encodeHTML(str) |
1560 { | 1556 { |
1561 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); | 1557 return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").
replace(/"/g, """); |
1562 } | 1558 } |
OLD | NEW |