Index: chrome/content/ui/sendReport.js |
=================================================================== |
--- a/chrome/content/ui/sendReport.js |
+++ b/chrome/content/ui/sendReport.js |
@@ -203,17 +203,17 @@ let requestsDataSource = |
thirdParty: entry.thirdParty, |
count: 1 |
}); |
} |
// Location is meaningless for element hiding hits |
if (entry.filter && entry.filter instanceof ElemHideBase) |
requestXML.removeAttribute("location"); |
- |
+ |
if (entry.filter) |
requestXML.setAttribute("filter", entry.filter.text); |
if (node instanceof Element) |
{ |
requestXML.setAttribute("node", (node.namespaceURI ? node.namespaceURI + "#" : "") + node.localName); |
try |
@@ -328,42 +328,42 @@ let screenshotDataSource = |
// Do not resize canvas any more (no idea why Gecko requires both to be set) |
this._canvas.parentNode.style.MozBoxAlign = "center"; |
this._canvas.parentNode.align = "center"; |
this._context = this._canvas.getContext("2d"); |
let wndWidth = wnd.document.documentElement.scrollWidth; |
let wndHeight = wnd.document.documentElement.scrollHeight; |
- |
+ |
// Copy scaled screenshot of the webpage. We scale the webpage by width |
// but leave 10px on each side for easier selecting. |
- |
+ |
// Gecko doesn't like sizes more than 64k, restrict to 30k to be on the safe side. |
// Also, make sure height is at most five times the width to keep image size down. |
let copyWidth = Math.min(wndWidth, 30000); |
let copyHeight = Math.min(wndHeight, 30000, copyWidth * 5); |
let copyX = Math.max(Math.min(wnd.scrollX - copyWidth / 2, wndWidth - copyWidth), 0); |
let copyY = Math.max(Math.min(wnd.scrollY - copyHeight / 2, wndHeight - copyHeight), 0); |
- |
+ |
let scalingFactor = (this._canvas.width - this.imageOffset * 2) / copyWidth; |
this._canvas.height = copyHeight * scalingFactor + this.imageOffset * 2; |
- |
+ |
this._context.save(); |
this._context.translate(this.imageOffset, this.imageOffset); |
this._context.scale(scalingFactor, scalingFactor); |
this._context.drawWindow(wnd, copyX, copyY, copyWidth, copyHeight, "rgb(255,255,255)"); |
this._context.restore(); |
- |
+ |
// Init canvas settings |
this._context.fillStyle = "rgb(0, 0, 0)"; |
this._context.strokeStyle = "rgba(255, 0, 0, 0.7)"; |
this._context.lineWidth = 3; |
this._context.lineJoin = "round"; |
- |
+ |
// Reduce colors asynchronously |
this._pixelData = this._context.getImageData(this.imageOffset, this.imageOffset, |
this._canvas.width - this.imageOffset * 2, |
this._canvas.height - this.imageOffset * 2); |
this._max = this._pixelData.width * this._pixelData.height * 4; |
this._i = 0; |
Utils.threadManager.currentThread.dispatch(this, Ci.nsIEventTarget.DISPATCH_NORMAL); |
}, |
@@ -402,23 +402,23 @@ let screenshotDataSource = |
E("screenshotUndoButton").disabled = !this._enabled || !this._undoQueue.length; |
}, |
get selectionType() this._selectionType, |
set selectionType(type) |
{ |
if (this._selectionType == type) |
return; |
- |
+ |
// Abort selection already in progress |
this.abortSelection(); |
- |
+ |
this._selectionType = type; |
}, |
- |
+ |
exportData: function() |
{ |
removeReportElement("screenshot"); |
if (this.enabled) |
{ |
appendElement(reportData.documentElement, "screenshot", { |
edited: (this._undoQueue.length ? 'true' : 'false') |
}, this._canvas.toDataURL()); |
@@ -441,39 +441,39 @@ let screenshotDataSource = |
{ |
if (event.keyCode == Ci.nsIDOMKeyEvent.DOM_VK_ESCAPE) |
{ |
event.stopPropagation(); |
event.preventDefault(); |
screenshotDataSource.abortSelection(); |
} |
}, |
- |
+ |
startSelection: function(event) |
{ |
if (event.button == 2) |
this.abortSelection(); // Right mouse button aborts selection |
- |
+ |
if (event.button != 0 || !this.enabled) |
return; |
- |
+ |
// Abort selection already in progress |
this.abortSelection(); |
- |
+ |
let boxObject = document.getBoxObjectFor(this._canvas); |
let [x, y] = [event.screenX - boxObject.screenX, event.screenY - boxObject.screenY]; |
this._currentData = { |
data: null, |
anchorX: x, |
anchorY: y, |
currentX: -1, |
currentY: -1 |
}; |
this.updateSelection(event); |
- |
+ |
document.addEventListener("keypress", this.handleKeyPress, true); |
}, |
updateSelection: function(event) |
{ |
if (event.button != 0 || !this._currentData) |
return; |
@@ -516,37 +516,37 @@ let screenshotDataSource = |
else if (this._selectionType == "remove") |
this._context.fillRect(left, top, right - left, bottom - top); |
}, |
stopSelection: function(event) |
{ |
if (event.button != 0 || !this._currentData) |
return; |
- |
+ |
if (this._currentData.data) |
{ |
this._undoQueue.push(this._currentData); |
E("screenshotUndoButton").disabled = false; |
} |
- |
+ |
this._currentData = null; |
document.removeEventListener("keypress", this.handleKeyPress, true); |
}, |
- |
+ |
undo: function() |
{ |
let op = this._undoQueue.pop(); |
if (!op) |
return; |
- |
+ |
this._context.putImageData(op.data, |
Math.min(op.anchorX, op.currentX), |
Math.min(op.anchorY, op.currentY)); |
- |
+ |
if (!this._undoQueue.length) |
E("screenshotUndoButton").disabled = true; |
} |
}; |
let framesDataSource = |
{ |
site: null, |
@@ -577,17 +577,17 @@ let framesDataSource = |
scanFrames: function(wnd, xmlList) |
{ |
try |
{ |
for (let i = 0; i < wnd.frames.length; i++) |
{ |
let frame = wnd.frames[i]; |
- let frameXML = appendElement(xmllist, "frame", { |
+ let frameXML = appendElement(xmlList, "frame", { |
url: censorURL(frame.location.href) |
}); |
this.scanFrames(frame, frameXML); |
} |
} |
catch (e) |
{ |
// Don't break if something goes wrong |
@@ -610,53 +610,53 @@ let errorsDataSource = |
{ |
return (message instanceof Ci.nsIScriptError && |
!/^https?:/i.test(message.sourceName) && |
(/adblock/i.test(message.errorMessage) || /adblock/i.test(message.sourceName) || |
message.errorMessage.indexOf(addonID) >= 0 || message.sourceName.indexOf(addonID) >= 0)); |
}); |
if (messages.length > 10) // Only the last 10 messages |
messages = messages.slice(messages.length - 10, messages.length); |
- |
+ |
// Censor app and profile paths in error messages |
let censored = {__proto__: null}; |
let pathList = [["ProfD", "%PROFILE%"], ["GreD", "%GRE%"], ["CurProcD", "%APP%"]]; |
for (let i = 0; i < pathList.length; i++) |
{ |
let [pathID, placeholder] = pathList[i]; |
try |
{ |
let file = FileUtils.getDir(pathID, [], false); |
censored[file.path.replace(/[\\\/]+$/, '')] = placeholder; |
let uri = Utils.ioService.newFileURI(file); |
censored[uri.spec.replace(/[\\\/]+$/, '')] = placeholder; |
} catch(e) {} |
} |
- |
+ |
let errors = reportElement("errors"); |
for (let i = 0; i < messages.length; i++) |
{ |
let message = messages[i]; |
- |
+ |
let text = message.errorMessage; |
for (let path in censored) |
text = text.replace(path, censored[path], "gi"); |
if (text.length > 256) |
text = text.substr(0, 256) + "..."; |
- |
+ |
let file = message.sourceName; |
for (let path in censored) |
file = file.replace(path, censored[path], "gi"); |
if (file.length > 256) |
file = file.substr(0, 256) + "..."; |
- |
+ |
let sourceLine = message.sourceLine; |
if (sourceLine.length > 256) |
sourceLine = sourceLine.substr(0, 256) + "..."; |
- |
+ |
appendElement(errors, "error", { |
type: message.flags & Ci.nsIScriptError.warningFlag ? "warning" : "error", |
text: text, |
file: file, |
line: message.lineNumber, |
column: message.columnNumber, |
sourceLine: sourceLine |
}); |
@@ -880,17 +880,17 @@ let issuesDataSource = |
if (!this.whitelistFilter && this.isEnabled) |
{ |
// Find disabled filters in active subscriptions matching any of the requests |
let disabledMatcher = new CombinedMatcher(); |
for each (let subscription in FilterStorage.subscriptions) |
{ |
if (subscription.disabled) |
continue; |
- |
+ |
for each (let filter in subscription.filters) |
if (filter instanceof BlockingFilter && filter.disabled) |
disabledMatcher.add(filter); |
} |
let seenFilters = {__proto__: null}; |
for each (let request in requestsDataSource.origRequests) |
{ |
@@ -916,17 +916,17 @@ let issuesDataSource = |
for each (let filter in subscription.filters) |
if (filter instanceof BlockingFilter) |
disabledMatcher.add(filter); |
for each (let request in requestsDataSource.origRequests) |
{ |
if (request.filter) |
continue; |
- |
+ |
let filter = disabledMatcher.matchesAny(request.location, request.typeDescr, request.docDomain, request.thirdParty); |
if (filter && !(subscription.url in seenSubscriptions)) |
{ |
this.disabledSubscriptions.push(subscription); |
seenSubscriptions[subscription.text] = true; |
break; |
} |
} |
@@ -1083,29 +1083,29 @@ let issuesDataSource = |
{ |
let result = {}; |
openDialog("subscriptionSelection.xul", "_blank", "chrome,centerscreen,modal,resizable,dialog=no", null, result); |
if (!("url" in result)) |
return; |
let subscriptionResults = [[result.url, result.title]]; |
if ("mainSubscriptionURL" in result) |
- subscriptionResults.push([result.mainSubscriptionURL, result.mainSubscriptionTitle]); |
+ subscriptionResults.push([result.mainSubscriptionURL, result.mainSubscriptionTitle]); |
for each (let [url, title] in subscriptionResults) |
{ |
let subscription = Subscription.fromURL(url); |
if (!subscription) |
continue; |
- |
+ |
FilterStorage.addSubscription(subscription); |
subscription.disabled = false; |
subscription.title = title; |
- |
+ |
if (subscription instanceof DownloadableSubscription && !subscription.lastDownload) |
Synchronizer.execute(subscription); |
} |
E("issuesNoSubscriptionsBox").hidden = true; |
this.forceReload(); |
}, |
@@ -1452,26 +1452,26 @@ function reportSent(event) |
result = result.replace(/%CONFIRMATION%/g, encodeHTML(E("result").getAttribute("confirmationMessage"))); |
result = result.replace(/%KNOWNISSUE%/g, encodeHTML(E("result").getAttribute("knownIssueMessage"))); |
result = result.replace(/(<html)\b/, '$1 dir="' + window.getComputedStyle(document.documentElement, "").direction + '"'); |
if (!success) |
{ |
let errorElement = E("sendReportError"); |
let template = errorElement.getAttribute("textTemplate").replace(/[\r\n\s]+/g, " "); |
- |
+ |
let [, beforeLink, linkText, afterLink] = /(.*)\[link\](.*)\[\/link\](.*)/.exec(template) || [null, "", template, ""]; |
beforeLink = beforeLink.replace(/\?1\?/g, errorMessage); |
afterLink = afterLink.replace(/\?1\?/g, errorMessage); |
while (errorElement.firstChild && errorElement.firstChild.nodeType != Node.ELEMENT_NODE) |
errorElement.removeChild(errorElement.firstChild); |
while (errorElement.lastChild && errorElement.lastChild.nodeType != Node.ELEMENT_NODE) |
errorElement.removeChild(errorElement.lastChild); |
- |
+ |
if (errorElement.firstChild) |
errorElement.firstChild.textContent = linkText; |
errorElement.insertBefore(document.createTextNode(beforeLink), errorElement.firstChild); |
errorElement.appendChild(document.createTextNode(afterLink)); |
E("sendReportErrorBox").hidden = false; |
} |