summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-06-25 16:26:13 +0200
committerGitHub <noreply@github.com>2018-06-25 16:26:13 +0200
commit2b16e13f4e607cee8b2c036bb729a6405be8d724 (patch)
treeb25bfe25acea9b8ffe9deaaf1c70cd32400e1172 /devtools
parentb94a90dd7b3d4aeda8ec11f060a0cfcfa768f1c4 (diff)
parent24bdf7781da8aad8618436571f1c0e683a0deed9 (diff)
downloaduxp-2b16e13f4e607cee8b2c036bb729a6405be8d724.tar.gz
Merge pull request #545 from janekptacijarabaci/devtools_eyedropper_slow_1
DevTools - Eyedropper Tool - Used "createImageBitmap(canvas.toBlob())" instead of "createImageBitmap(ctx.getImageData())"
Diffstat (limited to 'devtools')
-rw-r--r--devtools/server/actors/highlighters/eye-dropper.js30
1 files changed, 16 insertions, 14 deletions
diff --git a/devtools/server/actors/highlighters/eye-dropper.js b/devtools/server/actors/highlighters/eye-dropper.js
index a90ec22bd0..bbfa2d78ca 100644
--- a/devtools/server/actors/highlighters/eye-dropper.js
+++ b/devtools/server/actors/highlighters/eye-dropper.js
@@ -191,20 +191,22 @@ EyeDropper.prototype = {
},
prepareImageCapture() {
- // Get the image data from the content window.
- let imageData = getWindowAsImageData(this.win);
-
- // We need to transform imageData to something drawWindow will consume. An ImageBitmap
- // works well. We could have used an Image, but doing so results in errors if the page
- // defines CSP headers.
- this.win.createImageBitmap(imageData).then(image => {
- this.pageImage = image;
- // We likely haven't drawn anything yet (no mousemove events yet), so start now.
- this.draw();
+ // Get the canvas from the content window.
+ let canvas = getWindowAsImageData(this.win);
+
+ canvas.toBlob(blob => {
+ // We need to transform imageData to something drawWindow will consume. An ImageBitmap
+ // works well. We could have used an Image, but doing so results in errors if the page
+ // defines CSP headers.
+ this.win.createImageBitmap(blob).then(image => {
+ this.pageImage = image;
+ // We likely haven't drawn anything yet (no mousemove events yet), so start now.
+ this.draw();
- // Set an attribute on the root element to be able to run tests after the first draw
- // was done.
- this.getElement("root").setAttribute("drawn", "true");
+ // Set an attribute on the root element to be able to run tests after the first draw
+ // was done.
+ this.getElement("root").setAttribute("drawn", "true");
+ });
});
},
@@ -486,7 +488,7 @@ function getWindowAsImageData(win) {
ctx.scale(scale, scale);
ctx.drawWindow(win, win.scrollX, win.scrollY, width, height, "#fff");
- return ctx.getImageData(0, 0, canvas.width, canvas.height);
+ return canvas;
}
/**