Title: [109905] trunk
Revision
109905
Author
podivi...@chromium.org
Date
2012-03-06 04:39:33 -0800 (Tue, 06 Mar 2012)

Log Message

Web Inspector: prepare for extracting ScriptMapping implementation from DebuggerPresentationModel.
https://bugs.webkit.org/show_bug.cgi?id=80396

Source/WebCore:

Limit RawSourceCode usages to a subset of methods. This subset will be moved to ScriptMapping implementation in a separate change.

Reviewed by Vsevolod Vlasov.

* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype.createPlacard):
(WebInspector.DebuggerPresentationModel.prototype.createLiveLocation):
(WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource):
(WebInspector.DebuggerPresentationModel.prototype._failedToParseScriptSource):
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
(WebInspector.DebuggerPresentationModel.prototype._forceUpdateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._addConsoleMessageToScript):
(WebInspector.DebuggerPresentationModel.prototype._debuggerPaused):
(WebInspector.DebuggerPresentationModel.prototype.set selectedCallFrame):
(WebInspector.PresentationCallFrame):
(WebInspector.PresentationCallFrame.prototype.uiLocation):
(WebInspector.DebuggerPresentationModel.CallFramePlacard):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype._uiSourceCodeForResource):
(WebInspector.DebuggerPresentationModel.Linkifier.prototype.linkifyRawLocation):

LayoutTests:

Reviewed by Vsevolod Vlasov.

* inspector/debugger/callstack-placards-discarded.html:
* inspector/debugger/linkifier.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109904 => 109905)


--- trunk/LayoutTests/ChangeLog	2012-03-06 12:34:05 UTC (rev 109904)
+++ trunk/LayoutTests/ChangeLog	2012-03-06 12:39:33 UTC (rev 109905)
@@ -1,3 +1,13 @@
+2012-03-06  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: prepare for extracting ScriptMapping implementation from DebuggerPresentationModel.
+        https://bugs.webkit.org/show_bug.cgi?id=80396
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/debugger/callstack-placards-discarded.html:
+        * inspector/debugger/linkifier.html:
+
 2012-03-06  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: [Regression] Execution line is not revealed when debugger is stopped if scripts panel was not yet shown.

Modified: trunk/LayoutTests/inspector/debugger/callstack-placards-discarded.html (109904 => 109905)


--- trunk/LayoutTests/inspector/debugger/callstack-placards-discarded.html	2012-03-06 12:34:05 UTC (rev 109904)
+++ trunk/LayoutTests/inspector/debugger/callstack-placards-discarded.html	2012-03-06 12:39:33 UTC (rev 109905)
@@ -21,7 +21,7 @@
                 InspectorTest.addResult("Received DebuggerPaused event.");
                 var callFrame = event.data.callFrames[0];
                 InspectorTest.addResult("Function name: " + callFrame._callFrame.functionName);
-                var rawSourceCode = callFrame._rawSourceCode;
+                var rawSourceCode = WebInspector.debuggerPresentationModel._rawSourceCodeForScriptId[callFrame._callFrame.location.scriptId];
                 var listeners = rawSourceCode._listeners[WebInspector.RawSourceCode.Events.UISourceCodeListChanged];
                 InspectorTest.addResult("Listeners length: " + listeners.length);
                 if (previousListenerLength !== undefined && listeners.length !== previousListenerLength)

Modified: trunk/LayoutTests/inspector/debugger/linkifier.html (109904 => 109905)


