Skip to content

Commit

Permalink
[DevTools] Draw screen border below screen image when taking screenshot.
Browse files Browse the repository at this point in the history
BUG=613515

Review-Url: https://codereview.chromium.org/2010773002
Cr-Commit-Position: refs/heads/master@{#396056}
  • Loading branch information
dgozman authored and Commit bot committed May 26, 2016
1 parent 6b50e7b commit 5a8e343
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ WebInspector.DeviceModeView.prototype = {
WebInspector.DOMModel.unmuteHighlight();
WebInspector.inspectorView.restore();

if (error)
if (error) {
console.error(error);
return;
}

// Create a canvas to splice the images together.
var canvas = createElement("canvas");
Expand All @@ -422,6 +424,7 @@ WebInspector.DeviceModeView.prototype = {
var promise = Promise.resolve();
if (this._model.outlineImage())
promise = promise.then(paintImage.bind(null, this._model.outlineImage(), outlineRect));
promise = promise.then(drawBorder);
if (this._model.screenImage())
promise = promise.then(paintImage.bind(null, this._model.screenImage(), screenRect));
promise.then(paintScreenshot.bind(this));
Expand Down Expand Up @@ -449,15 +452,19 @@ WebInspector.DeviceModeView.prototype = {
}
}

/**
* @this {WebInspector.DeviceModeView}
*/
function paintScreenshot()
function drawBorder()
{
ctx.strokeStyle = "hsla(0, 0%, 98%, 0.5)";
ctx.lineWidth = 1;
ctx.setLineDash([10, 10]);
ctx.strokeRect(screenRect.left + 1, screenRect.top + 1, screenRect.width - 2, screenRect.height - 2);
}

/**
* @this {WebInspector.DeviceModeView}
*/
function paintScreenshot()
{
var pageImage = new Image();
pageImage.src = "data:image/png;base64," + content;
ctx.drawImage(pageImage,
Expand Down

0 comments on commit 5a8e343

Please sign in to comment.