Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..64d50b4fa44c3886e8c08aa40e3c6ecfac029bdc |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineLandingPage.js |
| @@ -0,0 +1,173 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** @typedef {!{id: string, title: string, description: string, setting: string}} */ |
| +Timeline.RecordingOption; |
| + |
| +/** @type {!Object<string, !Timeline.RecordingOption>} */ |
| +Timeline.RecordingConfig = { |
| + network: { |
| + id: 'network', |
| + title: Common.UIString('Network'), |
| + description: Common.UIString('Capture network requests information.'), |
| + setting: 'timelineCaptureNetwork' |
| + }, |
| + javascript: { |
| + id: 'javascript', |
| + title: Common.UIString('JavaScript'), |
| + description: Common.UIString('Use sampling CPU profiler to collect JavaScript stacks.'), |
| + setting: 'timelineEnableJSSampling' |
| + }, |
| + screenshots: { |
| + id: 'screenshots', |
| + title: Common.UIString('Screenshots'), |
| + description: |
| + Common.UIString('Collect page screenshots, so you can observe how the page was evolving during recording.'), |
| + setting: 'timelineCaptureFilmStrip' |
| + }, |
| + paints: { |
| + id: 'paints', |
| + title: Common.UIString('Paints'), |
| + description: Common.UIString( |
| + 'Capture graphics layer positions and rasterization draw calls (moderate performance overhead).'), |
| + setting: 'timelineCaptureLayersAndPictures' |
| + }, |
| + memory: { |
| + id: 'memory', |
| + title: Common.UIString('Memory'), |
| + description: Common.UIString('Capture memory statistics on every timeline event.'), |
| + setting: 'timelineCaptureMemory' |
| + } |
| +}; |
| + |
| +Timeline.Perspective = class extends UI.VBox { |
| + /** |
| + * @param {string} description |
| + * @param {!Array<!Timeline.RecordingOption>=} visibleOptions |
| + * @param {!Array<!Timeline.RecordingOption>=} enabledOptions |
| + */ |
| + constructor(description, visibleOptions, enabledOptions) { |
| + super(false); |
| + enabledOptions = enabledOptions || []; |
| + this._enabledOptions = new Set(enabledOptions.map(option => option.id)); |
| + this._enabledOptions.add(Timeline.RecordingConfig.javascript.id); |
|
caseq
2016/12/09 22:05:25
So can I ever disable JavaScript?
alph
2016/12/09 22:23:21
Sure, you can. These are just defaults we show whe
|
| + this.contentElement.classList.add('timeline-perspective-body'); |
| + this.contentElement.createChild('div', 'timeline-perspective-description').textContent = description; |
| + for (const config of visibleOptions || []) |
| + this._createSettingCheckBox(this.contentElement, config); |
| + const actionButton = this.contentElement.createChild('div').createChild('button', 'action-button'); |
| + actionButton.textContent = Common.UIString('Start'); |
| + actionButton.addEventListener('click', () => this.action()); |
| + } |
| + |
| + /** |
| + * @param {!Element} parent |
| + * @param {!Timeline.RecordingOption} config |
| + */ |
| + _createSettingCheckBox(parent, config) { |
| + const div = parent.createChild('div', 'recording-setting'); |
| + const value = this._enabledOptions.has(config.id); |
| + const setting = Common.settings.createSetting(config.setting, value); |
| + div.appendChild(UI.SettingsUI.createSettingCheckbox(config.title, setting, true)); |
| + if (config.description) |
| + div.createChild('div', 'recording-setting-description').textContent = config.description; |
| + } |
| + |
| + activate() { |
| + for (let id in Timeline.RecordingConfig) { |
| + const config = Timeline.RecordingConfig[id]; |
| + const setting = Common.settings.createSetting(config.setting, false); |
| + setting.set(this._enabledOptions.has(id)); |
| + } |
| + } |
| + |
| + action() { |
| + UI.actionRegistry.action('timeline.toggle-recording').execute(); |
| + } |
| +}; |
| + |
| +Timeline.LoadPerspective = class extends Timeline.Perspective { |
| + constructor() { |
| + const config = Timeline.RecordingConfig; |
| + super( |
| + Common.UIString( |
| + 'Page Load mode allows you to analyze how fast the page is loaded and becomes responsive.\n' + |
| + 'In this mode the page is automatically reloaded right after the recording has started. ' + |
| + 'During recording it collects information about network requests, screen state updates, ' + |
| + 'and CPU threads acivity along with JavaScript stacks. ' + |
| + 'Recording is stopped automatically shortly after the page processes load event.'), |
| + [config.screenshots], [config.network, config.screenshots]); |
| + } |
| + |
| + /** |
| + * @override |
| + */ |
| + action() { |
| + SDK.targetManager.reloadPage(); |
| + } |
| +}; |
| + |
| +Timeline.ResponsivenessPerspective = class extends Timeline.Perspective { |
| + constructor() { |
| + const config = Timeline.RecordingConfig; |
| + super(Common.UIString('Record page responsiveness.'), [config.screenshots], [config.network]); |
| + } |
| +}; |
| + |
| +Timeline.JavaScriptPerspective = class extends Timeline.Perspective { |
| + constructor() { |
| + super(Common.UIString( |
| + 'This mode is useful when you want to focus on JavaScript performance. ' + |
| + 'All the options besides sampling CPU profiler are turned off to minimize measurement errors.')); |
| + } |
| +}; |
| + |
| +Timeline.CustomPerspective = class extends Timeline.Perspective { |
| + constructor() { |
| + const config = Timeline.RecordingConfig; |
| + super( |
| + Common.UIString('Advanced mode that allows you to customize recording options.'), |
| + [config.network, config.javascript, config.screenshots, config.memory, config.paints], |
| + [config.network, config.screenshots]); |
| + } |
| +}; |
| + |
| +Timeline.LandingPage = class extends UI.VBox { |
| + constructor() { |
| + super(true); |
| + this.registerRequiredCSS('timeline/timelineLandingPage.css'); |
| + this.contentElement.classList.add('timeline-landing-page', 'fill'); |
| + const perspectives = Timeline.TimelinePanel.Perspectives; |
| + this._tabbedPane = new UI.TabbedPane(); |
| + this._tabbedPane.registerRequiredCSS('timeline/timelineLandingPage.css'); |
| + this._tabbedPane.registerRequiredCSS('ui_lazy/dialog.css'); |
| + this._tabbedPane.contentElement.classList.add('timeline-landing-page'); |
| + this._tabbedPane.setTabSlider(true); |
| + this._tabbedPane.appendTab(perspectives.Load, Common.UIString('Page Load'), new Timeline.LoadPerspective()); |
| + this._tabbedPane.appendTab( |
| + perspectives.Responsiveness, Common.UIString('Responsiveness'), new Timeline.ResponsivenessPerspective()); |
| + this._tabbedPane.appendTab( |
| + perspectives.JavaScript, Common.UIString('JavaScript'), new Timeline.JavaScriptPerspective()); |
| + this._tabbedPane.appendTab(perspectives.Custom, Common.UIString('Custom'), new Timeline.CustomPerspective()); |
| + this._tabbedPane.addEventListener(UI.TabbedPane.Events.TabSelected, this._tabSelected, this); |
| + this._tabbedPane.show(this.contentElement); |
| + this._perspectiveSetting = |
| + Common.settings.createSetting('timelinePerspective', Timeline.TimelinePanel.Perspectives.Load); |
| + this._perspectiveSetting.addChangeListener(this._perspectiveChanged, this); |
| + } |
| + |
| + /** |
| + * @param {!Common.Event} event |
| + */ |
| + _tabSelected(event) { |
| + if (this._perspectiveSetting.get() !== event.data.tabId) |
| + this._perspectiveSetting.set(event.data.tabId); |
| + } |
| + |
| + _perspectiveChanged() { |
| + this._tabbedPane.selectTab(this._perspectiveSetting.get()); |
| + const perspective = /** @type {!Timeline.Perspective} */ (this._tabbedPane.visibleView); |
| + perspective.activate(); |
| + } |
| +}; |