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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js

Issue 2637443004: DevTools: bring back old landing page in timeline/performance. (Closed)
Patch Set: review comments addressed Created 3 years, 11 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
OLDNEW
(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 config = Timeline.TimelineLandingPage.RecordingConfig;
11 this._tabbedPane = new UI.TabbedPane();
12 this._tabbedPane.setTabSlider(true);
13 this._tabbedPane.renderWithNoHeaderBackground();
14 this._currentTabSetting =
15 Common.settings.createSetting('performanceLandingPageTab', Timeline.Time lineLandingPage.PageId.Basic);
16
17 var tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget();
18 appendCommonPart(tab);
19 tab.appendDescription(Common.UIString(
20 'The basic profile collects network, JavaScript and browser activity as you interact with the page.'));
21 tab.appendOption(config.screenshots);
22 tab.appendOption(config.javascript, true);
23 tab.appendOption(config.paints, false);
24 this._tabbedPane.appendTab(Timeline.TimelineLandingPage.PageId.Basic, Common .UIString('Basic'), tab);
25
26 tab = new Timeline.TimelineLandingPage.PerspectiveTabWidget();
27 appendCommonPart(tab);
28 tab.appendDescription(Common.UIString(
29 'Select what additional details you’d like to record. ' +
30 'By default, the advanced profile will collect all data of the basic pro file.'));
31 tab.appendOption(config.screenshots);
32 tab.appendOption(config.javascript);
33 tab.appendOption(config.paints);
34 this._tabbedPane.appendTab(Timeline.TimelineLandingPage.PageId.Advanced, Com mon.UIString('Advanced'), tab);
35
36 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this);
37 this._tabbedPane.selectTab(this._currentTabSetting.get());
38 this._tabbedPane.show(this.contentElement);
39
40 /**
41 * @param {!Timeline.TimelineLandingPage.PerspectiveTabWidget} tab
42 */
43 function appendCommonPart(tab) {
44 tab.appendDescription(Common.UIString(
45 'The Performance panel lets you record what the browser does during pa ge load and user interaction. ' +
46 'The timeline it generates can help you determine why certain parts of your page are slow.\u2002'));
47 tab.appendDescription(UI.createExternalLink(
48 'https://developers.google.com/web/tools/chrome-devtools/evaluate-perf ormance/',
49 Common.UIString('Learn more')));
50 tab.appendDescription(createElement('p'));
51 }
52 }
53
54 /**
55 * @return {!Timeline.TimelineController.RecordingOptions}
56 */
57 recordingOptions() {
58 const tabWidget = /** @type {!Timeline.TimelineLandingPage.PerspectiveTabWid get} */ (this._tabbedPane.visibleView);
59 return tabWidget.recordingOptions();
60 }
61
62 _tabSelected() {
63 this._currentTabSetting.set(this._tabbedPane.selectedTabId);
64 }
65 };
66
67 /**
68 * @typedef {!{
69 * id: string,
70 * title: string,
71 * description: string,
72 * settingName: string,
73 * captureOptionName: string,
74 * value: boolean
75 * }}
76 */
77 Timeline.TimelineLandingPage.RecordingOption;
78
79 /** @type {!Object<string, !Timeline.TimelineLandingPage.RecordingOption>} */
80 Timeline.TimelineLandingPage.RecordingConfig = {
81 javascript: {
82 id: 'javascript',
83 title: Common.UIString('JavaScript'),
84 description: Common.UIString('Use sampling CPU profiler to collect JavaScrip t stacks.'),
85 settingName: 'timelineEnableJSSampling',
86 captureOptionName: 'enableJSSampling',
87 value: true
88 },
89 screenshots: {
90 id: 'screenshots',
91 title: Common.UIString('Screenshots'),
92 description: Common.UIString(
93 'Collect page screenshots, so you can observe how the page was evolving during recording (moderate performance overhead).'),
94 settingName: 'timelineCaptureFilmStrip',
95 captureOptionName: 'captureFilmStrip',
96 value: true
97 },
98 paints: {
99 id: 'paints',
100 title: Common.UIString('Paints'),
101 description: Common.UIString(
102 'Capture graphics layer positions and rasterization draw calls (signific ant performance overhead).'),
103 settingName: 'timelineCaptureLayersAndPictures',
104 captureOptionName: 'capturePictures',
105 value: false
106 }
107 };
108
109 /** @enum {string} */
110 Timeline.TimelineLandingPage.PageId = {
111 Basic: 'Basic',
112 Advanced: 'Advanced'
113 };
114
115 Timeline.TimelineLandingPage.PerspectiveTabWidget = class extends UI.VBox {
116 constructor() {
117 super(false);
118 this.contentElement.classList.add('timeline-perspective-body');
119 /** @type {!Map<string, boolean>} */
120 this._forceEnable = new Map();
121 this._descriptionDiv = this.contentElement.createChild('div', 'timeline-pers pective-description');
122 this._actionButtonDiv = this.contentElement.createChild('div');
123 this._actionButtonDiv.appendChild(UI.createTextButton(Common.UIString('Start profiling'), this._record));
124 this._actionButtonDiv.appendChild(UI.createTextButton(Common.UIString('Profi le page load'), this._recordPageLoad));
125 }
126
127 /**
128 * @param {!Element|string} value
129 */
130 appendDescription(value) {
131 if (typeof value === 'string')
132 this._descriptionDiv.createTextChild(value);
133 else
134 this._descriptionDiv.appendChild(value);
135 }
136
137 /**
138 * @param {!Timeline.TimelineLandingPage.RecordingOption} option
139 * @param {boolean=} forceEnable
140 */
141 appendOption(option, forceEnable) {
142 if (typeof forceEnable === 'boolean') {
143 this._forceEnable.set(option.id, forceEnable);
144 return;
145 }
146 const div = createElementWithClass('div', 'recording-setting');
147 const setting = Common.settings.createSetting(option.settingName, option.val ue);
148 div.appendChild(UI.SettingsUI.createSettingCheckbox(option.title, setting, t rue));
149 if (option.description)
150 div.createChild('div', 'recording-setting-description').textContent = opti on.description;
151 this.contentElement.insertBefore(div, this._actionButtonDiv);
152 }
153
154 /**
155 * @return {!Timeline.TimelineController.RecordingOptions}
156 */
157 recordingOptions() {
158 const options = {};
159 for (const id in Timeline.TimelineLandingPage.RecordingConfig) {
160 const config = Timeline.TimelineLandingPage.RecordingConfig[id];
161 const setting = Common.settings.createSetting(config.settingName, config.v alue);
162 options[config.captureOptionName] = this._forceEnable.has(id) ? this._forc eEnable.get(id) : setting.get();
163 }
164 return options;
165 }
166
167 _record() {
168 UI.actionRegistry.action('timeline.toggle-recording').execute();
169 }
170
171 _recordPageLoad() {
172 SDK.targetManager.reloadPage();
173 }
174 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698