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

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

Issue 2472213005: DevTools: introduce "Track CSS Usage" experiment (Closed)
Patch Set: Unused CSS highlight in sources panel Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 /** @type {!Array.<!WebInspector.TimelineModeView>} */ 74 /** @type {!Array.<!WebInspector.TimelineModeView>} */
75 this._currentViews = []; 75 this._currentViews = [];
76 76
77 this._captureNetworkSetting = WebInspector.settings.createSetting('timelineC aptureNetwork', false); 77 this._captureNetworkSetting = WebInspector.settings.createSetting('timelineC aptureNetwork', false);
78 this._captureJSProfileSetting = WebInspector.settings.createSetting('timelin eEnableJSSampling', true); 78 this._captureJSProfileSetting = WebInspector.settings.createSetting('timelin eEnableJSSampling', true);
79 this._captureMemorySetting = WebInspector.settings.createSetting('timelineCa ptureMemory', false); 79 this._captureMemorySetting = WebInspector.settings.createSetting('timelineCa ptureMemory', false);
80 this._captureLayersAndPicturesSetting = 80 this._captureLayersAndPicturesSetting =
81 WebInspector.settings.createSetting('timelineCaptureLayersAndPictures', false); 81 WebInspector.settings.createSetting('timelineCaptureLayersAndPictures', false);
82 this._captureFilmStripSetting = WebInspector.settings.createSetting('timelin eCaptureFilmStrip', false); 82 this._captureFilmStripSetting = WebInspector.settings.createSetting('timelin eCaptureFilmStrip', false);
83 83
84 if (Runtime.experiments.isEnabled('timelineRuleUsageRecording')) {
85 this._markUnusedCSS = WebInspector.settings.createSetting('timelineMarkUnu sedCSS', false);
86 }
87
84 this._panelToolbar = new WebInspector.Toolbar('', this.element); 88 this._panelToolbar = new WebInspector.Toolbar('', this.element);
85 this._createToolbarItems(); 89 this._createToolbarItems();
86 90
87 var timelinePane = new WebInspector.VBox(); 91 var timelinePane = new WebInspector.VBox();
88 timelinePane.show(this.element); 92 timelinePane.show(this.element);
89 var topPaneElement = timelinePane.element.createChild('div', 'hbox'); 93 var topPaneElement = timelinePane.element.createChild('div', 'hbox');
90 topPaneElement.id = 'timeline-overview-panel'; 94 topPaneElement.id = 'timeline-overview-panel';
91 95
92 // Create top overview component. 96 // Create top overview component.
93 this._overviewPane = new WebInspector.TimelineOverviewPane('timeline'); 97 this._overviewPane = new WebInspector.TimelineOverviewPane('timeline');
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 WebInspector.UIString('Memory'), this._captureMemorySetting, 361 WebInspector.UIString('Memory'), this._captureMemorySetting,
358 WebInspector.UIString('Capture memory information on every timeline ev ent.'))); 362 WebInspector.UIString('Capture memory information on every timeline ev ent.')));
359 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox( 363 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(
360 WebInspector.UIString('Paint'), this._captureLayersAndPicturesSetting, 364 WebInspector.UIString('Paint'), this._captureLayersAndPicturesSetting,
361 WebInspector.UIString( 365 WebInspector.UIString(
362 'Capture graphics layer positions and rasterization draw calls. (H as large performance overhead)'))); 366 'Capture graphics layer positions and rasterization draw calls. (H as large performance overhead)')));
363 } else { 367 } else {
364 this._panelToolbar.appendToolbarItem(screenshotCheckbox); 368 this._panelToolbar.appendToolbarItem(screenshotCheckbox);
365 } 369 }
366 370
371 if (Runtime.experiments.isEnabled('timelineRuleUsageRecording')) {
372 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(
373 WebInspector.UIString('Audits'), this._markUnusedCSS,
alph 2016/11/08 17:10:25 Audits is too generic. Maybe "CSS coverage"?
374 WebInspector.UIString('Mark unused CSS in souces.')));
375 }
376
367 this._captureNetworkSetting.addChangeListener(this._onNetworkChanged, this); 377 this._captureNetworkSetting.addChangeListener(this._onNetworkChanged, this);
368 this._captureMemorySetting.addChangeListener(this._onModeChanged, this); 378 this._captureMemorySetting.addChangeListener(this._onModeChanged, this);
369 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, this); 379 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, this);
370 380
371 this._panelToolbar.appendSeparator(); 381 this._panelToolbar.appendSeparator();
372 var garbageCollectButton = 382 var garbageCollectButton =
373 new WebInspector.ToolbarButton(WebInspector.UIString('Collect garbage'), 'garbage-collect-toolbar-item'); 383 new WebInspector.ToolbarButton(WebInspector.UIString('Collect garbage'), 'garbage-collect-toolbar-item');
374 garbageCollectButton.addEventListener('click', this._garbageCollectButtonCli cked, this); 384 garbageCollectButton.addEventListener('click', this._garbageCollectButtonCli cked, this);
375 this._panelToolbar.appendToolbarItem(garbageCollectButton); 385 this._panelToolbar.appendToolbarItem(garbageCollectButton);
376 386
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 * @param {boolean} userInitiated 577 * @param {boolean} userInitiated
568 */ 578 */
569 _startRecording(userInitiated) { 579 _startRecording(userInitiated) {
570 console.assert(!this._statusPane, 'Status pane is already opened.'); 580 console.assert(!this._statusPane, 'Status pane is already opened.');
571 var mainTarget = WebInspector.targetManager.mainTarget(); 581 var mainTarget = WebInspector.targetManager.mainTarget();
572 if (!mainTarget) 582 if (!mainTarget)
573 return; 583 return;
574 this._setState(WebInspector.TimelinePanel.State.StartPending); 584 this._setState(WebInspector.TimelinePanel.State.StartPending);
575 this._showRecordingStarted(); 585 this._showRecordingStarted();
576 586
587 if (Runtime.experiments.isEnabled('timelineRuleUsageRecording') && this._mar kUnusedCSS.get())
alph 2016/11/08 17:10:25 ditto for ths._markUnusedCSS being undefined. Just
588 WebInspector.CSSModel.fromTarget(mainTarget).startRuleUsageTracking();
589
577 this._autoRecordGeneration = userInitiated ? null : Symbol('Generation'); 590 this._autoRecordGeneration = userInitiated ? null : Symbol('Generation');
578 this._controller = new WebInspector.TimelineController(mainTarget, this, thi s._tracingModel); 591 this._controller = new WebInspector.TimelineController(mainTarget, this, thi s._tracingModel);
579 this._controller.startRecording( 592 this._controller.startRecording(
580 true, this._captureJSProfileSetting.get(), this._captureMemorySetting.ge t(), 593 true, this._captureJSProfileSetting.get(), this._captureMemorySetting.ge t(),
581 this._captureLayersAndPicturesSetting.get(), 594 this._captureLayersAndPicturesSetting.get(),
582 this._captureFilmStripSetting && this._captureFilmStripSetting.get()); 595 this._captureFilmStripSetting && this._captureFilmStripSetting.get());
583 596
584 for (var i = 0; i < this._overviewControls.length; ++i) 597 for (var i = 0; i < this._overviewControls.length; ++i)
585 this._overviewControls[i].timelineStarted(); 598 this._overviewControls[i].timelineStarted();
586 599
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 this._stopRecording(); 635 this._stopRecording();
623 } 636 }
624 637
625 _garbageCollectButtonClicked() { 638 _garbageCollectButtonClicked() {
626 var targets = WebInspector.targetManager.targets(); 639 var targets = WebInspector.targetManager.targets();
627 for (var i = 0; i < targets.length; ++i) 640 for (var i = 0; i < targets.length; ++i)
628 targets[i].heapProfilerAgent().collectGarbage(); 641 targets[i].heapProfilerAgent().collectGarbage();
629 } 642 }
630 643
631 _clear() { 644 _clear() {
645 if (Runtime.experiments.isEnabled('timelineRuleUsageRecording') && this._mar kUnusedCSS.get())
alph 2016/11/08 17:10:25 ditto
646 WebInspector.CoverageProfile.instance().reset();
647
632 WebInspector.LineLevelProfile.instance().reset(); 648 WebInspector.LineLevelProfile.instance().reset();
633 this._tracingModel.reset(); 649 this._tracingModel.reset();
634 this._model.reset(); 650 this._model.reset();
635 this._showRecordingHelpMessage(); 651 this._showRecordingHelpMessage();
636 652
637 this.requestWindowTimes(0, Infinity); 653 this.requestWindowTimes(0, Infinity);
638 delete this._selection; 654 delete this._selection;
639 this._frameModel.reset(); 655 this._frameModel.reset();
640 this._filmStripModel.reset(this._tracingModel); 656 this._filmStripModel.reset(this._tracingModel);
641 this._overviewPane.reset(); 657 this._overviewPane.reset();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 this._statusPane.updateStatus(WebInspector.UIString('Processing timeline\u 2026')); 771 this._statusPane.updateStatus(WebInspector.UIString('Processing timeline\u 2026'));
756 this._model.setEvents(this._tracingModel, loadedFromFile); 772 this._model.setEvents(this._tracingModel, loadedFromFile);
757 this._frameModel.reset(); 773 this._frameModel.reset();
758 this._frameModel.addTraceEvents( 774 this._frameModel.addTraceEvents(
759 WebInspector.targetManager.mainTarget(), this._model.inspectedTargetEven ts(), this._model.sessionId() || ''); 775 WebInspector.targetManager.mainTarget(), this._model.inspectedTargetEven ts(), this._model.sessionId() || '');
760 this._filmStripModel.reset(this._tracingModel); 776 this._filmStripModel.reset(this._tracingModel);
761 var groups = WebInspector.TimelineModel.AsyncEventGroup; 777 var groups = WebInspector.TimelineModel.AsyncEventGroup;
762 var asyncEventsByGroup = this._model.mainThreadAsyncEvents(); 778 var asyncEventsByGroup = this._model.mainThreadAsyncEvents();
763 this._irModel.populate(asyncEventsByGroup.get(groups.input), asyncEventsByGr oup.get(groups.animation)); 779 this._irModel.populate(asyncEventsByGroup.get(groups.input), asyncEventsByGr oup.get(groups.animation));
764 this._model.cpuProfiles().forEach(profile => WebInspector.LineLevelProfile.i nstance().appendCPUProfile(profile)); 780 this._model.cpuProfiles().forEach(profile => WebInspector.LineLevelProfile.i nstance().appendCPUProfile(profile));
781
782 if (Runtime.experiments.isEnabled('timelineRuleUsageRecording') && this._mar kUnusedCSS.get()) {
caseq 2016/11/08 01:54:11 Let's extract this into a separate function at lea
783 var mainTarget = WebInspector.targetManager.mainTarget();
784 if (!mainTarget)
785 return;
786 var cssModel = WebInspector.CSSModel.fromTarget(mainTarget);
787
788 function ruleListReceived(ruleUsageList) {
alph 2016/11/08 17:10:25 Annotate
789 if (!ruleUsageList)
alph 2016/11/08 17:10:25 why can it be null?
790 return;
791
792 for (var rule of ruleUsageList) {
793 if (rule.wasUsed)
794 continue;
795
796 var styleSheetHeader = cssModel.styleSheetHeaderForId(rule.styleSheetI d);
797 var url = styleSheetHeader.sourceURL;
798
799 WebInspector.CoverageProfile.instance().appendUnusedRule(url, rule.ran ge.startLine);
800 }
801 }
802
803 cssModel.ruleListPromise().then(ruleListReceived);
804 }
805
765 if (this._statusPane) 806 if (this._statusPane)
766 this._statusPane.hide(); 807 this._statusPane.hide();
767 delete this._statusPane; 808 delete this._statusPane;
768 this._overviewPane.reset(); 809 this._overviewPane.reset();
769 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._model.ma ximumRecordTime()); 810 this._overviewPane.setBounds(this._model.minimumRecordTime(), this._model.ma ximumRecordTime());
770 this._setAutoWindowTimes(); 811 this._setAutoWindowTimes();
771 this._refreshViews(); 812 this._refreshViews();
772 for (var i = 0; i < this._overviewControls.length; ++i) 813 for (var i = 0; i < this._overviewControls.length; ++i)
773 this._overviewControls[i].timelineStopped(); 814 this._overviewControls[i].timelineStopped();
774 this._setMarkers(); 815 this._setMarkers();
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 /** 2037 /**
1997 * @param {!Event} event 2038 * @param {!Event} event
1998 */ 2039 */
1999 _onKeyDown(event) { 2040 _onKeyDown(event) {
2000 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) { 2041 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code) {
2001 event.preventDefault(); 2042 event.preventDefault();
2002 this._apply(); 2043 this._apply();
2003 } 2044 }
2004 } 2045 }
2005 }; 2046 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698