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

Delta Between Two Patch Sets: chrome/content/ui/sendReport.js

Issue 29333297: Issue 3375 - Issue reporter: move screenshot creation into the content process (Closed)
Left Patch Set: Created Jan. 7, 2016, 4:59 p.m.
Right Patch Set: Made sure screenshotDataCollector is always initialized Created Jan. 7, 2016, 6:57 p.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 | lib/child/dataCollector.js » ('j') | 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-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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 _undoQueue: [], 330 _undoQueue: [],
331 331
332 collectData: function(wnd, windowURI, callback) 332 collectData: function(wnd, windowURI, callback)
333 { 333 {
334 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor) 334 let outerWindowID = wnd.QueryInterface(Ci.nsIInterfaceRequestor)
335 .getInterface(Ci.nsIDOMWindowUtils) 335 .getInterface(Ci.nsIDOMWindowUtils)
336 .outerWindowID; 336 .outerWindowID;
337 let dataCollector = require("dataCollector"); 337 let dataCollector = require("dataCollector");
338 let canvas = E("screenshotCanvas"); 338 let canvas = E("screenshotCanvas");
339 let screenshotWidth = canvas.offsetWidth - this.imageOffset * 2; 339 let screenshotWidth = canvas.offsetWidth - this.imageOffset * 2;
340
341 // Do not resize canvas any more (no idea why Gecko requires both to be set)
342 canvas.parentNode.style.MozBoxAlign = "center";
343 canvas.parentNode.align = "center";
344
345 // Init canvas settings
346 let context = canvas.getContext("2d");
347 context.fillStyle = "rgb(0, 0, 0)";
348 context.strokeStyle = "rgba(255, 0, 0, 0.7)";
349 context.lineWidth = 3;
350 context.lineJoin = "round";
351
352 this._canvas = canvas;
353 this._context = context;
354
340 dataCollector.collectData(outerWindowID, screenshotWidth, data => { 355 dataCollector.collectData(outerWindowID, screenshotWidth, data => {
341 if (!data || !data.screenshot) 356 if (data && data.screenshot)
342 { 357 {
343 callback(); 358 let image = new Image();
344 return; 359 image.src = data.screenshot;
360 image.addEventListener("load", () => {
361 canvas.width = image.width + this.imageOffset * 2;
362 canvas.height = image.height + this.imageOffset * 2;
363 context.drawImage(image, this.imageOffset, this.imageOffset);
364 });
345 } 365 }
346 366 callback();
347 let image = new Image();
348 image.src = data.screenshot;
349 image.addEventListener("load", () => {
350 canvas.width = image.width + this.imageOffset * 2;
351 canvas.height = image.height + this.imageOffset * 2;
352
353 // Do not resize canvas any more (no idea why Gecko requires both to be set)
354 canvas.parentNode.style.MozBoxAlign = "center";
355 canvas.parentNode.align = "center";
356
357 let context = canvas.getContext("2d");
358 context.drawImage(image, this.imageOffset, this.imageOffset);
359
360 // Init canvas settings
361 context.fillStyle = "rgb(0, 0, 0)";
362 context.strokeStyle = "rgba(255, 0, 0, 0.7)";
363 context.lineWidth = 3;
364 context.lineJoin = "round";
365
366 this._canvas = canvas;
367 this._context = context;
368
369 callback();
370 });
371 }); 367 });
372 }, 368 },
373 369
374 get enabled() this._enabled, 370 get enabled() this._enabled,
375 set enabled(enabled) 371 set enabled(enabled)
376 { 372 {
377 if (this._enabled == enabled) 373 if (this._enabled == enabled)
378 return; 374 return;
379 375
380 this._enabled = enabled; 376 this._enabled = enabled;
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 1545
1550 function censorURL(url) 1546 function censorURL(url)
1551 { 1547 {
1552 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); 1548 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*");
1553 } 1549 }
1554 1550
1555 function encodeHTML(str) 1551 function encodeHTML(str)
1556 { 1552 {
1557 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;"); 1553 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;");
1558 } 1554 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld