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 this._setShowPaintRects.bind(this)); |
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 this._setShowDebugBorders.bind(this)); |
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 this._setShowFPSCounter.bind(this)); |
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 this._setShowScrollBottleneckRects.bind(this)); |
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 {function(boolean)} callback |
99 */ | 86 */ |
100 _appendCheckbox(label, setterName, subtitle) { | 87 _appendCheckbox(label, subtitle, callback) { |
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 checkboxLabel.checkboxElement.addEventListener('click', () => callback(check boxLabel.checkboxElement.checked)); |
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 | 94 * @param {boolean} show |
109 */ | 95 */ |
110 _settingToggled(setterName) { | 96 _setShowPaintRects(show) { |
111 var enabled = this._settings.get(setterName).checked; | 97 this._showPaintRects = show; |
112 for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser)) | 98 for (var overlayModel of SDK.targetManager.models(SDK.OverlayModel)) |
113 target.renderingAgent()[setterName](enabled); | 99 overlayModel.setShowPaintRects(show); |
114 } | 100 } |
115 | 101 |
116 /** | 102 /** |
103 * @param {boolean} show | |
104 */ | |
105 _setShowDebugBorders(show) { | |
106 this._showDebugBorders = show; | |
107 for (var overlayModel of SDK.targetManager.models(SDK.OverlayModel)) | |
108 overlayModel.setShowDebugBorders(show); | |
109 } | |
110 | |
111 /** | |
112 * @param {boolean} show | |
113 */ | |
114 _setShowFPSCounter(show) { | |
115 this._showFPSCounter = show; | |
116 for (var overlayModel of SDK.targetManager.models(SDK.OverlayModel)) | |
117 overlayModel.setShowFPSCounter(show); | |
118 } | |
119 | |
120 /** | |
121 * @param {boolean} show | |
122 */ | |
123 _setShowScrollBottleneckRects(show) { | |
124 this._showScrollBottleneckRects = show; | |
125 for (var overlayModel of SDK.targetManager.models(SDK.OverlayModel)) | |
126 overlayModel.setShowScrollBottleneckRects(show); | |
127 } | |
128 | |
129 /** | |
117 * @override | 130 * @override |
118 * @param {!SDK.Target} target | 131 * @param {!SDK.Target} target |
119 */ | 132 */ |
120 targetAdded(target) { | 133 targetAdded(target) { |
121 for (var setterName of this._settings.keysArray()) { | 134 var overlayModel = target.model(SDK.OverlayModel); |
122 if (this._settings.get(setterName).checked) | 135 if (overlayModel) { |
123 target.renderingAgent()[setterName](true); | 136 if (this._showPaintRects) |
pfeldman
2017/04/18 00:25:08
Follow up with transient setting?
dgozman
2017/04/18 20:39:32
Done.
| |
137 overlayModel.setShowPaintRects(true); | |
138 if (this._showDebugBorders) | |
139 overlayModel.setShowDebugBorders(true); | |
140 if (this._showFPSCounter) | |
141 overlayModel.setShowFPSCounter(true); | |
142 if (this._showScrollBottleneckRects) | |
143 overlayModel.setShowScrollBottleneckRects(true); | |
124 } | 144 } |
125 if (this._mediaCheckbox.checked) | 145 if (this._mediaCheckbox.checked && target.hasBrowserCapability()) |
126 this._applyPrintMediaOverride(target); | 146 this._applyPrintMediaOverride(target); |
127 } | 147 } |
128 | 148 |
129 _mediaToggled() { | 149 _mediaToggled() { |
130 this._mediaSelect.disabled = !this._mediaCheckbox.checked; | 150 this._mediaSelect.disabled = !this._mediaCheckbox.checked; |
131 var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser); | 151 var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser); |
132 for (var target of targets) | 152 for (var target of targets) |
133 this._applyPrintMediaOverride(target); | 153 this._applyPrintMediaOverride(target); |
134 } | 154 } |
135 | 155 |
136 /** | 156 /** |
137 * @param {!SDK.Target} target | 157 * @param {!SDK.Target} target |
138 */ | 158 */ |
139 _applyPrintMediaOverride(target) { | 159 _applyPrintMediaOverride(target) { |
140 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this. _mediaSelect.value : ''); | 160 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this. _mediaSelect.value : ''); |
141 var cssModel = target.model(SDK.CSSModel); | 161 var cssModel = target.model(SDK.CSSModel); |
142 if (cssModel) | 162 if (cssModel) |
143 cssModel.mediaQueryResultChanged(); | 163 cssModel.mediaQueryResultChanged(); |
144 } | 164 } |
145 | 165 |
146 /** | 166 /** |
147 * @override | 167 * @override |
148 * @param {!SDK.Target} target | 168 * @param {!SDK.Target} target |
149 */ | 169 */ |
150 targetRemoved(target) { | 170 targetRemoved(target) { |
151 } | 171 } |
152 }; | 172 }; |
OLD | NEW |