Commit 89d016a1 authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Get rid of WebInspector.ConsoleModel.UIDelegate

BUG=

Review URL: https://codereview.chromium.org/206253005

git-svn-id: svn://svn.chromium.org/blink/trunk@169667 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 21dca92f
...@@ -35,7 +35,7 @@ function test() ...@@ -35,7 +35,7 @@ function test()
InspectorTest.runTestSuite([ InspectorTest.runTestSuite([
function testRevealElement(next) function testRevealElement(next)
{ {
InspectorTest.addSniffer(WebInspector.Revealer, "reveal", step2); InspectorTest.addSniffer(WebInspector.Revealer, "reveal", step2, true);
evalAndDump("inspect($('#p1'))"); evalAndDump("inspect($('#p1'))");
function step2(node) function step2(node)
......
...@@ -12,7 +12,7 @@ function testFunction() ...@@ -12,7 +12,7 @@ function testFunction()
var test = function() var test = function()
{ {
InspectorTest.addSniffer(WebInspector.Main.prototype, "inspect", inspect); InspectorTest.addSniffer(WebInspector.Main.prototype, "inspect", inspect);
InspectorTest.addSniffer(WebInspector.Revealer, "reveal", updateFocusedNode); InspectorTest.addSniffer(WebInspector.Revealer, "reveal", updateFocusedNode, true);
function updateFocusedNode(node) function updateFocusedNode(node)
{ {
......
...@@ -46,9 +46,10 @@ WebInspector.ConsoleModel = function(target) ...@@ -46,9 +46,10 @@ WebInspector.ConsoleModel = function(target)
} }
WebInspector.ConsoleModel.Events = { WebInspector.ConsoleModel.Events = {
ConsoleCleared: "console-cleared", ConsoleCleared: "ConsoleCleared",
MessageAdded: "console-message-added", MessageAdded: "MessageAdded",
RepeatCountUpdated: "repeat-count-updated" RepeatCountUpdated: "RepeatCountUpdated",
CommandEvaluated: "CommandEvaluated",
} }
WebInspector.ConsoleModel.prototype = { WebInspector.ConsoleModel.prototype = {
...@@ -77,14 +78,6 @@ WebInspector.ConsoleModel.prototype = { ...@@ -77,14 +78,6 @@ WebInspector.ConsoleModel.prototype = {
return !!this._enablingConsole; return !!this._enablingConsole;
}, },
/**
* @param {!WebInspector.ConsoleModel.UIDelegate} delegate
*/
setUIDelegate: function(delegate)
{
this._uiDelegate = delegate;
},
/** /**
* @param {!WebInspector.ConsoleMessage} msg * @param {!WebInspector.ConsoleMessage} msg
* @param {boolean=} isFromBackend * @param {boolean=} isFromBackend
...@@ -108,20 +101,15 @@ WebInspector.ConsoleModel.prototype = { ...@@ -108,20 +101,15 @@ WebInspector.ConsoleModel.prototype = {
/** /**
* @param {string} text * @param {string} text
* @param {?string} newPromptText
* @param {boolean} useCommandLineAPI * @param {boolean} useCommandLineAPI
*/ */
evaluateCommand: function(text, newPromptText, useCommandLineAPI) evaluateCommand: function(text, useCommandLineAPI)
{ {
if (!this._uiDelegate) this.show();
this.show();
var commandMessage = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageType.Command); var commandMessage = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageType.Command);
this.addMessage(commandMessage); this.addMessage(commandMessage);
if (newPromptText !== null)
this._uiDelegate.setPromptText(newPromptText);
/** /**
* @param {?WebInspector.RemoteObject} result * @param {?WebInspector.RemoteObject} result
* @param {boolean} wasThrown * @param {boolean} wasThrown
...@@ -133,7 +121,7 @@ WebInspector.ConsoleModel.prototype = { ...@@ -133,7 +121,7 @@ WebInspector.ConsoleModel.prototype = {
if (!result) if (!result)
return; return;
this._uiDelegate.printEvaluationResult(result, wasThrown, text, commandMessage); this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEvaluated, {result: result, wasThrown: wasThrown, text: text, commandMessage: commandMessage});
} }
this._target.runtimeModel.evaluate(text, "console", useCommandLineAPI, false, false, true, printResult.bind(this)); this._target.runtimeModel.evaluate(text, "console", useCommandLineAPI, false, false, true, printResult.bind(this));
...@@ -150,7 +138,7 @@ WebInspector.ConsoleModel.prototype = { ...@@ -150,7 +138,7 @@ WebInspector.ConsoleModel.prototype = {
*/ */
evaluate: function(expression) evaluate: function(expression)
{ {
this.evaluateCommand(expression, null, false); this.evaluateCommand(expression, false);
}, },
/** /**
...@@ -240,26 +228,6 @@ WebInspector.ConsoleModel.prototype = { ...@@ -240,26 +228,6 @@ WebInspector.ConsoleModel.prototype = {
__proto__: WebInspector.Object.prototype __proto__: WebInspector.Object.prototype
} }
/**
* @interface
*/
WebInspector.ConsoleModel.UIDelegate = function() { }
WebInspector.ConsoleModel.UIDelegate.prototype = {
/**
* @param {string} text
*/
setPromptText: function(text) { },
/**
* @param {?WebInspector.RemoteObject} result
* @param {boolean} wasThrown
* @param {string} promptText
* @param {!WebInspector.ConsoleMessage} commandMessage
*/
printEvaluationResult: function(result, wasThrown, promptText, commandMessage) { }
}
/** /**
* @constructor * @constructor
* @param {string} source * @param {string} source
......
...@@ -44,10 +44,9 @@ WebInspector.ConsolePanel = function() ...@@ -44,10 +44,9 @@ WebInspector.ConsolePanel = function()
*/ */
WebInspector.ConsolePanel._view = function() WebInspector.ConsolePanel._view = function()
{ {
if (!WebInspector.ConsolePanel._consoleView) { if (!WebInspector.ConsolePanel._consoleView)
WebInspector.ConsolePanel._consoleView = new WebInspector.ConsoleView(!Capabilities.isMainFrontend); WebInspector.ConsolePanel._consoleView = new WebInspector.ConsoleView(!Capabilities.isMainFrontend);
WebInspector.console.setUIDelegate(WebInspector.ConsolePanel._consoleView);
}
return WebInspector.ConsolePanel._consoleView; return WebInspector.ConsolePanel._consoleView;
} }
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
/** /**
* @extends {WebInspector.VBox} * @extends {WebInspector.VBox}
* @implements {WebInspector.ConsoleModel.UIDelegate}
* @implements {WebInspector.Searchable} * @implements {WebInspector.Searchable}
* @constructor * @constructor
* @param {boolean} hideContextSelector * @param {boolean} hideContextSelector
...@@ -101,6 +100,7 @@ WebInspector.ConsoleView = function(hideContextSelector) ...@@ -101,6 +100,7 @@ WebInspector.ConsoleView = function(hideContextSelector)
WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this); WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this);
WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this); WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._repeatCountUpdated, this); WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._repeatCountUpdated, this);
WebInspector.console.addEventListener(WebInspector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this);
this._linkifier = new WebInspector.Linkifier(); this._linkifier = new WebInspector.Linkifier();
...@@ -670,7 +670,7 @@ WebInspector.ConsoleView.prototype = { ...@@ -670,7 +670,7 @@ WebInspector.ConsoleView.prototype = {
var str = this.prompt.text; var str = this.prompt.text;
if (!str.length) if (!str.length)
return; return;
this._appendCommand(str, "", true); this._appendCommand(str, true);
}, },
/** /**
...@@ -731,35 +731,23 @@ WebInspector.ConsoleView.prototype = { ...@@ -731,35 +731,23 @@ WebInspector.ConsoleView.prototype = {
/** /**
* @param {string} text * @param {string} text
* @param {string} newPromptText
* @param {boolean} useCommandLineAPI * @param {boolean} useCommandLineAPI
*/ */
_appendCommand: function(text, newPromptText, useCommandLineAPI) _appendCommand: function(text, useCommandLineAPI)
{ {
WebInspector.console.evaluateCommand(text, newPromptText, useCommandLineAPI); this.prompt.text = "";
WebInspector.console.evaluateCommand(text, useCommandLineAPI);
}, },
/** /**
* @override * @param {!WebInspector.Event} event
* @param {string} text
*/
setPromptText: function(text)
{
this.prompt.text = text;
},
/**
* @override
* @param {?WebInspector.RemoteObject} result
* @param {boolean} wasThrown
* @param {string} promptText
* @param {!WebInspector.ConsoleMessage} commandMessage
*/ */
printEvaluationResult: function(result, wasThrown, promptText, commandMessage) _commandEvaluated: function(event)
{ {
this.prompt.pushHistoryItem(promptText); var data = /**{{result: ?WebInspector.RemoteObject, wasThrown: boolean, text: string, commandMessage: !WebInspector.ConsoleMessage}} */ (event.data);
this.prompt.pushHistoryItem(data.text);
WebInspector.settings.consoleHistory.set(this.prompt.historyData.slice(-30)); WebInspector.settings.consoleHistory.set(this.prompt.historyData.slice(-30));
this._printResult(result, wasThrown, /** @type {!WebInspector.ConsoleCommand} */ (this._messageToViewMessage.get(commandMessage))); this._printResult(data.result, data.wasThrown, /** @type {!WebInspector.ConsoleCommand} */ (this._messageToViewMessage.get(data.commandMessage)));
}, },
/** /**
......
...@@ -111,7 +111,6 @@ WebInspector.JavaScriptSourceFrame.prototype = { ...@@ -111,7 +111,6 @@ WebInspector.JavaScriptSourceFrame.prototype = {
*/ */
_evaluateInConsole: function(expression) _evaluateInConsole: function(expression)
{ {
WebInspector.console.show();
WebInspector.console.evaluate(expression); WebInspector.console.evaluate(expression);
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment