| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 Timeline.TimelineLandingPage = class extends UI.VBox { | 5 Timeline.TimelineLandingPage = class extends UI.VBox { |
| 6 constructor() { | 6 constructor() { |
| 7 super(true); | 7 super(true); |
| 8 this.registerRequiredCSS('timeline/timelineLandingPage.css'); | 8 this.registerRequiredCSS('timeline/timelineLandingPage.css'); |
| 9 this.contentElement.classList.add('timeline-landing-page', 'fill'); | 9 this.contentElement.classList.add('timeline-landing-page', 'fill'); |
| 10 const perspectives = Timeline.TimelinePanel.Perspectives; | 10 const perspectives = Timeline.TimelinePanel.Perspectives; |
| 11 const config = Timeline.TimelineLandingPage.RecordingConfig; | 11 const config = Timeline.TimelineLandingPage.RecordingConfig; |
| 12 this._tabbedPane = new UI.TabbedPane(); | 12 this._tabbedPane = new UI.TabbedPane(); |
| 13 this._tabbedPane.setTabSlider(true); | 13 this._tabbedPane.setTabSlider(true); |
| 14 this._tabbedPane.renderWithNoHeaderBackground(); | 14 this._tabbedPane.renderWithNoHeaderBackground(); |
| 15 | 15 |
| 16 var tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); | 16 var tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); |
| 17 tab.setDescription(Common.UIString( | 17 tab.appendDescription(Common.UIString( |
| 18 'Page Load mode allows you to analyze how fast the page is loaded and be
comes responsive.\n' + | 18 'The Performance panel lets you record what the browser does during page
load and user interaction. ' + |
| 19 'In this mode the page is automatically reloaded right after the recordi
ng has started. ' + | 19 'The timeline it generates can help you determine why certain parts of y
our page are slow.\u2002')); |
| 20 'During recording it collects information about network requests, screen
state updates, ' + | 20 tab.appendDescription(learnMore()); |
| 21 'and CPU threads acivity along with JavaScript stacks. ' + | 21 tab.appendDescription(createElement('p')); |
| 22 'Recording is stopped automatically shortly after the page processes loa
d event.')); | 22 tab.appendDescription(Common.UIString( |
| 23 tab.setAction(recordAndReload); | 23 'The basic profile collects network, JavaScript and browser activity as
you interact with the page.')); |
| 24 tab.appendOption(config.network, false, true); | 24 tab.appendOption(config.network, false, true); |
| 25 tab.appendOption(config.screenshots, true, true); | 25 tab.appendOption(config.screenshots, true, true); |
| 26 this._tabbedPane.appendTab(perspectives.Load, Common.UIString('Page Load'),
tab); | 26 this._tabbedPane.appendTab(perspectives.Responsiveness, Common.UIString('Bas
ic'), tab); |
| 27 | 27 |
| 28 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); | 28 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); |
| 29 tab.setDescription(Common.UIString('Record page responsiveness.')); | 29 tab.appendDescription(Common.UIString( |
| 30 tab.setAction(record); | 30 'Select what additional details you’d like to record. ' + |
| 31 tab.appendOption(config.network, false, true); | 31 'By default, the advanced profile will collect all data of the basic pro
file.\u2002')); |
| 32 tab.appendOption(config.screenshots, true, false); | 32 tab.appendDescription(learnMore()); |
| 33 this._tabbedPane.appendTab(perspectives.Responsiveness, Common.UIString('Res
ponsiveness'), tab); | |
| 34 | |
| 35 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); | |
| 36 tab.setDescription(Common.UIString( | |
| 37 'This mode is useful when you want to focus on JavaScript performance. '
+ | |
| 38 'All the options besides sampling CPU profiler are turned off to minimiz
e measurement errors.')); | |
| 39 tab.setAction(record); | |
| 40 this._tabbedPane.appendTab(perspectives.JavaScript, Common.UIString('JavaScr
ipt'), tab); | |
| 41 | |
| 42 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); | |
| 43 tab.setDescription(Common.UIString('Advanced mode that allows you to customi
ze recording options.')); | |
| 44 tab.setAction(record); | |
| 45 tab.appendOption(config.network, true, true); | 33 tab.appendOption(config.network, true, true); |
| 46 tab.appendOption(config.javascript, true, true); | 34 tab.appendOption(config.javascript, true, true); |
| 47 tab.appendOption(config.screenshots, true, true); | 35 tab.appendOption(config.screenshots, true, true); |
| 48 tab.appendOption(config.memory, true, false); | 36 tab.appendOption(config.memory, true, false); |
| 49 tab.appendOption(config.paints, true, false); | 37 tab.appendOption(config.paints, true, false); |
| 50 this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Custom'), t
ab); | 38 this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Advanced'),
tab); |
| 51 | 39 |
| 52 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); | 40 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); |
| 53 this._tabbedPane.show(this.contentElement); | 41 this._tabbedPane.show(this.contentElement); |
| 54 this._perspectiveSetting = | 42 this._perspectiveSetting = |
| 55 Common.settings.createSetting('timelinePerspective', Timeline.TimelinePa
nel.Perspectives.Load); | 43 Common.settings.createSetting('timelinePerspective', Timeline.TimelinePa
nel.Perspectives.Load); |
| 56 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); | 44 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); |
| 57 | 45 |
| 58 function record() { | 46 /** |
| 59 UI.actionRegistry.action('timeline.toggle-recording').execute(); | 47 * @return {!Element} |
| 60 } | 48 */ |
| 61 | 49 function learnMore() { |
| 62 function recordAndReload() { | 50 return UI.createExternalLink( |
| 63 SDK.targetManager.reloadPage(); | 51 'https://developers.google.com/web/tools/chrome-devtools/evaluate-perfor
mance/timeline-tool', |
| 52 Common.UIString('Learn more')); |
| 64 } | 53 } |
| 65 } | 54 } |
| 66 | 55 |
| 67 /** | 56 /** |
| 68 * @param {!Common.Event} event | 57 * @param {!Common.Event} event |
| 69 */ | 58 */ |
| 70 _tabSelected(event) { | 59 _tabSelected(event) { |
| 71 if (this._perspectiveSetting.get() !== event.data.tabId) | 60 if (this._perspectiveSetting.get() !== event.data.tabId) |
| 72 this._perspectiveSetting.set(event.data.tabId); | 61 this._perspectiveSetting.set(event.data.tabId); |
| 73 } | 62 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 setting: 'timelineCaptureMemory' | 106 setting: 'timelineCaptureMemory' |
| 118 } | 107 } |
| 119 }; | 108 }; |
| 120 | 109 |
| 121 Timeline.TimelineLandingPage.PerspectiveTabWidget = class extends UI.VBox { | 110 Timeline.TimelineLandingPage.PerspectiveTabWidget = class extends UI.VBox { |
| 122 constructor() { | 111 constructor() { |
| 123 super(false); | 112 super(false); |
| 124 this.contentElement.classList.add('timeline-perspective-body'); | 113 this.contentElement.classList.add('timeline-perspective-body'); |
| 125 this._enabledOptions = new Set([Timeline.TimelineLandingPage.RecordingConfig
.javascript.id]); | 114 this._enabledOptions = new Set([Timeline.TimelineLandingPage.RecordingConfig
.javascript.id]); |
| 126 this._descriptionDiv = this.contentElement.createChild('div', 'timeline-pers
pective-description'); | 115 this._descriptionDiv = this.contentElement.createChild('div', 'timeline-pers
pective-description'); |
| 127 this._actionButton = createTextButton(Common.UIString('Start')); | |
| 128 this._actionButtonDiv = this.contentElement.createChild('div'); | 116 this._actionButtonDiv = this.contentElement.createChild('div'); |
| 129 this._actionButtonDiv.appendChild(this._actionButton); | 117 this._actionButtonDiv.appendChild(createTextButton(Common.UIString('Record')
, this._record.bind(this))); |
| 118 this._actionButtonDiv.appendChild(createTextButton(Common.UIString('Record P
age Load'), |
| 119 this._recordPageLoad.bind(this))); |
| 130 } | 120 } |
| 131 | 121 |
| 132 /** | 122 /** |
| 133 * @param {string} text | 123 * @param {!Element|string} value |
| 134 */ | 124 */ |
| 135 setDescription(text) { | 125 appendDescription(value) { |
| 136 this._descriptionDiv.textContent = text; | 126 if (typeof value === 'string') |
| 127 this._descriptionDiv.createTextChild(value); |
| 128 else |
| 129 this._descriptionDiv.appendChild(value); |
| 137 } | 130 } |
| 138 | 131 |
| 139 /** | 132 /** |
| 140 * @param {function()} action | |
| 141 */ | |
| 142 setAction(action) { | |
| 143 this._actionButton.addEventListener('click', action); | |
| 144 } | |
| 145 | |
| 146 /** | |
| 147 * @param {!Timeline.TimelineLandingPage.RecordingOption} option | 133 * @param {!Timeline.TimelineLandingPage.RecordingOption} option |
| 148 * @param {boolean} visible | 134 * @param {boolean} visible |
| 149 * @param {boolean} enabled | 135 * @param {boolean} enabled |
| 150 */ | 136 */ |
| 151 appendOption(option, visible, enabled) { | 137 appendOption(option, visible, enabled) { |
| 152 if (enabled) | 138 if (enabled) |
| 153 this._enabledOptions.add(option.id); | 139 this._enabledOptions.add(option.id); |
| 154 if (!visible) | 140 if (!visible) |
| 155 return; | 141 return; |
| 156 const div = createElementWithClass('div', 'recording-setting'); | 142 const div = createElementWithClass('div', 'recording-setting'); |
| 157 const value = this._enabledOptions.has(option.id); | 143 const value = this._enabledOptions.has(option.id); |
| 158 const setting = Common.settings.createSetting(option.setting, value); | 144 const setting = Common.settings.createSetting(option.setting, value); |
| 159 div.appendChild(UI.SettingsUI.createSettingCheckbox(option.title, setting, t
rue)); | 145 div.appendChild(UI.SettingsUI.createSettingCheckbox(option.title, setting, t
rue)); |
| 160 if (option.description) | 146 if (option.description) |
| 161 div.createChild('div', 'recording-setting-description').textContent = opti
on.description; | 147 div.createChild('div', 'recording-setting-description').textContent = opti
on.description; |
| 162 this.contentElement.insertBefore(div, this._actionButtonDiv); | 148 this.contentElement.insertBefore(div, this._actionButtonDiv); |
| 163 } | 149 } |
| 164 | 150 |
| 165 activate() { | 151 activate() { |
| 166 for (const id in Timeline.TimelineLandingPage.RecordingConfig) { | 152 for (const id in Timeline.TimelineLandingPage.RecordingConfig) { |
| 167 const config = Timeline.TimelineLandingPage.RecordingConfig[id]; | 153 const config = Timeline.TimelineLandingPage.RecordingConfig[id]; |
| 168 const setting = Common.settings.createSetting(config.setting, false); | 154 const setting = Common.settings.createSetting(config.setting, false); |
| 169 setting.set(this._enabledOptions.has(id)); | 155 setting.set(this._enabledOptions.has(id)); |
| 170 } | 156 } |
| 171 } | 157 } |
| 158 |
| 159 _record() { |
| 160 UI.actionRegistry.action('timeline.toggle-recording').execute(); |
| 161 } |
| 162 |
| 163 _recordPageLoad() { |
| 164 SDK.targetManager.reloadPage(); |
| 165 } |
| 172 }; | 166 }; |
| OLD | NEW |