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

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

Issue 2557973002: DevTools: Introduce Landing page for Timeline panel. (Closed)
Patch Set: addressing comments Created 4 years 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 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 this._tabbedPane.renderWithNoTabBorders();
16 this._tabbedPane.appendTab(perspectives.Load, Common.UIString('Page Load'),
17 new Timeline.TimelineLandingPage.PerspectiveTabWidget(Common.UIString(
18 'Page Load mode allows you to analyze how fast the page is loaded an d becomes responsive.\n' +
19 'In this mode the page is automatically reloaded right after the rec ording has started. ' +
20 'During recording it collects information about network requests, sc reen state updates, ' +
21 'and CPU threads acivity along with JavaScript stacks. ' +
22 'Recording is stopped automatically shortly after the page processes load event.'), recordAndReload,
23 [config.screenshots], [config.network, config.screenshots]));
24 this._tabbedPane.appendTab(perspectives.Responsiveness, Common.UIString('Res ponsiveness'),
25 new Timeline.TimelineLandingPage.PerspectiveTabWidget(Common.UIString('R ecord page responsiveness.'),
26 record, [config.screenshots], [config.network]));
27 this._tabbedPane.appendTab(perspectives.JavaScript, Common.UIString('JavaScr ipt'),
28 new Timeline.TimelineLandingPage.PerspectiveTabWidget(Common.UIString(
29 'This mode is useful when you want to focus on JavaScript performanc e. ' +
30 'All the options besides sampling CPU profiler are turned off to min imize measurement errors.'), record));
31 this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Custom'),
32 new Timeline.TimelineLandingPage.PerspectiveTabWidget(Common.UIString(
33 'Advanced mode that allows you to customize recording options.'), re cord,
34 [config.network, config.javascript, config.screenshots, config.memor y, config.paints],
pfeldman 2016/12/10 02:15:59 var tab = new Tab(id); tab.setDescription(.....);
35 [config.network, config.screenshots]));
36 this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._ta bSelected, this);
37 this._tabbedPane.show(this.contentElement);
38 this._perspectiveSetting =
39 Common.settings.createSetting('timelinePerspective', Timeline.TimelinePa nel.Perspectives.Load);
40 this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this);
41
42 function record() {
43 UI.actionRegistry.action('timeline.toggle-recording').execute();
44 }
45
46 function recordAndReload() {
47 SDK.targetManager.reloadPage();
48 }
49 }
50
51 /**
52 * @param {!Common.Event} event
53 */
54 _tabSelected(event) {
55 if (this._perspectiveSetting.get() !== event.data.tabId)
56 this._perspectiveSetting.set(event.data.tabId);
57 }
58
59 _perspectiveChanged() {
60 this._tabbedPane.selectTab(this._perspectiveSetting.get());
61 const tabWidget = /** @type {!Timeline.TimelineLandingPage.PerspectiveTabWid get} */ (this._tabbedPane.visibleView);
62 tabWidget.activate();
63 }
64 };
65
66 /** @typedef {!{id: string, title: string, description: string, setting: string} } */
67 Timeline.TimelineLandingPage.RecordingOption;
68
69 /** @type {!Object<string, !Timeline.TimelineLandingPage.RecordingOption>} */
70 Timeline.TimelineLandingPage.RecordingConfig = {
71 network: {
72 id: 'network',
73 title: Common.UIString('Network'),
74 description: Common.UIString('Capture network requests information.'),
75 setting: 'timelineCaptureNetwork'
76 },
77 javascript: {
78 id: 'javascript',
79 title: Common.UIString('JavaScript'),
80 description: Common.UIString('Use sampling CPU profiler to collect JavaScrip t stacks.'),
81 setting: 'timelineEnableJSSampling'
82 },
83 screenshots: {
84 id: 'screenshots',
85 title: Common.UIString('Screenshots'),
86 description:
87 Common.UIString('Collect page screenshots, so you can observe how the pa ge was evolving during recording.'),
88 setting: 'timelineCaptureFilmStrip'
89 },
90 paints: {
91 id: 'paints',
92 title: Common.UIString('Paints'),
93 description: Common.UIString(
94 'Capture graphics layer positions and rasterization draw calls (moderate performance overhead).'),
95 setting: 'timelineCaptureLayersAndPictures'
96 },
97 memory: {
98 id: 'memory',
99 title: Common.UIString('Memory'),
100 description: Common.UIString('Capture memory statistics on every timeline ev ent.'),
101 setting: 'timelineCaptureMemory'
102 }
103 };
104
105 Timeline.TimelineLandingPage.PerspectiveTabWidget = class extends UI.VBox {
106 /**
107 * @param {string} description
108 * @param {function()} action
109 * @param {!Array<!Timeline.TimelineLandingPage.RecordingOption>=} visibleOpti ons
110 * @param {!Array<!Timeline.TimelineLandingPage.RecordingOption>=} enabledOpti ons
111 */
112 constructor(description, action, visibleOptions, enabledOptions) {
113 super(false);
114 enabledOptions = enabledOptions || [];
115 this._enabledOptions = new Set(enabledOptions.map(option => option.id));
116 this._enabledOptions.add(Timeline.TimelineLandingPage.RecordingConfig.javasc ript.id);
117 this.contentElement.classList.add('timeline-perspective-body');
118 this.contentElement.createChild('div', 'timeline-perspective-description').t extContent = description;
119 for (const config of visibleOptions || [])
120 this._createSettingCheckBox(this.contentElement, config);
121 const actionButton = this.contentElement.createChild('div').createChild('but ton', 'action-button');
122 actionButton.textContent = Common.UIString('Start');
123 actionButton.addEventListener('click', action);
124 }
125
126 /**
127 * @param {!Element} parent
128 * @param {!Timeline.TimelineLandingPage.RecordingOption} config
129 */
130 _createSettingCheckBox(parent, config) {
131 const div = parent.createChild('div', 'recording-setting');
132 const value = this._enabledOptions.has(config.id);
133 const setting = Common.settings.createSetting(config.setting, value);
134 div.appendChild(UI.SettingsUI.createSettingCheckbox(config.title, setting, t rue));
135 if (config.description)
136 div.createChild('div', 'recording-setting-description').textContent = conf ig.description;
137 }
138
139 activate() {
140 for (let id in Timeline.TimelineLandingPage.RecordingConfig) {
141 const config = Timeline.TimelineLandingPage.RecordingConfig[id];
142 const setting = Common.settings.createSetting(config.setting, false);
143 setting.set(this._enabledOptions.has(id));
144 }
145 }
146 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698