| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.SearchResultsPane} | 7 * @extends {WebInspector.SearchResultsPane} |
| 8 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 8 * @param {!WebInspector.ProjectSearchConfig} searchConfig |
| 9 */ | 9 */ |
| 10 WebInspector.FileBasedSearchResultsPane = function(searchConfig) | 10 WebInspector.FileBasedSearchResultsPane = function(searchConfig) |
| 11 { | 11 { |
| 12 WebInspector.SearchResultsPane.call(this, searchConfig); | 12 WebInspector.SearchResultsPane.call(this, searchConfig); |
| 13 | 13 |
| 14 this._searchResults = []; | 14 this._searchResults = []; |
| 15 | 15 |
| 16 this.element.id = "search-results-pane-file-based"; | 16 this.element.id = "search-results-pane-file-based"; |
| 17 | 17 |
| 18 this._treeOutlineElement = document.createElement("ol"); | 18 this._treeOutlineElement = createElement("ol"); |
| 19 this._treeOutlineElement.className = "search-results-outline-disclosure"; | 19 this._treeOutlineElement.className = "search-results-outline-disclosure"; |
| 20 this.element.appendChild(this._treeOutlineElement); | 20 this.element.appendChild(this._treeOutlineElement); |
| 21 this._treeOutline = new TreeOutline(this._treeOutlineElement); | 21 this._treeOutline = new TreeOutline(this._treeOutlineElement); |
| 22 | 22 |
| 23 this._matchesExpandedCount = 0; | 23 this._matchesExpandedCount = 0; |
| 24 } | 24 } |
| 25 | 25 |
| 26 WebInspector.FileBasedSearchResultsPane.matchesExpandedByDefaultCount = 20; | 26 WebInspector.FileBasedSearchResultsPane.matchesExpandedByDefaultCount = 20; |
| 27 WebInspector.FileBasedSearchResultsPane.fileMatchesShownAtOnce = 20; | 27 WebInspector.FileBasedSearchResultsPane.fileMatchesShownAtOnce = 20; |
| 28 | 28 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 onattach: function() | 96 onattach: function() |
| 97 { | 97 { |
| 98 this._updateSearchMatches(); | 98 this._updateSearchMatches(); |
| 99 }, | 99 }, |
| 100 | 100 |
| 101 _updateSearchMatches: function() | 101 _updateSearchMatches: function() |
| 102 { | 102 { |
| 103 this.listItemElement.classList.add("search-result"); | 103 this.listItemElement.classList.add("search-result"); |
| 104 | 104 |
| 105 var fileNameSpan = document.createElement("span"); | 105 var fileNameSpan = createElement("span"); |
| 106 fileNameSpan.className = "search-result-file-name"; | 106 fileNameSpan.className = "search-result-file-name"; |
| 107 fileNameSpan.textContent = this._searchResult.uiSourceCode.fullDisplayNa
me(); | 107 fileNameSpan.textContent = this._searchResult.uiSourceCode.fullDisplayNa
me(); |
| 108 this.listItemElement.appendChild(fileNameSpan); | 108 this.listItemElement.appendChild(fileNameSpan); |
| 109 | 109 |
| 110 var matchesCountSpan = document.createElement("span"); | 110 var matchesCountSpan = createElement("span"); |
| 111 matchesCountSpan.className = "search-result-matches-count"; | 111 matchesCountSpan.className = "search-result-matches-count"; |
| 112 | 112 |
| 113 var searchMatchesCount = this._searchResult.searchMatches.length; | 113 var searchMatchesCount = this._searchResult.searchMatches.length; |
| 114 if (searchMatchesCount === 1) | 114 if (searchMatchesCount === 1) |
| 115 matchesCountSpan.textContent = WebInspector.UIString("(%d match)", s
earchMatchesCount); | 115 matchesCountSpan.textContent = WebInspector.UIString("(%d match)", s
earchMatchesCount); |
| 116 else | 116 else |
| 117 matchesCountSpan.textContent = WebInspector.UIString("(%d matches)",
searchMatchesCount); | 117 matchesCountSpan.textContent = WebInspector.UIString("(%d matches)",
searchMatchesCount); |
| 118 | 118 |
| 119 this.listItemElement.appendChild(matchesCountSpan); | 119 this.listItemElement.appendChild(matchesCountSpan); |
| 120 if (this.expanded) | 120 if (this.expanded) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 139 for (var i = fromIndex; i < toIndex; ++i) { | 139 for (var i = fromIndex; i < toIndex; ++i) { |
| 140 var lineNumber = searchMatches[i].lineNumber; | 140 var lineNumber = searchMatches[i].lineNumber; |
| 141 var lineContent = searchMatches[i].lineContent; | 141 var lineContent = searchMatches[i].lineContent; |
| 142 var matchRanges = []; | 142 var matchRanges = []; |
| 143 for (var j = 0; j < regexes.length; ++j) | 143 for (var j = 0; j < regexes.length; ++j) |
| 144 matchRanges = matchRanges.concat(this._regexMatchRanges(lineCont
ent, regexes[j])); | 144 matchRanges = matchRanges.concat(this._regexMatchRanges(lineCont
ent, regexes[j])); |
| 145 | 145 |
| 146 var anchor = this._createAnchor(uiSourceCode, lineNumber, matchRange
s[0].offset); | 146 var anchor = this._createAnchor(uiSourceCode, lineNumber, matchRange
s[0].offset); |
| 147 | 147 |
| 148 var numberString = numberToStringWithSpacesPadding(lineNumber + 1, 4
); | 148 var numberString = numberToStringWithSpacesPadding(lineNumber + 1, 4
); |
| 149 var lineNumberSpan = document.createElement("span"); | 149 var lineNumberSpan = createElement("span"); |
| 150 lineNumberSpan.classList.add("search-match-line-number"); | 150 lineNumberSpan.classList.add("search-match-line-number"); |
| 151 lineNumberSpan.textContent = numberString; | 151 lineNumberSpan.textContent = numberString; |
| 152 anchor.appendChild(lineNumberSpan); | 152 anchor.appendChild(lineNumberSpan); |
| 153 | 153 |
| 154 var contentSpan = this._createContentSpan(lineContent, matchRanges); | 154 var contentSpan = this._createContentSpan(lineContent, matchRanges); |
| 155 anchor.appendChild(contentSpan); | 155 anchor.appendChild(contentSpan); |
| 156 | 156 |
| 157 var searchMatchElement = new TreeElement(""); | 157 var searchMatchElement = new TreeElement(""); |
| 158 searchMatchElement.selectable = false; | 158 searchMatchElement.selectable = false; |
| 159 this.appendChild(searchMatchElement); | 159 this.appendChild(searchMatchElement); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 185 { | 185 { |
| 186 return WebInspector.Linkifier.linkifyUsingRevealer(uiSourceCode.uiLocati
on(lineNumber, columnNumber), "", uiSourceCode.url, lineNumber); | 186 return WebInspector.Linkifier.linkifyUsingRevealer(uiSourceCode.uiLocati
on(lineNumber, columnNumber), "", uiSourceCode.url, lineNumber); |
| 187 }, | 187 }, |
| 188 | 188 |
| 189 /** | 189 /** |
| 190 * @param {string} lineContent | 190 * @param {string} lineContent |
| 191 * @param {!Array.<!WebInspector.SourceRange>} matchRanges | 191 * @param {!Array.<!WebInspector.SourceRange>} matchRanges |
| 192 */ | 192 */ |
| 193 _createContentSpan: function(lineContent, matchRanges) | 193 _createContentSpan: function(lineContent, matchRanges) |
| 194 { | 194 { |
| 195 var contentSpan = document.createElement("span"); | 195 var contentSpan = createElement("span"); |
| 196 contentSpan.className = "search-match-content"; | 196 contentSpan.className = "search-match-content"; |
| 197 contentSpan.textContent = lineContent; | 197 contentSpan.textContent = lineContent; |
| 198 WebInspector.highlightRangesWithStyleClass(contentSpan, matchRanges, "hi
ghlighted-match"); | 198 WebInspector.highlightRangesWithStyleClass(contentSpan, matchRanges, "hi
ghlighted-match"); |
| 199 return contentSpan; | 199 return contentSpan; |
| 200 }, | 200 }, |
| 201 | 201 |
| 202 /** | 202 /** |
| 203 * @param {string} lineContent | 203 * @param {string} lineContent |
| 204 * @param {!RegExp} regex | 204 * @param {!RegExp} regex |
| 205 * @return {!Array.<!WebInspector.SourceRange>} | 205 * @return {!Array.<!WebInspector.SourceRange>} |
| (...skipping 16 matching lines...) Expand all Loading... |
| 222 */ | 222 */ |
| 223 _showMoreMatchesElementSelected: function(startMatchIndex) | 223 _showMoreMatchesElementSelected: function(startMatchIndex) |
| 224 { | 224 { |
| 225 this.removeChild(this._showMoreMatchesTreeElement); | 225 this.removeChild(this._showMoreMatchesTreeElement); |
| 226 this._appendSearchMatches(startMatchIndex, this._searchResult.searchMatc
hes.length); | 226 this._appendSearchMatches(startMatchIndex, this._searchResult.searchMatc
hes.length); |
| 227 return false; | 227 return false; |
| 228 }, | 228 }, |
| 229 | 229 |
| 230 __proto__: TreeElement.prototype | 230 __proto__: TreeElement.prototype |
| 231 } | 231 } |
| OLD | NEW |