Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/main/RenderingOptions.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 * @implements {WebInspector.TargetManager.Observer} 31 * @implements {SDK.TargetManager.Observer}
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.RenderingOptionsView = class extends WebInspector.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 /** @type {!Map.<string, !Element>} */
40 this._settings = new Map(); 40 this._settings = new Map();
41 41
42 var options = [ 42 var options = [
43 { 43 {
44 label: WebInspector.UIString('Paint Flashing'), 44 label: Common.UIString('Paint Flashing'),
45 subtitle: WebInspector.UIString('Highlights areas of the page that need to be repainted'), 45 subtitle: Common.UIString('Highlights areas of the page that need to be repainted'),
46 setterName: 'setShowPaintRects' 46 setterName: 'setShowPaintRects'
47 }, 47 },
48 { 48 {
49 label: WebInspector.UIString('Layer Borders'), 49 label: Common.UIString('Layer Borders'),
50 subtitle: WebInspector.UIString('Shows layer borders (orange/olive) and tiles (cyan)'), 50 subtitle: Common.UIString('Shows layer borders (orange/olive) and tiles (cyan)'),
51 setterName: 'setShowDebugBorders' 51 setterName: 'setShowDebugBorders'
52 }, 52 },
53 { 53 {
54 label: WebInspector.UIString('FPS Meter'), 54 label: Common.UIString('FPS Meter'),
55 subtitle: WebInspector.UIString('Plots frames per second, frame rate dis tribution, and GPU memory'), 55 subtitle: Common.UIString('Plots frames per second, frame rate distribut ion, and GPU memory'),
56 setterName: 'setShowFPSCounter' 56 setterName: 'setShowFPSCounter'
57 }, 57 },
58 { 58 {
59 label: WebInspector.UIString('Scrolling Performance Issues'), 59 label: Common.UIString('Scrolling Performance Issues'),
60 subtitle: WebInspector.UIString('Shows areas of the page that slow down scrolling'), 60 subtitle: Common.UIString('Shows areas of the page that slow down scroll ing'),
61 setterName: 'setShowScrollBottleneckRects', 61 setterName: 'setShowScrollBottleneckRects',
62 tooltip: 62 tooltip:
63 'Touch and mousewheel event listeners can delay scrolling.\nSome are as need to repaint their content when scrolled.' 63 'Touch and mousewheel event listeners can delay scrolling.\nSome are as need to repaint their content when scrolled.'
64 } 64 }
65 ]; 65 ];
66 for (var i = 0; i < options.length; i++) 66 for (var i = 0; i < options.length; i++)
67 this._appendCheckbox(options[i].label, options[i].setterName, options[i].s ubtitle, options[i].tooltip); 67 this._appendCheckbox(options[i].label, options[i].setterName, options[i].s ubtitle, options[i].tooltip);
68 68
69 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 69 this.contentElement.createChild('div').classList.add('panel-section-separato r');
70 70
71 var cssMediaSubtitle = WebInspector.UIString('Forces media type for testing print and screen styles'); 71 var cssMediaSubtitle = Common.UIString('Forces media type for testing print and screen styles');
72 var checkboxLabel = createCheckboxLabel(WebInspector.UIString('Emulate CSS M edia'), false, cssMediaSubtitle); 72 var checkboxLabel = createCheckboxLabel(Common.UIString('Emulate CSS Media') , false, cssMediaSubtitle);
73 this._mediaCheckbox = checkboxLabel.checkboxElement; 73 this._mediaCheckbox = checkboxLabel.checkboxElement;
74 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this), false); 74 this._mediaCheckbox.addEventListener('click', this._mediaToggled.bind(this), false);
75 this.contentElement.appendChild(checkboxLabel); 75 this.contentElement.appendChild(checkboxLabel);
76 76
77 var mediaRow = this.contentElement.createChild('div', 'media-row'); 77 var mediaRow = this.contentElement.createChild('div', 'media-row');
78 this._mediaSelect = mediaRow.createChild('select', 'chrome-select'); 78 this._mediaSelect = mediaRow.createChild('select', 'chrome-select');
79 this._mediaSelect.appendChild(new Option(WebInspector.UIString('print'), 'pr int')); 79 this._mediaSelect.appendChild(new Option(Common.UIString('print'), 'print')) ;
80 this._mediaSelect.appendChild(new Option(WebInspector.UIString('screen'), 's creen')); 80 this._mediaSelect.appendChild(new Option(Common.UIString('screen'), 'screen' ));
81 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this), false); 81 this._mediaSelect.addEventListener('change', this._mediaToggled.bind(this), false);
82 this._mediaSelect.disabled = true; 82 this._mediaSelect.disabled = true;
83 83
84 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Capabili ty.Browser); 84 SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser);
85 } 85 }
86 86
87 /** 87 /**
88 * @return {!WebInspector.RenderingOptionsView} 88 * @return {!Main.RenderingOptionsView}
89 */ 89 */
90 static instance() { 90 static instance() {
91 if (!WebInspector.RenderingOptionsView._instanceObject) 91 if (!Main.RenderingOptionsView._instanceObject)
92 WebInspector.RenderingOptionsView._instanceObject = new WebInspector.Rende ringOptionsView(); 92 Main.RenderingOptionsView._instanceObject = new Main.RenderingOptionsView( );
93 return WebInspector.RenderingOptionsView._instanceObject; 93 return Main.RenderingOptionsView._instanceObject;
94 } 94 }
95 95
96 /** 96 /**
97 * @param {string} label 97 * @param {string} label
98 * @param {string} setterName 98 * @param {string} setterName
99 * @param {string=} subtitle 99 * @param {string=} subtitle
100 * @param {string=} tooltip 100 * @param {string=} tooltip
101 */ 101 */
102 _appendCheckbox(label, setterName, subtitle, tooltip) { 102 _appendCheckbox(label, setterName, subtitle, tooltip) {
103 var checkboxLabel = createCheckboxLabel(label, false, subtitle); 103 var checkboxLabel = createCheckboxLabel(label, false, subtitle);
104 this._settings.set(setterName, checkboxLabel.checkboxElement); 104 this._settings.set(setterName, checkboxLabel.checkboxElement);
105 checkboxLabel.checkboxElement.addEventListener('click', this._settingToggled .bind(this, setterName)); 105 checkboxLabel.checkboxElement.addEventListener('click', this._settingToggled .bind(this, setterName));
106 if (tooltip) 106 if (tooltip)
107 checkboxLabel.title = tooltip; 107 checkboxLabel.title = tooltip;
108 this.contentElement.appendChild(checkboxLabel); 108 this.contentElement.appendChild(checkboxLabel);
109 } 109 }
110 110
111 /** 111 /**
112 * @param {string} setterName 112 * @param {string} setterName
113 */ 113 */
114 _settingToggled(setterName) { 114 _settingToggled(setterName) {
115 var enabled = this._settings.get(setterName).checked; 115 var enabled = this._settings.get(setterName).checked;
116 for (var target of WebInspector.targetManager.targets(WebInspector.Target.Ca pability.Browser)) 116 for (var target of SDK.targetManager.targets(SDK.Target.Capability.Browser))
117 target.renderingAgent()[setterName](enabled); 117 target.renderingAgent()[setterName](enabled);
118 } 118 }
119 119
120 /** 120 /**
121 * @override 121 * @override
122 * @param {!WebInspector.Target} target 122 * @param {!SDK.Target} target
123 */ 123 */
124 targetAdded(target) { 124 targetAdded(target) {
125 for (var setterName of this._settings.keysArray()) { 125 for (var setterName of this._settings.keysArray()) {
126 if (this._settings.get(setterName).checked) 126 if (this._settings.get(setterName).checked)
127 target.renderingAgent()[setterName](true); 127 target.renderingAgent()[setterName](true);
128 } 128 }
129 if (this._mediaCheckbox.checked) 129 if (this._mediaCheckbox.checked)
130 this._applyPrintMediaOverride(target); 130 this._applyPrintMediaOverride(target);
131 } 131 }
132 132
133 _mediaToggled() { 133 _mediaToggled() {
134 this._mediaSelect.disabled = !this._mediaCheckbox.checked; 134 this._mediaSelect.disabled = !this._mediaCheckbox.checked;
135 var targets = WebInspector.targetManager.targets(WebInspector.Target.Capabil ity.Browser); 135 var targets = SDK.targetManager.targets(SDK.Target.Capability.Browser);
136 for (var target of targets) 136 for (var target of targets)
137 this._applyPrintMediaOverride(target); 137 this._applyPrintMediaOverride(target);
138 } 138 }
139 139
140 /** 140 /**
141 * @param {!WebInspector.Target} target 141 * @param {!SDK.Target} target
142 */ 142 */
143 _applyPrintMediaOverride(target) { 143 _applyPrintMediaOverride(target) {
144 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this. _mediaSelect.value : ''); 144 target.emulationAgent().setEmulatedMedia(this._mediaCheckbox.checked ? this. _mediaSelect.value : '');
145 var cssModel = WebInspector.CSSModel.fromTarget(target); 145 var cssModel = SDK.CSSModel.fromTarget(target);
146 if (cssModel) 146 if (cssModel)
147 cssModel.mediaQueryResultChanged(); 147 cssModel.mediaQueryResultChanged();
148 } 148 }
149 149
150 /** 150 /**
151 * @override 151 * @override
152 * @param {!WebInspector.Target} target 152 * @param {!SDK.Target} target
153 */ 153 */
154 targetRemoved(target) { 154 targetRemoved(target) {
155 } 155 }
156 }; 156 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698