OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
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 | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 elementsToRestoreScrollPositionsFor: function() | 869 elementsToRestoreScrollPositionsFor: function() |
870 { | 870 { |
871 return [this._messagesElement]; | 871 return [this._messagesElement]; |
872 }, | 872 }, |
873 | 873 |
874 searchCanceled: function() | 874 searchCanceled: function() |
875 { | 875 { |
876 this._clearCurrentSearchResultHighlight(); | 876 this._clearCurrentSearchResultHighlight(); |
877 delete this._searchResults; | 877 delete this._searchResults; |
878 delete this._searchRegex; | 878 delete this._searchRegex; |
| 879 this._viewport.refresh(); |
879 }, | 880 }, |
880 | 881 |
881 /** | 882 /** |
882 * @param {string} query | 883 * @param {string} query |
883 * @param {boolean} shouldJump | 884 * @param {boolean} shouldJump |
884 * @param {boolean=} jumpBackwards | 885 * @param {boolean=} jumpBackwards |
885 */ | 886 */ |
886 performSearch: function(query, shouldJump, jumpBackwards) | 887 performSearch: function(query, shouldJump, jumpBackwards) |
887 { | 888 { |
888 this.searchCanceled(); | 889 this.searchCanceled(); |
889 this._searchableView.updateSearchMatchesCount(0); | 890 this._searchableView.updateSearchMatchesCount(0); |
890 this._searchRegex = createPlainTextSearchRegex(query, "gi"); | 891 this._searchRegex = createPlainTextSearchRegex(query, "gi"); |
891 | 892 |
| 893 /** @type {!Array.<number>} */ |
892 this._searchResults = []; | 894 this._searchResults = []; |
893 for (var i = 0; i < this._visibleViewMessages.length; i++) { | 895 for (var i = 0; i < this._visibleViewMessages.length; i++) { |
894 if (this._visibleViewMessages[i].matchesRegex(this._searchRegex)) | 896 if (this._visibleViewMessages[i].matchesRegex(this._searchRegex)) |
895 this._searchResults.push(this._visibleViewMessages[i]); | 897 this._searchResults.push(i); |
896 } | 898 } |
897 this._searchableView.updateSearchMatchesCount(this._searchResults.length
); | 899 this._searchableView.updateSearchMatchesCount(this._searchResults.length
); |
898 this._currentSearchResultIndex = -1; | 900 this._currentSearchResultIndex = -1; |
899 if (shouldJump && this._searchResults.length) | 901 if (shouldJump && this._searchResults.length) |
900 this._jumpToSearchResult(jumpBackwards ? -1 : 0); | 902 this._jumpToSearchResult(jumpBackwards ? -1 : 0); |
| 903 this._viewport.refresh(); |
901 }, | 904 }, |
902 | 905 |
903 jumpToNextSearchResult: function() | 906 jumpToNextSearchResult: function() |
904 { | 907 { |
905 if (!this._searchResults || !this._searchResults.length) | 908 if (!this._searchResults || !this._searchResults.length) |
906 return; | 909 return; |
907 this._jumpToSearchResult(this._currentSearchResultIndex + 1); | 910 this._jumpToSearchResult(this._currentSearchResultIndex + 1); |
908 }, | 911 }, |
909 | 912 |
910 jumpToPreviousSearchResult: function() | 913 jumpToPreviousSearchResult: function() |
911 { | 914 { |
912 if (!this._searchResults || !this._searchResults.length) | 915 if (!this._searchResults || !this._searchResults.length) |
913 return; | 916 return; |
914 this._jumpToSearchResult(this._currentSearchResultIndex - 1); | 917 this._jumpToSearchResult(this._currentSearchResultIndex - 1); |
915 }, | 918 }, |
916 | 919 |
917 _clearCurrentSearchResultHighlight: function() | 920 _clearCurrentSearchResultHighlight: function() |
918 { | 921 { |
919 if (!this._searchResults) | 922 if (!this._searchResults) |
920 return; | 923 return; |
921 | 924 |
922 var highlightedViewMessage = this._searchResults[this._currentSearchResu
ltIndex]; | 925 var highlightedViewMessage = this._visibleViewMessages[this._searchResul
ts[this._currentSearchResultIndex]]; |
923 if (highlightedViewMessage) | 926 if (highlightedViewMessage) |
924 highlightedViewMessage.clearHighlight(); | 927 highlightedViewMessage.clearHighlight(); |
925 this._currentSearchResultIndex = -1; | 928 this._currentSearchResultIndex = -1; |
926 }, | 929 }, |
927 | 930 |
928 _jumpToSearchResult: function(index) | 931 _jumpToSearchResult: function(index) |
929 { | 932 { |
930 index = mod(index, this._searchResults.length); | 933 index = mod(index, this._searchResults.length); |
931 this._clearCurrentSearchResultHighlight(); | 934 this._clearCurrentSearchResultHighlight(); |
932 this._currentSearchResultIndex = index; | 935 this._currentSearchResultIndex = index; |
933 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultIn
dex); | 936 this._searchableView.updateCurrentMatchIndex(this._currentSearchResultIn
dex); |
934 this._searchResults[index].highlightSearchResults(this._searchRegex); | 937 var currentViewMessageIndex = this._searchResults[index]; |
| 938 this._viewport.scrollItemIntoView(currentViewMessageIndex); |
| 939 this._visibleViewMessages[currentViewMessageIndex].highlightSearchResult
s(this._searchRegex); |
935 }, | 940 }, |
936 | 941 |
937 __proto__: WebInspector.VBox.prototype | 942 __proto__: WebInspector.VBox.prototype |
938 } | 943 } |
939 | 944 |
940 /** | 945 /** |
941 * @constructor | 946 * @constructor |
942 * @extends {WebInspector.Object} | 947 * @extends {WebInspector.Object} |
943 * @param {!WebInspector.ConsoleView} view | 948 * @param {!WebInspector.ConsoleView} view |
944 */ | 949 */ |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { | 1230 WebInspector.ConsoleView.ShowConsoleActionDelegate.prototype = { |
1226 /** | 1231 /** |
1227 * @return {boolean} | 1232 * @return {boolean} |
1228 */ | 1233 */ |
1229 handleAction: function() | 1234 handleAction: function() |
1230 { | 1235 { |
1231 WebInspector.console.show(); | 1236 WebInspector.console.show(); |
1232 return true; | 1237 return true; |
1233 } | 1238 } |
1234 } | 1239 } |
OLD | NEW |