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