OLD | NEW |
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 Loading... |
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; |
OLD | NEW |