OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 /** | 5 /** |
6 * @fileoverview Tools is a main class that wires all components of the | 6 * @fileoverview Tools is a main class that wires all components of the |
7 * DevTools frontend together. It is also responsible for overriding existing | 7 * DevTools frontend together. It is also responsible for overriding existing |
8 * WebInspector functionality while it is getting upstreamed into WebCore. | 8 * WebInspector functionality while it is getting upstreamed into WebCore. |
9 */ | 9 */ |
10 goog.provide('devtools.Tools'); | 10 goog.provide('devtools.Tools'); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 /////////////////////////////////////////////////////////////////////////////// | 153 /////////////////////////////////////////////////////////////////////////////// |
154 // Here and below are overrides to existing WebInspector methods only. | 154 // Here and below are overrides to existing WebInspector methods only. |
155 // TODO(pfeldman): Patch WebCore and upstream changes. | 155 // TODO(pfeldman): Patch WebCore and upstream changes. |
156 var oldLoaded = WebInspector.loaded; | 156 var oldLoaded = WebInspector.loaded; |
157 WebInspector.loaded = function() { | 157 WebInspector.loaded = function() { |
158 devtools.tools = new devtools.ToolsAgent(); | 158 devtools.tools = new devtools.ToolsAgent(); |
159 devtools.tools.reset(); | 159 devtools.tools.reset(); |
160 | 160 |
161 Preferences.ignoreWhitespace = false; | 161 Preferences.ignoreWhitespace = false; |
| 162 Preferences.samplingCPUProfiler = true; |
162 oldLoaded.call(this); | 163 oldLoaded.call(this); |
163 | 164 |
164 // Hide dock button on Mac OS. | 165 // Hide dock button on Mac OS. |
165 // TODO(pfeldman): remove once Mac OS docking is implemented. | 166 // TODO(pfeldman): remove once Mac OS docking is implemented. |
166 if (InspectorController.platform().indexOf('mac') == 0) { | 167 if (InspectorController.platform().indexOf('mac') == 0) { |
167 document.getElementById('dock-status-bar-item').addStyleClass('hidden'); | 168 document.getElementById('dock-status-bar-item').addStyleClass('hidden'); |
168 } | 169 } |
169 | 170 |
170 // Mute refresh action. | 171 // Mute refresh action. |
171 document.addEventListener("keydown", function(event) { | 172 document.addEventListener("keydown", function(event) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 (function() { | 270 (function() { |
270 var oldShow = WebInspector.ScriptsPanel.prototype.show; | 271 var oldShow = WebInspector.ScriptsPanel.prototype.show; |
271 WebInspector.ScriptsPanel.prototype.show = function() { | 272 WebInspector.ScriptsPanel.prototype.show = function() { |
272 devtools.tools.getDebuggerAgent().initUI(); | 273 devtools.tools.getDebuggerAgent().initUI(); |
273 this.enableToggleButton.visible = false; | 274 this.enableToggleButton.visible = false; |
274 oldShow.call(this); | 275 oldShow.call(this); |
275 }; | 276 }; |
276 })(); | 277 })(); |
277 | 278 |
278 | 279 |
279 // As columns in data grid can't be changed after initialization, | |
280 // we need to intercept the constructor and modify columns upon creation. | |
281 (function InterceptDataGridForProfiler() { | |
282 var originalDataGrid = WebInspector.DataGrid; | |
283 WebInspector.DataGrid = function(columns) { | |
284 if (('average' in columns) && ('calls' in columns)) { | |
285 delete columns['average']; | |
286 delete columns['calls']; | |
287 } | |
288 return new originalDataGrid(columns); | |
289 }; | |
290 })(); | |
291 | |
292 | |
293 // WebKit's profiler displays milliseconds with high resolution (shows | |
294 // three digits after the decimal point). We never have such resolution, | |
295 // as our minimal sampling rate is 1 ms. So we are disabling high resolution | |
296 // to avoid visual clutter caused by meaningless ".000" parts. | |
297 (function InterceptTimeDisplayInProfiler() { | |
298 var originalDataGetter = | |
299 WebInspector.ProfileDataGridNode.prototype.__lookupGetter__('data'); | |
300 WebInspector.ProfileDataGridNode.prototype.__defineGetter__('data', | |
301 function() { | |
302 var oldNumberSecondsToString = Number.secondsToString; | |
303 Number.secondsToString = function(seconds, formatterFunction) { | |
304 return oldNumberSecondsToString(seconds, formatterFunction, false); | |
305 }; | |
306 var data = originalDataGetter.call(this); | |
307 Number.secondsToString = oldNumberSecondsToString; | |
308 return data; | |
309 }); | |
310 })(); | |
311 | |
312 | |
313 (function InterceptProfilesPanelEvents() { | 280 (function InterceptProfilesPanelEvents() { |
314 var oldShow = WebInspector.ProfilesPanel.prototype.show; | 281 var oldShow = WebInspector.ProfilesPanel.prototype.show; |
315 WebInspector.ProfilesPanel.prototype.show = function() { | 282 WebInspector.ProfilesPanel.prototype.show = function() { |
316 devtools.tools.getDebuggerAgent().initializeProfiling(); | 283 devtools.tools.getDebuggerAgent().initializeProfiling(); |
317 this.enableToggleButton.visible = false; | 284 this.enableToggleButton.visible = false; |
318 oldShow.call(this); | 285 oldShow.call(this); |
319 // Show is called on every show event of a panel, so | 286 // Show is called on every show event of a panel, so |
320 // we only need to intercept it once. | 287 // we only need to intercept it once. |
321 WebInspector.ProfilesPanel.prototype.show = oldShow; | 288 WebInspector.ProfilesPanel.prototype.show = oldShow; |
322 }; | 289 }; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 { | 366 { |
400 InspectorController.resourceTrackingEnabled_ = true; | 367 InspectorController.resourceTrackingEnabled_ = true; |
401 this.panels.resources.resourceTrackingWasEnabled(); | 368 this.panels.resources.resourceTrackingWasEnabled(); |
402 } | 369 } |
403 | 370 |
404 WebInspector.resourceTrackingWasDisabled = function() | 371 WebInspector.resourceTrackingWasDisabled = function() |
405 { | 372 { |
406 InspectorController.resourceTrackingEnabled_ = false; | 373 InspectorController.resourceTrackingEnabled_ = false; |
407 this.panels.resources.resourceTrackingWasDisabled(); | 374 this.panels.resources.resourceTrackingWasDisabled(); |
408 } | 375 } |
OLD | NEW |