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

Unified Diff: Source/devtools/front_end/sdk/OverridesSupport.js

Issue 300103004: DevTools: allow independent sidebar and viewport resize while in responsive mode. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For landing Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/responsiveDesignView.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sdk/OverridesSupport.js
diff --git a/Source/devtools/front_end/sdk/OverridesSupport.js b/Source/devtools/front_end/sdk/OverridesSupport.js
index 986f56a6ec1d2a5ebb4cec09fa4f18459b252493..61d0a43a7438b14ae11205db03593a7b6f7b8859 100644
--- a/Source/devtools/front_end/sdk/OverridesSupport.js
+++ b/Source/devtools/front_end/sdk/OverridesSupport.js
@@ -491,6 +491,14 @@ WebInspector.OverridesSupport.prototype = {
_onPageResizerAvailableSizeChanged: function()
{
+ var metrics = WebInspector.OverridesSupport.DeviceMetrics.parseSetting(this.settings.deviceMetrics.get());
+ if (!metrics.isValid())
+ return;
+
+ var available = this._pageResizer.availableDipSize();
+ if (available.width > metrics.width && available.height > metrics.height)
+ return;
+
this._deviceMetricsChanged();
},
@@ -550,21 +558,39 @@ WebInspector.OverridesSupport.prototype = {
overrideWidth = 0;
overrideHeight = 0;
} else {
- var widthScale = dipWidth ? dipWidth / Math.max(available.width, 1) : 1;
- var heightScale = dipHeight ? dipHeight / Math.max(available.height, 1) : 1;
- var scale = 1 / Math.max(widthScale, heightScale);
- this._pageResizer.enable(dipWidth ? Math.max(Math.floor(dipWidth * scale), 1) : 0, dipHeight ? Math.max(Math.floor(dipHeight * scale), 1) : 0, scale);
- if (!dipWidth)
- overrideWidth = Math.round(available.width / scale);
- if (!dipHeight)
- overrideHeight = Math.round(available.height / scale);
+ this._pageResizer.enable(Math.min(dipWidth, available.width), Math.min(dipHeight, available.height), 0);
}
}
- PageAgent.setDeviceMetricsOverride(
- overrideWidth, overrideHeight, metrics.deviceScaleFactor,
- this.settings.emulateViewport.get(), this._pageResizer ? true : this.settings.deviceFitWindow.get(),
- metrics.textAutosizing, metrics.fontScaleFactor(),
- apiCallback.bind(this));
+
+ // Do not emulate resolution more often than 10Hz.
+ this._setDeviceMetricsTimers = (this._setDeviceMetricsTimers || 0) + 1;
+ if (overrideWidth || overrideHeight)
+ setTimeout(setDeviceMetricsOverride.bind(this), 100);
+ else
+ setDeviceMetricsOverride.call(this);
+
+ /**
+ * @this {WebInspector.OverridesSupport}
+ */
+ function setDeviceMetricsOverride()
+ {
+ // Drop heavy intermediate commands.
+ this._setDeviceMetricsTimers--;
+ var isExpensive = overrideWidth || overrideHeight;
+ if (isExpensive && this._setDeviceMetricsTimers) {
+ var commandThreshold = 100;
+ var time = window.performance.now();
+ if (time - this._lastExpensivePageAgentCommandTime < commandThreshold)
+ return;
+ this._lastExpensivePageAgentCommandTime = time;
+ }
+
+ PageAgent.setDeviceMetricsOverride(
+ overrideWidth, overrideHeight, metrics.deviceScaleFactor,
+ this.settings.emulateViewport.get(), this._pageResizer ? false : this.settings.deviceFitWindow.get(),
+ metrics.textAutosizing, metrics.fontScaleFactor(),
+ apiCallback.bind(this));
+ }
this.maybeHasActiveOverridesChanged();
@@ -656,6 +682,8 @@ WebInspector.OverridesSupport.prototype = {
_showRulersChanged: function()
{
+ if (WebInspector.experimentsSettings.responsiveDesign.isEnabled())
+ return;
PageAgent.setShowViewportSizeOnResize(true, this.showMetricsRulers());
},
« no previous file with comments | « Source/devtools/front_end/responsiveDesignView.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698