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

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

Issue 1450133003: [DevTools] Promote Device Mode v2 to default experiments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweaks Created 5 years, 1 month 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 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder 8 * @param {!WebInspector.InspectedPagePlaceholder} inspectedPagePlaceholder
9 */ 9 */
10 WebInspector.DeviceModeView = function(inspectedPagePlaceholder) 10 WebInspector.DeviceModeView = function(inspectedPagePlaceholder)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 var resizable = this._model.isResizable(); 158 var resizable = this._model.isResizable();
159 if (resizable !== this._cachedResizable) { 159 if (resizable !== this._cachedResizable) {
160 this._resizerElement.classList.toggle("hidden", !resizable); 160 this._resizerElement.classList.toggle("hidden", !resizable);
161 this._cachedResizable = resizable; 161 this._cachedResizable = resizable;
162 } 162 }
163 163
164 this._toolbar.update(); 164 this._toolbar.update();
165 this._loadScreenImage(this._model.screenImage()); 165 this._loadScreenImage(this._model.screenImage());
166 if (resizePagePlaceholder) 166 if (resizePagePlaceholder)
167 this._inspectedPagePlaceholder.onResize(); 167 this._inspectedPagePlaceholder.onResize();
168 this._mediaInspector.setAxisTransform(-cssScreenRect.left, this._model.f itScale()); 168 this._mediaInspector.setAxisTransform(-cssScreenRect.left / this._model. fitScale(), this._model.fitScale());
169 }, 169 },
170 170
171 /** 171 /**
172 * @param {string} srcset 172 * @param {string} srcset
173 */ 173 */
174 _loadScreenImage: function(srcset) 174 _loadScreenImage: function(srcset)
175 { 175 {
176 if (this._screenImage.getAttribute("srcset") === srcset) 176 if (this._screenImage.getAttribute("srcset") === srcset)
177 return; 177 return;
178 this._screenImage.setAttribute("srcset", srcset); 178 this._screenImage.setAttribute("srcset", srcset);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 select.addEventListener("change", optionSelected.bind(this), false); 397 select.addEventListener("change", optionSelected.bind(this), false);
398 return select; 398 return select;
399 399
400 /** 400 /**
401 * @this {WebInspector.DeviceModeView.Toolbar} 401 * @this {WebInspector.DeviceModeView.Toolbar}
402 */ 402 */
403 function deviceListChanged() 403 function deviceListChanged()
404 { 404 {
405 select.removeChildren(); 405 select.removeChildren();
406 406
407 addOption.call(this, select, WebInspector.DeviceModeModel.Type.Mobil e, null, WebInspector.UIString("Responsive")); 407 var defaultGroup = select.createChild("optgroup");
408 defaultGroup.label = WebInspector.UIString("Default");
409 addOption.call(this, defaultGroup, WebInspector.DeviceModeModel.Type .Mobile, null, WebInspector.UIString("Responsive"));
408 410
409 var group = select.createChild("optgroup"); 411 var devicesGroup = select.createChild("optgroup");
410 group.label = WebInspector.UIString("Devices"); 412 devicesGroup.label = WebInspector.UIString("Devices");
411 addGroup.call(this, group, WebInspector.emulatedDevicesList.custom() ); 413 addGroup.call(this, devicesGroup, WebInspector.emulatedDevicesList.s tandard());
412 addGroup.call(this, group, WebInspector.emulatedDevicesList.standard ()); 414
415 var customGroup = select.createChild("optgroup");
416 customGroup.label = WebInspector.UIString("Custom");
417 addGroup.call(this, customGroup, WebInspector.emulatedDevicesList.cu stom());
418 var editCustomOption = new Option(WebInspector.UIString("Edit\u2026" ), WebInspector.UIString("Edit\u2026"));
419 editCustomOption.edit = true;
420 customGroup.appendChild(editCustomOption);
413 } 421 }
414 422
415 /** 423 /**
416 * @param {!Element} parent 424 * @param {!Element} parent
417 * @param {!Array<!WebInspector.EmulatedDevice>} devices 425 * @param {!Array<!WebInspector.EmulatedDevice>} devices
418 * @this {WebInspector.DeviceModeView.Toolbar} 426 * @this {WebInspector.DeviceModeView.Toolbar}
419 */ 427 */
420 function addGroup(parent, devices) 428 function addGroup(parent, devices)
421 { 429 {
422 devices = devices.filter(function(d) { return d.show(); }); 430 devices = devices.filter(function(d) { return d.show(); });
(...skipping 18 matching lines...) Expand all
441 449
442 if (type === this._model.type() && device === this._model.device()) 450 if (type === this._model.type() && device === this._model.device())
443 select.selectedIndex = Array.prototype.slice.call(select.options ).indexOf(option); 451 select.selectedIndex = Array.prototype.slice.call(select.options ).indexOf(option);
444 } 452 }
445 453
446 /** 454 /**
447 * @this {WebInspector.DeviceModeView.Toolbar} 455 * @this {WebInspector.DeviceModeView.Toolbar}
448 */ 456 */
449 function optionSelected() 457 function optionSelected()
450 { 458 {
451 this._emulateDeviceSelectOption(select.options[select.selectedIndex] ); 459 var option = select.options[select.selectedIndex];
460 if (option.edit) {
461 WebInspector.emulatedDevicesList.revealCustomSetting();
462 this._updateDeviceSelectedIndex();
463 } else {
464 this._emulateDeviceSelectOption(option);
465 }
452 } 466 }
453 }, 467 },
454 468
469 _updateDeviceSelectedIndex: function()
470 {
471 for (var i = 0; i < this._deviceSelect.options.length; ++i) {
472 if (this._deviceSelect.options[i].device === this._model.device())
473 this._deviceSelect.selectedIndex = i;
474 }
475 },
476
455 /** 477 /**
456 * @param {!Option} option 478 * @param {!Option} option
457 */ 479 */
458 _emulateDeviceSelectOption: function(option) 480 _emulateDeviceSelectOption: function(option)
459 { 481 {
460 this._model.emulate(option.type, option.device, option.device ? (this._l astMode.get(option.device) || option.device.modes[0]) : null); 482 this._model.emulate(option.type, option.device, option.device ? (this._l astMode.get(option.device) || option.device.modes[0]) : null);
461 }, 483 },
462 484
463 /** 485 /**
464 * @param {!WebInspector.Event} event 486 * @param {!WebInspector.Event} event
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 this._deviceScaleFactorItem.setText(String(deviceScaleFactor)); 611 this._deviceScaleFactorItem.setText(String(deviceScaleFactor));
590 this._cachedDeviceScaleFactor = deviceScaleFactor; 612 this._cachedDeviceScaleFactor = deviceScaleFactor;
591 } 613 }
592 } 614 }
593 615
594 if (this._model.device() !== this._cachedModelDevice) { 616 if (this._model.device() !== this._cachedModelDevice) {
595 var device = this._model.device(); 617 var device = this._model.device();
596 618
597 var modeCount = device ? device.modes.length : 0; 619 var modeCount = device ? device.modes.length : 0;
598 this._modeToolbar.element.classList.toggle("hidden", modeCount < 2); 620 this._modeToolbar.element.classList.toggle("hidden", modeCount < 2);
599 621 this._updateDeviceSelectedIndex();
600 for (var i = 0; i < this._deviceSelect.options.length; ++i) {
601 if (this._deviceSelect.options[i].device === this._model.device( ))
602 this._deviceSelect.selectedIndex = i;
603 }
604 622
605 this._cachedModelDevice = device; 623 this._cachedModelDevice = device;
606 } 624 }
607 625
608 if (this._model.device() && this._model.mode()) 626 if (this._model.device() && this._model.mode())
609 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this ._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model .mode())); 627 this._lastMode.set(/** @type {!WebInspector.EmulatedDevice} */ (this ._model.device()), /** @type {!WebInspector.EmulatedDevice.Mode} */ (this._model .mode()));
610 628
611 if (this._model.type() !== WebInspector.DeviceModeModel.Type.Desktop) 629 if (this._model.type() !== WebInspector.DeviceModeModel.Type.Desktop)
612 this._lastDevice = this._model.device(); 630 this._lastDevice = this._model.device();
613 } 631 }
614 } 632 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698