--- trunk/LayoutTests/inspector/debugger/linkifier.html	2012-03-06 12:34:05 UTC (rev 109904)
+++ trunk/LayoutTests/inspector/debugger/linkifier.html	2012-03-06 12:39:33 UTC (rev 109905)
@@ -34,7 +34,7 @@
     function debuggerTest()
     {
         linkifier = WebInspector.debuggerPresentationModel.createLinkifier();
-        rawSourceCode = WebInspector.debuggerPresentationModel._rawSourceCodeForScriptWithURL(WebInspector.inspectedPageURL);
+        rawSourceCode = WebInspector.debuggerPresentationModel._rawSourceCodeForURL[WebInspector.inspectedPageURL];
 
         var count1 = listenersCount(rawSourceCode);
         link = linkifier.linkifyLocation(WebInspector.inspectedPageURL, 20, 0, "dummy-class");

Modified: trunk/Source/WebCore/ChangeLog (109904 => 109905)


--- trunk/Source/WebCore/ChangeLog	2012-03-06 12:34:05 UTC (rev 109904)
+++ trunk/Source/WebCore/ChangeLog	2012-03-06 12:39:33 UTC (rev 109905)
@@ -1,3 +1,32 @@
+2012-03-06  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: prepare for extracting ScriptMapping implementation from DebuggerPresentationModel.
+        https://bugs.webkit.org/show_bug.cgi?id=80396
+
+        Limit RawSourceCode usages to a subset of methods. This subset will be moved to ScriptMapping implementation in a separate change.
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        (WebInspector.DebuggerPresentationModel.prototype.createPlacard):
+        (WebInspector.DebuggerPresentationModel.prototype.createLiveLocation):
+        (WebInspector.DebuggerPresentationModel.prototype._parsedScriptSource):
+        (WebInspector.DebuggerPresentationModel.prototype._failedToParseScriptSource):
+        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
+        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
+        (WebInspector.DebuggerPresentationModel.prototype._forceUpdateSourceMapping):
+        (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessageToScript):
+        (WebInspector.DebuggerPresentationModel.prototype._debuggerPaused):
+        (WebInspector.DebuggerPresentationModel.prototype.set selectedCallFrame):
+        (WebInspector.PresentationCallFrame):
+        (WebInspector.PresentationCallFrame.prototype.uiLocation):
+        (WebInspector.DebuggerPresentationModel.CallFramePlacard):
+        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
+        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
+        (WebInspector.DebuggerPresentationModelResourceBinding.prototype._uiSourceCodeForResource):
+        (WebInspector.DebuggerPresentationModel.Linkifier.prototype.linkifyRawLocation):
+
 2012-03-06  Vsevolod Vlasov  <vse...@chromium.org>
 
         Web Inspector: [Regression] Execution line is not revealed when debugger is stopped if scripts panel was not yet shown.

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-06 12:34:05 UTC (rev 109904)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-06 12:39:33 UTC (rev 109905)
@@ -42,6 +42,7 @@
     this._rawSourceCodeForDocumentURL = {};
     this._rawSourceCodeForUISourceCode = new Map();
     this._presentationCallFrames = [];
+    this._formatSource = false;
 
     this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bind(this), WebInspector.debuggerModel, this);
 
@@ -92,7 +93,7 @@
      */
     createPlacard: function(callFrame)
     {
-        return new WebInspector.DebuggerPresentationModel.CallFramePlacard(callFrame);
+        return new WebInspector.DebuggerPresentationModel.CallFramePlacard(callFrame, this);
     },
 
     /**
@@ -118,12 +119,24 @@
     },
 
     /**
+     * @param {DebuggerAgent.Location} rawLocation
+     * @param {function(WebInspector.UILocation)} updateDelegate
+     * @return {WebInspector.RawSourceCode.LiveLocation}
+     */
+    createLiveLocation: function(rawLocation, updateDelegate)
+    {
+        var rawSourceCode = this._rawSourceCodeForScriptId[rawLocation.scriptId];
+        return new WebInspector.RawSourceCode.LiveLocation(rawSourceCode, rawLocation, updateDelegate);
+    },
+
+    /**
      * @param {WebInspector.Event} event
      */
     _parsedScriptSource: function(event)
     {
         var script = /** @type {WebInspector.Script} */ event.data;
         this._addScript(script);
+        this._addPendingConsoleMessagesToScript(script);
     },
 
     /**
@@ -131,8 +144,7 @@
      */
     _failedToParseScriptSource: function(event)
     {
-        var script = /** @type {WebInspector.Script} */ event.data;
-        this._addScript(script);
+        this._parsedScriptSource(event);
     },
 
     /**
@@ -166,8 +178,6 @@
         if (isInlineScript)
             this._rawSourceCodeForDocumentURL[script.sourceURL] = rawSourceCode;
 
-        this._addPendingConsoleMessagesToScript(script);
-
         if (rawSourceCode.uiSourceCodeList().length)
             this._uiSourceCodeListChanged(rawSourceCode, [], rawSourceCode.uiSourceCodeList());
         rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeListChanged, this._handleUISourceCodeListChanged, this);
@@ -347,6 +357,15 @@
     },
 
     /**
+     * @param {DebuggerAgent.Location} rawLocation
+     */
+    _forceUpdateSourceMapping: function(rawLocation)
+    {
+        var rawSourceCode = this._rawSourceCodeForScriptId[rawLocation.scriptId];
+        rawSourceCode.forceUpdateSourceMapping();
+    },
+
+    /**
      * @param {WebInspector.Event} event
      */
     _consoleMessageAdded: function(event)
