| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | |
| 32 * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>} | |
| 33 */ | |
| 34 Main.RenderingOptionsView = class extends UI.VBox { | 31 Main.RenderingOptionsView = class extends UI.VBox { |
| 35 constructor() { | 32 constructor() { |
| 36 super(true); | 33 super(true); |
| 37 this.registerRequiredCSS('main/renderingOptions.css'); | 34 this.registerRequiredCSS('main/renderingOptions.css'); |
| 38 | 35 |
| 39 this._appendCheckbox( | 36 this._appendCheckbox( |
| 40 Common.UIString('Paint Flashing'), | 37 Common.UIString('Paint Flashing'), |
| 41 Common.UIString('Highlights areas of the page (green) that need to be re
painted'), | 38 Common.UIString('Highlights areas of the page (green) that need to be re
painted'), |
| 42 Common.moduleSetting('showPaintRects')); | 39 Common.moduleSetting('showPaintRects')); |
| 43 this._appendCheckbox( | 40 this._appendCheckbox( |
| 44 Common.UIString('Layer Borders'), Common.UIString('Shows layer borders (
orange/olive) and tiles (cyan)'), | 41 Common.UIString('Layer Borders'), Common.UIString('Shows layer borders (
orange/olive) and tiles (cyan)'), |
| 45 Common.moduleSetting('showDebugBorders')); | 42 Common.moduleSetting('showDebugBorders')); |
| 46 this._appendCheckbox( | 43 this._appendCheckbox( |
| 47 Common.UIString('FPS Meter'), | 44 Common.UIString('FPS Meter'), |
| 48 Common.UIString('Plots frames per second, frame rate distribution, and G
PU memory'), | 45 Common.UIString('Plots frames per second, frame rate distribution, and G
PU memory'), |
| 49 Common.moduleSetting('showFPSCounter')); | 46 Common.moduleSetting('showFPSCounter')); |
| 50 this._appendCheckbox( | 47 this._appendCheckbox( |
| 51 Common.UIString('Scrolling Performance Issues'), | 48 Common.UIString('Scrolling Performance Issues'), |
| 52 Common.UIString( | 49 Common.UIString( |
| 53 'Highlights elements (teal) that can slow down scrolling, including
touch & wheel event handlers and other main-thread scrolling situations.'), | 50 'Highlights elements (teal) that can slow down scrolling, including
touch & wheel event handlers and other main-thread scrolling situations.'), |
| 54 Common.moduleSetting('showScrollBottleneckRects')); | 51 Common.moduleSetting('showScrollBottleneckRects')); |
| 55 this.contentElement.createChild('div').classList.add('panel-section-separato
r'); | 52 this.contentElement.createChild('div').classList.add('panel-section-separato
r'); |
| 56 | 53 |
| 57 var cssMediaSubtitle = Common.UIString('Forces media type for testing print
and screen styles'); | 54 var mediaSetting = Common.moduleSetting('emulatedCSSMedia'); |
| 58 var checkboxLabel = UI.CheckboxLabel.create(Common.UIString('Emulate CSS Med
ia'), false, cssMediaSubtitle); | 55 var mediaSelect = UI.SettingsUI.createControlForSetting(mediaSetting); |
| 59 this._mediaCheckbox = checkboxLabel.checkboxElement; | 56 if (mediaSelect) { |
| 60 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this),
false); | 57 var mediaRow = this.contentElement.createChild('span', 'media-row'); |
| 61 this.contentElement.appendChild(checkboxLabel); | 58 mediaRow.createChild('label').textContent = Common.UIString('Emulate CSS M
edia'); |
| 62 | 59 mediaRow.createChild('p').textContent = Common.UIString('Forces media type
for testing print and screen styles'); |
| 63 var mediaRow = this.contentElement.createChild('div', 'media-row'); | 60 mediaRow.appendChild(mediaSelect); |
| 64 this._mediaSelect = mediaRow.createChild('select', 'chrome-select'); | 61 } |
| 65 this._mediaSelect.appendChild(new Option(Common.UIString('print'), 'print'))
; | |
| 66 this._mediaSelect.appendChild(new Option(Common.UIString('screen'), 'screen'
)); | |
| 67 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this),
false); | |
| 68 this._mediaSelect.disabled = true; | |
| 69 | |
| 70 SDK.targetManager.observeModels(SDK.EmulationModel, this); | |
| 71 } | 62 } |
| 72 | 63 |
| 73 /** | 64 /** |
| 74 * @param {string} label | 65 * @param {string} label |
| 75 * @param {string} subtitle | 66 * @param {string} subtitle |
| 76 * @param {!Common.Setting} setting | 67 * @param {!Common.Setting} setting |
| 77 */ | 68 */ |
| 78 _appendCheckbox(label, subtitle, setting) { | 69 _appendCheckbox(label, subtitle, setting) { |
| 79 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle); | 70 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle); |
| 80 UI.SettingsUI.bindCheckbox(checkboxLabel.checkboxElement, setting); | 71 UI.SettingsUI.bindCheckbox(checkboxLabel.checkboxElement, setting); |
| 81 this.contentElement.appendChild(checkboxLabel); | 72 this.contentElement.appendChild(checkboxLabel); |
| 82 } | 73 } |
| 83 | |
| 84 /** | |
| 85 * @override | |
| 86 * @param {!SDK.EmulationModel} emulationModel | |
| 87 */ | |
| 88 modelAdded(emulationModel) { | |
| 89 if (this._mediaCheckbox.checked) | |
| 90 emulationModel.emulateCSSMedia(this._mediaSelect.value); | |
| 91 } | |
| 92 | |
| 93 _mediaToggled() { | |
| 94 this._mediaSelect.disabled = !this._mediaCheckbox.checked; | |
| 95 var media = this._mediaCheckbox.checked ? this._mediaSelect.value : null; | |
| 96 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel)) | |
| 97 emulationModel.emulateCSSMedia(media); | |
| 98 } | |
| 99 | |
| 100 /** | |
| 101 * @override | |
| 102 * @param {!SDK.EmulationModel} emulationModel | |
| 103 */ | |
| 104 modelRemoved(emulationModel) { | |
| 105 } | |
| 106 }; | 74 }; |
| OLD | NEW |