Title: [112402] trunk
Revision
112402
Author
podivi...@chromium.org
Date
2012-03-28 08:20:06 -0700 (Wed, 28 Mar 2012)

Log Message

Web Inspector: dispatch console-message-added and console-messages-cleared events on UISourceCode.
https://bugs.webkit.org/show_bug.cgi?id=82463

Reviewed by Vsevolod Vlasov.

Source/WebCore:

Those events are related to specific UISourceCode. See bug 82224 for more details.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype._addConsoleMessageToScript):
(WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
(WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
(WebInspector.UISourceCodeImpl):
(WebInspector.UISourceCodeImpl.prototype.consoleMessages):
(WebInspector.UISourceCodeImpl.prototype.consoleMessageAdded):
(WebInspector.UISourceCodeImpl.prototype.consoleMessagesCleared):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame):
(WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
(WebInspector._javascript_SourceFrame.prototype._consoleMessageAdded):
(WebInspector._javascript_SourceFrame.prototype._consoleMessagesCleared):
(WebInspector._javascript_SourceFrame.prototype._onTextViewerContentLoaded):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._sourceFrameLoaded):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode.prototype.breakpoints):
(WebInspector.UISourceCode.prototype.consoleMessages):

LayoutTests:

* inspector/debugger/scripts-panel.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (112401 => 112402)


--- trunk/LayoutTests/ChangeLog	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/LayoutTests/ChangeLog	2012-03-28 15:20:06 UTC (rev 112402)
@@ -1,3 +1,12 @@
+2012-03-28  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: dispatch console-message-added and console-messages-cleared events on UISourceCode.
+        https://bugs.webkit.org/show_bug.cgi?id=82463
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/debugger/scripts-panel.html:
+
 2012-03-28  Yi Shen  <yi.4.s...@nokia.com>
 
         An extra line break is inserted when pasting into a font element.

Modified: trunk/LayoutTests/inspector/debugger/scripts-panel.html (112401 => 112402)


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2012-03-28 15:20:06 UTC (rev 112402)
@@ -23,7 +23,7 @@
     }
     function createUISouceCode(url)
     {
-        var uiSourceCode = new WebInspector.UISourceCode(0, url, null, null);
+        var uiSourceCode = new WebInspector.UISourceCodeImpl(0, url, null, null);
         uiSourceCode.requestContent = function(callback)
         {
             InspectorTest.addResult("Source requested for " + url);

Modified: trunk/Source/WebCore/ChangeLog (112401 => 112402)


--- trunk/Source/WebCore/ChangeLog	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/Source/WebCore/ChangeLog	2012-03-28 15:20:06 UTC (rev 112402)
@@ -1,3 +1,33 @@
+2012-03-28  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: dispatch console-message-added and console-messages-cleared events on UISourceCode.
+        https://bugs.webkit.org/show_bug.cgi?id=82463
+
+        Reviewed by Vsevolod Vlasov.
+
+        Those events are related to specific UISourceCode. See bug 82224 for more details.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessageToScript):
+        (WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
+        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
+        (WebInspector.UISourceCodeImpl):
+        (WebInspector.UISourceCodeImpl.prototype.consoleMessages):
+        (WebInspector.UISourceCodeImpl.prototype.consoleMessageAdded):
+        (WebInspector.UISourceCodeImpl.prototype.consoleMessagesCleared):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame):
+        (WebInspector._javascript_SourceFrame.prototype.beforeTextChanged):
+        (WebInspector._javascript_SourceFrame.prototype._consoleMessageAdded):
+        (WebInspector._javascript_SourceFrame.prototype._consoleMessagesCleared):
+        (WebInspector._javascript_SourceFrame.prototype._onTextViewerContentLoaded):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._sourceFrameLoaded):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode.prototype.breakpoints):
+        (WebInspector.UISourceCode.prototype.consoleMessages):
+
 2012-03-28  Carlos Garcia Campos  <cgar...@igalia.com>
 
         [GTK] Implement PlatformStrategies

Modified: trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js (112401 => 112402)


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-28 15:20:06 UTC (rev 112402)
@@ -43,7 +43,6 @@
 
     this._pendingConsoleMessages = {};
     this._consoleMessageLiveLocations = [];
-    this._presentationConsoleMessages = [];
 
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.ParsedScriptSource, this._parsedScriptSource, this);
     WebInspector.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, this._failedToParseScriptSource, this);
@@ -61,8 +60,6 @@
     UISourceCodeAdded: "source-file-added",
     UISourceCodeReplaced: "source-file-replaced",
     UISourceCodeRemoved: "source-file-removed",
