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

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

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

Powered by Google App Engine
This is Rietveld 408576698