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

Side by Side Diff: Source/devtools/front_end/elements/OverridesView.js

Issue 306803004: DevTools: hide emulation bits that are available in responsive design toolbar from the drawer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 26 matching lines...) Expand all
37 WebInspector.VBox.call(this); 37 WebInspector.VBox.call(this);
38 this.registerRequiredCSS("overrides.css"); 38 this.registerRequiredCSS("overrides.css");
39 this.registerRequiredCSS("helpScreen.css"); 39 this.registerRequiredCSS("helpScreen.css");
40 this.element.classList.add("overrides-view"); 40 this.element.classList.add("overrides-view");
41 41
42 this._tabbedPane = new WebInspector.TabbedPane(); 42 this._tabbedPane = new WebInspector.TabbedPane();
43 this._tabbedPane.shrinkableTabs = false; 43 this._tabbedPane.shrinkableTabs = false;
44 this._tabbedPane.verticalTabLayout = true; 44 this._tabbedPane.verticalTabLayout = true;
45 45
46 if (!WebInspector.overridesSupport.isInspectingDevice()) { 46 if (!WebInspector.overridesSupport.isInspectingDevice()) {
47 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedPane) ; 47 if (!WebInspector.overridesSupport.responsiveDesignAvailable())
48 new WebInspector.OverridesView.DeviceTab().appendAsTab(this._tabbedP ane);
48 new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPan e); 49 new WebInspector.OverridesView.ViewportTab().appendAsTab(this._tabbedPan e);
49 } 50 }
50 new WebInspector.OverridesView.UserAgentTab().appendAsTab(this._tabbedPane); 51 new WebInspector.OverridesView.UserAgentTab().appendAsTab(this._tabbedPane);
51 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane); 52 new WebInspector.OverridesView.SensorsTab().appendAsTab(this._tabbedPane);
52 53
53 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele ctedEmulateTab", "device"); 54 this._lastSelectedTabSetting = WebInspector.settings.createSetting("lastSele ctedEmulateTab", "device");
54 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get()); 55 this._tabbedPane.selectTab(this._lastSelectedTabSetting.get());
55 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele cted, this._tabSelected, this); 56 this._tabbedPane.addEventListener(WebInspector.TabbedPane.EventTypes.TabSele cted, this._tabSelected, this);
56 this._tabbedPane.show(this.element); 57 this._tabbedPane.show(this.element);
57 58
(...skipping 15 matching lines...) Expand all
73 { 74 {
74 var message = WebInspector.overridesSupport.warningMessage(); 75 var message = WebInspector.overridesSupport.warningMessage();
75 this._warningFooter.classList.toggle("hidden", !message); 76 this._warningFooter.classList.toggle("hidden", !message);
76 this._warningFooter.textContent = message; 77 this._warningFooter.textContent = message;
77 }, 78 },
78 79
79 __proto__: WebInspector.VBox.prototype 80 __proto__: WebInspector.VBox.prototype
80 } 81 }
81 82
82 /** 83 /**
83 * @return {boolean}
84 */
85 WebInspector.OverridesView.isResponsiveDesignEnabled = function()
86 {
87 return WebInspector.dockController.canDock() && WebInspector.experimentsSett ings.responsiveDesign.isEnabled();
88 };
89
90 /**
91 * @constructor 84 * @constructor
92 * @extends {WebInspector.VBox} 85 * @extends {WebInspector.VBox}
93 * @param {string} id 86 * @param {string} id
94 * @param {string} name 87 * @param {string} name
95 * @param {!Array.<!WebInspector.Setting>} settings 88 * @param {!Array.<!WebInspector.Setting>} settings
96 */ 89 */
97 WebInspector.OverridesView.Tab = function(id, name, settings) 90 WebInspector.OverridesView.Tab = function(id, name, settings)
98 { 91 {
99 WebInspector.VBox.call(this); 92 WebInspector.VBox.call(this);
100 this._id = id; 93 this._id = id;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 this._userAgentLabel.textContent = WebInspector.UIString("User agent:"); 173 this._userAgentLabel.textContent = WebInspector.UIString("User agent:");
181 this._userAgentValueElement = this._userAgentLabel.createChild("span", "over rides-device-value"); 174 this._userAgentValueElement = this._userAgentLabel.createChild("span", "over rides-device-value");
182 175
183 this._updateValueLabels(); 176 this._updateValueLabels();
184 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport .Events.HasActiveOverridesChanged, this._hasActiveOverridesChanged, this); 177 WebInspector.overridesSupport.addEventListener(WebInspector.OverridesSupport .Events.HasActiveOverridesChanged, this._hasActiveOverridesChanged, this);
185 this._hasActiveOverridesChanged(); 178 this._hasActiveOverridesChanged();
186 } 179 }
187 180
188 WebInspector.OverridesView.DeviceTab.prototype = { 181 WebInspector.OverridesView.DeviceTab.prototype = {
189 /** 182 /**
190 * @param {!Event} e 183 * @param {?Event} e
191 */ 184 */
192 _keyPressed: function(e) 185 _keyPressed: function(e)
193 { 186 {
194 if (e.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) 187 if (e.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code)
195 this._emulateButtonClicked(); 188 this._emulateButtonClicked();
196 }, 189 },
197 190
198 _emulateButtonClicked: function() 191 _emulateButtonClicked: function()
199 { 192 {
200 var option = this._deviceSelectElement.options[this._deviceSelectElement .selectedIndex]; 193 var option = this._deviceSelectElement.options[this._deviceSelectElement .selectedIndex];
(...skipping 24 matching lines...) Expand all
225 __proto__: WebInspector.OverridesView.Tab.prototype 218 __proto__: WebInspector.OverridesView.Tab.prototype
226 } 219 }
227 220
228 221
229 /** 222 /**
230 * @constructor 223 * @constructor
231 * @extends {WebInspector.OverridesView.Tab} 224 * @extends {WebInspector.OverridesView.Tab}
232 */ 225 */
233 WebInspector.OverridesView.ViewportTab = function() 226 WebInspector.OverridesView.ViewportTab = function()
234 { 227 {
235 WebInspector.OverridesView.Tab.call(this, "viewport", WebInspector.UIString( "Screen"), [WebInspector.overridesSupport.settings.overrideDeviceResolution, Web Inspector.overridesSupport.settings.emulateViewport, WebInspector.overridesSuppo rt.settings.overrideCSSMedia]); 228 var settings = [WebInspector.overridesSupport.settings.overrideCSSMedia];
229 if (!WebInspector.overridesSupport.responsiveDesignAvailable())
230 settings = settings.concat([WebInspector.overridesSupport.settings.overr ideDeviceResolution, WebInspector.overridesSupport.settings.emulateViewport]);
231 WebInspector.OverridesView.Tab.call(this, "viewport", WebInspector.UIString( "Screen"), settings);
236 this.element.classList.add("overrides-viewport"); 232 this.element.classList.add("overrides-viewport");
237 233
238 this._createDeviceMetricsElement(); 234 if (!WebInspector.overridesSupport.responsiveDesignAvailable()) {
239 var checkbox = this._createSettingCheckbox(WebInspector.UIString("Emulate vi ewport"), WebInspector.overridesSupport.settings.emulateViewport); 235 this._createDeviceMetricsElement();
240 this.element.appendChild(checkbox); 236 var checkbox = this._createSettingCheckbox(WebInspector.UIString("Emulat e viewport"), WebInspector.overridesSupport.settings.emulateViewport);
237 this.element.appendChild(checkbox);
238 }
241 this._createMediaEmulationFragment(); 239 this._createMediaEmulationFragment();
242 240
243 var footnote = this.element.createChild("p", "help-footnote"); 241 var footnote = this.element.createChild("p", "help-footnote");
244 var footnoteLink = footnote.createChild("a"); 242 var footnoteLink = footnote.createChild("a");
245 footnoteLink.href = "https://developers.google.com/chrome-developer-tools/do cs/mobile-emulation"; 243 footnoteLink.href = "https://developers.google.com/chrome-developer-tools/do cs/mobile-emulation";
246 footnoteLink.target = "_blank"; 244 footnoteLink.target = "_blank";
247 footnoteLink.createTextChild(WebInspector.UIString("More information about s creen emulation")); 245 footnoteLink.createTextChild(WebInspector.UIString("More information about s creen emulation"));
248 } 246 }
249 247
250 WebInspector.OverridesView.ViewportTab.prototype = { 248 WebInspector.OverridesView.ViewportTab.prototype = {
(...skipping 18 matching lines...) Expand all
269 var widthOverrideInput = WebInspector.SettingsUI.createSettingInputField ("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "80px", WebIns pector.OverridesSupport.inputValidator, true); 267 var widthOverrideInput = WebInspector.SettingsUI.createSettingInputField ("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "80px", WebIns pector.OverridesSupport.inputValidator, true);
270 cellElement.appendChild(widthOverrideInput); 268 cellElement.appendChild(widthOverrideInput);
271 this._swapDimensionsElement = cellElement.createChild("button", "overrid es-swap"); 269 this._swapDimensionsElement = cellElement.createChild("button", "overrid es-swap");
272 this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW. 270 this._swapDimensionsElement.appendChild(document.createTextNode(" \u21C4 ")); // RIGHTWARDS ARROW OVER LEFTWARDS ARROW.
273 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns"); 271 this._swapDimensionsElement.title = WebInspector.UIString("Swap dimensio ns");
274 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false); 272 this._swapDimensionsElement.addEventListener("click", WebInspector.overr idesSupport.swapDimensions.bind(WebInspector.overridesSupport), false);
275 this._swapDimensionsElement.tabIndex = -1; 273 this._swapDimensionsElement.tabIndex = -1;
276 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI nspector.OverridesSupport.inputValidator, true); 274 var heightOverrideInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.deviceHeight, true, 4, "80px", WebI nspector.OverridesSupport.inputValidator, true);
277 cellElement.appendChild(heightOverrideInput); 275 cellElement.appendChild(heightOverrideInput);
278 276
279 if (!WebInspector.OverridesView.isResponsiveDesignEnabled()) { 277 rowElement = tableElement.createChild("tr");
280 rowElement = tableElement.createChild("tr"); 278 cellElement = rowElement.createChild("td");
281 cellElement = rowElement.createChild("td"); 279 cellElement.colSpan = 4;
282 cellElement.colSpan = 4;
283 280
284 var widthRangeInput = WebInspector.SettingsUI.createSettingInputFiel d("", WebInspector.overridesSupport.settings.deviceWidth, true, 4, "200px", unde fined, true); 281 var widthRangeInput = WebInspector.SettingsUI.createSettingInputField("" , WebInspector.overridesSupport.settings.deviceWidth, true, 4, "200px", undefine d, true).lastChild;
285 widthRangeInput.type = "range"; 282 widthRangeInput.type = "range";
286 widthRangeInput.min = 100; 283 widthRangeInput.min = 100;
287 widthRangeInput.max = 2000; 284 widthRangeInput.max = 2000;
288 cellElement.appendChild(widthRangeInput); 285 cellElement.appendChild(widthRangeInput);
289 }
290 286
291 rowElement = tableElement.createChild("tr"); 287 rowElement = tableElement.createChild("tr");
292 rowElement.title = WebInspector.UIString("Ratio between a device's physi cal pixels and device-independent pixels."); 288 rowElement.title = WebInspector.UIString("Ratio between a device's physi cal pixels and device-independent pixels.");
293 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp ector.UIString("Device pixel ratio:"))); 289 rowElement.createChild("td").appendChild(document.createTextNode(WebInsp ector.UIString("Device pixel ratio:")));
294 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t rue, 2, "80px", WebInspector.OverridesSupport.inputValidator, true)); 290 rowElement.createChild("td").appendChild(WebInspector.SettingsUI.createS ettingInputField("", WebInspector.overridesSupport.settings.deviceScaleFactor, t rue, 2, "80px", WebInspector.OverridesSupport.inputValidator, true));
295 291
296 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings .deviceTextAutosizing); 292 var textAutosizingOverrideElement = this._createSettingCheckbox(WebInspe ctor.UIString("Enable text autosizing "), WebInspector.overridesSupport.settings .deviceTextAutosizing);
297 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi zing is the feature that boosts font sizes on mobile devices."); 293 textAutosizingOverrideElement.title = WebInspector.UIString("Text autosi zing is the feature that boosts font sizes on mobile devices.");
298 fieldsetElement.appendChild(textAutosizingOverrideElement); 294 fieldsetElement.appendChild(textAutosizingOverrideElement);
299 295
300 if (!WebInspector.OverridesView.isResponsiveDesignEnabled()) { 296 checkbox = this._createSettingCheckbox(WebInspector.UIString("Shrink to fit"), WebInspector.overridesSupport.settings.deviceFitWindow);
301 checkbox = this._createSettingCheckbox(WebInspector.UIString("Shrink to fit"), WebInspector.overridesSupport.settings.deviceFitWindow); 297 fieldsetElement.appendChild(checkbox);
302 fieldsetElement.appendChild(checkbox);
303 }
304 this.element.appendChild(fieldsetElement); 298 this.element.appendChild(fieldsetElement);
305 }, 299 },
306 300
307 _createMediaEmulationFragment: function() 301 _createMediaEmulationFragment: function()
308 { 302 {
309 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspecto r.UIString("CSS media"), WebInspector.overridesSupport.settings.overrideCSSMedia , true); 303 var checkbox = WebInspector.SettingsUI.createSettingCheckbox(WebInspecto r.UIString("CSS media"), WebInspector.overridesSupport.settings.overrideCSSMedia , true);
310 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI nspector.overridesSupport.settings.overrideCSSMedia); 304 var fieldsetElement = WebInspector.SettingsUI.createSettingFieldset(WebI nspector.overridesSupport.settings.overrideCSSMedia);
311 if (WebInspector.overridesSupport.isInspectingDevice()) 305 if (WebInspector.overridesSupport.isInspectingDevice())
312 fieldsetElement.disabled = true; 306 fieldsetElement.disabled = true;
313 307
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 } 493 }
500 494
501 495
502 /** 496 /**
503 * @constructor 497 * @constructor
504 * @extends {WebInspector.OverridesView.Tab} 498 * @extends {WebInspector.OverridesView.Tab}
505 */ 499 */
506 WebInspector.OverridesView.SensorsTab = function() 500 WebInspector.OverridesView.SensorsTab = function()
507 { 501 {
508 var settings = [WebInspector.overridesSupport.settings.overrideGeolocation, WebInspector.overridesSupport.settings.overrideDeviceOrientation]; 502 var settings = [WebInspector.overridesSupport.settings.overrideGeolocation, WebInspector.overridesSupport.settings.overrideDeviceOrientation];
509 if (!WebInspector.overridesSupport.hasTouchInputs()) 503 if (!WebInspector.overridesSupport.hasTouchInputs() && !WebInspector.overrid esSupport.responsiveDesignAvailable())
510 settings.push(WebInspector.overridesSupport.settings.emulateTouchEvents) ; 504 settings.push(WebInspector.overridesSupport.settings.emulateTouchEvents) ;
511 WebInspector.OverridesView.Tab.call(this, "sensors", WebInspector.UIString(" Sensors"), settings); 505 WebInspector.OverridesView.Tab.call(this, "sensors", WebInspector.UIString(" Sensors"), settings);
512 506
513 this.element.classList.add("overrides-sensors"); 507 this.element.classList.add("overrides-sensors");
514 this.registerRequiredCSS("accelerometer.css"); 508 this.registerRequiredCSS("accelerometer.css");
515 if (!WebInspector.overridesSupport.hasTouchInputs()) 509 if (!WebInspector.overridesSupport.hasTouchInputs() && !WebInspector.overrid esSupport.responsiveDesignAvailable())
516 this.element.appendChild(this._createSettingCheckbox(WebInspector.UIStri ng("Emulate touch screen"), WebInspector.overridesSupport.settings.emulateTouchE vents)); 510 this.element.appendChild(this._createSettingCheckbox(WebInspector.UIStri ng("Emulate touch screen"), WebInspector.overridesSupport.settings.emulateTouchE vents));
517 this._appendGeolocationOverrideControl(); 511 this._appendGeolocationOverrideControl();
518 this._apendDeviceOrientationOverrideControl(); 512 this._apendDeviceOrientationOverrideControl();
519 } 513 }
520 514
521 WebInspector.OverridesView.SensorsTab.prototype = { 515 WebInspector.OverridesView.SensorsTab.prototype = {
522 _appendGeolocationOverrideControl: function() 516 _appendGeolocationOverrideControl: function()
523 { 517 {
524 const geolocationSetting = WebInspector.overridesSupport.settings.geoloc ationOverride.get(); 518 const geolocationSetting = WebInspector.overridesSupport.settings.geoloc ationOverride.get();
525 var geolocation = WebInspector.OverridesSupport.GeolocationPosition.pars eSetting(geolocationSetting); 519 var geolocation = WebInspector.OverridesSupport.GeolocationPosition.pars eSetting(geolocationSetting);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 763
770 __proto__ : WebInspector.OverridesView.Tab.prototype 764 __proto__ : WebInspector.OverridesView.Tab.prototype
771 } 765 }
772 766
773 /** @enum {string} */ 767 /** @enum {string} */
774 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = { 768 WebInspector.OverridesView.SensorsTab.DeviceOrientationModificationSource = {
775 UserInput: "userInput", 769 UserInput: "userInput",
776 UserDrag: "userDrag", 770 UserDrag: "userDrag",
777 ResetButton: "resetButton" 771 ResetButton: "resetButton"
778 } 772 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ResponsiveDesignView.js ('k') | Source/devtools/front_end/main/Main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698