@@ -368,14 +387,15 @@
      */
     _addConsoleMessageToScript: function(message, script)
     {
-        var rawSourceCode = this._rawSourceCodeForScript(script);
         function updateLocation(uiLocation)
         {
             var presentationMessage = new WebInspector.PresentationConsoleMessage(uiLocation.uiSourceCode, uiLocation.lineNumber, message);
             this._presentationConsoleMessages.push(presentationMessage);
             this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
         }
-        var liveLocation = rawSourceCode.createLiveLocation(message.location, updateLocation.bind(this));
+        var rawLocation = new WebInspector.DebuggerModel.Location(message.location.lineNumber, message.location.columnNumber);
+        rawLocation.scriptId = script.scriptId;
+        var liveLocation = this.createLiveLocation(rawLocation, updateLocation.bind(this));
         liveLocation.init();
         this._consoleMessageLiveLocations.push(liveLocation);
     },
@@ -549,11 +569,8 @@
         this._presentationCallFrames = [];
         for (var i = 0; i < callFrames.length; ++i) {
             var callFrame = callFrames[i];
-            var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId);
-            if (!script)
-                continue;
-            var rawSourceCode = this._rawSourceCodeForScript(script);
-            this._presentationCallFrames.push(new WebInspector.PresentationCallFrame(callFrame, i, this, rawSourceCode));
+            if (WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId))
+                this._presentationCallFrames.push(new WebInspector.PresentationCallFrame(callFrame, i, this));
         }
         var details = WebInspector.debuggerModel.debuggerPausedDetails;
         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.DebuggerPaused, { callFrames: this._presentationCallFrames, details: details });
@@ -582,14 +599,14 @@
         if (!this._selectedCallFrame)
             return;
 
-        this._selectedCallFrame.rawSourceCode.forceUpdateSourceMapping();
+        this._forceUpdateSourceMapping(callFrame._callFrame.location);
         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, callFrame);
 
         function updateExecutionLine(uiLocation)
         {
             this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ExecutionLineChanged, uiLocation);
         }
-        this._executionLineLiveLocation = this._selectedCallFrame.rawSourceCode.createLiveLocation(callFrame._callFrame.location, updateExecutionLine.bind(this));
+        this._executionLineLiveLocation = this.createLiveLocation(callFrame._callFrame.location, updateExecutionLine.bind(this));
         this._executionLineLiveLocation.init();
     },
 
@@ -651,22 +668,6 @@
     },
 
     /**
-     * @param {string} sourceURL
-     */
-    _rawSourceCodeForScriptWithURL: function(sourceURL)
-    {
-        return this._rawSourceCodeForURL[sourceURL];
-    },
-
-    /**
-     * @param {WebInspector.Script} script
-     */
-    _rawSourceCodeForScript: function(script)
-    {
-        return this._rawSourceCodeForScriptId[script.scriptId];
-    },
-
-    /**
      * @param {string} url
      * @param {DebuggerAgent.Location} rawLocation
      * @return {WebInspector.Script}
@@ -726,15 +727,13 @@
  * @constructor
  * @param {DebuggerAgent.CallFrame} callFrame
  * @param {number} index
- * @param {WebInspector.DebuggerPresentationModel} model
- * @param {WebInspector.RawSourceCode} rawSourceCode
+ * @param {WebInspector.ScriptMapping} scriptMapping
  */
