Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js

Issue 1939803002: DevTools: mute the node highlight & hide devtools while taking screenshots. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.DeviceModeView = function() 9 WebInspector.DeviceModeView = function()
10 { 10 {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 willHide: function() 373 willHide: function()
374 { 374 {
375 this._model.emulate(WebInspector.DeviceModeModel.Type.None, null, null); 375 this._model.emulate(WebInspector.DeviceModeModel.Type.None, null, null);
376 }, 376 },
377 377
378 captureScreenshot: function() 378 captureScreenshot: function()
379 { 379 {
380 var mainTarget = WebInspector.targetManager.mainTarget(); 380 var mainTarget = WebInspector.targetManager.mainTarget();
381 if (!mainTarget) 381 if (!mainTarget)
382 return; 382 return;
383 WebInspector.DOMModel.muteHighlight();
384
385 var zoomFactor = WebInspector.zoomManager.zoomFactor();
386 var rect = this._contentArea.getBoundingClientRect();
387 var availableSize = new Size(Math.max(rect.width * zoomFactor, 1), Math. max(rect.height * zoomFactor, 1));
388
389 if (availableSize.width < this._model.screenRect().width ||
390 availableSize.height < this._model.screenRect().height) {
391 WebInspector.inspectorView.minimize();
392 }
393
383 mainTarget.pageAgent().captureScreenshot(screenshotCaptured.bind(this)); 394 mainTarget.pageAgent().captureScreenshot(screenshotCaptured.bind(this));
384 395
385 /** 396 /**
386 * @param {?Protocol.Error} error 397 * @param {?Protocol.Error} error
387 * @param {string} content 398 * @param {string} content
388 * @this {WebInspector.DeviceModeView} 399 * @this {WebInspector.DeviceModeView}
389 */ 400 */
390 function screenshotCaptured(error, content) 401 function screenshotCaptured(error, content)
391 { 402 {
392 if (error) 403 if (error) {
404 WebInspector.DOMModel.unmuteHighlight();
405 WebInspector.inspectorView.restore();
393 return; 406 return;
407 }
394 408
395 // Create a canvas to splice the images together. 409 // Create a canvas to splice the images together.
396 var canvas = createElement("canvas"); 410 var canvas = createElement("canvas");
397 var ctx = canvas.getContext("2d"); 411 var ctx = canvas.getContext("2d");
398 var screenRect = this._model.screenRect(); 412 var screenRect = this._model.screenRect();
399 var dpr = window.devicePixelRatio; 413 var dpr = window.devicePixelRatio;
400 canvas.width = screenRect.width * dpr; 414 canvas.width = screenRect.width * dpr;
401 canvas.height = screenRect.height * dpr; 415 canvas.height = screenRect.height * dpr;
402 // Add any available screen images. 416 // Add any available screen images.
403 if (this._model.screenImage()) { 417 if (this._model.screenImage()) {
(...skipping 30 matching lines...) Expand all
434 visiblePageRect.height); 448 visiblePageRect.height);
435 var mainFrame = mainTarget.resourceTreeModel.mainFrame; 449 var mainFrame = mainTarget.resourceTreeModel.mainFrame;
436 var fileName = mainFrame ? mainFrame.url.trimURL().removeURLFrag ment() : ""; 450 var fileName = mainFrame ? mainFrame.url.trimURL().removeURLFrag ment() : "";
437 if (this._model.type() === WebInspector.DeviceModeModel.Type.Dev ice) 451 if (this._model.type() === WebInspector.DeviceModeModel.Type.Dev ice)
438 fileName += WebInspector.UIString("(%s)", this._model.device ().title); 452 fileName += WebInspector.UIString("(%s)", this._model.device ().title);
439 // Trigger download. 453 // Trigger download.
440 var link = createElement("a"); 454 var link = createElement("a");
441 link.download = fileName + ".png"; 455 link.download = fileName + ".png";
442 link.href = canvas.toDataURL("image/png"); 456 link.href = canvas.toDataURL("image/png");
443 link.click(); 457 link.click();
458 WebInspector.DOMModel.unmuteHighlight();
459 WebInspector.inspectorView.restore();
444 } 460 }
445 } 461 }
446 }, 462 },
447 463
448 __proto__: WebInspector.VBox.prototype 464 __proto__: WebInspector.VBox.prototype
449 } 465 }
450 466
451 /** 467 /**
452 * @constructor 468 * @constructor
453 * @extends {WebInspector.VBox} 469 * @extends {WebInspector.VBox}
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 /** 564 /**
549 * @param {number} size 565 * @param {number} size
550 */ 566 */
551 _onMarkerClick: function(size) 567 _onMarkerClick: function(size)
552 { 568 {
553 this._applyCallback.call(null, size); 569 this._applyCallback.call(null, size);
554 }, 570 },
555 571
556 __proto__: WebInspector.VBox.prototype 572 __proto__: WebInspector.VBox.prototype
557 } 573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698