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

Side by Side Diff: Source/devtools/front_end/toolbox/OverridesUI.js

Issue 662793002: [DevTools] Replace usages of document with custom functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 WebInspector.OverridesUI = {} 5 WebInspector.OverridesUI = {}
6 6
7 /** 7 /**
8 * @param {!Document} document 8 * @param {!Document} document
9 * @param {!function(!function(string))=} titleProvider 9 * @param {!function(!function(string))=} titleProvider
10 * @return {!Element} 10 * @return {!Element}
11 */ 11 */
12 WebInspector.OverridesUI.createDeviceSelect = function(document, titleProvider) 12 WebInspector.OverridesUI.createDeviceSelect = function(document, titleProvider)
13 { 13 {
14 var p = document.createElement("p"); 14 var p = createElement("p");
15 15
16 var deviceSelectElement = p.createChild("select"); 16 var deviceSelectElement = p.createChild("select");
17 deviceSelectElement.addEventListener("change", deviceSelected, false); 17 deviceSelectElement.addEventListener("change", deviceSelected, false);
18 18
19 var saveButton = p.createChild("button"); 19 var saveButton = p.createChild("button");
20 saveButton.textContent = WebInspector.UIString("Save as"); 20 saveButton.textContent = WebInspector.UIString("Save as");
21 saveButton.addEventListener("click", saveClicked, false); 21 saveButton.addEventListener("click", saveClicked, false);
22 22
23 var removeButton = p.createChild("button"); 23 var removeButton = p.createChild("button");
24 removeButton.textContent = WebInspector.UIString("Remove"); 24 removeButton.textContent = WebInspector.UIString("Remove");
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return p; 153 return p;
154 } 154 }
155 155
156 /** 156 /**
157 * @param {!Document} document 157 * @param {!Document} document
158 * @return {!Element} 158 * @return {!Element}
159 */ 159 */
160 WebInspector.OverridesUI.createNetworkConditionsSelect = function(document) 160 WebInspector.OverridesUI.createNetworkConditionsSelect = function(document)
161 { 161 {
162 var networkConditionsSetting = WebInspector.overridesSupport.settings.networ kConditions; 162 var networkConditionsSetting = WebInspector.overridesSupport.settings.networ kConditions;
163 var conditionsSelectElement = document.createElement("select"); 163 var conditionsSelectElement = createElement("select");
164 var presets = WebInspector.OverridesUI._networkConditionsPresets; 164 var presets = WebInspector.OverridesUI._networkConditionsPresets;
165 for (var i = 0; i < presets.length; ++i) { 165 for (var i = 0; i < presets.length; ++i) {
166 var preset = presets[i]; 166 var preset = presets[i];
167 var throughput = preset.throughput | 0; 167 var throughput = preset.throughput | 0;
168 var latency = preset.latency | 0; 168 var latency = preset.latency | 0;
169 var isThrottling = (throughput > 0) || latency; 169 var isThrottling = (throughput > 0) || latency;
170 if (!isThrottling) { 170 if (!isThrottling) {
171 conditionsSelectElement.add(new Option(preset.title, preset.id)); 171 conditionsSelectElement.add(new Option(preset.title, preset.id));
172 } else { 172 } else {
173 var throughputText = (throughput < 1024) ? WebInspector.UIString("%d Kbps", throughput) : WebInspector.UIString("%d Mbps", (throughput / 1024) | 0); 173 var throughputText = (throughput < 1024) ? WebInspector.UIString("%d Kbps", throughput) : WebInspector.UIString("%d Mbps", (throughput / 1024) | 0);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 * @param {!Document} document 222 * @param {!Document} document
223 * @return {{select: !Element, input: !Element}} 223 * @return {{select: !Element, input: !Element}}
224 */ 224 */
225 WebInspector.OverridesUI.createUserAgentSelectAndInput = function(document) 225 WebInspector.OverridesUI.createUserAgentSelectAndInput = function(document)
226 { 226 {
227 var userAgentSetting = WebInspector.overridesSupport.settings.userAgent; 227 var userAgentSetting = WebInspector.overridesSupport.settings.userAgent;
228 const noOverride = {title: WebInspector.UIString("No override"), value: ""}; 228 const noOverride = {title: WebInspector.UIString("No override"), value: ""};
229 const customOverride = {title: WebInspector.UIString("Other"), value: "Other "}; 229 const customOverride = {title: WebInspector.UIString("Other"), value: "Other "};
230 var userAgents = [noOverride].concat(WebInspector.OverridesUI._userAgents).c oncat([customOverride]); 230 var userAgents = [noOverride].concat(WebInspector.OverridesUI._userAgents).c oncat([customOverride]);
231 231
232 var userAgentSelectElement = document.createElement("select"); 232 var userAgentSelectElement = createElement("select");
233 for (var i = 0; i < userAgents.length; ++i) 233 for (var i = 0; i < userAgents.length; ++i)
234 userAgentSelectElement.add(new Option(userAgents[i].title, userAgents[i] .value)); 234 userAgentSelectElement.add(new Option(userAgents[i].title, userAgents[i] .value));
235 userAgentSelectElement.selectedIndex = 0; 235 userAgentSelectElement.selectedIndex = 0;
236 236
237 var otherUserAgentElement = document.createElement("input"); 237 var otherUserAgentElement = createElement("input");
238 otherUserAgentElement.type = "text"; 238 otherUserAgentElement.type = "text";
239 otherUserAgentElement.value = userAgentSetting.get(); 239 otherUserAgentElement.value = userAgentSetting.get();
240 otherUserAgentElement.title = userAgentSetting.get(); 240 otherUserAgentElement.title = userAgentSetting.get();
241 241
242 settingChanged(); 242 settingChanged();
243 userAgentSetting.addChangeListener(settingChanged); 243 userAgentSetting.addChangeListener(settingChanged);
244 userAgentSelectElement.addEventListener("change", userAgentSelected, false); 244 userAgentSelectElement.addEventListener("change", userAgentSelected, false);
245 245
246 otherUserAgentElement.addEventListener("dblclick", textDoubleClicked, true); 246 otherUserAgentElement.addEventListener("dblclick", textDoubleClicked, true);
247 otherUserAgentElement.addEventListener("blur", textChanged, false); 247 otherUserAgentElement.addEventListener("blur", textChanged, false);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 {title: "iPhone \u2014 iOS 7", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_ 0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/1 1A4449d Safari/9537.53"}, 406 {title: "iPhone \u2014 iOS 7", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_ 0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/1 1A4449d Safari/9537.53"},
407 {title: "iPhone \u2014 iOS 6", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_ 0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A53 76e Safari/8536.25"}, 407 {title: "iPhone \u2014 iOS 6", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_ 0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A53 76e Safari/8536.25"},
408 {title: "MeeGo \u2014 Nokia N9", value: "Mozilla/5.0 (MeeGo; NokiaN9) AppleW ebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"}, 408 {title: "MeeGo \u2014 Nokia N9", value: "Mozilla/5.0 (MeeGo; NokiaN9) AppleW ebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"},
409 {title: "Opera 18 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537. 36 OPR/18.0.1284.68"}, 409 {title: "Opera 18 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537. 36 OPR/18.0.1284.68"},
410 {title: "Opera 18 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.12 84.68"}, 410 {title: "Opera 18 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.12 84.68"},
411 {title: "Opera 12 \u2014 Mac", value: "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16"}, 411 {title: "Opera 12 \u2014 Mac", value: "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16"},
412 {title: "Opera 12 \u2014 Windows", value: "Opera/9.80 (Windows NT 6.1) Prest o/2.12.388 Version/12.16"}, 412 {title: "Opera 12 \u2014 Windows", value: "Opera/9.80 (Windows NT 6.1) Prest o/2.12.388 Version/12.16"},
413 {title: "Silk \u2014 Kindle Fire (Desktop view)", value: "Mozilla/5.0 (Linux ; U; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true"}, 413 {title: "Silk \u2014 Kindle Fire (Desktop view)", value: "Mozilla/5.0 (Linux ; U; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true"},
414 {title: "Silk \u2014 Kindle Fire (Mobile view)", value: "Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Ge cko) Silk/3.13 Mobile Safari/535.19 Silk-Accelerated=true"} 414 {title: "Silk \u2014 Kindle Fire (Mobile view)", value: "Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Ge cko) Silk/3.13 Mobile Safari/535.19 Silk-Accelerated=true"}
415 ]; 415 ];
OLDNEW
« no previous file with comments | « Source/devtools/front_end/toolbox/MediaQueryInspector.js ('k') | Source/devtools/front_end/ui/Checkbox.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698