Changeset 76488 in webkit
- Timestamp:
- Jan 24, 2011 12:44:20 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r76487 r76488 1 2011-01-21 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: move search functions from SourceView to SourceFrame. 6 https://bugs.webkit.org/show_bug.cgi?id=52895 7 8 This is the last step before eliminating SourceView and ScriptView since 9 this classes just delegate everything to SourceFrame. 10 11 * inspector/front-end/SourceFrame.js: 12 (WebInspector.SourceFrame.prototype.set visible): 13 (WebInspector.SourceFrame.prototype._clearLineHighlight): 14 (WebInspector.SourceFrame.prototype._createTextViewer): 15 (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches): 16 (WebInspector.SourceFrame.prototype.performSearch): 17 (WebInspector.SourceFrame.prototype.searchCanceled): 18 (WebInspector.SourceFrame.prototype.jumpToFirstSearchResult): 19 (WebInspector.SourceFrame.prototype.jumpToLastSearchResult): 20 (WebInspector.SourceFrame.prototype.jumpToNextSearchResult): 21 (WebInspector.SourceFrame.prototype.jumpToPreviousSearchResult): 22 (WebInspector.SourceFrame.prototype.showingFirstSearchResult): 23 (WebInspector.SourceFrame.prototype.showingLastSearchResult): 24 (WebInspector.SourceFrame.prototype._jumpToSearchResult): 25 * inspector/front-end/SourceView.js: 26 (WebInspector.SourceView.prototype.hide): 27 (WebInspector.SourceView.prototype.searchCanceled): 28 (WebInspector.SourceView.prototype.performSearch): 29 (WebInspector.SourceView.prototype.jumpToFirstSearchResult): 30 (WebInspector.SourceView.prototype.jumpToLastSearchResult): 31 (WebInspector.SourceView.prototype.jumpToNextSearchResult): 32 (WebInspector.SourceView.prototype.jumpToPreviousSearchResult): 33 (WebInspector.SourceView.prototype.showingFirstSearchResult): 34 (WebInspector.SourceView.prototype.showingLastSearchResult): 35 (WebInspector.SourceView.prototype.clearMessages): 36 1 37 2011-01-24 Sheriff Bot <webkit.review.bot@gmail.com> 2 38 -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r76341 r76488 65 65 } else { 66 66 this._hidePopup(); 67 this._clearLineHighlight(); 67 68 if (this._textViewer) { 68 69 this._scrollTop = this._textViewer.element.scrollTop; … … 145 146 }, 146 147 147 clearLineHighlight: function()148 _clearLineHighlight: function() 148 149 { 149 150 if (this._textViewer) … … 178 179 } 179 180 180 if (this._pendingMarkRange) {181 var range = this._pendingMarkRange;182 this.markAndRevealRange(range);183 delete this._pendingMarkRange;184 }185 186 181 if (this._lineToHighlight) { 187 182 this.highlightLine(this._lineToHighlight); … … 224 219 }, 225 220 226 findSearchMatches: function(query, finishedCallback) 227 { 228 function doFindSearchMatches() 221 performSearch: function(query, callback) 222 { 223 // Call searchCanceled since it will reset everything we need before doing a new search. 224 this.searchCanceled(); 225 226 function doFindSearchMatches(query) 229 227 { 230 var ranges = []; 228 this._currentSearchResultIndex = -1; 229 this._searchResults = []; 231 230 232 231 // First do case-insensitive search. 233 232 var regexObject = createSearchRegex(query); 234 this._collectRegexMatches(regexObject, ranges);233 this._collectRegexMatches(regexObject, this._searchResults); 235 234 236 235 // Then try regex search if user knows the / / hint. 237 236 try { 238 237 if (/^\/.*\/$/.test(query)) 239 this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges);238 this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), this._searchResults); 240 239 } catch (e) { 241 240 // Silent catch. 242 241 } 243 finishedCallback(ranges); 242 243 callback(this._searchResults.length); 244 244 } 245 245 246 246 if (this._textViewer) 247 doFindSearchMatches.call(this );247 doFindSearchMatches.call(this, query); 248 248 else 249 this._delayedFindSearchMatches = doFindSearchMatches.bind(this); 250 }, 251 252 cancelFindSearchMatches: function() 249 this._delayedFindSearchMatches = doFindSearchMatches.bind(this, query); 250 251 }, 252 253 searchCanceled: function() 253 254 { 254 255 delete this._delayedFindSearchMatches; 256 if (!this._textViewer) 257 return; 258 259 this._currentSearchResultIndex = -1; 260 this._searchResults = []; 261 this._textViewer.markAndRevealRange(null); 262 }, 263 264 jumpToFirstSearchResult: function() 265 { 266 this._jumpToSearchResult(0); 267 }, 268 269 jumpToLastSearchResult: function() 270 { 271 this._jumpToSearchResult(this._searchResults.length - 1); 272 }, 273 274 jumpToNextSearchResult: function() 275 { 276 this._jumpToSearchResult(this._currentSearchResultIndex + 1); 277 }, 278 279 jumpToPreviousSearchResult: function() 280 { 281 this._jumpToSearchResult(this._currentSearchResultIndex - 1); 282 }, 283 284 showingFirstSearchResult: function() 285 { 286 return this._searchResults.length && this._currentSearchResultIndex === 0; 287 }, 288 289 showingLastSearchResult: function() 290 { 291 return this._searchResults.length && this._currentSearchResultIndex === (this._searchResults.length - 1); 292 }, 293 294 _jumpToSearchResult: function(index) 295 { 296 if (!this._textViewer || !this._searchResults.length) 297 return; 298 this._currentSearchResultIndex = (index + this._searchResults.length) % this._searchResults.length; 299 this._textViewer.markAndRevealRange(this._searchResults[this._currentSearchResultIndex]); 255 300 }, 256 301 … … 270 315 } 271 316 return ranges; 272 },273 274 markAndRevealRange: function(range)275 {276 if (this._textViewer)277 this._textViewer.markAndRevealRange(range);278 else279 this._pendingMarkRange = range;280 },281 282 clearMarkedRange: function()283 {284 if (this._textViewer) {285 this._textViewer.markAndRevealRange(null);286 } else287 delete this._pendingMarkRange;288 317 }, 289 318 -
trunk/Source/WebCore/inspector/front-end/SourceView.js
r76341 r76488 48 48 { 49 49 this.sourceFrame.visible = false; 50 this.sourceFrame.clearLineHighlight();51 50 WebInspector.View.prototype.hide.call(this); 52 this._currentSearchResultIndex = -1;53 51 }, 54 52 … … 78 76 searchCanceled: function() 79 77 { 80 this._currentSearchResultIndex = -1; 81 this._searchResults = []; 82 this.sourceFrame.clearMarkedRange(); 83 this.sourceFrame.cancelFindSearchMatches(); 78 this.sourceFrame.searchCanceled(); 84 79 }, 85 80 86 81 performSearch: function(query, finishedCallback) 87 82 { 88 // Call searchCanceled since it will reset everything we need before doing a new search. 89 this.searchCanceled(); 90 91 function didFindSearchMatches(searchResults) 92 { 93 this._searchResults = searchResults; 94 if (this._searchResults) 95 finishedCallback(this, this._searchResults.length); 96 } 97 this.sourceFrame.findSearchMatches(query, didFindSearchMatches.bind(this)); 83 this.sourceFrame.performSearch(query, finishedCallback.bind(null, this)); 98 84 }, 99 85 100 86 jumpToFirstSearchResult: function() 101 87 { 102 if (!this._searchResults || !this._searchResults.length) 103 return; 104 this._currentSearchResultIndex = 0; 105 this._jumpToSearchResult(this._currentSearchResultIndex); 88 this.sourceFrame.jumpToFirstSearchResult(); 106 89 }, 107 90 108 91 jumpToLastSearchResult: function() 109 92 { 110 if (!this._searchResults || !this._searchResults.length) 111 return; 112 this._currentSearchResultIndex = (this._searchResults.length - 1); 113 this._jumpToSearchResult(this._currentSearchResultIndex); 93 this.sourceFrame.jumpToLastSearchResult(); 114 94 }, 115 95 116 96 jumpToNextSearchResult: function() 117 97 { 118 if (!this._searchResults || !this._searchResults.length) 119 return; 120 if (++this._currentSearchResultIndex >= this._searchResults.length) 121 this._currentSearchResultIndex = 0; 122 this._jumpToSearchResult(this._currentSearchResultIndex); 98 this.sourceFrame.jumpToNextSearchResult(); 123 99 }, 124 100 125 101 jumpToPreviousSearchResult: function() 126 102 { 127 if (!this._searchResults || !this._searchResults.length) 128 return; 129 if (--this._currentSearchResultIndex < 0) 130 this._currentSearchResultIndex = (this._searchResults.length - 1); 131 this._jumpToSearchResult(this._currentSearchResultIndex); 103 this.sourceFrame.jumpToPreviousSearchResult(); 132 104 }, 133 105 134 106 showingFirstSearchResult: function() 135 107 { 136 return (this._currentSearchResultIndex === 0);108 this.sourceFrame.showingFirstSearchResult(); 137 109 }, 138 110 139 111 showingLastSearchResult: function() 140 112 { 141 return (this._searchResults && this._currentSearchResultIndex === (this._searchResults.length - 1));113 this.sourceFrame.showingLastSearchResult(); 142 114 }, 143 115 … … 160 132 { 161 133 this.sourceFrame.clearMessages(); 162 },163 164 _jumpToSearchResult: function(index)165 {166 var foundRange = this._searchResults[index];167 if (!foundRange)168 return;169 170 this.sourceFrame.markAndRevealRange(foundRange);171 134 } 172 135 }
Note: See TracChangeset
for help on using the changeset viewer.