Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.TabbedEditorContainerDelegate} | 7 * @implements {WebInspector.TabbedEditorContainerDelegate} |
| 8 * @implements {WebInspector.Searchable} | 8 * @implements {WebInspector.Searchable} |
| 9 * @implements {WebInspector.Replaceable} | 9 * @implements {WebInspector.Replaceable} |
| 10 * @extends {WebInspector.VBox} | 10 * @extends {WebInspector.VBox} |
| 11 * @param {!WebInspector.Workspace} workspace | 11 * @param {!WebInspector.Workspace} workspace |
| 12 * @param {!WebInspector.SourcesPanel} sourcesPanel | 12 * @param {!WebInspector.SourcesPanel} sourcesPanel |
| 13 */ | 13 */ |
| 14 WebInspector.SourcesView = function(workspace, sourcesPanel) | 14 WebInspector.SourcesView = function(workspace, sourcesPanel) |
| 15 { | 15 { |
| 16 WebInspector.VBox.call(this); | 16 WebInspector.VBox.call(this); |
| 17 this.registerRequiredCSS("sourcesView.css"); | 17 this.registerRequiredCSS("sourcesView.css"); |
| 18 this.element.id = "sources-panel-sources-view"; | 18 this.element.id = "sources-panel-sources-view"; |
| 19 this.setMinimumAndPreferredSizes(50, 25, 150, 100); | 19 this.setMinimumAndPreferredSizes(50, 25, 150, 100); |
| 20 | 20 |
| 21 this._workspace = workspace; | 21 this._workspace = workspace; |
| 22 this._sourcesPanel = sourcesPanel; | 22 this._sourcesPanel = sourcesPanel; |
| 23 | 23 |
| 24 this._searchableView = new WebInspector.SearchableView(this); | 24 this._searchableView = new WebInspector.SearchableView(this, "sourcesViewSea rchConfig"); |
| 25 this._searchableView.setMinimalSearchQuerySize(0); | 25 this._searchableView.setMinimalSearchQuerySize(0); |
| 26 this._searchableView.show(this.element); | 26 this._searchableView.show(this.element); |
| 27 | 27 |
| 28 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.UISourceCodeFrame >} */ | 28 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.UISourceCodeFrame >} */ |
| 29 this._sourceFramesByUISourceCode = new Map(); | 29 this._sourceFramesByUISourceCode = new Map(); |
| 30 | 30 |
| 31 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri ng("Hit Cmd+P to open a file") : WebInspector.UIString("Hit Ctrl+P to open a fil e"); | 31 var tabbedEditorPlaceholderText = WebInspector.isMac() ? WebInspector.UIStri ng("Hit Cmd+P to open a file") : WebInspector.UIString("Hit Ctrl+P to open a fil e"); |
| 32 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo uslyViewedFiles", tabbedEditorPlaceholderText); | 32 this._editorContainer = new WebInspector.TabbedEditorContainer(this, "previo uslyViewedFiles", tabbedEditorPlaceholderText); |
| 33 this._editorContainer.show(this._searchableView.element); | 33 this._editorContainer.show(this._searchableView.element); |
| 34 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev ents.EditorSelected, this._editorSelected, this); | 34 this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Ev ents.EditorSelected, this._editorSelected, this); |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 { | 490 { |
| 491 this._recreateSourceFrameIfNeeded(uiSourceCode); | 491 this._recreateSourceFrameIfNeeded(uiSourceCode); |
| 492 }, | 492 }, |
| 493 | 493 |
| 494 searchCanceled: function() | 494 searchCanceled: function() |
| 495 { | 495 { |
| 496 if (this._searchView) | 496 if (this._searchView) |
| 497 this._searchView.searchCanceled(); | 497 this._searchView.searchCanceled(); |
| 498 | 498 |
| 499 delete this._searchView; | 499 delete this._searchView; |
| 500 delete this._searchQuery; | 500 delete this._searchConfig; |
| 501 }, | 501 }, |
| 502 | 502 |
| 503 /** | 503 /** |
| 504 * @param {string} query | 504 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig |
| 505 * @param {boolean} shouldJump | 505 * @param {boolean} shouldJump |
| 506 * @param {boolean=} jumpBackwards | 506 * @param {boolean=} jumpBackwards |
| 507 */ | 507 */ |
| 508 performSearch: function(query, shouldJump, jumpBackwards) | 508 performSearch: function(searchConfig, shouldJump, jumpBackwards) |
| 509 { | 509 { |
| 510 var query = searchConfig.query; | |
|
lushnikov
2014/10/20 13:09:19
query is not used
| |
| 510 this._searchableView.updateSearchMatchesCount(0); | 511 this._searchableView.updateSearchMatchesCount(0); |
| 511 | 512 |
| 512 var sourceFrame = this.currentSourceFrame(); | 513 var sourceFrame = this.currentSourceFrame(); |
| 513 if (!sourceFrame) | 514 if (!sourceFrame) |
| 514 return; | 515 return; |
| 515 | 516 |
| 516 this._searchView = sourceFrame; | 517 this._searchView = sourceFrame; |
| 517 this._searchQuery = query; | 518 this._searchConfig = searchConfig; |
| 518 | 519 |
| 519 /** | 520 /** |
| 520 * @param {!WebInspector.View} view | 521 * @param {!WebInspector.View} view |
| 521 * @param {number} searchMatches | 522 * @param {number} searchMatches |
| 522 * @this {WebInspector.SourcesView} | 523 * @this {WebInspector.SourcesView} |
| 523 */ | 524 */ |
| 524 function finishedCallback(view, searchMatches) | 525 function finishedCallback(view, searchMatches) |
| 525 { | 526 { |
| 526 if (!searchMatches) | 527 if (!searchMatches) |
| 527 return; | 528 return; |
| 528 | 529 |
| 529 this._searchableView.updateSearchMatchesCount(searchMatches); | 530 this._searchableView.updateSearchMatchesCount(searchMatches); |
| 530 } | 531 } |
| 531 | 532 |
| 532 /** | 533 /** |
| 533 * @param {number} currentMatchIndex | 534 * @param {number} currentMatchIndex |
| 534 * @this {WebInspector.SourcesView} | 535 * @this {WebInspector.SourcesView} |
| 535 */ | 536 */ |
| 536 function currentMatchChanged(currentMatchIndex) | 537 function currentMatchChanged(currentMatchIndex) |
| 537 { | 538 { |
| 538 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); | 539 this._searchableView.updateCurrentMatchIndex(currentMatchIndex); |
| 539 } | 540 } |
| 540 | 541 |
| 541 /** | 542 /** |
| 542 * @this {WebInspector.SourcesView} | 543 * @this {WebInspector.SourcesView} |
| 543 */ | 544 */ |
| 544 function searchResultsChanged() | 545 function searchResultsChanged() |
| 545 { | 546 { |
| 546 this.performSearch(query, false, false); | 547 this.performSearch(this._searchConfig, false, false); |
| 547 } | 548 } |
| 548 | 549 |
| 549 this._searchView.performSearch(query, shouldJump, !!jumpBackwards, finis hedCallback.bind(this), currentMatchChanged.bind(this), searchResultsChanged.bin d(this)); | 550 this._searchView.performSearch(this._searchConfig, shouldJump, !!jumpBac kwards, finishedCallback.bind(this), currentMatchChanged.bind(this), searchResul tsChanged.bind(this)); |
| 550 }, | 551 }, |
| 551 | 552 |
| 552 jumpToNextSearchResult: function() | 553 jumpToNextSearchResult: function() |
| 553 { | 554 { |
| 554 if (!this._searchView) | 555 if (!this._searchView) |
| 555 return; | 556 return; |
| 556 | 557 |
| 557 if (this._searchView !== this.currentSourceFrame()) { | 558 if (this._searchView !== this.currentSourceFrame()) { |
| 558 this.performSearch(this._searchQuery, true); | 559 this.performSearch(this._searchConfig, true); |
| 559 return; | 560 return; |
| 560 } | 561 } |
| 561 | 562 |
| 562 this._searchView.jumpToNextSearchResult(); | 563 this._searchView.jumpToNextSearchResult(); |
| 563 }, | 564 }, |
| 564 | 565 |
| 565 jumpToPreviousSearchResult: function() | 566 jumpToPreviousSearchResult: function() |
| 566 { | 567 { |
| 567 if (!this._searchView) | 568 if (!this._searchView) |
| 568 return; | 569 return; |
| 569 | 570 |
| 570 if (this._searchView !== this.currentSourceFrame()) { | 571 if (this._searchView !== this.currentSourceFrame()) { |
| 571 this.performSearch(this._searchQuery, true); | 572 this.performSearch(this._searchConfig, true); |
| 572 if (this._searchView) | 573 if (this._searchView) |
| 573 this._searchView.jumpToLastSearchResult(); | 574 this._searchView.jumpToLastSearchResult(); |
| 574 return; | 575 return; |
| 575 } | 576 } |
| 576 | 577 |
| 577 this._searchView.jumpToPreviousSearchResult(); | 578 this._searchView.jumpToPreviousSearchResult(); |
| 578 }, | 579 }, |
| 579 | 580 |
| 580 /** | 581 /** |
| 581 * @param {string} text | 582 * @return {boolean} |
| 582 */ | 583 */ |
| 583 replaceSelectionWith: function(text) | 584 supportsCaseSensitiveSearch: function() |
| 585 { | |
| 586 return true; | |
| 587 }, | |
| 588 | |
| 589 /** | |
| 590 * @return {boolean} | |
| 591 */ | |
| 592 supportsRegexSearch: function() | |
| 593 { | |
| 594 return true; | |
| 595 }, | |
| 596 | |
| 597 /** | |
| 598 * @param {string} replacement | |
| 599 */ | |
| 600 replaceSelectionWith: function(replacement) | |
| 584 { | 601 { |
| 585 var sourceFrame = this.currentSourceFrame(); | 602 var sourceFrame = this.currentSourceFrame(); |
| 586 if (!sourceFrame) { | 603 if (!sourceFrame) { |
| 587 console.assert(sourceFrame); | 604 console.assert(sourceFrame); |
| 588 return; | 605 return; |
| 589 } | 606 } |
| 590 sourceFrame.replaceSelectionWith(text); | 607 sourceFrame.replaceSelectionWith(replacement); |
| 591 }, | 608 }, |
| 592 | 609 |
| 593 /** | 610 /** |
| 594 * @param {string} query | 611 * @param {!WebInspector.SearchableView.SearchConfig} searchConfig |
| 595 * @param {string} text | 612 * @param {string} replacement |
| 596 */ | 613 */ |
| 597 replaceAllWith: function(query, text) | 614 replaceAllWith: function(searchConfig, replacement) |
| 598 { | 615 { |
| 599 var sourceFrame = this.currentSourceFrame(); | 616 var sourceFrame = this.currentSourceFrame(); |
| 600 if (!sourceFrame) { | 617 if (!sourceFrame) { |
| 601 console.assert(sourceFrame); | 618 console.assert(sourceFrame); |
| 602 return; | 619 return; |
| 603 } | 620 } |
| 604 sourceFrame.replaceAllWith(query, text); | 621 sourceFrame.replaceAllWith(searchConfig, replacement); |
| 605 }, | 622 }, |
| 606 | 623 |
| 607 /** | 624 /** |
| 608 * @param {!Event=} event | 625 * @param {!Event=} event |
| 609 * @return {boolean} | 626 * @return {boolean} |
| 610 */ | 627 */ |
| 611 _showOutlineDialog: function(event) | 628 _showOutlineDialog: function(event) |
| 612 { | 629 { |
| 613 var uiSourceCode = this._editorContainer.currentFile(); | 630 var uiSourceCode = this._editorContainer.currentFile(); |
| 614 if (!uiSourceCode) | 631 if (!uiSourceCode) |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 var currentUISourceCode = sourcesView.currentUISourceCode(); | 800 var currentUISourceCode = sourcesView.currentUISourceCode(); |
| 784 if (!currentUISourceCode) | 801 if (!currentUISourceCode) |
| 785 return true; | 802 return true; |
| 786 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate ._nextFile(currentUISourceCode); | 803 var nextUISourceCode = WebInspector.SourcesView.SwitchFileActionDelegate ._nextFile(currentUISourceCode); |
| 787 if (!nextUISourceCode) | 804 if (!nextUISourceCode) |
| 788 return true; | 805 return true; |
| 789 sourcesView.showSourceLocation(nextUISourceCode); | 806 sourcesView.showSourceLocation(nextUISourceCode); |
| 790 return true; | 807 return true; |
| 791 } | 808 } |
| 792 } | 809 } |
| OLD | NEW |