OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 } | 945 } |
946 a.appendChild(toAppend); | 946 a.appendChild(toAppend); |
947 } | 947 } |
948 return a; | 948 return a; |
949 } | 949 } |
950 | 950 |
951 // String.format does treat formattedResult like a Builder, result is an
object. | 951 // String.format does treat formattedResult like a Builder, result is an
object. |
952 return String.format(format, parameters, formatters, formattedResult, ap
pend); | 952 return String.format(format, parameters, formatters, formattedResult, ap
pend); |
953 }, | 953 }, |
954 | 954 |
955 clearHighlight: function() | 955 clearHighlights: function() |
956 { | 956 { |
957 if (!this._formattedMessage) | 957 if (!this._formattedMessage) |
958 return; | 958 return; |
959 | 959 |
960 WebInspector.removeSearchResultsHighlight(this._formattedMessage); | 960 WebInspector.removeSearchResultsHighlight(this._formattedMessage, WebIns
pector.highlightedSearchResultClassName); |
961 }, | |
962 | |
963 highlightSearchResults: function(regexObject) | |
964 { | |
965 if (!this._formattedMessage) | |
966 return; | |
967 | |
968 this._highlightSearchResultsInElement(regexObject, this._messageElement)
; | |
969 if (this._anchorElement) | |
970 this._highlightSearchResultsInElement(regexObject, this._anchorEleme
nt); | |
971 }, | 961 }, |
972 | 962 |
973 _highlightSearchResultsInElement: function(regexObject, element) | 963 _highlightSearchResultsInElement: function(regexObject, element) |
974 { | 964 { |
975 regexObject.lastIndex = 0; | 965 regexObject.lastIndex = 0; |
976 var text = element.textContent; | 966 var text = element.textContent; |
977 var match = regexObject.exec(text); | 967 var match = regexObject.exec(text); |
978 var matchRanges = []; | 968 var matchRanges = []; |
979 while (match) { | 969 while (match) { |
980 matchRanges.push(new WebInspector.SourceRange(match.index, match[0].
length)); | 970 matchRanges.push(new WebInspector.SourceRange(match.index, match[0].
length)); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 | 1267 |
1278 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; | 1268 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; |
1279 }, | 1269 }, |
1280 | 1270 |
1281 get text() | 1271 get text() |
1282 { | 1272 { |
1283 return this._message.messageText; | 1273 return this._message.messageText; |
1284 }, | 1274 }, |
1285 | 1275 |
1286 /** | 1276 /** |
| 1277 * @return {string} |
| 1278 */ |
| 1279 renderedText: function () |
| 1280 { |
| 1281 if (!this._messageElement) |
| 1282 return ""; |
| 1283 return this._messageElement.textContent; |
| 1284 }, |
| 1285 |
| 1286 /** |
| 1287 * @param {!Array.<!Object>} ranges |
| 1288 * @return {!Array.<!Element>} |
| 1289 */ |
| 1290 highlightMatches: function(ranges) |
| 1291 { |
| 1292 var highlightNodes = []; |
| 1293 if (this._formattedMessage) |
| 1294 highlightNodes = WebInspector.highlightSearchResults(this._messageEl
ement, ranges); |
| 1295 return highlightNodes; |
| 1296 }, |
| 1297 |
| 1298 /** |
1287 * @param {string} string | 1299 * @param {string} string |
1288 * @return {?Element} | 1300 * @return {?Element} |
1289 */ | 1301 */ |
1290 _tryFormatAsError: function(string) | 1302 _tryFormatAsError: function(string) |
1291 { | 1303 { |
1292 var errorPrefixes = ["EvalError", "ReferenceError", "SyntaxError", "Type
Error", "RangeError", "Error", "URIError"]; | 1304 var errorPrefixes = ["EvalError", "ReferenceError", "SyntaxError", "Type
Error", "RangeError", "Error", "URIError"]; |
1293 var target = this._target(); | 1305 var target = this._target(); |
1294 if (!target || !errorPrefixes.some(String.prototype.startsWith.bind(new
String(string)))) | 1306 if (!target || !errorPrefixes.some(String.prototype.startsWith.bind(new
String(string)))) |
1295 return null; | 1307 return null; |
1296 | 1308 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 { | 1406 { |
1395 if (!this._wrapperElement) { | 1407 if (!this._wrapperElement) { |
1396 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1408 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1397 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1409 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1398 } | 1410 } |
1399 return this._wrapperElement; | 1411 return this._wrapperElement; |
1400 }, | 1412 }, |
1401 | 1413 |
1402 __proto__: WebInspector.ConsoleViewMessage.prototype | 1414 __proto__: WebInspector.ConsoleViewMessage.prototype |
1403 } | 1415 } |
OLD | NEW |