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

Side by Side Diff: Source/WebCore/inspector/front-end/ScriptsSearchScope.js

Issue 8381041: Merge 98105 - Web Inspector: Advanced search is working very slowly and does not show searching p... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/912/
Patch Set: Created 9 years, 2 months 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 10 *
(...skipping 16 matching lines...) Expand all
27 */ 27 */
28 28
29 /** 29 /**
30 * @constructor 30 * @constructor
31 * @implements {WebInspector.SearchScope} 31 * @implements {WebInspector.SearchScope}
32 */ 32 */
33 WebInspector.ScriptsSearchScope = function() 33 WebInspector.ScriptsSearchScope = function()
34 { 34 {
35 // FIXME: Add title once it is used by search controller. 35 // FIXME: Add title once it is used by search controller.
36 WebInspector.SearchScope.call(this) 36 WebInspector.SearchScope.call(this)
37 this._searchId = 0;
37 } 38 }
38 39
39 WebInspector.ScriptsSearchScope.prototype = { 40 WebInspector.ScriptsSearchScope.prototype = {
40 /** 41 /**
41 * @param {WebInspector.SearchConfig} searchConfig 42 * @param {WebInspector.SearchConfig} searchConfig
42 * @param {function(Object)} searchResultCallback 43 * @param {function(Object)} searchResultCallback
43 * @param {function()} searchFinishedCallback 44 * @param {function(boolean)} searchFinishedCallback
44 */ 45 */
45 performSearch: function(searchConfig, searchResultCallback, searchFinishedCa llback) 46 performSearch: function(searchConfig, searchResultCallback, searchFinishedCa llback)
46 { 47 {
47 var callbacksLeft = 0; 48 this.stopSearch();
48 49
49 function maybeSearchFinished() 50 var uiSourceCodes = this._sortedUISourceCodes();
51 var uiSourceCodeIndex = 0;
52
53 function filterOutContentScripts(uiSourceCode)
50 { 54 {
51 if (callbacksLeft === 0) 55 return !uiSourceCode.isContentScript;
52 searchFinishedCallback();
53 } 56 }
54 57
55 function searchCallbackWrapper(uiSourceCode, searchMatches) 58 // FIXME: Add setting to search in content scripts as well.
59 uiSourceCodes.filter(filterOutContentScripts);
60
61 function continueSearch()
56 { 62 {
57 if (searchMatches.length) { 63 // FIXME: Enable support for counting matches for incremental search .
58 var searchResult = new WebInspector.FileBasedSearchResultsPane.S earchResult(uiSourceCode, searchMatches); 64 // FIXME: Enable support for bounding search results/matches number to keep inspector responsive.
59 searchResultCallback(searchResult); 65 if (uiSourceCodeIndex < uiSourceCodes.length) {
66 var uiSourceCode = uiSourceCodes[uiSourceCodeIndex++];
67 uiSourceCode.searchInContent(searchConfig.query, !searchConfig.i gnoreCase, searchConfig.isRegex, searchCallbackWrapper.bind(this, this._searchId , uiSourceCode));
68 } else
69 searchFinishedCallback(true);
70 }
71
72 function searchCallbackWrapper(searchId, uiSourceCode, searchMatches)
73 {
74 if (searchId !== this._searchId) {
75 searchFinishedCallback(false);
76 return;
60 } 77 }
61 --callbacksLeft; 78
62 maybeSearchFinished(); 79 var searchResult = new WebInspector.FileBasedSearchResultsPane.Searc hResult(uiSourceCode, searchMatches);
80 searchResultCallback(searchResult);
81 continueSearch.call(this);
63 } 82 }
64 83
65 var uiSourceCodes = this._sortedUISourceCodes(); 84 continueSearch.call(this);
66 // FIXME: Enable support for counting matches for incremental search. 85 return uiSourceCodes.length;
67 // FIXME: Enable support for bounding search results/matches number to k eep inspector responsive.
68 for (var i = 0; i < uiSourceCodes.length; i++) {
69 var uiSourceCode = uiSourceCodes[i];
70 // FIXME: Add setting to search in content scripts as well.
71 if (!uiSourceCode.isContentScript) {
72 // Increase callbacksLeft first because searchInContent call cou ld be synchronous.
73 callbacksLeft++;
74 // FIXME: We should not request next searchInContent unless prev ious one is already finished.
75 uiSourceCode.searchInContent(searchConfig.query, !searchConfig.i gnoreCase, searchConfig.isRegex, searchCallbackWrapper.bind(this, uiSourceCode)) ;
76 }
77 }
78 maybeSearchFinished();
79 }, 86 },
80 87
81 stopSearch: function() 88 stopSearch: function()
82 { 89 {
83 // FIXME: Implement search so that it could be stopped. 90 ++this._searchId;
84 }, 91 },
85 92
86 /** 93 /**
87 * @param {WebInspector.SearchConfig} searchConfig 94 * @param {WebInspector.SearchConfig} searchConfig
88 */ 95 */
89 createSearchResultsPane: function(searchConfig) 96 createSearchResultsPane: function(searchConfig)
90 { 97 {
91 return new WebInspector.ScriptsSearchResultsPane(searchConfig); 98 return new WebInspector.ScriptsSearchResultsPane(searchConfig);
92 }, 99 },
93 100
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 * @param {WebInspector.RawSourceCode} rawSourceCode 179 * @param {WebInspector.RawSourceCode} rawSourceCode
173 * @param {Element} anchor 180 * @param {Element} anchor
174 */ 181 */
175 formatRawSourceCodeAnchor: function(rawSourceCode, anchor) 182 formatRawSourceCodeAnchor: function(rawSourceCode, anchor)
176 { 183 {
177 // Empty because we don't want to ever update anchor contents after crea tion. 184 // Empty because we don't want to ever update anchor contents after crea tion.
178 } 185 }
179 } 186 }
180 187
181 WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype.__proto__ = W ebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype; 188 WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype.__proto__ = W ebInspector.DebuggerPresentationModel.LinkifierFormatter.prototype;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698