Commit 052f0285 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

DevTools: move emulation button into the base App.js.

R=dgozman@chromium.org

Review URL: https://codereview.chromium.org/342163002

git-svn-id: svn://svn.chromium.org/blink/trunk@176515 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 14c1e19e
......@@ -192,7 +192,7 @@ InspectorTest.applyEmulationAndReload = function(enabled, width, height, deviceS
WebInspector.overridesSupport.emulateDevice(new WebInspector.OverridesSupport.Device(width + "x" + height + "x" + deviceScaleFactor + "x1x1", ""));
else
WebInspector.overridesSupport.reset();
WebInspector.overridesSupport.settings.emulationEnabled.set(enabled);
WebInspector.overridesSupport.settings._emulationEnabled.set(enabled);
function emulateCallback()
{
......
......@@ -51,7 +51,7 @@ WebInspector.ResponsiveDesignView = function(inspectedPagePlaceholder)
this._enabled = false;
WebInspector.zoomManager.addEventListener(WebInspector.ZoomManager.Events.ZoomChanged, this._onZoomChanged, this);
WebInspector.overridesSupport.settings.emulationEnabled.addChangeListener(this._emulationEnabledChanged, this);
WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.EmulationStateChanged, this._emulationEnabledChanged, this);
this._emulationEnabledChanged();
this._overridesWarningUpdated();
};
......@@ -74,7 +74,7 @@ WebInspector.ResponsiveDesignView.prototype = {
_emulationEnabledChanged: function()
{
var enabled = WebInspector.overridesSupport.settings.emulationEnabled.get();
var enabled = WebInspector.overridesSupport.emulationEnabled();
if (enabled && !this._enabled) {
this._invalidateCache();
this._ignoreResize = true;
......
......@@ -44,10 +44,8 @@ WebInspector.OverridesView = function()
this._tabbedPane.verticalTabLayout = true;
if (!WebInspector.overridesSupport.isInspectingDevice()) {
new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane);
new WebInspector.OverridesView.MediaTab().appendAsTab(this._tabbedPane);
}
new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane);
new WebInspector.OverridesView.MediaTab().appendAsTab(this._tabbedPane);
new WebInspector.OverridesView.NetworkTab().appendAsTab(this._tabbedPane);
new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane);
......@@ -65,13 +63,13 @@ WebInspector.OverridesView = function()
this._splashScreenElement = this.element.createChild("div", "overrides-splash-screen");
this._splashScreenElement.createTextChild(WebInspector.UIString("Emulation is currently disabled. Toggle "));
var toggleEmulationButton = new WebInspector.StatusBarButton("", "responsive-design-status-bar-item");
var toggleEmulationButton = new WebInspector.StatusBarButton("", "emulation-status-bar-item");
toggleEmulationButton.addEventListener("click", this._toggleEmulationEnabled, this);
this._splashScreenElement.appendChild(toggleEmulationButton.element);
this._splashScreenElement.createTextChild(WebInspector.UIString("in the main toolbar to enable it."));
WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.OverridesWarningUpdated, this._overridesWarningUpdated, this);
WebInspector.overridesSupport.settings.emulationEnabled.addChangeListener(this._emulationEnabledChanged, this);
WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.EmulationStateChanged, this._emulationEnabledChanged, this);
this._emulationEnabledChanged();
}
......@@ -87,20 +85,20 @@ WebInspector.OverridesView.prototype = {
_overridesWarningUpdated: function()
{
var message = WebInspector.overridesSupport.warningMessage();
this._warningFooter.classList.toggle("hidden", !WebInspector.overridesSupport.settings.emulationEnabled.get() || !message);
this._warningFooter.classList.toggle("hidden", !WebInspector.overridesSupport.emulationEnabled() || !message);
this._warningFooter.textContent = message;
},
_toggleEmulationEnabled: function()
{
WebInspector.overridesSupport.settings.emulationEnabled.set(true);
WebInspector.overridesSupport.setEmulationEnabled(true);
},
_emulationEnabledChanged: function()
{
this._tabbedPane.element.classList.toggle("hidden", !WebInspector.overridesSupport.settings.emulationEnabled.get());
this._tabbedPane.element.classList.toggle("hidden", !WebInspector.overridesSupport.emulationEnabled());
this._overridesWarningUpdated();
this._splashScreenElement.classList.toggle("hidden", WebInspector.overridesSupport.settings.emulationEnabled.get());
this._splashScreenElement.classList.toggle("hidden", WebInspector.overridesSupport.emulationEnabled());
},
__proto__: WebInspector.VBox.prototype
......
......@@ -2294,7 +2294,7 @@ body.inactive .sidebar-tree-item.selected {
-webkit-mask-position: -224px -24px;
}
.responsive-design-status-bar-item .glyph {
.emulation-status-bar-item .glyph {
-webkit-mask-position: -164px 0px;
}
......
......@@ -10,26 +10,9 @@ WebInspector.AdvancedApp = function()
{
WebInspector.App.call(this);
WebInspector.dockController.addEventListener(WebInspector.DockController.Events.BeforeDockSideChanged, this._openToolboxWindow, this);
this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspector.UIString("Toggle emulation enabled."), "responsive-design-status-bar-item");
this._toggleEmulationButton.toggled = WebInspector.overridesSupport.settings.emulationEnabled.get();
this._toggleEmulationButton.addEventListener("click", this._toggleEmulationEnabled, this);
WebInspector.overridesSupport.settings.emulationEnabled.addChangeListener(this._emulationEnabledChanged, this);
};
WebInspector.AdvancedApp.prototype = {
_toggleEmulationEnabled: function()
{
WebInspector.overridesSupport.settings.emulationEnabled.set(!this._toggleEmulationButton.toggled);
},
_emulationEnabledChanged: function()
{
this._toggleEmulationButton.toggled = WebInspector.overridesSupport.settings.emulationEnabled.get();
if (!WebInspector.experimentsSettings.responsiveDesign.isEnabled() && WebInspector.overridesSupport.settings.emulationEnabled.get())
WebInspector.inspectorView.showViewInDrawer("emulation", true);
},
createRootView: function()
{
var rootView = new WebInspector.RootView();
......@@ -175,26 +158,6 @@ WebInspector.AdvancedApp.prototype = {
__proto__: WebInspector.App.prototype
};
/**
* @constructor
* @implements {WebInspector.StatusBarButton.Provider}
*/
WebInspector.AdvancedApp.ResponsiveDesignButtonProvider = function()
{
}
WebInspector.AdvancedApp.ResponsiveDesignButtonProvider.prototype = {
/**
* @return {?WebInspector.StatusBarButton}
*/
button: function()
{
if (!(WebInspector.app instanceof WebInspector.AdvancedApp))
return null;
return /** @type {!WebInspector.AdvancedApp} */ (WebInspector.app)._toggleEmulationButton || null;
}
}
/**
* @constructor
*/
......
......@@ -7,9 +7,27 @@
*/
WebInspector.App = function()
{
if (WebInspector.overridesSupport.canEmulate()) {
this._toggleEmulationButton = new WebInspector.StatusBarButton(WebInspector.UIString("Toggle emulation enabled."), "emulation-status-bar-item");
this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emulationEnabled();
this._toggleEmulationButton.addEventListener("click", this._toggleEmulationEnabled, this);
WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport.Events.EmulationStateChanged, this._emulationEnabledChanged, this);
}
};
WebInspector.App.prototype = {
_toggleEmulationEnabled: function()
{
WebInspector.overridesSupport.setEmulationEnabled(!this._toggleEmulationButton.toggled);
},
_emulationEnabledChanged: function()
{
this._toggleEmulationButton.toggled = WebInspector.overridesSupport.emulationEnabled();
if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebInspector.overridesSupport.emulationEnabled())
WebInspector.inspectorView.showViewInDrawer("emulation", true);
},
createRootView: function()
{
},
......@@ -19,11 +37,31 @@ WebInspector.App.prototype = {
WebInspector.inspectorView.showInitialPanel();
WebInspector.overridesSupport.applyInitialOverrides();
if (WebInspector.overridesSupport.hasActiveOverrides() && !WebInspector.experimentsSettings.responsiveDesign.isEnabled())
if (!WebInspector.overridesSupport.responsiveDesignAvailable() && WebInspector.overridesSupport.emulationEnabled())
WebInspector.inspectorView.showViewInDrawer("emulation", true);
}
};
/**
* @constructor
* @implements {WebInspector.StatusBarButton.Provider}
*/
WebInspector.App.EmulationButtonProvider = function()
{
}
WebInspector.App.EmulationButtonProvider.prototype = {
/**
* @return {?WebInspector.StatusBarButton}
*/
button: function()
{
if (!(WebInspector.app instanceof WebInspector.App))
return null;
return WebInspector.app._toggleEmulationButton || null;
}
}
/**
* @type {!WebInspector.App}
*/
......
......@@ -124,7 +124,7 @@
},
{
"type": "@WebInspector.StatusBarButton.Provider",
"className": "WebInspector.AdvancedApp.ResponsiveDesignButtonProvider",
"className": "WebInspector.App.EmulationButtonProvider",
"order": 1,
"location": "toolbar-left"
},
......
......@@ -305,7 +305,7 @@ button.overrides-swap {
.overrides-splash-screen {
display: block;
padding: 3px 10px;
padding: 10px 10px;
}
.overrides-splash-screen > button {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment