| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {SDK.TargetManager.Observer} | 31 * @implements {SDK.TargetManager.Observer} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Main.RenderingOptionsView = class extends UI.VBox { | 34 Main.RenderingOptionsView = class extends UI.VBox { |
| 35 constructor() { | 35 constructor() { |
| 36 super(true); | 36 super(true); |
| 37 this.registerRequiredCSS('main/renderingOptions.css'); | 37 this.registerRequiredCSS('main/renderingOptions.css'); |
| 38 | 38 |
| 39 this._appendCheckbox( | 39 /** @type {!Map.<string, !Element>} */ |
| 40 Common.UIString('Paint Flashing'), | 40 this._settings = new Map(); |
| 41 Common.UIString('Highlights areas of the page (green) that need to be re
painted'), | 41 |
| 42 Common.moduleSetting('showPaintRects')); | 42 var options = [ |
| 43 this._appendCheckbox( | 43 { |
| 44 Common.UIString('Layer Borders'), Common.UIString('Shows layer borders (
orange/olive) and tiles (cyan)'), | 44 label: Common.UIString('Paint Flashing'), |
| 45 Common.moduleSetting('showDebugBorders')); | 45 subtitle: Common.UIString('Highlights areas of the page (green) that nee
d to be repainted'), |
| 46 this._appendCheckbox( | 46 setterName: 'setShowPaintRects' |
| 47 Common.UIString('FPS Meter'), | 47 }, |
| 48 Common.UIString('Plots frames per second, frame rate distribution, and G
PU memory'), | 48 { |
| 49 Common.moduleSetting('showFPSCounter')); | 49 label: Common.UIString('Layer Borders'), |
| 50 this._appendCheckbox( | 50 subtitle: Common.UIString('Shows layer borders (orange/olive) and tiles
(cyan)'), |
| 51 Common.UIString('Scrolling Performance Issues'), | 51 setterName: 'setShowDebugBorders' |
| 52 Common.UIString( | 52 }, |
| 53 { |
| 54 label: Common.UIString('FPS Meter'), |
| 55 subtitle: Common.UIString('Plots frames per second, frame rate distribut
ion, and GPU memory'), |
| 56 setterName: 'setShowFPSCounter' |
| 57 }, |
| 58 { |
| 59 label: Common.UIString('Scrolling Performance Issues'), |
| 60 subtitle: Common.UIString( |
| 53 'Highlights elements (teal) that can slow down scrolling, including
touch & wheel event handlers and other main-thread scrolling situations.'), | 61 'Highlights elements (teal) that can slow down scrolling, including
touch & wheel event handlers and other main-thread scrolling situations.'), |
| 54 Common.moduleSetting('showScrollBottleneckRects')); | 62 setterName: 'setShowScrollBottleneckRects' |
| 63 } |
| 64 ]; |
| 65 for (var i = 0; i < options.length; i++) |
| 66 this._appendCheckbox(options[i].label, options[i].setterName, options[i].s
ubtitle); |
| 67 |
| 55 this.contentElement.createChild('div').classList.add('panel-section-separato
r'); | 68 this.contentElement.createChild('div').classList.add('panel-section-separato
r'); |
| 56 | 69 |
| 57 var cssMediaSubtitle = Common.UIString('Forces media type for testing print
and screen styles'); | 70 var cssMediaSubtitle = Common.UIString('Forces media type for testing print
and screen styles'); |
| 58 var checkboxLabel = UI.CheckboxLabel.create(Common.UIString('Emulate CSS Med
ia'), false, cssMediaSubtitle); | 71 var checkboxLabel = UI.CheckboxLabel.create(Common.UIString('Emulate CSS Med
ia'), false, cssMediaSubtitle); |
| 59 this._mediaCheckbox = checkboxLabel.checkboxElement; | 72 this._mediaCheckbox = checkboxLabel.checkboxElement; |
| 60 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this),
false); | 73 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this),
false); |
| 61 this.contentElement.appendChild(checkboxLabel); | 74 this.contentElement.appendChild(checkboxLabel); |
| 62 | 75 |
| 63 var mediaRow = this.contentElement.createChild('div', 'media-row'); | 76 var mediaRow = this.contentElement.createChild('div', 'media-row'); |
| 64 this._mediaSelect = mediaRow.createChild('select', 'chrome-select'); | 77 this._mediaSelect = mediaRow.createChild('select', 'chrome-select'); |
| 65 this._mediaSelect.appendChild(new Option(Common.UIString('print'), 'print'))
; | 78 this._mediaSelect.appendChild(new Option(Common.UIString('print'), 'print'))
; |
| 66 this._mediaSelect.appendChild(new Option(Common.UIString('screen'), 'screen'
)); | 79 this._mediaSelect.appendChild(new Option(Common.UIString('screen'), 'screen'
)); |
| 67 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this),
false); | 80 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this),
false); |
| 68 this._mediaSelect.disabled = true; | 81 this._mediaSelect.disabled = true; |
| 69 | 82 |
| 70 SDK.targetManager.observeTargets(this); | 83 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser); |
| 71 } | 84 } |
| 72 | 85 |
| 73 /** | 86 /** |
| 74 * @return {!Main.RenderingOptionsView} | 87 * @return {!Main.RenderingOptionsView} |
| 75 */ | 88 */ |
| 76 static instance() { | 89 static instance() { |
| 77 if (!Main.RenderingOptionsView._instanceObject) | 90 if (!Main.RenderingOptionsView._instanceObject) |
| 78 Main.RenderingOptionsView._instanceObject = new Main.RenderingOptionsView(
); | 91 Main.RenderingOptionsView._instanceObject = new Main.RenderingOptionsView(
); |
| 79 return Main.RenderingOptionsView._instanceObject; | 92 return Main.RenderingOptionsView._instanceObject; |
| 80 } | 93 } |
| 81 | 94 |
| 82 /** | 95 /** |
| 83 * @param {string} label | 96 * @param {string} label |
| 84 * @param {string} subtitle | 97 * @param {string} setterName |
| 85 * @param {!Common.Setting} setting | 98 * @param {string=} subtitle |
| 86 */ | 99 */ |
| 87 _appendCheckbox(label, subtitle, setting) { | 100 _appendCheckbox(label, setterName, subtitle) { |
| 88 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle); | 101 var checkboxLabel = UI.CheckboxLabel.create(label, false, subtitle); |
| 89 UI.SettingsUI.bindCheckbox(checkboxLabel.checkboxElement, setting); | 102 this._settings.set(setterName, checkboxLabel.checkboxElement); |
| 103 checkboxLabel.checkboxElement.addEventListener('click', this._settingToggled
.bind(this, setterName)); |
| 90 this.contentElement.appendChild(checkboxLabel); | 104 this.contentElement.appendChild(checkboxLabel); |
| 91 } | 105 } |
| 92 | 106 |
| 93 /** | 107 /** |
| 108 * @param {string} setterName |
| 109 */ |
| 110 _settingToggled(setterName) { |
| 111 var enabled = this._settings.get(setterName).checked; |
| 112 for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser)) |
| 113 target.renderingAgent()[setterName](enabled); |
| 114 } |
| 115 |
| 116 /** |
| 94 * @override | 117 * @override |
| 95 * @param {!SDK.Target} target | 118 * @param {!SDK.Target} target |
| 96 */ | 119 */ |
| 97 targetAdded(target) { | 120 targetAdded(target) { |
| 98 if (this._mediaCheckbox.checked && target.hasBrowserCapability()) | 121 for (var setterName of this._settings.keysArray()) { |
| 122 if (this._settings.get(setterName).checked) |
| 123 target.renderingAgent()[setterName](true); |
| 124 } |
| 125 if (this._mediaCheckbox.checked) |
| 99 this._applyPrintMediaOverride(target); | 126 this._applyPrintMediaOverride(target); |
| 100 } | 127 } |
| 101 | 128 |
| 102 _mediaToggled() { | 129 _mediaToggled() { |
| 103 this._mediaSelect.disabled = !this._mediaCheckbox.checked; | 130 this._mediaSelect.disabled = !this._mediaCheckbox.checked; |
| 104 var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser); | 131 var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser); |
| 105 for (var target of targets) | 132 for (var target of targets) |
| 106 this._applyPrintMediaOverride(target); | 133 this._applyPrintMediaOverride(target); |
| 107 } | 134 } |
| 108 | 135 |
| 109 /** | 136 /** |
| 110 * @param {!SDK.Target} target | 137 * @param {!SDK.Target} target |
| 111 */ | 138 */ |
| 112 _applyPrintMediaOverride(target) { | 139 _applyPrintMediaOverride(target) { |
| 113 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this.
_mediaSelect.value : ''); | 140 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this.
_mediaSelect.value : ''); |
| 114 var cssModel = target.model(SDK.CSSModel); | 141 var cssModel = target.model(SDK.CSSModel); |
| 115 if (cssModel) | 142 if (cssModel) |
| 116 cssModel.mediaQueryResultChanged(); | 143 cssModel.mediaQueryResultChanged(); |
| 117 } | 144 } |
| 118 | 145 |
| 119 /** | 146 /** |
| 120 * @override | 147 * @override |
| 121 * @param {!SDK.Target} target | 148 * @param {!SDK.Target} target |
| 122 */ | 149 */ |
| 123 targetRemoved(target) { | 150 targetRemoved(target) { |
| 124 } | 151 } |
| 125 }; | 152 }; |
| OLD | NEW |