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

Side by Side Diff: Source/devtools/front_end/profiler/CPUProfileFlameChart.js

Issue 696703003: DevTools: implement search for CPUProfiler FlameChart view (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 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 | Annotate | Revision Log
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 colorGenerator.setColorForID("(program):", "hsl(0, 0%, 80%)"); 372 colorGenerator.setColorForID("(program):", "hsl(0, 0%, 80%)");
373 colorGenerator.setColorForID("(garbage collector):", "hsl(0, 0%, 80%)"); 373 colorGenerator.setColorForID("(garbage collector):", "hsl(0, 0%, 80%)");
374 WebInspector.CPUFlameChartDataProvider._colorGenerator = colorGenerator; 374 WebInspector.CPUFlameChartDataProvider._colorGenerator = colorGenerator;
375 } 375 }
376 return WebInspector.CPUFlameChartDataProvider._colorGenerator; 376 return WebInspector.CPUFlameChartDataProvider._colorGenerator;
377 } 377 }
378 378
379 379
380 /** 380 /**
381 * @constructor 381 * @constructor
382 * @implements {WebInspector.CPUProfileView.Searchable}
382 * @extends {WebInspector.VBox} 383 * @extends {WebInspector.VBox}
383 * @param {!WebInspector.FlameChartDataProvider} dataProvider 384 * @param {!WebInspector.FlameChartDataProvider} dataProvider
384 */ 385 */
385 WebInspector.CPUProfileFlameChart = function(dataProvider) 386 WebInspector.CPUProfileFlameChart = function(dataProvider)
386 { 387 {
387 WebInspector.VBox.call(this); 388 WebInspector.VBox.call(this);
388 this.element.id = "cpu-flame-chart"; 389 this.element.id = "cpu-flame-chart";
389 390
390 this._overviewPane = new WebInspector.CPUProfileFlameChart.OverviewPane(data Provider); 391 this._overviewPane = new WebInspector.CPUProfileFlameChart.OverviewPane(data Provider);
391 this._overviewPane.show(this.element); 392 this._overviewPane.show(this.element);
392 393
393 this._mainPane = new WebInspector.FlameChart(dataProvider, this._overviewPan e, true); 394 this._mainPane = new WebInspector.FlameChart(dataProvider, this._overviewPan e, true);
394 this._mainPane.show(this.element); 395 this._mainPane.show(this.element);
395 this._mainPane.addEventListener(WebInspector.FlameChart.Events.EntrySelected , this._onEntrySelected, this); 396 this._mainPane.addEventListener(WebInspector.FlameChart.Events.EntrySelected , this._onEntrySelected, this);
396 this._overviewPane.addEventListener(WebInspector.OverviewGrid.Events.WindowC hanged, this._onWindowChanged, this); 397 this._overviewPane.addEventListener(WebInspector.OverviewGrid.Events.WindowC hanged, this._onWindowChanged, this);
398 this._dataProvider = dataProvider;
399 this._searchResults = [];
397 } 400 }
398 401
399 WebInspector.CPUProfileFlameChart.prototype = { 402 WebInspector.CPUProfileFlameChart.prototype = {
400 focus: function() 403 focus: function()
401 { 404 {
402 this._mainPane.focus(); 405 this._mainPane.focus();
403 }, 406 },
404 407
405 /** 408 /**
406 * @param {!WebInspector.Event} event 409 * @param {!WebInspector.Event} event
(...skipping 21 matching lines...) Expand all
428 { 431 {
429 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelect ed, event.data); 432 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelect ed, event.data);
430 }, 433 },
431 434
432 update: function() 435 update: function()
433 { 436 {
434 this._overviewPane.update(); 437 this._overviewPane.update();
435 this._mainPane.update(); 438 this._mainPane.update();
436 }, 439 },
437 440
441 /**
442 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
443 * @param {boolean} shouldJump
444 * @param {boolean=} jumpBackwards
445 * @return {number}
446 */
447 performSearch: function(searchConfig, shouldJump, jumpBackwards)
448 {
449 var matcher = createPlainTextSearchRegex(searchConfig.query, searchConfi g.caseSensitive ? "": "i");
450
451 var selectedEntryIndex = this._searchResultIndex !== -1 ? this._searchRe sults[this._searchResultIndex] : -1;
452 this._searchResults = [];
453 var entriesCount = this._dataProvider._entryNodes.length;
454 for(var index = 0; index < entriesCount; ++index) {
455 if (this._dataProvider.entryTitle(index).match(matcher))
456 this._searchResults.push(index);
457 }
458
459 if (this._searchResults.length) {
460 this._searchResultIndex = this._searchResults.indexOf(selectedEntryI ndex);
461 if (this._searchResultIndex === -1)
462 this._searchResultIndex = jumpBackwards ? this._searchResults.le ngth - 1 : 0;
463 this._mainPane.setSelectedEntry(this._searchResults[this._searchResu ltIndex]);
464 } else
465 this.searchCanceled();
466
467 return this._searchResults.length;
468 },
469
470 searchCanceled: function()
471 {
472 this._mainPane.setSelectedEntry(-1);
473 this._searchResults = [];
474 this._searchResultIndex = -1;
475 },
476
477 jumpToNextSearchResult: function()
478 {
479 this._searchResultIndex = (this._searchResultIndex + 1) % this._searchRe sults.length;
480 this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIn dex]);
481 },
482
483 jumpToPreviousSearchResult: function()
484 {
485 this._searchResultIndex = (this._searchResultIndex - 1 + this._searchRes ults.length) % this._searchResults.length;
486 this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIn dex]);
487 },
488
489 /**
490 * @return {number}
491 */
492 currentSearchResultIndex: function()
493 {
494 return this._searchResultIndex;
495 },
496
438 __proto__: WebInspector.VBox.prototype 497 __proto__: WebInspector.VBox.prototype
439 }; 498 };
440 499
441 /** 500 /**
442 * @constructor 501 * @constructor
443 * @implements {WebInspector.TimelineGrid.Calculator} 502 * @implements {WebInspector.TimelineGrid.Calculator}
444 */ 503 */
445 WebInspector.CPUProfileFlameChart.OverviewCalculator = function() 504 WebInspector.CPUProfileFlameChart.OverviewCalculator = function()
446 { 505 {
447 } 506 }
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 { 734 {
676 var ratio = window.devicePixelRatio; 735 var ratio = window.devicePixelRatio;
677 this._overviewCanvas.width = width * ratio; 736 this._overviewCanvas.width = width * ratio;
678 this._overviewCanvas.height = height * ratio; 737 this._overviewCanvas.height = height * ratio;
679 this._overviewCanvas.style.width = width + "px"; 738 this._overviewCanvas.style.width = width + "px";
680 this._overviewCanvas.style.height = height + "px"; 739 this._overviewCanvas.style.height = height + "px";
681 }, 740 },
682 741
683 __proto__: WebInspector.VBox.prototype 742 __proto__: WebInspector.VBox.prototype
684 } 743 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileDataGrid.js ('k') | Source/devtools/front_end/profiler/CPUProfileView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698