-    ConsoleMessageAdded: "console-message-added",
-    ConsoleMessagesCleared: "console-messages-cleared",
     DebuggerPaused: "debugger-paused",
     DebuggerResumed: "debugger-resumed",
     DebuggerReset: "debugger-reset",
@@ -280,8 +277,7 @@
         function updateLocation(uiLocation)
         {
             var presentationMessage = new WebInspector.PresentationConsoleMessage(uiLocation.uiSourceCode, uiLocation.lineNumber, message);
-            this._presentationConsoleMessages.push(presentationMessage);
-            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
+            uiLocation.uiSourceCode.consoleMessageAdded(presentationMessage);
         }
         var liveLocation = this.createLiveLocation(rawLocation, updateLocation.bind(this));
         liveLocation.init();
@@ -329,8 +325,9 @@
         for (var i = 0; i < this._consoleMessageLiveLocations.length; ++i)
             this._consoleMessageLiveLocations[i].dispose();
         this._consoleMessageLiveLocations = [];
-        this._presentationConsoleMessages = [];
-        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared);
+        var uiSourceCodes = this.uiSourceCodes();
+        for (var i = 0; i < uiSourceCodes.length; ++i)
+            uiSourceCodes[i].consoleMessagesCleared();
     },
 
     /**
@@ -358,21 +355,6 @@
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
-     * @return {Array.<WebInspector.PresentationConsoleMessage>}
-     */
-    messagesForUISourceCode: function(uiSourceCode)
-    {
-        var messages = [];
-        for (var i = 0; i < this._presentationConsoleMessages.length; ++i) {
-            var message = this._presentationConsoleMessages[i];
-            if (message.uiSourceCode === uiSourceCode)
-                messages.push(message);
-        }
-        return messages;
-    },
-
-    /**
-     * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {number} lineNumber
      * @param {string} condition
      * @param {boolean} enabled
@@ -546,7 +528,6 @@
         this._breakpointManager.debuggerReset();
         this._pendingConsoleMessages = {};
         this._consoleMessageLiveLocations = [];
-        this._presentationConsoleMessages = [];
         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerReset);
     }
 }
@@ -568,14 +549,25 @@
      * @type {Object.<string,WebInspector.UIBreakpoint>}
      */
     this._breakpoints = {};
+    /**
+     * @type {Array.<WebInspector.PresentationConsoleMessage>}
+     */
+    this._consoleMessages = [];
 }
 
 WebInspector.UISourceCodeImpl.prototype = {
+    /**
+     * @return {Object.<string,WebInspector.UIBreakpoint>}
+     */
     breakpoints: function()
     {
         return this._breakpoints;
     },
 
+    /**
+     * @param {number} lineNumber
+     * @param {WebInspector.UIBreakpoint} breakpoint
+     */
     breakpointAdded: function(lineNumber, breakpoint)
     {
         console.assert(!this._breakpoints[lineNumber]);
@@ -583,12 +575,38 @@
         this.dispatchEventToListeners(WebInspector.UISourceCode.Events.BreakpointAdded, breakpoint);
     },
 
+    /**
+     * @param {number} lineNumber
+     */
     breakpointRemoved: function(lineNumber)
     {
         var breakpoint = this._breakpoints[lineNumber];
         delete this._breakpoints[lineNumber];
         this.dispatchEventToListeners(WebInspector.UISourceCode.Events.BreakpointRemoved, breakpoint);
     },
+
+    /**
+     * @return {Array.<WebInspector.PresentationConsoleMessage>}
+     */
+    consoleMessages: function()
+    {
+        return this._consoleMessages;
+    },
+
+    /**
+     * @param {WebInspector.PresentationConsoleMessage} message
+     */
+    consoleMessageAdded: function(message)
+    {
+        this._consoleMessages.push(message);
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessageAdded, message);
+    },
+
+    consoleMessagesCleared: function()
+    {
+        this._consoleMessages = [];
+        this.dispatchEventToListeners(WebInspector.UISourceCode.Events.ConsoleMessagesCleared);
+    }
 }
 
 WebInspector.UISourceCodeImpl.prototype.__proto__ = WebInspector.UISourceCode.prototype;

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js (112401 => 112402)


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2012-03-28 15:20:06 UTC (rev 112402)
@@ -49,6 +49,8 @@
     this.textViewer.element.addEventListener("mousedown", this._onMouseDown.bind(this), true);
     this.textViewer.element.addEventListener("keydown", this._onKeyDown.bind(this), true);
     this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ContentChanged, this._onContentChanged, this);
