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

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

Issue 1433753002: DevTools: extract filters from TimelinePanel into a class for re-use (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests, addressed review comments Created 5 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 this._model = new WebInspector.TimelineModel(this._tracingModel, WebInspecto r.TimelineUIUtils.visibleEventsFilter()); 55 this._model = new WebInspector.TimelineModel(this._tracingModel, WebInspecto r.TimelineUIUtils.visibleEventsFilter());
56 this._frameModel = new WebInspector.TracingTimelineFrameModel(); 56 this._frameModel = new WebInspector.TracingTimelineFrameModel();
57 57
58 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); 58 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this);
59 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this); 59 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStop ped, this._onRecordingStopped, this);
60 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this); 60 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordsCleare d, this._onRecordsCleared, this);
61 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordFilterC hanged, this._refreshViews, this); 61 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordFilterC hanged, this._refreshViews, this);
62 this._model.addEventListener(WebInspector.TimelineModel.Events.BufferUsage, this._onTracingBufferUsage, this); 62 this._model.addEventListener(WebInspector.TimelineModel.Events.BufferUsage, this._onTracingBufferUsage, this);
63 this._model.addEventListener(WebInspector.TimelineModel.Events.RetrieveEvent sProgress, this._onRetrieveEventsProgress, this); 63 this._model.addEventListener(WebInspector.TimelineModel.Events.RetrieveEvent sProgress, this._onRetrieveEventsProgress, this);
64 64
65 this._categoryFilter = new WebInspector.TimelineCategoryFilter(); 65 this._filters = new WebInspector.TimelineFilters();
66 this._durationFilter = new WebInspector.TimelineIsLongFilter(); 66 for (var filter of this._filters.filters())
67 this._textFilter = new WebInspector.TimelineTextFilter(); 67 this._model.addFilter(filter);
68 this._model.addFilter(this._categoryFilter);
69 this._model.addFilter(this._durationFilter);
70 this._model.addFilter(this._textFilter);
71 this._model.addFilter(new WebInspector.TimelineStaticFilter()); 68 this._model.addFilter(new WebInspector.TimelineStaticFilter());
72 69
73 /** @type {!Array.<!WebInspector.TimelineModeView>} */ 70 /** @type {!Array.<!WebInspector.TimelineModeView>} */
74 this._currentViews = []; 71 this._currentViews = [];
75 72
76 this._flameChartEnabledSetting = WebInspector.settings.createSetting("timeli neFlameChartEnabled", true); 73 this._flameChartEnabledSetting = WebInspector.settings.createSetting("timeli neFlameChartEnabled", true);
77 this._viewModeSetting = WebInspector.settings.createSetting("timelineViewMod e", WebInspector.TimelinePanel.ViewMode.FlameChart); 74 this._viewModeSetting = WebInspector.settings.createSetting("timelineViewMod e", WebInspector.TimelinePanel.ViewMode.FlameChart);
78 this._createToolbarItems(); 75 this._createToolbarItems();
79 76
80 var timelinePane = new WebInspector.VBox(); 77 var timelinePane = new WebInspector.VBox();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 StartPending: Symbol("StartPending"), 153 StartPending: Symbol("StartPending"),
157 Recording: Symbol("Recording"), 154 Recording: Symbol("Recording"),
158 StopPending: Symbol("StopPending"), 155 StopPending: Symbol("StopPending"),
159 Loading: Symbol("Loading") 156 Loading: Symbol("Loading")
160 } 157 }
161 158
162 // Define row and header height, should be in sync with styles for timeline grap hs. 159 // Define row and header height, should be in sync with styles for timeline grap hs.
163 WebInspector.TimelinePanel.rowHeight = 18; 160 WebInspector.TimelinePanel.rowHeight = 18;
164 WebInspector.TimelinePanel.headerHeight = 20; 161 WebInspector.TimelinePanel.headerHeight = 20;
165 162
166 WebInspector.TimelinePanel.durationFilterPresetsMs = [0, 1, 15];
167
168 WebInspector.TimelinePanel.prototype = { 163 WebInspector.TimelinePanel.prototype = {
169 /** 164 /**
170 * @override 165 * @override
171 * @return {?WebInspector.SearchableView} 166 * @return {?WebInspector.SearchableView}
172 */ 167 */
173 searchableView: function() 168 searchableView: function()
174 { 169 {
175 return this._searchableView; 170 return this._searchableView;
176 }, 171 },
177 172
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 this._lazyPaintProfilerView = new WebInspector.TimelinePaintProfilerView (this._frameModel); 285 this._lazyPaintProfilerView = new WebInspector.TimelinePaintProfilerView (this._frameModel);
291 return this._lazyPaintProfilerView; 286 return this._lazyPaintProfilerView;
292 }, 287 },
293 288
294 /** 289 /**
295 * @param {!WebInspector.TimelineModeView} modeView 290 * @param {!WebInspector.TimelineModeView} modeView
296 */ 291 */
297 _addModeView: function(modeView) 292 _addModeView: function(modeView)
298 { 293 {
299 modeView.setWindowTimes(this.windowStartTime(), this.windowEndTime()); 294 modeView.setWindowTimes(this.windowStartTime(), this.windowEndTime());
300 modeView.refreshRecords(this._textFilter._regex); 295 modeView.refreshRecords(this._filters.searchRegExp());
301 this._stackView.appendView(modeView.view(), "timelinePanelTimelineStackS plitViewState", undefined, 112); 296 this._stackView.appendView(modeView.view(), "timelinePanelTimelineStackS plitViewState", undefined, 112);
302 modeView.view().addEventListener(WebInspector.SplitWidget.Events.Sidebar SizeChanged, this._sidebarResized, this); 297 modeView.view().addEventListener(WebInspector.SplitWidget.Events.Sidebar SizeChanged, this._sidebarResized, this);
303 this._currentViews.push(modeView); 298 this._currentViews.push(modeView);
304 }, 299 },
305 300
306 _removeAllModeViews: function() 301 _removeAllModeViews: function()
307 { 302 {
308 for (var i = 0; i < this._currentViews.length; ++i) { 303 for (var i = 0; i < this._currentViews.length; ++i) {
309 this._currentViews[i].removeEventListener(WebInspector.SplitWidget.E vents.SidebarSizeChanged, this._sidebarResized, this); 304 this._currentViews[i].removeEventListener(WebInspector.SplitWidget.E vents.SidebarSizeChanged, this._sidebarResized, this);
310 this._currentViews[i].dispose(); 305 this._currentViews[i].dispose();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 338
344 this._toggleTimelineButton = WebInspector.ToolbarButton.createActionButt on("timeline.toggle-recording"); 339 this._toggleTimelineButton = WebInspector.ToolbarButton.createActionButt on("timeline.toggle-recording");
345 this._panelToolbar.appendToolbarItem(this._toggleTimelineButton); 340 this._panelToolbar.appendToolbarItem(this._toggleTimelineButton);
346 this._updateTimelineControls(); 341 this._updateTimelineControls();
347 342
348 var clearButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Clear recording"), "clear-toolbar-item"); 343 var clearButton = new WebInspector.ToolbarButton(WebInspector.UIString(" Clear recording"), "clear-toolbar-item");
349 clearButton.addEventListener("click", this._onClearButtonClick, this); 344 clearButton.addEventListener("click", this._onClearButtonClick, this);
350 this._panelToolbar.appendToolbarItem(clearButton); 345 this._panelToolbar.appendToolbarItem(clearButton);
351 this._panelToolbar.appendSeparator(); 346 this._panelToolbar.appendSeparator();
352 347
353 this._filterBar = this._createFilterBar(); 348 this._panelToolbar.appendToolbarItem(this._filters.filterButton());
354 this._panelToolbar.appendToolbarItem(this._filterBar.filterButton());
355 349
356 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U IString("Collect garbage"), "garbage-collect-toolbar-item"); 350 var garbageCollectButton = new WebInspector.ToolbarButton(WebInspector.U IString("Collect garbage"), "garbage-collect-toolbar-item");
357 garbageCollectButton.addEventListener("click", this._garbageCollectButto nClicked, this); 351 garbageCollectButton.addEventListener("click", this._garbageCollectButto nClicked, this);
358 this._panelToolbar.appendToolbarItem(garbageCollectButton); 352 this._panelToolbar.appendToolbarItem(garbageCollectButton);
359 this._panelToolbar.appendSeparator(); 353 this._panelToolbar.appendSeparator();
360 354
361 if (!Runtime.experiments.isEnabled("multipleTimelineViews")) { 355 if (!Runtime.experiments.isEnabled("multipleTimelineViews")) {
362 var viewModeLabel = new WebInspector.ToolbarText(WebInspector.UIStri ng("View:"), "toolbar-group-label"); 356 var viewModeLabel = new WebInspector.ToolbarText(WebInspector.UIStri ng("View:"), "toolbar-group-label");
363 this._panelToolbar.appendToolbarItem(viewModeLabel); 357 this._panelToolbar.appendToolbarItem(viewModeLabel);
364 358
(...skipping 30 matching lines...) Expand all
395 this._captureFilmStripSetting = WebInspector.settings.createSetting("tim elineCaptureFilmStrip", false); 389 this._captureFilmStripSetting = WebInspector.settings.createSetting("tim elineCaptureFilmStrip", false);
396 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s); 390 this._captureFilmStripSetting.addChangeListener(this._onModeChanged, thi s);
397 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Screenshots"), 391 this._panelToolbar.appendToolbarItem(this._createSettingCheckbox(WebInsp ector.UIString("Screenshots"),
398 this._c aptureFilmStripSetting, 392 this._c aptureFilmStripSetting,
399 WebInsp ector.UIString("Capture screenshots while recording. (Has performance overhead)" ))); 393 WebInsp ector.UIString("Capture screenshots while recording. (Has performance overhead)" )));
400 394
401 this._progressToolbarItem = new WebInspector.ToolbarItem(createElement(" div")); 395 this._progressToolbarItem = new WebInspector.ToolbarItem(createElement(" div"));
402 this._progressToolbarItem.setVisible(false); 396 this._progressToolbarItem.setVisible(false);
403 this._panelToolbar.appendToolbarItem(this._progressToolbarItem); 397 this._panelToolbar.appendToolbarItem(this._progressToolbarItem);
404 398
405 this.element.appendChild(this._filterBar.filtersElement()); 399 this.element.appendChild(this._filters.filtersElement());
406 }, 400 },
407 401
408 /** 402 /**
409 * @return {!WebInspector.FilterBar}
410 */
411 _createFilterBar: function()
412 {
413 this._filterBar = new WebInspector.FilterBar("timelinePanel");
414 this._filters = {};
415 this._filters._textFilterUI = new WebInspector.TextFilterUI();
416 this._filters._textFilterUI.addEventListener(WebInspector.FilterUI.Event s.FilterChanged, this._textFilterChanged, this);
417 this._filterBar.addFilter(this._filters._textFilterUI);
418
419 var durationOptions = [];
420 for (var presetIndex = 0; presetIndex < WebInspector.TimelinePanel.durat ionFilterPresetsMs.length; ++presetIndex) {
421 var durationMs = WebInspector.TimelinePanel.durationFilterPresetsMs[ presetIndex];
422 var durationOption = {};
423 if (!durationMs) {
424 durationOption.label = WebInspector.UIString("All");
425 durationOption.title = WebInspector.UIString("Show all records") ;
426 } else {
427 durationOption.label = WebInspector.UIString("\u2265 %dms", dura tionMs);
428 durationOption.title = WebInspector.UIString("Hide records short er than %dms", durationMs);
429 }
430 durationOption.value = durationMs;
431 durationOptions.push(durationOption);
432 }
433 this._filters._durationFilterUI = new WebInspector.ComboBoxFilterUI(dura tionOptions);
434 this._filters._durationFilterUI.addEventListener(WebInspector.FilterUI.E vents.FilterChanged, this._durationFilterChanged, this);
435 this._filterBar.addFilter(this._filters._durationFilterUI);
436
437 this._filters._categoryFiltersUI = {};
438 var categories = WebInspector.TimelineUIUtils.categories();
439 for (var categoryName in categories) {
440 var category = categories[categoryName];
441 if (!category.visible)
442 continue;
443 var filter = new WebInspector.CheckboxFilterUI(category.name, catego ry.title);
444 filter.setColor(category.fillColorStop0, category.borderColor);
445 this._filters._categoryFiltersUI[category.name] = filter;
446 filter.addEventListener(WebInspector.FilterUI.Events.FilterChanged, this._categoriesFilterChanged.bind(this, categoryName), this);
447 this._filterBar.addFilter(filter);
448 }
449 return this._filterBar;
450 },
451
452 _textFilterChanged: function(event)
453 {
454 var searchQuery = this._filters._textFilterUI.value();
455 this.searchCanceled();
456 this._textFilter.setRegex(searchQuery ? createPlainTextSearchRegex(searc hQuery, "i") : null);
457 },
458
459 _durationFilterChanged: function()
460 {
461 var duration = this._filters._durationFilterUI.value();
462 var minimumRecordDuration = parseInt(duration, 10);
463 this._durationFilter.setMinimumRecordDuration(minimumRecordDuration);
464 },
465
466 /**
467 * @param {string} name
468 */
469 _categoriesFilterChanged: function(name)
470 {
471 var categories = WebInspector.TimelineUIUtils.categories();
472 categories[name].hidden = !this._filters._categoryFiltersUI[name].checke d();
473 this._categoryFilter.notifyFilterChanged();
474 },
475
476 /**
477 * @return {!WebInspector.Progress} 403 * @return {!WebInspector.Progress}
478 */ 404 */
479 _prepareToLoadTimeline: function() 405 _prepareToLoadTimeline: function()
480 { 406 {
481 /** 407 /**
482 * @this {!WebInspector.TimelinePanel} 408 * @this {!WebInspector.TimelinePanel}
483 */ 409 */
484 function finishLoading() 410 function finishLoading()
485 { 411 {
486 this._setState(WebInspector.TimelinePanel.State.Idle); 412 this._setState(WebInspector.TimelinePanel.State.Idle);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 { 496 {
571 if (this._state !== WebInspector.TimelinePanel.State.Idle) 497 if (this._state !== WebInspector.TimelinePanel.State.Idle)
572 return; 498 return;
573 this._model.loadFromURL(url, this._prepareToLoadTimeline()); 499 this._model.loadFromURL(url, this._prepareToLoadTimeline());
574 }, 500 },
575 501
576 _refreshViews: function() 502 _refreshViews: function()
577 { 503 {
578 for (var i = 0; i < this._currentViews.length; ++i) { 504 for (var i = 0; i < this._currentViews.length; ++i) {
579 var view = this._currentViews[i]; 505 var view = this._currentViews[i];
580 view.refreshRecords(this._textFilter._regex); 506 view.refreshRecords(this._filters.searchRegExp());
581 } 507 }
582 this._updateSelectionDetails(); 508 this._updateSelectionDetails();
583 }, 509 },
584 510
585 _onModeChanged: function() 511 _onModeChanged: function()
586 { 512 {
587 // Set up overview controls. 513 // Set up overview controls.
588 this._overviewControls = []; 514 this._overviewControls = [];
589 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview")) 515 if (Runtime.experiments.isEnabled("inputEventsOnTimelineOverview"))
590 this._overviewControls.push(new WebInspector.TimelineEventOverview.I nput(this._model)); 516 this._overviewControls.push(new WebInspector.TimelineEventOverview.I nput(this._model));
(...skipping 12 matching lines...) Expand all
603 this._removeAllModeViews(); 529 this._removeAllModeViews();
604 var viewMode = this._flameChartEnabledSetting.get() ? WebInspector.Timel inePanel.ViewMode.FlameChart : WebInspector.TimelinePanel.ViewMode.Waterfall; 530 var viewMode = this._flameChartEnabledSetting.get() ? WebInspector.Timel inePanel.ViewMode.FlameChart : WebInspector.TimelinePanel.ViewMode.Waterfall;
605 if (Runtime.experiments.isEnabled("multipleTimelineViews") && this._tabb edPane) { 531 if (Runtime.experiments.isEnabled("multipleTimelineViews") && this._tabb edPane) {
606 viewMode = this._tabbedPane.selectedTabId; 532 viewMode = this._tabbedPane.selectedTabId;
607 this._stackView.show(this._tabbedPane.visibleView.element); 533 this._stackView.show(this._tabbedPane.visibleView.element);
608 } else { 534 } else {
609 this._stackView.show(this._searchableView.element); 535 this._stackView.show(this._searchableView.element);
610 } 536 }
611 this._flameChart = null; 537 this._flameChart = null;
612 if (viewMode === WebInspector.TimelinePanel.ViewMode.FlameChart) { 538 if (viewMode === WebInspector.TimelinePanel.ViewMode.FlameChart) {
613 this._filterBar.filterButton().setEnabled(false); 539 this._filters.setEnabled(false);
614 this._filterBar.filtersElement().classList.toggle("hidden", true);
615 this._flameChart = new WebInspector.TimelineFlameChartView(this, thi s._model, this._frameModel); 540 this._flameChart = new WebInspector.TimelineFlameChartView(this, thi s._model, this._frameModel);
616 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get() ); 541 this._flameChart.enableNetworkPane(this._captureNetworkSetting.get() );
617 this._addModeView(this._flameChart); 542 this._addModeView(this._flameChart);
618 } else if (viewMode === WebInspector.TimelinePanel.ViewMode.Waterfall) { 543 } else if (viewMode === WebInspector.TimelinePanel.ViewMode.Waterfall) {
619 this._filterBar.filterButton().setEnabled(true); 544 this._filters.setEnabled(true);
620 this._filterBar.filtersElement().classList.toggle("hidden", !this._f ilterBar.filtersToggled());
621 var timelineView = new WebInspector.TimelineView(this, this._model); 545 var timelineView = new WebInspector.TimelineView(this, this._model);
622 this._addModeView(timelineView); 546 this._addModeView(timelineView);
623 timelineView.setFrameModel(this._frameModel); 547 timelineView.setFrameModel(this._frameModel);
624 } else if (viewMode === WebInspector.TimelinePanel.ViewMode.CallTree || viewMode === WebInspector.TimelinePanel.ViewMode.BottomUp) { 548 } else if (viewMode === WebInspector.TimelinePanel.ViewMode.CallTree || viewMode === WebInspector.TimelinePanel.ViewMode.BottomUp) {
625 this._filterBar.filterButton().setEnabled(false); 549 this._filters.setEnabled(false);
626 this._filterBar.filtersElement().classList.toggle("hidden", true);
627 var innerView = viewMode === WebInspector.TimelinePanel.ViewMode.Bot tomUp ? new WebInspector.BottomUpTimelineTreeView(this._model) : new WebInspecto r.CallTreeTimelineTreeView(this._model); 550 var innerView = viewMode === WebInspector.TimelinePanel.ViewMode.Bot tomUp ? new WebInspector.BottomUpTimelineTreeView(this._model) : new WebInspecto r.CallTreeTimelineTreeView(this._model);
628 var treeView = new WebInspector.TimelineTreeModeView(this, innerView ); 551 var treeView = new WebInspector.TimelineTreeModeView(this, innerView );
629 this._addModeView(treeView); 552 this._addModeView(treeView);
630 } 553 }
631 554
632 if (this._captureMemorySetting.get() && viewMode !== WebInspector.Timeli nePanel.ViewMode.CallTree && viewMode !== WebInspector.TimelinePanel.ViewMode.Bo ttomUp) 555 if (this._captureMemorySetting.get() && viewMode !== WebInspector.Timeli nePanel.ViewMode.CallTree && viewMode !== WebInspector.TimelinePanel.ViewMode.Bo ttomUp)
633 this._addModeView(new WebInspector.MemoryCountersGraph(this, this._m odel)); 556 this._addModeView(new WebInspector.MemoryCountersGraph(this, this._m odel));
634 557
635 this.doResize(); 558 this.doResize();
636 this.select(null); 559 this.select(null);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 this._currentViews[0].highlightSearchResult(null); 874 this._currentViews[0].highlightSearchResult(null);
952 }, 875 },
953 876
954 /** 877 /**
955 * @param {boolean} revealRecord 878 * @param {boolean} revealRecord
956 * @param {boolean} shouldJump 879 * @param {boolean} shouldJump
957 * @param {boolean=} jumpBackwards 880 * @param {boolean=} jumpBackwards
958 */ 881 */
959 _updateSearchHighlight: function(revealRecord, shouldJump, jumpBackwards) 882 _updateSearchHighlight: function(revealRecord, shouldJump, jumpBackwards)
960 { 883 {
961 if (!this._textFilter.isEmpty() || !this._searchRegex) { 884 if (this._filters.searchRegExp() || !this._searchRegex) {
962 this._clearHighlight(); 885 this._clearHighlight();
963 return; 886 return;
964 } 887 }
965 888
966 if (!this._searchResults) 889 if (!this._searchResults)
967 this._updateSearchResults(shouldJump, jumpBackwards); 890 this._updateSearchResults(shouldJump, jumpBackwards);
968 this._currentViews[0].highlightSearchResult(this._selectedSearchResult, this._searchRegex, revealRecord); 891 this._currentViews[0].highlightSearchResult(this._selectedSearchResult, this._searchRegex, revealRecord);
969 }, 892 },
970 893
971 /** 894 /**
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 * @constructor 1618 * @constructor
1696 * @extends {WebInspector.TimelineModel.Filter} 1619 * @extends {WebInspector.TimelineModel.Filter}
1697 */ 1620 */
1698 WebInspector.TimelineTextFilter = function() 1621 WebInspector.TimelineTextFilter = function()
1699 { 1622 {
1700 WebInspector.TimelineModel.Filter.call(this); 1623 WebInspector.TimelineModel.Filter.call(this);
1701 } 1624 }
1702 1625
1703 WebInspector.TimelineTextFilter.prototype = { 1626 WebInspector.TimelineTextFilter.prototype = {
1704 /** 1627 /**
1705 * @return {boolean} 1628 * @param {?RegExp} regExp
1706 */ 1629 */
1707 isEmpty: function() 1630 _setRegExp: function(regExp)
1708 { 1631 {
1709 return !this._regex; 1632 this._regExp = regExp;
1710 },
1711
1712 /**
1713 * @param {?RegExp} regex
1714 */
1715 setRegex: function(regex)
1716 {
1717 this._regex = regex;
1718 this.notifyFilterChanged(); 1633 this.notifyFilterChanged();
1719 }, 1634 },
1720 1635
1721 /** 1636 /**
1722 * @override 1637 * @override
1723 * @param {!WebInspector.TracingModel.Event} event 1638 * @param {!WebInspector.TracingModel.Event} event
1724 * @return {boolean} 1639 * @return {boolean}
1725 */ 1640 */
1726 accept: function(event) 1641 accept: function(event)
1727 { 1642 {
1728 return !this._regex || WebInspector.TimelineUIUtils.testContentMatching( event, this._regex); 1643 return !this._regExp || WebInspector.TimelineUIUtils.testContentMatching (event, this._regExp);
1729 }, 1644 },
1730 1645
1731 __proto__: WebInspector.TimelineModel.Filter.prototype 1646 __proto__: WebInspector.TimelineModel.Filter.prototype
1732 } 1647 }
1733 1648
1734 /** 1649 /**
1735 * @constructor 1650 * @constructor
1736 * @extends {WebInspector.TimelineModel.Filter} 1651 * @extends {WebInspector.TimelineModel.Filter}
1737 */ 1652 */
1738 WebInspector.TimelineStaticFilter = function() 1653 WebInspector.TimelineStaticFilter = function()
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1939 case "timeline.jump-to-previous-frame": 1854 case "timeline.jump-to-previous-frame":
1940 panel._jumpToFrame(-1); 1855 panel._jumpToFrame(-1);
1941 return true; 1856 return true;
1942 case "timeline.jump-to-next-frame": 1857 case "timeline.jump-to-next-frame":
1943 panel._jumpToFrame(1); 1858 panel._jumpToFrame(1);
1944 return true; 1859 return true;
1945 } 1860 }
1946 return false; 1861 return false;
1947 } 1862 }
1948 } 1863 }
1864
1865 /**
1866 * @constructor
1867 */
1868 WebInspector.TimelineFilters = function()
1869 {
1870 this._categoryFilter = new WebInspector.TimelineCategoryFilter();
1871 this._durationFilter = new WebInspector.TimelineIsLongFilter();
1872 this._textFilter = new WebInspector.TimelineTextFilter();
1873 this._filters = [this._categoryFilter, this._durationFilter, this._textFilte r];
1874
1875 this._createFilterBar();
1876 }
1877
1878 WebInspector.TimelineFilters._durationFilterPresetsMs = [0, 1, 15];
1879
1880 WebInspector.TimelineFilters.prototype = {
1881 /**
1882 * @return {!Array<!WebInspector.TimelineModel.Filter>}
1883 */
1884 filters: function()
1885 {
1886 return this._filters;
1887 },
1888
1889 /**
1890 * @param {boolean} enabled
1891 */
1892 setEnabled: function(enabled)
1893 {
1894 this.filterButton().setEnabled(enabled);
1895 this.filtersElement().classList.toggle("hidden", !enabled || !this._filt erBar.filtersToggled());
1896 },
1897
1898 /**
1899 * @return {?RegExp}
1900 */
1901 searchRegExp: function()
1902 {
1903 return this._textFilter._regExp;
1904 },
1905
1906 /**
1907 * @return {!WebInspector.ToolbarItem}
1908 */
1909 filterButton: function()
1910 {
1911 return this._filterBar.filterButton();
1912 },
1913
1914 /**
1915 * @return {!Element}
1916 */
1917 filtersElement: function()
1918 {
1919 return this._filterBar.filtersElement();
1920 },
1921
1922 _createFilterBar: function()
1923 {
1924 this._filterBar = new WebInspector.FilterBar("timelinePanel");
1925
1926 this._textFilterUI = new WebInspector.TextFilterUI();
1927 this._textFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterC hanged, textFilterChanged, this);
1928 this._filterBar.addFilter(this._textFilterUI);
1929
1930 var durationOptions = [];
1931 for (var durationMs of WebInspector.TimelineFilters._durationFilterPrese tsMs) {
1932 var durationOption = {};
1933 if (!durationMs) {
1934 durationOption.label = WebInspector.UIString("All");
1935 durationOption.title = WebInspector.UIString("Show all records") ;
1936 } else {
1937 durationOption.label = WebInspector.UIString("\u2265 %dms", dura tionMs);
1938 durationOption.title = WebInspector.UIString("Hide records short er than %dms", durationMs);
1939 }
1940 durationOption.value = durationMs;
1941 durationOptions.push(durationOption);
1942 }
1943 var durationFilterUI = new WebInspector.ComboBoxFilterUI(durationOptions );
1944 durationFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterCha nged, durationFilterChanged, this);
1945 this._filterBar.addFilter(durationFilterUI);
1946
1947 var categoryFiltersUI = {};
1948 var categories = WebInspector.TimelineUIUtils.categories();
1949 for (var categoryName in categories) {
1950 var category = categories[categoryName];
1951 if (!category.visible)
1952 continue;
1953 var filter = new WebInspector.CheckboxFilterUI(category.name, catego ry.title);
1954 filter.setColor(category.fillColorStop0, category.borderColor);
1955 categoryFiltersUI[category.name] = filter;
1956 filter.addEventListener(WebInspector.FilterUI.Events.FilterChanged, categoriesFilterChanged.bind(this, categoryName));
1957 this._filterBar.addFilter(filter);
1958 }
1959 return this._filterBar;
1960
1961 /**
1962 * @this {WebInspector.TimelineFilters}
1963 */
1964 function textFilterChanged()
1965 {
1966 var searchQuery = this._textFilterUI.value();
1967 this._textFilter._setRegExp(searchQuery ? createPlainTextSearchRegex (searchQuery, "i") : null);
1968 }
1969
1970 /**
1971 * @this {WebInspector.TimelineFilters}
1972 */
1973 function durationFilterChanged()
1974 {
1975 var duration = durationFilterUI.value();
1976 var minimumRecordDuration = parseInt(duration, 10);
1977 this._durationFilter.setMinimumRecordDuration(minimumRecordDuration) ;
1978 }
1979
1980 /**
1981 * @param {string} name
1982 * @this {WebInspector.TimelineFilters}
1983 */
1984 function categoriesFilterChanged(name)
1985 {
1986 var categories = WebInspector.TimelineUIUtils.categories();
1987 categories[name].hidden = !categoryFiltersUI[name].checked();
1988 this._categoryFilter.notifyFilterChanged();
1989 }
1990 }
1991 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698