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

Side by Side Diff: Source/devtools/front_end/emulation/OverridesSupport.js

Issue 1200903003: [DevTools] Pass screen size and position to setDeviceMetricsOverrides. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/emulation/OverridesUI.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (this._pageResizer) 549 if (this._pageResizer)
550 this._pageResizer.update(0, 0, 1); 550 this._pageResizer.update(0, 0, 1);
551 return; 551 return;
552 } 552 }
553 553
554 var dipWidth = this.settings.emulateResolution.get() ? this.settings.dev iceWidth.get() : 0; 554 var dipWidth = this.settings.emulateResolution.get() ? this.settings.dev iceWidth.get() : 0;
555 var dipHeight = this.settings.emulateResolution.get() ? this.settings.de viceHeight.get() : 0; 555 var dipHeight = this.settings.emulateResolution.get() ? this.settings.de viceHeight.get() : 0;
556 556
557 var overrideWidth = dipWidth; 557 var overrideWidth = dipWidth;
558 var overrideHeight = dipHeight; 558 var overrideHeight = dipHeight;
559 var screenWidth = dipWidth;
560 var screenHeight = dipHeight;
561 var positionX = 0;
562 var positionY = 0;
559 var scale = 1; 563 var scale = 1;
560 if (this._pageResizer) { 564 if (this._pageResizer) {
561 var available = this._pageResizerAvailableSize; 565 var available = this._pageResizerAvailableSize;
562 var insets = this._pageResizerInsets; 566 var insets = this._pageResizerInsets;
563 if (this.settings.deviceFitWindow.get()) { 567 if (this.settings.deviceFitWindow.get()) {
564 if (this._fixedDeviceScale) { 568 if (this._fixedDeviceScale) {
565 scale = this._deviceScale; 569 scale = this._deviceScale;
566 } else { 570 } else {
567 scale = 1; 571 scale = 1;
568 while (available.width < (dipWidth + insets.left + insets.ri ght) * scale || available.height < (dipHeight + insets.top + insets.bottom) * sc ale) 572 while (available.width < (dipWidth + insets.left + insets.ri ght) * scale || available.height < (dipHeight + insets.top + insets.bottom) * sc ale)
569 scale *= 0.8; 573 scale *= 0.8;
570 } 574 }
571 } 575 }
572 576
573 this._pageResizer.update(Math.min(dipWidth * scale, available.width - insets.left * scale), Math.min(dipHeight * scale, available.height - insets.to p * scale), scale); 577 this._pageResizer.update(Math.min(dipWidth * scale, available.width - insets.left * scale), Math.min(dipHeight * scale, available.height - insets.to p * scale), scale);
574 if (scale === 1 && available.width >= dipWidth && available.height > = dipHeight) { 578 if (scale === 1 && available.width >= dipWidth && available.height > = dipHeight) {
575 // When we have enough space, no page size override is required. This will speed things up and remove lag. 579 // When we have enough space, no page size override is required. This will speed things up and remove lag.
576 overrideWidth = 0; 580 overrideWidth = 0;
577 overrideHeight = 0; 581 overrideHeight = 0;
578 } 582 }
579 if (dipWidth === 0 && dipHeight !== 0) 583 if (dipWidth === 0 && dipHeight !== 0)
580 overrideWidth = Math.round(available.width / scale); 584 overrideWidth = Math.round(available.width / scale);
581 if (dipHeight === 0 && dipWidth !== 0) 585 if (dipHeight === 0 && dipWidth !== 0)
582 overrideHeight = Math.round(available.height / scale); 586 overrideHeight = Math.round(available.height / scale);
587 screenWidth = dipWidth + insets.left + insets.right;
588 screenHeight = dipHeight + insets.top + insets.bottom;
589 positionX = insets.left;
590 positionY = insets.top;
583 } 591 }
584 this._deviceScale = scale; 592 this._deviceScale = scale;
585 593
586 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this )); 594 this._deviceMetricsThrottler.schedule(setDeviceMetricsOverride.bind(this ));
587 595
588 /** 596 /**
589 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 597 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
590 * @this {WebInspector.OverridesSupport} 598 * @this {WebInspector.OverridesSupport}
591 */ 599 */
592 function setDeviceMetricsOverride(finishCallback) 600 function setDeviceMetricsOverride(finishCallback)
593 { 601 {
594 this._target.emulationAgent().setDeviceMetricsOverride( 602 this._target.emulationAgent().setDeviceMetricsOverride(
595 overrideWidth, overrideHeight, this.settings.emulateResolution.g et() ? this.settings.deviceScaleFactor.get() : 0, 603 overrideWidth, overrideHeight, this.settings.emulateResolution.g et() ? this.settings.deviceScaleFactor.get() : 0,
596 this.settings.emulateMobile.get(), this._pageResizer ? false : t his.settings.deviceFitWindow.get(), scale, 0, 0, 604 this.settings.emulateMobile.get(), this._pageResizer ? false : t his.settings.deviceFitWindow.get(), scale, 0, 0,
605 screenWidth, screenHeight, positionX, positionY,
597 apiCallback.bind(this, finishCallback)); 606 apiCallback.bind(this, finishCallback));
598 } 607 }
599 608
600 /** 609 /**
601 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 610 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
602 * @this {WebInspector.OverridesSupport} 611 * @this {WebInspector.OverridesSupport}
603 */ 612 */
604 function clearDeviceMetricsOverride(finishCallback) 613 function clearDeviceMetricsOverride(finishCallback)
605 { 614 {
606 this._target.emulationAgent().clearDeviceMetricsOverride(apiCallback .bind(this, finishCallback)); 615 this._target.emulationAgent().clearDeviceMetricsOverride(apiCallback .bind(this, finishCallback));
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 }, 798 },
790 799
791 __proto__: WebInspector.Object.prototype 800 __proto__: WebInspector.Object.prototype
792 } 801 }
793 802
794 803
795 /** 804 /**
796 * @type {!WebInspector.OverridesSupport} 805 * @type {!WebInspector.OverridesSupport}
797 */ 806 */
798 WebInspector.overridesSupport; 807 WebInspector.overridesSupport;
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/emulation/OverridesUI.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698