| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 this._mediaCheckbox.addEventListener("click", this._mediaToggled.bind(this),
false); | 75 this._mediaCheckbox.addEventListener("click", this._mediaToggled.bind(this),
false); |
| 76 this.contentElement.appendChild(checkboxLabel); | 76 this.contentElement.appendChild(checkboxLabel); |
| 77 | 77 |
| 78 var mediaRow = this.contentElement.createChild("div", "media-row"); | 78 var mediaRow = this.contentElement.createChild("div", "media-row"); |
| 79 this._mediaSelect = mediaRow.createChild("select", "chrome-select"); | 79 this._mediaSelect = mediaRow.createChild("select", "chrome-select"); |
| 80 this._mediaSelect.appendChild(new Option(WebInspector.UIString("print"), "pr
int")); | 80 this._mediaSelect.appendChild(new Option(WebInspector.UIString("print"), "pr
int")); |
| 81 this._mediaSelect.appendChild(new Option(WebInspector.UIString("screen"), "s
creen")); | 81 this._mediaSelect.appendChild(new Option(WebInspector.UIString("screen"), "s
creen")); |
| 82 this._mediaSelect.addEventListener("change", this._mediaToggled.bind(this),
false); | 82 this._mediaSelect.addEventListener("change", this._mediaToggled.bind(this),
false); |
| 83 this._mediaSelect.disabled = true; | 83 this._mediaSelect.disabled = true; |
| 84 | 84 |
| 85 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag
e); | 85 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili
ty.Browser); |
| 86 } | 86 } |
| 87 | 87 |
| 88 WebInspector.RenderingOptionsView.prototype = { | 88 WebInspector.RenderingOptionsView.prototype = { |
| 89 /** | 89 /** |
| 90 * @param {string} label | 90 * @param {string} label |
| 91 * @param {string} setterName | 91 * @param {string} setterName |
| 92 * @param {string=} subtitle | 92 * @param {string=} subtitle |
| 93 * @param {string=} tooltip | 93 * @param {string=} tooltip |
| 94 */ | 94 */ |
| 95 _appendCheckbox: function(label, setterName, subtitle, tooltip) | 95 _appendCheckbox: function(label, setterName, subtitle, tooltip) |
| 96 { | 96 { |
| 97 var checkboxLabel = createCheckboxLabel(label, false, subtitle); | 97 var checkboxLabel = createCheckboxLabel(label, false, subtitle); |
| 98 this._settings.set(setterName, checkboxLabel.checkboxElement); | 98 this._settings.set(setterName, checkboxLabel.checkboxElement); |
| 99 checkboxLabel.checkboxElement.addEventListener("click", this._settingTog
gled.bind(this, setterName)); | 99 checkboxLabel.checkboxElement.addEventListener("click", this._settingTog
gled.bind(this, setterName)); |
| 100 if (tooltip) | 100 if (tooltip) |
| 101 checkboxLabel.title = tooltip; | 101 checkboxLabel.title = tooltip; |
| 102 this.contentElement.appendChild(checkboxLabel); | 102 this.contentElement.appendChild(checkboxLabel); |
| 103 }, | 103 }, |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * @param {string} setterName | 106 * @param {string} setterName |
| 107 */ | 107 */ |
| 108 _settingToggled: function(setterName) | 108 _settingToggled: function(setterName) |
| 109 { | 109 { |
| 110 var enabled = this._settings.get(setterName).checked; | 110 var enabled = this._settings.get(setterName).checked; |
| 111 var targets = WebInspector.targetManager.targets(WebInspector.Target.Typ
e.Page); | 111 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Capability.Browser)) |
| 112 for (var i = 0; i < targets.length; ++i) | 112 target.renderingAgent()[setterName](enabled); |
| 113 targets[i].renderingAgent()[setterName](enabled); | |
| 114 }, | 113 }, |
| 115 | 114 |
| 116 /** | 115 /** |
| 117 * @override | 116 * @override |
| 118 * @param {!WebInspector.Target} target | 117 * @param {!WebInspector.Target} target |
| 119 */ | 118 */ |
| 120 targetAdded: function(target) | 119 targetAdded: function(target) |
| 121 { | 120 { |
| 122 for (var setterName of this._settings.keysArray()) { | 121 for (var setterName of this._settings.keysArray()) { |
| 123 if (this._settings.get(setterName).checked) | 122 if (this._settings.get(setterName).checked) |
| 124 target.renderingAgent()[setterName](true); | 123 target.renderingAgent()[setterName](true); |
| 125 } | 124 } |
| 126 if (this._mediaCheckbox.checked) | 125 if (this._mediaCheckbox.checked) |
| 127 this._applyPrintMediaOverride(target); | 126 this._applyPrintMediaOverride(target); |
| 128 }, | 127 }, |
| 129 | 128 |
| 130 _mediaToggled: function() | 129 _mediaToggled: function() |
| 131 { | 130 { |
| 132 this._mediaSelect.disabled = !this._mediaCheckbox.checked; | 131 this._mediaSelect.disabled = !this._mediaCheckbox.checked; |
| 133 var targets = WebInspector.targetManager.targets(WebInspector.Target.Typ
e.Page); | 132 var targets = WebInspector.targetManager.targets(WebInspector.Target.Cap
ability.Browser); |
| 134 for (var target of targets) | 133 for (var target of targets) |
| 135 this._applyPrintMediaOverride(target); | 134 this._applyPrintMediaOverride(target); |
| 136 }, | 135 }, |
| 137 | 136 |
| 138 /** | 137 /** |
| 139 * @param {!WebInspector.Target} target | 138 * @param {!WebInspector.Target} target |
| 140 */ | 139 */ |
| 141 _applyPrintMediaOverride: function(target) | 140 _applyPrintMediaOverride: function(target) |
| 142 { | 141 { |
| 143 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? t
his._mediaSelect.value : ""); | 142 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? t
his._mediaSelect.value : ""); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 159 | 158 |
| 160 /** | 159 /** |
| 161 * @return {!WebInspector.RenderingOptionsView} | 160 * @return {!WebInspector.RenderingOptionsView} |
| 162 */ | 161 */ |
| 163 WebInspector.RenderingOptionsView.instance = function() | 162 WebInspector.RenderingOptionsView.instance = function() |
| 164 { | 163 { |
| 165 if (!WebInspector.RenderingOptionsView._instanceObject) | 164 if (!WebInspector.RenderingOptionsView._instanceObject) |
| 166 WebInspector.RenderingOptionsView._instanceObject = new WebInspector.Ren
deringOptionsView(); | 165 WebInspector.RenderingOptionsView._instanceObject = new WebInspector.Ren
deringOptionsView(); |
| 167 return WebInspector.RenderingOptionsView._instanceObject; | 166 return WebInspector.RenderingOptionsView._instanceObject; |
| 168 } | 167 } |
| OLD | NEW |