-WebInspector.PresentationCallFrame = function(callFrame, index, model, rawSourceCode)
+WebInspector.PresentationCallFrame = function(callFrame, index, scriptMapping)
 {
     this._callFrame = callFrame;
     this._index = index;
-    this._model = model;
-    this._rawSourceCode = rawSourceCode;
+    this._scriptMapping = scriptMapping;
 }
 
 WebInspector.PresentationCallFrame.prototype = {
@@ -771,14 +770,6 @@
     },
 
     /**
-     * @return {WebInspector.RawSourceCode}
-     */
-    get rawSourceCode()
-    {
-        return this._rawSourceCode;
-    },
-
-    /**
      * @param {string} code
      * @param {string} objectGroup
      * @param {boolean} includeCommandLineAPI
@@ -815,7 +806,7 @@
             callback(uiLocation);
             liveLocation.dispose();
         }
-        var liveLocation = this._rawSourceCode.createLiveLocation(this._callFrame.location, locationUpdated.bind(this));
+        var liveLocation = this._scriptMapping.createLiveLocation(this._callFrame.location, locationUpdated.bind(this));
         liveLocation.init();
     }
 }
@@ -824,11 +815,12 @@
  * @constructor
  * @extends {WebInspector.Placard}
  * @param {WebInspector.PresentationCallFrame} callFrame
+ * @param {WebInspector.ScriptMapping} scriptMapping
  */
-WebInspector.DebuggerPresentationModel.CallFramePlacard = function(callFrame)
+WebInspector.DebuggerPresentationModel.CallFramePlacard = function(callFrame, scriptMapping)
 {
     WebInspector.Placard.call(this, callFrame._callFrame.functionName || WebInspector.UIString("(anonymous function)"), "");
-    this._liveLocation = callFrame._rawSourceCode.createLiveLocation(callFrame._callFrame.location, this._update.bind(this));
+    this._liveLocation = scriptMapping.createLiveLocation(callFrame._callFrame.location, this._update.bind(this));
     this._liveLocation.init();
 }
 
@@ -863,10 +855,8 @@
      */
     canSetContent: function(resource)
     {
-        var rawSourceCode = this._presentationModel._rawSourceCodeForScriptWithURL(resource.url)
-        if (!rawSourceCode)
-            return false;
-        return this._presentationModel.canEditScriptSource(rawSourceCode.uiSourceCodeList()[0]);
+        var uiSourceCode = this._uiSourceCodeForResource(resource);
+        return uiSourceCode && this._presentationModel.canEditScriptSource(uiSourceCode);
     },
 
     /**
@@ -880,16 +870,31 @@
         if (!majorChange)
             return;
 
-        var rawSourceCode = this._presentationModel._rawSourceCodeForScriptWithURL(resource.url);
-        if (!rawSourceCode) {
+        var uiSourceCode = this._uiSourceCodeForResource(resource);
+        if (!uiSourceCode) {
             userCallback("Resource is not editable");
             return;
         }
 
-        resource.requestContent(this._setContentWithInitialContent.bind(this, rawSourceCode.uiSourceCodeList()[0], content, userCallback));
+        resource.requestContent(this._setContentWithInitialContent.bind(this, uiSourceCode, content, userCallback));
     },
 
     /**
+     * @param {WebInspector.Resource} resource
+     * @return {WebInspector.UISourceCode}
+     */
+    _uiSourceCodeForResource: function(resource)
+    {
+        var script = WebInspector.debuggerModel.scriptsForURL(resource.url)[0];
+        if (!script)
+            return null;
+        var rawLocation = new WebInspector.DebuggerModel.Location(0, 0);
+        rawLocation.scriptId = script.scriptId;
+        var uiLocation = this._presentationModel.rawLocationToUILocation(rawLocation);
+        return uiLocation ? uiLocation.uiSourceCode : null;
+    },
+
+    /**
      * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {string} content
      * @param {function(?string)} userCallback
@@ -994,9 +999,7 @@
     linkifyRawLocation: function(rawLocation, classes)
     {
         var anchor = WebInspector.linkifyURLAsNode("", "", classes, false);
-        var script = WebInspector.debuggerModel.scriptForSourceID(rawLocation.scriptId);
-        var rawSourceCode = this._model._rawSourceCodeForScript(script);
-        var liveLocation = rawSourceCode.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor));
+        var liveLocation = this._model.createLiveLocation(rawLocation, this._updateAnchor.bind(this, anchor));
         liveLocation.init();
         this._liveLocations.push(liveLocation);
         return anchor;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to