| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.TargetAwareObject} |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 35 */ | 35 */ |
| 36 WebInspector.ConsoleModel = function(target) | 36 WebInspector.ConsoleModel = function(target) |
| 37 { | 37 { |
| 38 WebInspector.TargetAwareObject.call(this, target); |
| 39 |
| 38 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ | 40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ |
| 39 this.messages = []; | 41 this.messages = []; |
| 40 this.warnings = 0; | 42 this.warnings = 0; |
| 41 this.errors = 0; | 43 this.errors = 0; |
| 42 this._target = target; | |
| 43 this._consoleAgent = target.consoleAgent(); | 44 this._consoleAgent = target.consoleAgent(); |
| 44 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); | 45 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); |
| 45 this._enableAgent(); | 46 this._enableAgent(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebInspector.ConsoleModel.Events = { | 49 WebInspector.ConsoleModel.Events = { |
| 49 ConsoleCleared: "ConsoleCleared", | 50 ConsoleCleared: "ConsoleCleared", |
| 50 MessageAdded: "MessageAdded", | 51 MessageAdded: "MessageAdded", |
| 51 CommandEvaluated: "CommandEvaluated", | 52 CommandEvaluated: "CommandEvaluated", |
| 52 } | 53 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 * @param {?RuntimeAgent.RemoteObject=} valueResult | 111 * @param {?RuntimeAgent.RemoteObject=} valueResult |
| 111 * @this {WebInspector.ConsoleModel} | 112 * @this {WebInspector.ConsoleModel} |
| 112 */ | 113 */ |
| 113 function printResult(result, wasThrown, valueResult) | 114 function printResult(result, wasThrown, valueResult) |
| 114 { | 115 { |
| 115 if (!result) | 116 if (!result) |
| 116 return; | 117 return; |
| 117 | 118 |
| 118 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Comma
ndEvaluated, {result: result, wasThrown: wasThrown, text: text, commandMessage:
commandMessage}); | 119 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Comma
ndEvaluated, {result: result, wasThrown: wasThrown, text: text, commandMessage:
commandMessage}); |
| 119 } | 120 } |
| 120 this._target.runtimeModel.evaluate(text, "console", useCommandLineAPI, f
alse, false, true, printResult.bind(this)); | 121 this.target().runtimeModel.evaluate(text, "console", useCommandLineAPI,
false, false, true, printResult.bind(this)); |
| 121 | 122 |
| 122 WebInspector.userMetrics.ConsoleEvaluated.record(); | 123 WebInspector.userMetrics.ConsoleEvaluated.record(); |
| 123 }, | 124 }, |
| 124 | 125 |
| 125 show: function() | 126 show: function() |
| 126 { | 127 { |
| 127 WebInspector.Revealer.reveal(this); | 128 WebInspector.Revealer.reveal(this); |
| 128 }, | 129 }, |
| 129 | 130 |
| 130 /** | 131 /** |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 | 184 |
| 184 clearMessages: function() | 185 clearMessages: function() |
| 185 { | 186 { |
| 186 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); | 187 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); |
| 187 | 188 |
| 188 this.messages = []; | 189 this.messages = []; |
| 189 this.errors = 0; | 190 this.errors = 0; |
| 190 this.warnings = 0; | 191 this.warnings = 0; |
| 191 }, | 192 }, |
| 192 | 193 |
| 193 __proto__: WebInspector.Object.prototype | 194 __proto__: WebInspector.TargetAwareObject.prototype |
| 194 } | 195 } |
| 195 | 196 |
| 196 /** | 197 /** |
| 197 * @constructor | 198 * @constructor |
| 198 * @param {string} source | 199 * @param {string} source |
| 199 * @param {?string} level | 200 * @param {?string} level |
| 200 * @param {string} messageText | 201 * @param {string} messageText |
| 201 * @param {string=} type | 202 * @param {string=} type |
| 202 * @param {?string=} url | 203 * @param {?string=} url |
| 203 * @param {number=} line | 204 * @param {number=} line |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 { | 402 { |
| 402 if (!WebInspector.settings.preserveConsoleLog.get()) | 403 if (!WebInspector.settings.preserveConsoleLog.get()) |
| 403 this._console.clearMessages(); | 404 this._console.clearMessages(); |
| 404 } | 405 } |
| 405 } | 406 } |
| 406 | 407 |
| 407 /** | 408 /** |
| 408 * @type {!WebInspector.ConsoleModel} | 409 * @type {!WebInspector.ConsoleModel} |
| 409 */ | 410 */ |
| 410 WebInspector.console; | 411 WebInspector.console; |
| OLD | NEW |