| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 Timeline.TimelineLandingPage = class extends UI.VBox { |
| 6 constructor() { |
| 7 super(true); |
| 8 this.registerRequiredCSS('timeline/timelineLandingPage.css'); |
| 9 this.contentElement.classList.add('timeline-landing-page', 'fill'); |
| 10 const perspectives = Timeline.TimelinePanel.Perspectives; |
| 11 const config = Timeline.TimelineLandingPage.RecordingConfig; |
| 12 this._tabbedPane = new UI.TabbedPane(); |
| 13 this._tabbedPane.setTabSlider(true); |
| 14 this._tabbedPane.renderWithNoHeaderBackground(); |
| 15 |
| 16 var tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); |
| 17 tab.setDescription(Common.UIString( |
| 18 'Page Load mode allows you to analyze how fast the page is loaded and be
comes responsive.\n' + |
| 19 'In this mode the page is automatically reloaded right after the recordi
ng has started. ' + |
| 20 'During recording it collects information about network requests, screen
state updates, ' + |
| 21 'and CPU threads acivity along with JavaScript stacks. ' + |
| 22 'Recording is stopped automatically shortly after the page processes loa
d event.')); |
| 23 tab.setAction(recordAndReload); |
| 24 tab.appendOption(config.network, false, true); |
| 25 tab.appendOption(config.screenshots, true, true); |
| 26 this._tabbedPane.appendTab(perspectives.Load, Common.UIString('Page Load'),
tab); |
| 27 |
| 28 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget(); |
| 29 tab.setDescription(Common.UIString('Record page responsiveness.')); |
| 30 tab.setAction(record); |
| 31 tab.appendOption(config.network, false, true); |
| 32 tab.appendOption(config.screenshots, true, false); |
| 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); |
| 46 tab.appendOption(config.javascript, true, true); |
| 47 tab.appendOption(config.screenshots, true, true); |
| 48 tab.appendOption(config.memory, true, false); |
| 49 tab.appendOption(config.paints, true, false); |
| 50 this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Custom'), t
ab); |
| 51 |
| 52 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta
bSelected, this); |
| 53 this._tabbedPane.show(this.contentElement); |
| 54 this._perspectiveSetting = |
| 55 Common.settings.createSetting('timelinePerspective', Timeline.TimelinePa
nel.Perspectives.Load); |
| 56 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); |
| 57 |
| 58 function record() { |
| 59 UI.actionRegistry.action('timeline.toggle-recording').execute(); |
| 60 } |
| 61 |
| 62 function recordAndReload() { |
| 63 SDK.targetManager.reloadPage(); |
| 64 } |
| 65 } |
| 66 |
| 67 /** |
| 68 * @param {!Common.Event} event |
| 69 */ |
| 70 _tabSelected(event) { |
| 71 if (this._perspectiveSetting.get() !== event.data.tabId) |
| 72 this._perspectiveSetting.set(event.data.tabId); |
| 73 } |
| 74 |
| 75 _perspectiveChanged() { |
| 76 this._tabbedPane.selectTab(this._perspectiveSetting.get()); |
| 77 const tabWidget = /** @type {!Timeline.TimelineLandingPage.PerspectiveTabWid
get} */ (this._tabbedPane.visibleView); |
| 78 tabWidget.activate(); |
| 79 } |
| 80 }; |
| 81 |
| 82 /** @typedef {!{id: string, title: string, description: string, setting: string}
} */ |
| 83 Timeline.TimelineLandingPage.RecordingOption; |
| 84 |
| 85 /** @type {!Object<string, !Timeline.TimelineLandingPage.RecordingOption>} */ |
| 86 Timeline.TimelineLandingPage.RecordingConfig = { |
| 87 network: { |
| 88 id: 'network', |
| 89 title: Common.UIString('Network'), |
| 90 description: Common.UIString('Capture network requests information.'), |
| 91 setting: 'timelineCaptureNetwork' |
| 92 }, |
| 93 javascript: { |
| 94 id: 'javascript', |
| 95 title: Common.UIString('JavaScript'), |
| 96 description: Common.UIString('Use sampling CPU profiler to collect JavaScrip
t stacks.'), |
| 97 setting: 'timelineEnableJSSampling' |
| 98 }, |
| 99 screenshots: { |
| 100 id: 'screenshots', |
| 101 title: Common.UIString('Screenshots'), |
| 102 description: |
| 103 Common.UIString('Collect page screenshots, so you can observe how the pa
ge was evolving during recording.'), |
| 104 setting: 'timelineCaptureFilmStrip' |
| 105 }, |
| 106 paints: { |
| 107 id: 'paints', |
| 108 title: Common.UIString('Paints'), |
| 109 description: Common.UIString( |
| 110 'Capture graphics layer positions and rasterization draw calls (moderate
performance overhead).'), |
| 111 setting: 'timelineCaptureLayersAndPictures' |
| 112 }, |
| 113 memory: { |
| 114 id: 'memory', |
| 115 title: Common.UIString('Memory'), |
| 116 description: Common.UIString('Capture memory statistics on every timeline ev
ent.'), |
| 117 setting: 'timelineCaptureMemory' |
| 118 } |
| 119 }; |
| 120 |
| 121 Timeline.TimelineLandingPage.PerspectiveTabWidget = class extends UI.VBox { |
| 122 constructor() { |
| 123 super(false); |
| 124 this.contentElement.classList.add('timeline-perspective-body'); |
| 125 this._enabledOptions = new Set([Timeline.TimelineLandingPage.RecordingConfig
.javascript.id]); |
| 126 this._descriptionDiv = this.contentElement.createChild('div', 'timeline-pers
pective-description'); |
| 127 this._actionButton = createTextButton(Common.UIString('Start')); |
| 128 this._actionButtonDiv = this.contentElement.createChild('div'); |
| 129 this._actionButtonDiv.appendChild(this._actionButton); |
| 130 } |
| 131 |
| 132 /** |
| 133 * @param {string} text |
| 134 */ |
| 135 setDescription(text) { |
| 136 this._descriptionDiv.textContent = text; |
| 137 } |
| 138 |
| 139 /** |
| 140 * @param {function()} action |
| 141 */ |
| 142 setAction(action) { |
| 143 this._actionButton.addEventListener('click', action); |
| 144 } |
| 145 |
| 146 /** |
| 147 * @param {!Timeline.TimelineLandingPage.RecordingOption} option |
| 148 * @param {boolean} visible |
| 149 * @param {boolean} enabled |
| 150 */ |
| 151 appendOption(option, visible, enabled) { |
| 152 if (enabled) |
| 153 this._enabledOptions.add(option.id); |
| 154 if (!visible) |
| 155 return; |
| 156 const div = createElementWithClass('div', 'recording-setting'); |
| 157 const value = this._enabledOptions.has(option.id); |
| 158 const setting = Common.settings.createSetting(option.setting, value); |
| 159 div.appendChild(UI.SettingsUI.createSettingCheckbox(option.title, setting, t
rue)); |
| 160 if (option.description) |
| 161 div.createChild('div', 'recording-setting-description').textContent = opti
on.description; |
| 162 this.contentElement.insertBefore(div, this._actionButtonDiv); |
| 163 } |
| 164 |
| 165 activate() { |
| 166 for (const id in Timeline.TimelineLandingPage.RecordingConfig) { |
| 167 const config = Timeline.TimelineLandingPage.RecordingConfig[id]; |
| 168 const setting = Common.settings.createSetting(config.setting, false); |
| 169 setting.set(this._enabledOptions.has(id)); |
| 170 } |
| 171 } |
| 172 }; |
| OLD | NEW |