Title: [140809] trunk/Source/WebCore
- Revision
- 140809
- Author
- [email protected]
- Date
- 2013-01-25 03:14:33 -0800 (Fri, 25 Jan 2013)
Log Message
Web Inspector: implement search for workspace sources
https://bugs.webkit.org/show_bug.cgi?id=107814
Patch by Andrey Lushnikov <[email protected]> on 2013-01-25
Reviewed by Pavel Feldman.
Implement generic WebInspector.ContentProvider.performSearchInContent method and use it in both
StaticContentProvider and fileSystemWorkspaceProvider.
No new tests.
* inspector/front-end/ContentProvider.js:
(WebInspector.ContentProvider.performSearchInContent): Added.
* inspector/front-end/ContentProviders.js:
(WebInspector.StaticContentProvider.prototype.):
(WebInspector.StaticContentProvider.prototype.searchInContent):
* inspector/front-end/FileSystemWorkspaceProvider.js:
(WebInspector.FileSystemWorkspaceProvider.prototype.contentCallback):
(WebInspector.FileSystemWorkspaceProvider.prototype.searchInFileContent):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (140808 => 140809)
--- trunk/Source/WebCore/ChangeLog 2013-01-25 11:03:30 UTC (rev 140808)
+++ trunk/Source/WebCore/ChangeLog 2013-01-25 11:14:33 UTC (rev 140809)
@@ -1,3 +1,24 @@
+2013-01-25 Andrey Lushnikov <[email protected]>
+
+ Web Inspector: implement search for workspace sources
+ https://bugs.webkit.org/show_bug.cgi?id=107814
+
+ Reviewed by Pavel Feldman.
+
+ Implement generic WebInspector.ContentProvider.performSearchInContent method and use it in both
+ StaticContentProvider and fileSystemWorkspaceProvider.
+
+ No new tests.
+
+ * inspector/front-end/ContentProvider.js:
+ (WebInspector.ContentProvider.performSearchInContent): Added.
+ * inspector/front-end/ContentProviders.js:
+ (WebInspector.StaticContentProvider.prototype.):
+ (WebInspector.StaticContentProvider.prototype.searchInContent):
+ * inspector/front-end/FileSystemWorkspaceProvider.js:
+ (WebInspector.FileSystemWorkspaceProvider.prototype.contentCallback):
+ (WebInspector.FileSystemWorkspaceProvider.prototype.searchInFileContent):
+
2013-01-25 Elliott Sprehn <[email protected]>
Assert the connectedSubframeCount is consistent and fix over counting
Modified: trunk/Source/WebCore/inspector/front-end/ContentProvider.js (140808 => 140809)
--- trunk/Source/WebCore/inspector/front-end/ContentProvider.js 2013-01-25 11:03:30 UTC (rev 140808)
+++ trunk/Source/WebCore/inspector/front-end/ContentProvider.js 2013-01-25 11:14:33 UTC (rev 140809)
@@ -67,3 +67,29 @@
this.lineNumber = lineNumber;
this.lineContent = lineContent;
}
+
+/**
+ * @param {string} content
+ * @param {string} query
+ * @param {boolean} caseSensitive
+ * @param {boolean} isRegex
+ * @return {Array.<WebInspector.ContentProvider.SearchMatch>}
+ */
+WebInspector.ContentProvider.performSearchInContent = function(content, query, caseSensitive, isRegex)
+{
+ var regex = createSearchRegex(query, caseSensitive, isRegex);
+
+ var result = [];
+ var lineEndings = content.lineEndings();
+ for (var i = 0; i < lineEndings.length; ++i) {
+ var lineStart = i > 0 ? lineEndings[i - 1] + 1 : 0;
+ var lineEnd = lineEndings[i];
+ var lineContent = content.substring(lineStart, lineEnd);
+ if (lineContent.length > 0 && lineContent.charAt(lineContent.length - 1) === "\r")
+ lineContent = lineContent.substring(0, lineContent.length - 1)
+
+ if (regex.exec(lineContent))
+ result.push(new WebInspector.ContentProvider.SearchMatch(i, lineContent));
+ }
+ return result;
+}
Modified: trunk/Source/WebCore/inspector/front-end/ContentProviders.js (140808 => 140809)
--- trunk/Source/WebCore/inspector/front-end/ContentProviders.js 2013-01-25 11:03:30 UTC (rev 140808)
+++ trunk/Source/WebCore/inspector/front-end/ContentProviders.js 2013-01-25 11:14:33 UTC (rev 140809)
@@ -287,21 +287,7 @@
{
function performSearch()
{
- var regex = createSearchRegex(query, caseSensitive, isRegex);
-
- var result = [];
- var lineEndings = this._content.lineEndings();
- for (var i = 0; i < lineEndings.length; ++i) {
- var lineStart = i > 0 ? lineEndings[i - 1] + 1 : 0;
- var lineEnd = lineEndings[i];
- var lineContent = this._content.substring(lineStart, lineEnd);
- if (lineContent.length > 0 && lineContent.charAt(lineContent.length - 1) === "\r")
- lineContent = lineContent.substring(0, lineContent.length - 1)
-
- if (regex.exec(lineContent))
- result.push(new WebInspector.ContentProvider.SearchMatch(i, lineContent));
- }
- callback(result);
+ callback(WebInspector.ContentProvider.performSearchInContent(this._content, query, caseSensitive, isRegex));
}
// searchInContent should call back later.
Modified: trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js (140808 => 140809)
--- trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js 2013-01-25 11:03:30 UTC (rev 140808)
+++ trunk/Source/WebCore/inspector/front-end/FileSystemWorkspaceProvider.js 2013-01-25 11:14:33 UTC (rev 140809)
@@ -91,7 +91,20 @@
*/
searchInFileContent: function(uri, query, caseSensitive, isRegex, callback)
{
- callback([]);
+ this.requestFileContent(uri, contentCallback.bind(this));
+
+ /**
+ * @param {?string} content
+ * @param {boolean} base64Encoded
+ * @param {string} mimeType
+ */
+ function contentCallback(content, base64Encoded, mimeType)
+ {
+ var result = [];
+ if (content)
+ result = WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex);
+ callback(result);
+ }
},
/**
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes