mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-26 19:55:39 +00:00
Backed out changeset 52434d177be3 (bug 1171614) for test failures in clipboard tests
This commit is contained in:
parent
6f0f8498d5
commit
2f13468501
@ -3028,15 +3028,22 @@ var imageToImageData = Task.async(function* (node, maxDim) {
|
||||
}
|
||||
|
||||
// Extract the image data
|
||||
// Create a canvas to copy the rawNode into and get the imageData from
|
||||
let canvas = node.ownerDocument.createElementNS(XHTML_NS, "canvas");
|
||||
canvas.width = imgWidth * resizeRatio;
|
||||
canvas.height = imgHeight * resizeRatio;
|
||||
let ctx = canvas.getContext("2d");
|
||||
let imageData;
|
||||
// The image may already be a data-uri, in which case, save ourselves the
|
||||
// trouble of converting via the canvas.drawImage.toDataURL method
|
||||
if (isImg && node.src.startsWith("data:")) {
|
||||
imageData = node.src;
|
||||
} else {
|
||||
// Create a canvas to copy the rawNode into and get the imageData from
|
||||
let canvas = node.ownerDocument.createElementNS(XHTML_NS, "canvas");
|
||||
canvas.width = imgWidth * resizeRatio;
|
||||
canvas.height = imgHeight * resizeRatio;
|
||||
let ctx = canvas.getContext("2d");
|
||||
|
||||
// Copy the rawNode image or canvas in the new canvas and extract data
|
||||
ctx.drawImage(node, 0, 0, canvas.width, canvas.height);
|
||||
let imageData = canvas.toDataURL("image/png");
|
||||
// Copy the rawNode image or canvas in the new canvas and extract data
|
||||
ctx.drawImage(node, 0, 0, canvas.width, canvas.height);
|
||||
imageData = canvas.toDataURL("image/png");
|
||||
}
|
||||
|
||||
return {
|
||||
data: imageData,
|
||||
|
Loading…
Reference in New Issue
Block a user