+    this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
+    this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
     this.addEventListener(WebInspector.SourceFrame.Events.Loaded, this._onTextViewerContentLoaded, this);
 }
 
@@ -174,7 +176,7 @@
                 if (breakpoint) {
                     this._model.removeBreakpoint(this._uiSourceCode, lineNumber);
                     // Re-adding decoration only.
-                    this.addBreakpoint(lineNumber, breakpoint.resolved, breakpoint.conditional, breakpoint.enabled, true); 
+                    this.addBreakpoint(lineNumber, breakpoint.resolved, breakpoint.conditional, breakpoint.enabled, true);
                 }
             }
         }
@@ -461,10 +463,28 @@
         return newLineNumber;
     },
 
+    _consoleMessageAdded: function(event)
+    {
+        var message = event.data;
+        if (this.loaded)
+            this.addMessageToSource(message.lineNumber, message.originalMessage);
+    },
+
+    _consoleMessagesCleared: function(event)
+    {
+        this.clearMessages();
+    },
+
     _onTextViewerContentLoaded: function()
     {
         if (typeof this._executionLineNumber === "number")
             this.setExecutionLine(this._executionLineNumber);
+
+        var messages = this._uiSourceCode.consoleMessages();
+        for (var i = 0; i < messages.length; ++i) {
+            var message = messages[i];
+            this.addMessageToSource(message.lineNumber, message.originalMessage);
+        }
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js (112401 => 112402)


--- trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js	2012-03-28 15:20:06 UTC (rev 112402)
@@ -175,8 +175,6 @@
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded, this._uiSourceCodeAdded, this)
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeRemoved, this._uiSourceCodeRemoved, this);
-    this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, this._consoleMessageAdded, this);
-    this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared, this._consoleMessagesCleared, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerPaused, this._debuggerPaused, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.DebuggerResumed, this._debuggerResumed, this);
     this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this);
@@ -314,22 +312,6 @@
         this._editorContainer.setFileIsDirty(uiSourceCode, isDirty);
     },
 
-    _consoleMessagesCleared: function()
-    {
-        var sourceFrames = this._sourceFramesByUISourceCode.values();
-        for (var i = 0; i < sourceFrames.length; ++i)
-            sourceFrames[i].clearMessages();
-    },
-
-    _consoleMessageAdded: function(event)
-    {
-        var message = event.data;
-
-        var sourceFrame = this._sourceFramesByUISourceCode.get(message.uiSourceCode)
-        if (sourceFrame && sourceFrame.loaded)
-            sourceFrame.addMessageToSource(message.lineNumber, message.originalMessage);
-    },
-
     _uiBreakpointAdded: function(event)
     {
         var uiBreakpoint = /** @type {WebInspector.UIBreakpoint} */ event.data;
@@ -607,12 +589,6 @@
         var sourceFrame = /** @type {WebInspector._javascript_SourceFrame} */ event.target;
         var uiSourceCode = sourceFrame._uiSourceCode;
 
-        var messages = this._presentationModel.messagesForUISourceCode(uiSourceCode);
-        for (var i = 0; i < messages.length; ++i) {
-            var message = messages[i];
-            sourceFrame.addMessageToSource(message.lineNumber, message.originalMessage);
-        }
-
         var breakpoints = this._presentationModel.breakpointsForUISourceCode(uiSourceCode);
         for (var i = 0; i < breakpoints.length; ++i) {
             var breakpoint = breakpoints[i];

Modified: trunk/Source/WebCore/inspector/front-end/UISourceCode.js (112401 => 112402)


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-03-28 15:13:51 UTC (rev 112401)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2012-03-28 15:20:06 UTC (rev 112402)
@@ -51,7 +51,9 @@
 WebInspector.UISourceCode.Events = {
     ContentChanged: "content-changed",
     BreakpointAdded: "breakpoint-added",
-    BreakpointRemoved: "breakpoint-removed"
+    BreakpointRemoved: "breakpoint-removed",
+    ConsoleMessageAdded: "console-message-added",
+    ConsoleMessagesCleared: "console-messages-cleared"
 }
 
 WebInspector.UISourceCode.prototype = {
@@ -210,9 +212,14 @@
     },
 
     /**
-     * @return {Array.<WebInspector.UIBreakpoint>}
+     * @return {Object.<string,WebInspector.UIBreakpoint>}
      */
-    breakpoints: function() {}
+    breakpoints: function() {},
+
+    /**
+     * @return {Array.<WebInspector.PresentationConsoleMessage>}
+     */
+    consoleMessages: function() {}
 }
 
 WebInspector.UISourceCode.prototype.__proto__ = WebInspector.Object.prototype;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to