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

Unified Diff: Source/WebCore/inspector/front-end/AdvancedSearchController.js

Issue 8382007: Merge 97975 - Web Inspector: Advanced search results should keep working after pretty print toggled. (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 side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/inspector/front-end/AdvancedSearchController.js
===================================================================
--- Source/WebCore/inspector/front-end/AdvancedSearchController.js (revision 98246)
+++ Source/WebCore/inspector/front-end/AdvancedSearchController.js (working copy)
@@ -296,9 +296,10 @@
stopSearch: function() { },
/**
+ * @param {WebInspector.SearchConfig} searchConfig
* @return WebInspector.SearchResultsPane}
*/
- createSearchResultsPane: function() { }
+ createSearchResultsPane: function(searchConfig) { }
}
/**
@@ -349,9 +350,10 @@
/**
* @param {Object} file
* @param {number} lineNumber
+ * @param {number} columnNumber
* @return {Element}
*/
- createAnchor: function(file, lineNumber) { },
+ createAnchor: function(file, lineNumber, columnNumber) { },
/**
* @param {Object} file
@@ -372,11 +374,13 @@
// Expand first file with matches only.
var fileTreeElement = this._addFileTreeElement(fileName, searchMatches.length, this._searchResults.length === 1);
- var regexObject = createSearchRegex(this._searchConfig.query, !this._searchConfig.ignoreCase, this._searchConfig.isRegex);
+ var regex = createSearchRegex(this._searchConfig.query, !this._searchConfig.ignoreCase, this._searchConfig.isRegex);
for (var i = 0; i < searchMatches.length; i++) {
var lineNumber = searchMatches[i].lineNumber;
+ var lineContent = searchMatches[i].lineContent;
+ var matchRanges = this._regexMatchRanges(lineContent, regex);
- var anchor = this.createAnchor(file, lineNumber);
+ var anchor = this.createAnchor(file, lineNumber, matchRanges[0].offset);
var numberString = numberToStringWithSpacesPadding(lineNumber + 1, 4);
var lineNumberSpan = document.createElement("span");
@@ -385,7 +389,7 @@
lineNumberSpan.textContent = numberString;
anchor.appendChild(lineNumberSpan);
- var contentSpan = this._createContentSpan(searchMatches[i].lineContent, regexObject);
+ var contentSpan = this._createContentSpan(lineContent, matchRanges);
anchor.appendChild(contentSpan);
var searchMatchElement = new TreeElement("", null, false);
@@ -429,24 +433,31 @@
/**
* @param {string} lineContent
- * @param {RegExp} regexObject
+ * @param {RegExp} regex
+ * @return {Array.<Object>}
*/
- _createContentSpan: function(lineContent, regexObject)
+ _regexMatchRanges: function(lineContent, regex)
{
+ regex.lastIndex = 0;
+ var match;
+ var offset = 0;
+ var matchRanges = [];
+ while (match = regex.exec(lineContent))
+ matchRanges.push({ offset: match.index, length: match[0].length });
+
+ return matchRanges;
+ },
+
+ /**
+ * @param {string} lineContent
+ * @param {Array.<Object>} matchRanges
+ */
+ _createContentSpan: function(lineContent, matchRanges)
+ {
var contentSpan = document.createElement("span");
contentSpan.className = "search-match-content";
contentSpan.textContent = lineContent;
-
- regexObject.lastIndex = 0;
- var match = regexObject.exec(lineContent);
- var offset = 0;
- var matchRanges = [];
- while (match) {
- matchRanges.push({ offset: match.index, length: match[0].length });
- match = regexObject.exec(lineContent);
- }
highlightRangesWithStyleClass(contentSpan, matchRanges, "highlighted-match");
-
return contentSpan;
}
}
« no previous file with comments | « LayoutTests/inspector/debugger/raw-source-code.html ('k') | Source/WebCore/inspector/front-end/BreakpointManager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698