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 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 } | 951 } |
952 a.appendChild(toAppend); | 952 a.appendChild(toAppend); |
953 } | 953 } |
954 return a; | 954 return a; |
955 } | 955 } |
956 | 956 |
957 // String.format does treat formattedResult like a Builder, result is an
object. | 957 // String.format does treat formattedResult like a Builder, result is an
object. |
958 return String.format(format, parameters, formatters, formattedResult, ap
pend); | 958 return String.format(format, parameters, formatters, formattedResult, ap
pend); |
959 }, | 959 }, |
960 | 960 |
961 clearHighlight: function() | 961 clearHighlights: function() |
962 { | 962 { |
963 if (!this._formattedMessage) | 963 if (!this._formattedMessage) |
964 return; | 964 return; |
965 | 965 |
966 WebInspector.removeSearchResultsHighlight(this._formattedMessage); | 966 WebInspector.removeSearchResultsHighlight(this._formattedMessage, WebIns
pector.highlightedSearchResultClassName); |
967 }, | |
968 | |
969 highlightSearchResults: function(regexObject) | |
970 { | |
971 if (!this._formattedMessage) | |
972 return; | |
973 | |
974 this._highlightSearchResultsInElement(regexObject, this._messageElement)
; | |
975 if (this._anchorElement) | |
976 this._highlightSearchResultsInElement(regexObject, this._anchorEleme
nt); | |
977 }, | 967 }, |
978 | 968 |
979 _highlightSearchResultsInElement: function(regexObject, element) | 969 _highlightSearchResultsInElement: function(regexObject, element) |
980 { | 970 { |
981 regexObject.lastIndex = 0; | 971 regexObject.lastIndex = 0; |
982 var text = element.textContent; | 972 var text = element.textContent; |
983 var match = regexObject.exec(text); | 973 var match = regexObject.exec(text); |
984 var matchRanges = []; | 974 var matchRanges = []; |
985 while (match) { | 975 while (match) { |
986 matchRanges.push(new WebInspector.SourceRange(match.index, match[0].
length)); | 976 matchRanges.push(new WebInspector.SourceRange(match.index, match[0].
length)); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 | 1273 |
1284 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; | 1274 return sourceString + " " + typeString + " " + levelString + ": " + this
.formattedMessage().textContent + "\n" + this._message.url + " line " + this._me
ssage.line; |
1285 }, | 1275 }, |
1286 | 1276 |
1287 get text() | 1277 get text() |
1288 { | 1278 { |
1289 return this._message.messageText; | 1279 return this._message.messageText; |
1290 }, | 1280 }, |
1291 | 1281 |
1292 /** | 1282 /** |
| 1283 * @return {string} |
| 1284 */ |
| 1285 renderedText: function () |
| 1286 { |
| 1287 if (!this._messageElement) |
| 1288 return ""; |
| 1289 return this._messageElement.textContent; |
| 1290 }, |
| 1291 |
| 1292 /** |
| 1293 * @param {!Array.<!Object>} ranges |
| 1294 * @return {!Array.<!Element>} |
| 1295 */ |
| 1296 highlightMatches: function(ranges) |
| 1297 { |
| 1298 var highlightNodes = []; |
| 1299 if (this._formattedMessage) |
| 1300 highlightNodes = WebInspector.highlightSearchResults(this._messageEl
ement, ranges); |
| 1301 return highlightNodes; |
| 1302 }, |
| 1303 |
| 1304 /** |
1293 * @param {string} string | 1305 * @param {string} string |
1294 * @return {?Element} | 1306 * @return {?Element} |
1295 */ | 1307 */ |
1296 _tryFormatAsError: function(string) | 1308 _tryFormatAsError: function(string) |
1297 { | 1309 { |
1298 var errorPrefixes = ["EvalError", "ReferenceError", "SyntaxError", "Type
Error", "RangeError", "Error", "URIError"]; | 1310 var errorPrefixes = ["EvalError", "ReferenceError", "SyntaxError", "Type
Error", "RangeError", "Error", "URIError"]; |
1299 var target = this._target(); | 1311 var target = this._target(); |
1300 if (!target || !errorPrefixes.some(String.prototype.startsWith.bind(new
String(string)))) | 1312 if (!target || !errorPrefixes.some(String.prototype.startsWith.bind(new
String(string)))) |
1301 return null; | 1313 return null; |
1302 | 1314 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 { | 1412 { |
1401 if (!this._wrapperElement) { | 1413 if (!this._wrapperElement) { |
1402 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1414 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1403 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1415 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1404 } | 1416 } |
1405 return this._wrapperElement; | 1417 return this._wrapperElement; |
1406 }, | 1418 }, |
1407 | 1419 |
1408 __proto__: WebInspector.ConsoleViewMessage.prototype | 1420 __proto__: WebInspector.ConsoleViewMessage.prototype |
1409 } | 1421 } |
OLD | NEW |