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

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

Issue 8368025: Merge 97959 - Web Inspector: Enable support for advanced search in script's static content provider. (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 * * 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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 }, 297 },
298 298
299 /** 299 /**
300 * @param {string} query 300 * @param {string} query
301 * @param {boolean} caseSensitive 301 * @param {boolean} caseSensitive
302 * @param {boolean} isRegex 302 * @param {boolean} isRegex
303 * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callb ack 303 * @param {function(Array.<WebInspector.ContentProvider.SearchMatch>)} callb ack
304 */ 304 */
305 searchInContent: function(query, caseSensitive, isRegex, callback) 305 searchInContent: function(query, caseSensitive, isRegex, callback)
306 { 306 {
307 callback([]); 307 function performSearch()
308 {
309 var regex = createSearchRegex(query, caseSensitive, isRegex);
310
311 var result = [];
312 var lineEndings = this._content.lineEndings();
313 for (var i = 0; i < lineEndings.length; ++i) {
314 var lineStart = i > 0 ? lineEndings[i - 1] + 1 : 0;
315 var lineEnd = lineEndings[i];
316 var lineContent = this._content.substring(lineStart, lineEnd);
317 if (lineContent.length > 0 && lineContent.charAt(lineContent.len gth - 1) === "\r")
318 lineContent = lineContent.substring(0, lineContent.length - 1)
319
320 if (regex.exec(lineContent))
321 result.push(new WebInspector.ContentProvider.SearchMatch(i, lineContent));
322 }
323 callback(result);
324 }
325
326 // searchInContent should call back later.
327 window.setTimeout(performSearch.bind(this), 0);
308 } 328 }
309 } 329 }
310 330
311 WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentPro vider.prototype; 331 WebInspector.StaticContentProvider.prototype.__proto__ = WebInspector.ContentPro vider.prototype;
OLDNEW
« no previous file with comments | « Source/WebCore/inspector/front-end/ConsolePanel.js ('k') | Source/WebCore/inspector/front-end/ElementsTreeOutline.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698