| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi
s); | 399 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi
s); |
| 400 | 400 |
| 401 this._panelToolbar.appendSeparator(); | 401 this._panelToolbar.appendSeparator(); |
| 402 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U
IString("Collect garbage"), "garbage-collect-toolbar-item"); | 402 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U
IString("Collect garbage"), "garbage-collect-toolbar-item"); |
| 403 garbageCollectButton.addEventListener("click", this._garbageCollectButto
nClicked, this); | 403 garbageCollectButton.addEventListener("click", this._garbageCollectButto
nClicked, this); |
| 404 this._panelToolbar.appendToolbarItem(garbageCollectButton); | 404 this._panelToolbar.appendToolbarItem(garbageCollectButton); |
| 405 | 405 |
| 406 if (Runtime.experiments.isEnabled("cpuThrottling")) { | 406 if (Runtime.experiments.isEnabled("cpuThrottling")) { |
| 407 this._panelToolbar.appendSeparator(); | 407 this._panelToolbar.appendSeparator(); |
| 408 this._cpuThrottlingCombobox = new WebInspector.ToolbarComboBox(this.
_onCPUThrottlingChanged.bind(this)); | 408 this._cpuThrottlingCombobox = new WebInspector.ToolbarComboBox(this.
_onCPUThrottlingChanged.bind(this)); |
| 409 /** | |
| 410 * @param {string} name | |
| 411 * @param {number} value | |
| 412 * @this {WebInspector.TimelinePanel} | |
| 413 */ | |
| 414 function addGroupingOption(name, value) | |
| 415 { | |
| 416 var option = this._cpuThrottlingCombobox.createOption(name, "",
String(value)); | |
| 417 this._cpuThrottlingCombobox.addOption(option); | |
| 418 if (value === this._cpuThrottlingManager.rate()) | |
| 419 this._cpuThrottlingCombobox.select(option); | |
| 420 } | |
| 421 addGroupingOption.call(this, WebInspector.UIString("No CPU throttlin
g"), 1); | |
| 422 addGroupingOption.call(this, WebInspector.UIString("High end device\
u2003(2x slowdown)"), 2); | |
| 423 addGroupingOption.call(this, WebInspector.UIString("Low end device\u
2003(5x slowdown)"), 5); | |
| 424 this._panelToolbar.appendToolbarItem(this._cpuThrottlingCombobox); | 409 this._panelToolbar.appendToolbarItem(this._cpuThrottlingCombobox); |
| 410 this._populateCPUThrottingCombobox(); |
| 425 } | 411 } |
| 426 }, | 412 }, |
| 427 | 413 |
| 414 _populateCPUThrottingCombobox: function() |
| 415 { |
| 416 var cpuThrottlingCombobox = this._cpuThrottlingCombobox; |
| 417 cpuThrottlingCombobox.removeOptions(); |
| 418 var currentRate = this._cpuThrottlingManager.rate(); |
| 419 var hasSelection = false; |
| 420 /** |
| 421 * @param {string} name |
| 422 * @param {number} value |
| 423 */ |
| 424 function addGroupingOption(name, value) |
| 425 { |
| 426 var option = cpuThrottlingCombobox.createOption(name, "", String(val
ue)); |
| 427 cpuThrottlingCombobox.addOption(option); |
| 428 if (hasSelection || (value && value !== currentRate)) |
| 429 return; |
| 430 cpuThrottlingCombobox.select(option); |
| 431 hasSelection = true; |
| 432 } |
| 433 var predefinedRates = new Map([ |
| 434 [1, WebInspector.UIString("No CPU throttling")], |
| 435 [2, WebInspector.UIString("High end device (2\xD7 slowdown)")], |
| 436 [5, WebInspector.UIString("Low end device (5\xD7 slowdown)")] |
| 437 ]); |
| 438 for (var rate of predefinedRates) |
| 439 addGroupingOption(rate[1], rate[0]); |
| 440 var customRateText = predefinedRates.has(currentRate) |
| 441 ? WebInspector.UIString("Custom rate\u2026") |
| 442 : WebInspector.UIString("Custom rate (%d\xD7 slowdown)", currentRate
); |
| 443 addGroupingOption(customRateText, 0); |
| 444 }, |
| 445 |
| 428 _prepareToLoadTimeline: function() | 446 _prepareToLoadTimeline: function() |
| 429 { | 447 { |
| 430 console.assert(this._state === WebInspector.TimelinePanel.State.Idle); | 448 console.assert(this._state === WebInspector.TimelinePanel.State.Idle); |
| 431 this._setState(WebInspector.TimelinePanel.State.Loading); | 449 this._setState(WebInspector.TimelinePanel.State.Loading); |
| 432 }, | 450 }, |
| 433 | 451 |
| 434 _createFileSelector: function() | 452 _createFileSelector: function() |
| 435 { | 453 { |
| 436 if (this._fileSelectorElement) | 454 if (this._fileSelectorElement) |
| 437 this._fileSelectorElement.remove(); | 455 this._fileSelectorElement.remove(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 _onNetworkChanged: function() | 569 _onNetworkChanged: function() |
| 552 { | 570 { |
| 553 if (this._flameChart) | 571 if (this._flameChart) |
| 554 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get()
, true); | 572 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get()
, true); |
| 555 }, | 573 }, |
| 556 | 574 |
| 557 _onCPUThrottlingChanged: function() | 575 _onCPUThrottlingChanged: function() |
| 558 { | 576 { |
| 559 if (!this._cpuThrottlingManager) | 577 if (!this._cpuThrottlingManager) |
| 560 return; | 578 return; |
| 561 var value = Number.parseFloat(this._cpuThrottlingCombobox.selectedOption
().value); | 579 var value = this._cpuThrottlingCombobox.selectedOption().value; |
| 562 this._cpuThrottlingManager.setRate(value); | 580 var isLastOption = this._cpuThrottlingCombobox.selectedIndex() === this.
_cpuThrottlingCombobox.size() - 1; |
| 581 this._populateCPUThrottingCombobox(); |
| 582 var resultPromise = isLastOption |
| 583 ? WebInspector.TimelinePanel.CustomCPUThrottlingRateDialog.show(this
._cpuThrottlingCombobox.element) |
| 584 : Promise.resolve(value); |
| 585 resultPromise.then(text => { |
| 586 this._cpuThrottlingManager.setRate(Number.parseFloat(text)); |
| 587 this._populateCPUThrottingCombobox(); |
| 588 }); |
| 563 }, | 589 }, |
| 564 | 590 |
| 565 /** | 591 /** |
| 566 * @param {boolean} enabled | 592 * @param {boolean} enabled |
| 567 */ | 593 */ |
| 568 _setUIControlsEnabled: function(enabled) | 594 _setUIControlsEnabled: function(enabled) |
| 569 { | 595 { |
| 570 /** | 596 /** |
| 571 * @param {!WebInspector.ToolbarButton} toolbarButton | 597 * @param {!WebInspector.ToolbarButton} toolbarButton |
| 572 */ | 598 */ |
| (...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 * @override | 2042 * @override |
| 2017 * @param {!WebInspector.Target} target | 2043 * @param {!WebInspector.Target} target |
| 2018 */ | 2044 */ |
| 2019 targetRemoved: function(target) | 2045 targetRemoved: function(target) |
| 2020 { | 2046 { |
| 2021 this._targets.remove(target, true); | 2047 this._targets.remove(target, true); |
| 2022 }, | 2048 }, |
| 2023 | 2049 |
| 2024 __proto__: WebInspector.Object.prototype | 2050 __proto__: WebInspector.Object.prototype |
| 2025 } | 2051 } |
| 2052 |
| 2053 /** |
| 2054 * @constructor |
| 2055 * @extends {WebInspector.HBox} |
| 2056 */ |
| 2057 WebInspector.TimelinePanel.CustomCPUThrottlingRateDialog = function() |
| 2058 { |
| 2059 WebInspector.HBox.call(this, true); |
| 2060 this.registerRequiredCSS("ui_lazy/dialog.css"); |
| 2061 this.contentElement.createChild("label").textContent = WebInspector.UIString
("CPU Slowdown Rate: "); |
| 2062 |
| 2063 this._input = this.contentElement.createChild("input"); |
| 2064 this._input.setAttribute("type", "text"); |
| 2065 this._input.style.width = "64px"; |
| 2066 this._input.addEventListener("keydown", this._onKeyDown.bind(this), false); |
| 2067 |
| 2068 var addButton = this.contentElement.createChild("button"); |
| 2069 addButton.textContent = WebInspector.UIString("Set"); |
| 2070 addButton.addEventListener("click", this._apply.bind(this), false); |
| 2071 |
| 2072 this.setDefaultFocusedElement(this._input); |
| 2073 this.contentElement.tabIndex = 0; |
| 2074 this._resultPromise = new Promise(fulfill => this._callback = fulfill); |
| 2075 } |
| 2076 |
| 2077 /** |
| 2078 * @param {!Element=} anchor |
| 2079 * @return {!Promise<string>} |
| 2080 */ |
| 2081 WebInspector.TimelinePanel.CustomCPUThrottlingRateDialog.show = function(anchor) |
| 2082 { |
| 2083 var dialog = new WebInspector.Dialog(); |
| 2084 var dialogContent = new WebInspector.TimelinePanel.CustomCPUThrottlingRateDi
alog(); |
| 2085 dialogContent.show(dialog.element); |
| 2086 dialog.setWrapsContent(true); |
| 2087 if (anchor) |
| 2088 dialog.setPosition(anchor.totalOffsetLeft() - 32, anchor.totalOffsetTop(
) + anchor.offsetHeight); |
| 2089 dialog.show(); |
| 2090 return dialogContent.result().then(value => (dialog.detach(), value)); |
| 2091 } |
| 2092 |
| 2093 WebInspector.TimelinePanel.CustomCPUThrottlingRateDialog.prototype = { |
| 2094 /** |
| 2095 * @return {!Promise<string>} |
| 2096 */ |
| 2097 result: function() |
| 2098 { |
| 2099 return this._resultPromise; |
| 2100 }, |
| 2101 |
| 2102 _apply: function() |
| 2103 { |
| 2104 this._callback(this._input.value); |
| 2105 }, |
| 2106 |
| 2107 /** |
| 2108 * @param {!Event} event |
| 2109 */ |
| 2110 _onKeyDown: function(event) |
| 2111 { |
| 2112 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) { |
| 2113 event.preventDefault(); |
| 2114 this._apply(); |
| 2115 } |
| 2116 }, |
| 2117 |
| 2118 __proto__: WebInspector.HBox.prototype |
| 2119 } |
| OLD | NEW |