Changeset 86539 in webkit
- Timestamp:
- May 16, 2011 12:30:04 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r86537 r86539 1 2011-05-12 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: inspector console should be searchable 6 https://bugs.webkit.org/show_bug.cgi?id=60711 7 8 Search now works for Console panel. It shows number of matching console entries 9 and allows to jump to the next matching console entry. Also the matches count 10 is dynamically updated when new messages are added to the console. 11 12 ResourceTreeModel and DebuggerPresentationModel now listen to console events instead 13 of being called directly from ConsoleView. 14 15 * inspector/front-end/ConsolePanel.js: 16 (WebInspector.ConsolePanel): 17 (WebInspector.ConsolePanel.prototype.show): 18 (WebInspector.ConsolePanel.prototype.hide): 19 (WebInspector.ConsolePanel.prototype.searchCanceled): 20 (WebInspector.ConsolePanel.prototype.performSearch): 21 (WebInspector.ConsolePanel.prototype.jumpToNextSearchResult): 22 (WebInspector.ConsolePanel.prototype.jumpToPreviousSearchResult): 23 (WebInspector.ConsolePanel.prototype._clearCurrentSearchResultHighlight): 24 (WebInspector.ConsolePanel.prototype._jumpToSearchResult): 25 (WebInspector.ConsolePanel.prototype._consoleMessageAdded): 26 (WebInspector.ConsolePanel.prototype._consoleCleared): 27 * inspector/front-end/ConsoleView.js: 28 (WebInspector.ConsoleView.prototype.addMessage): 29 (WebInspector.ConsoleView.prototype.clearMessages): 30 (WebInspector.ConsoleMessage.prototype.clearHighlight): 31 (WebInspector.ConsoleMessage.prototype.highlightSearchResults): 32 (WebInspector.ConsoleMessage.prototype.matchesRegex): 33 (WebInspector.ConsoleMessage.prototype.toMessageElement): 34 (WebInspector.ConsoleCommand.prototype.clearHighlight): 35 (WebInspector.ConsoleCommand.prototype.highlightSearchResults): 36 (WebInspector.ConsoleCommand.prototype.matchesRegex): 37 (WebInspector.ConsoleCommand.prototype.toMessageElement): 38 (WebInspector.ConsoleCommand.prototype._formatCommand): 39 * inspector/front-end/DebuggerPresentationModel.js: 40 (WebInspector.DebuggerPresentationModel): 41 (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles): 42 (WebInspector.DebuggerPresentationModel.prototype._consoleMessageAdded): 43 (WebInspector.DebuggerPresentationModel.prototype._consoleCleared): 44 * inspector/front-end/ResourceTreeModel.js: 45 (WebInspector.ResourceTreeModel): 46 (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded): 47 * inspector/front-end/ScriptsPanel.js: 48 (WebInspector.ScriptsPanel): 49 (WebInspector.ScriptsPanel.prototype._consoleMessagesCleared): 50 * inspector/front-end/utilities.js: 51 (): 52 1 53 2011-05-16 Adam Barth <abarth@webkit.org> 2 54 -
trunk/Source/WebCore/inspector/front-end/ConsolePanel.js
r62647 r86539 30 30 { 31 31 WebInspector.Panel.call(this, "console"); 32 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.EntryAdded, this._consoleMessageAdded, this); 33 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.ConsoleCleared, this._consoleCleared, this); 32 34 } 33 35 … … 45 47 WebInspector.drawer.enterPanelMode(); 46 48 WebInspector.showConsole(); 47 49 48 50 // Move the scope bar to the top of the messages, like the resources filter. 49 51 var scopeBar = document.getElementById("console-filter"); … … 52 54 scopeBar.parentNode.removeChild(scopeBar); 53 55 document.getElementById("console-view").insertBefore(scopeBar, consoleMessages); 54 56 55 57 // Update styles, and give console-messages a top margin so it doesn't overwrite the scope bar. 56 58 scopeBar.addStyleClass("console-filter-top"); … … 69 71 WebInspector.drawer.exitPanelMode(); 70 72 delete this._previousConsoleState; 71 73 72 74 // Move the scope bar back to the bottom bar, next to Clear Console. 73 75 var scopeBar = document.getElementById("console-filter"); … … 75 77 scopeBar.parentNode.removeChild(scopeBar); 76 78 document.getElementById("other-drawer-status-bar-items").appendChild(scopeBar); 77 79 78 80 // Update styles, and remove the top margin on console-messages. 79 81 scopeBar.removeStyleClass("console-filter-top"); … … 81 83 82 84 document.getElementById("console-messages").removeStyleClass("console-filter-top"); 85 }, 86 87 searchCanceled: function() 88 { 89 this._clearCurrentSearchResultHighlight(); 90 delete this._searchResults; 91 delete this._searchRegex; 92 }, 93 94 performSearch: function(query) 95 { 96 WebInspector.searchController.updateSearchMatchesCount(0, this); 97 this.searchCanceled(); 98 this._searchRegex = createSearchRegex(query, "g"); 99 100 this._searchResults = []; 101 var messages = WebInspector.console.messages; 102 for (var i = 0; i < messages.length; i++) { 103 if (messages[i].matchesRegex(this._searchRegex)) { 104 this._searchResults.push(messages[i]); 105 this._searchRegex.lastIndex = 0; 106 } 107 } 108 WebInspector.searchController.updateSearchMatchesCount(this._searchResults.length, this); 109 this._currentSearchResultIndex = -1; 110 if (this._searchResults.length) 111 this._jumpToSearchResult(0); 112 }, 113 114 jumpToNextSearchResult: function() 115 { 116 if (!this._searchResults || !this._searchResults.length) 117 return; 118 this._jumpToSearchResult((this._currentSearchResultIndex + 1) % this._searchResults.length); 119 }, 120 121 jumpToPreviousSearchResult: function() 122 { 123 if (!this._searchResults || !this._searchResults.length) 124 return; 125 var index = this._currentSearchResultIndex - 1; 126 if (index === -1) 127 index = this._searchResults.length - 1; 128 this._jumpToSearchResult(index); 129 }, 130 131 _clearCurrentSearchResultHighlight: function() 132 { 133 if (!this._searchResults) 134 return; 135 var highlightedMessage = this._searchResults[this._currentSearchResultIndex]; 136 if (highlightedMessage) 137 highlightedMessage.clearHighlight(); 138 this._currentSearchResultIndex = -1; 139 }, 140 141 _jumpToSearchResult: function(index) 142 { 143 this._clearCurrentSearchResultHighlight(); 144 this._currentSearchResultIndex = index; 145 this._searchResults[index].highlightSearchResults(this._searchRegex); 146 }, 147 148 _consoleMessageAdded: function(event) 149 { 150 if (!this._searchRegex || !this.visible) 151 return; 152 var message = event.data; 153 this._searchRegex.lastIndex = 0; 154 if (message.matchesRegex(this._searchRegex)) { 155 this._searchResults.push(message); 156 WebInspector.searchController.updateSearchMatchesCount(this._searchResults.length, this); 157 } 158 }, 159 160 _consoleCleared: function() 161 { 162 if (!this._searchResults) 163 return; 164 this._clearCurrentSearchResultHighlight(); 165 this._searchResults.length = 0; 166 if (this.visible) 167 WebInspector.searchController.updateSearchMatchesCount(0, this); 83 168 } 84 169 } -
trunk/Source/WebCore/inspector/front-end/ConsoleView.js
r85319 r86539 102 102 } 103 103 104 WebInspector.ConsoleView.Events = { 105 ConsoleCleared: "console-cleared", 106 EntryAdded: "console-entry-added", 107 MessageAdded: "console-message-added" 108 } 109 104 110 WebInspector.ConsoleView.prototype = { 105 111 _registerConsoleDomainDispatcher: function() { … … 275 281 if (msg instanceof WebInspector.ConsoleMessage && !(msg instanceof WebInspector.ConsoleCommandResult)) { 276 282 this._incrementErrorWarningCount(msg); 277 WebInspector.resourceTreeModel.addConsoleMessage(msg); 278 WebInspector.panels.scripts.addConsoleMessage(msg); 283 this.dispatchEventToListeners(WebInspector.ConsoleView.Events.MessageAdded, msg); 279 284 this.commandSincePreviousMessage = false; 280 285 this.previousMessage = msg; … … 304 309 if (shouldScrollToLastMessage || (msg instanceof WebInspector.ConsoleCommandResult)) 305 310 this._scheduleScrollIntoView(); 311 312 this.dispatchEventToListeners(WebInspector.ConsoleView.Events.EntryAdded, msg); 306 313 }, 307 314 … … 325 332 clearMessages: function() 326 333 { 327 WebInspector.resourceTreeModel.clearConsoleMessages(); 328 WebInspector.panels.scripts.clearConsoleMessages(); 334 this.dispatchEventToListeners(WebInspector.ConsoleView.Events.ConsoleCleared); 329 335 330 336 this.messages = []; … … 866 872 }, 867 873 874 clearHighlight: function() 875 { 876 var highlightedMessage = this._formattedMessage; 877 delete this._formattedMessage; 878 this._formatMessage(); 879 this._element.replaceChild(this._formattedMessage, highlightedMessage); 880 }, 881 882 highlightSearchResults: function(regexObject) 883 { 884 regexObject.lastIndex = 0; 885 var text = this.message; 886 var match = regexObject.exec(text); 887 var offset = 0; 888 var matchRanges = []; 889 while (match) { 890 matchRanges.push({ offset: match.index, length: match[0].length }); 891 match = regexObject.exec(text); 892 } 893 highlightSearchResults(this._formattedMessage, matchRanges); 894 this._element.scrollIntoViewIfNeeded(); 895 }, 896 897 matchesRegex: function(regexObject) 898 { 899 return regexObject.test(this.message); 900 }, 901 868 902 toMessageElement: function() 869 903 { … … 897 931 if (this.type === WebInspector.ConsoleMessage.MessageType.StartGroup || this.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed) 898 932 element.addStyleClass("console-group-title"); 899 900 if (this.elementsTreeOutline) {901 element.addStyleClass("outline-disclosure");902 element.appendChild(this.elementsTreeOutline.element);903 return element;904 }905 933 906 934 element.appendChild(this._formattedMessage); … … 1079 1107 1080 1108 WebInspector.ConsoleCommand.prototype = { 1109 clearHighlight: function() 1110 { 1111 var highlightedMessage = this._formattedCommand; 1112 delete this._formattedCommand; 1113 this._formatCommand(); 1114 this._element.replaceChild(this._formattedCommand, highlightedMessage); 1115 }, 1116 1117 highlightSearchResults: function(regexObject) 1118 { 1119 regexObject.lastIndex = 0; 1120 var text = this.command; 1121 var match = regexObject.exec(text); 1122 var offset = 0; 1123 var matchRanges = []; 1124 while (match) { 1125 matchRanges.push({ offset: match.index, length: match[0].length }); 1126 match = regexObject.exec(text); 1127 } 1128 highlightSearchResults(this._formattedCommand, matchRanges); 1129 this._element.scrollIntoViewIfNeeded(); 1130 }, 1131 1132 matchesRegex: function(regexObject) 1133 { 1134 return regexObject.test(this.command); 1135 }, 1136 1081 1137 toMessageElement: function() 1082 1138 { 1083 var element = document.createElement("div"); 1084 element.command = this; 1085 element.className = "console-user-command"; 1086 1087 var commandTextElement = document.createElement("span"); 1088 commandTextElement.className = "console-message-text source-code"; 1089 commandTextElement.textContent = this.command; 1090 element.appendChild(commandTextElement); 1091 1092 return element; 1093 } 1139 if (!this._element) { 1140 this._element = document.createElement("div"); 1141 this._element.command = this; 1142 this._element.className = "console-user-command"; 1143 1144 this._formatCommand(); 1145 this._element.appendChild(this._formattedCommand); 1146 } 1147 return this._element; 1148 }, 1149 1150 _formatCommand: function() 1151 { 1152 this._formattedCommand = document.createElement("span"); 1153 this._formattedCommand.className = "console-message-text source-code"; 1154 this._formattedCommand.textContent = this.command; 1155 }, 1094 1156 } 1095 1157 -
trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js
r85321 r86539 47 47 WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.Reset, this._debuggerReset, this); 48 48 49 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.MessageAdded, this._consoleMessageAdded, this); 50 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.ConsoleCleared, this._consoleCleared, this); 51 49 52 new WebInspector.DebuggerPresentationModelResourceBinding(this); 50 53 } … … 54 57 SourceFileChanged: "source-file-changed", 55 58 ConsoleMessageAdded: "console-message-added", 59 ConsoleMessagesCleared: "console-messages-cleared", 56 60 BreakpointAdded: "breakpoint-added", 57 61 BreakpointRemoved: "breakpoint-removed", … … 225 229 226 230 for (var i = 0; i < messages.length; ++i) 227 this. addConsoleMessage(messages[i]);231 this._addConsoleMessage(messages[i]); 228 232 229 233 if (WebInspector.debuggerModel.callFrames) … … 238 242 }, 239 243 240 addConsoleMessage: function(message) 244 _consoleMessageAdded: function(event) 245 { 246 var message = event.data; 247 if (message.isErrorOrWarning() && message.message) 248 this._addConsoleMessage(message); 249 }, 250 251 _addConsoleMessage: function(message) 241 252 { 242 253 this._messages.push(message); … … 258 269 }, 259 270 260 clearConsoleMessages: function()271 _consoleCleared: function() 261 272 { 262 273 this._messages = []; 263 274 for (var id in this._sourceFiles) 264 275 this._sourceFiles[id].messages = []; 276 this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared); 265 277 }, 266 278 -
trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js
r85591 r86539 36 36 WebInspector.networkManager.addEventListener(WebInspector.NetworkManager.EventTypes.ResourceFinished, this._onResourceUpdated, this); 37 37 38 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.MessageAdded, this._consoleMessageAdded, this); 39 WebInspector.console.addEventListener(WebInspector.ConsoleView.Events.ConsoleCleared, this._consoleCleared, this); 40 38 41 this.frontendReused(); 39 42 InspectorBackend.registerDomainDispatcher("Page", new WebInspector.PageDispatcher(this)); … … 213 216 }, 214 217 215 addConsoleMessage: function(msg) 216 { 218 _consoleMessageAdded: function(event) 219 { 220 var msg = event.data; 217 221 var resource = this.resourceForURL(msg.url); 218 222 if (!resource) … … 233 237 }, 234 238 235 clearConsoleMessages: function()239 _consoleCleared: function() 236 240 { 237 241 function callback(resource) -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r85321 r86539 188 188 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.SourceFileChanged, this._sourceFileChanged, this); 189 189 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, this._consoleMessageAdded, this); 190 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this); 190 191 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, this._breakpointAdded, this); 191 192 this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, this._breakpointRemoved, this); … … 332 333 }, 333 334 334 addConsoleMessage: function(message) 335 { 336 if (message.isErrorOrWarning() && message.message) 337 this._presentationModel.addConsoleMessage(message); 338 }, 339 340 clearConsoleMessages: function() 341 { 342 this._presentationModel.clearConsoleMessages(); 335 _consoleMessagesCleared: function() 336 { 343 337 for (var sourceFileId in this._sourceFileIdToSourceFrame) 344 338 this._sourceFileIdToSourceFrame[sourceFileId].clearMessages(); -
trunk/Source/WebCore/inspector/front-end/utilities.js
r85751 r86539 976 976 textNode = textNodeSnapshot.snapshotItem(currentSnapshotItem++); 977 977 var textNodeLength = textNode.nodeValue.length; 978 if (snapshotNodeOffset + textNodeLength > =startOffset) {978 if (snapshotNodeOffset + textNodeLength > startOffset) { 979 979 textNodeOffset = startOffset - snapshotNodeOffset; 980 980 snapshotNodeOffset += textNodeLength;
Note: See TracChangeset
for help on using the changeset viewer.