Title: [109872] trunk
Revision
109872
Author
[email protected]
Date
2012-03-06 00:10:28 -0800 (Tue, 06 Mar 2012)

Log Message

Web Inspector: stop using RawSourceCode in BreakpointManager.
https://bugs.webkit.org/show_bug.cgi?id=80286

Reviewed by Vsevolod Vlasov.

Source/WebCore:

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/BreakpointManager.js:
(WebInspector.BreakpointManager.prototype.uiSourceCodeAdded):
(WebInspector.BreakpointManager.prototype.setBreakpoint):
(WebInspector.BreakpointManager.prototype._materializeBreakpoint):
(WebInspector.BreakpointManager.prototype._breakpointDebuggerLocationChanged):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel):
* inspector/front-end/ScriptMapping.js: Added.
(WebInspector.ScriptMapping):
(WebInspector.ScriptMapping.prototype.rawLocationToUILocation):
(WebInspector.ScriptMapping.prototype.uiLocationToRawLocation):
(WebInspector.ScriptMapping.prototype.createLiveLocation):
(WebInspector.ScriptMapping.prototype.uiSourceCodeList):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

LayoutTests:

* inspector/debugger/breakpoint-manager.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109871 => 109872)


--- trunk/LayoutTests/ChangeLog	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/LayoutTests/ChangeLog	2012-03-06 08:10:28 UTC (rev 109872)
@@ -1,3 +1,12 @@
+2012-03-05  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: stop using RawSourceCode in BreakpointManager.
+        https://bugs.webkit.org/show_bug.cgi?id=80286
+
+        Reviewed by Vsevolod Vlasov.
+
+        * inspector/debugger/breakpoint-manager.html:
+
 2012-03-05  Csaba Osztrogonác  <[email protected]>
 
         [Qt] Unreviewed gardening. Skip new crashing tests,

Modified: trunk/LayoutTests/inspector/debugger/breakpoint-manager.html (109871 => 109872)


--- trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/LayoutTests/inspector/debugger/breakpoint-manager.html	2012-03-06 08:10:28 UTC (rev 109872)
@@ -58,35 +58,31 @@
     serializedBreakpoints.push(createBreakpoint("a.js", 20, "", false));
     serializedBreakpoints.push(createBreakpoint("b.js", 3, "", true));
 
-    function createUISourceCode(id, url, rawLocationToUILocation, uiLocationToRawLocation)
+    function createUISourceCode(id, url) { return { id: id, url: url }; }
+    var uiSourceCodeA = createUISourceCode("a.js", "a.js");
+    var uiSourceCodeB = createUISourceCode("b.js", "b.js");
+
+    var scriptMapping = {};
+    scriptMapping.rawLocationToUILocation = function(rawLocation) { return rawLocation; };
+    scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber)
     {
-        return {
-            id: id,
-            url: url,
-            rawSourceCode: { rawLocationToUILocation: rawLocationToUILocation, uiLocationToRawLocation: uiLocationToRawLocation }
-        };
+        scriptId = uiSourceCode === uiSourceCodeA ? "a.js" : "b.js";
+        return { scriptId: scriptId, lineNumber: lineNumber, columnNumber: 0 };
     }
 
-    var uiSourceCodeA = createUISourceCode("a.js", "a.js",
-            function(rawLocation) { return rawLocation; },
-            function(uiSourceCode, lineNumber) { return { scriptId: "a.js", lineNumber: lineNumber, columnNumber: 0 }; });
-    var uiSourceCodeB = createUISourceCode("b.js", "b.js",
-            function(rawLocation) { return rawLocation; },
-            function(uiSourceCode, lineNumber) { return { scriptId: "b.js", lineNumber: lineNumber, columnNumber: 0 }; });
-
-    function createBreakpointManager(breakpoints)
+    function createBreakpointManager(breakpoints, scriptMapping)
     {
         breakpointStorage.set(breakpoints);
         uiBreakpoints = {};
         debuggerBreakpoints = {};
         debuggerModel.removeAllListeners();
-        return new WebInspector.BreakpointManager(breakpointStorage, breakpointAdded, breakpointRemoved, debuggerModel);
+        return new WebInspector.BreakpointManager(breakpointStorage, breakpointAdded, breakpointRemoved, debuggerModel, scriptMapping);
     }
 
     InspectorTest.runTestSuite([
         function uiSourceCodeAdded(next)
         {
-            var breakpointManager = createBreakpointManager(serializedBreakpoints);
+            var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
             setTimeout(checkResults, 0);
@@ -101,7 +97,7 @@
 
         function setAndRemoveBreakpoints(next)
         {
-            var breakpointManager = createBreakpointManager(serializedBreakpoints);
+            var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
             setTimeout(setAndRemove, 0);
@@ -127,7 +123,7 @@
 
         function setBreakpointOnComment(next)
         {
-            var breakpointManager = createBreakpointManager([]);
+            var breakpointManager = createBreakpointManager([], scriptMapping);
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
 
@@ -143,7 +139,7 @@
 
         function setBreakpointOutsideOfScript(next)
         {
-            var breakpointManager = createBreakpointManager([]);
+            var breakpointManager = createBreakpointManager([], scriptMapping);
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
 
@@ -159,7 +155,7 @@
 
         function testNavigation(next)
         {
-            var breakpointManager = createBreakpointManager(serializedBreakpoints);
+            var breakpointManager = createBreakpointManager(serializedBreakpoints, scriptMapping);
 
             breakpointManager.uiSourceCodeAdded(uiSourceCodeA);
             setTimeout(navigateToB, 0);
@@ -202,15 +198,16 @@
 
         function testFormatting(next)
         {
-            var breakpointManager = createBreakpointManager([createBreakpoint("c.js", 4, "", true)]);
-            var uiSourceCodeC = createUISourceCode("c.js", "c.js",
-                    function(rawLocation) { return rawLocation; },
-                    function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: 0 }; });
-            var uiSourceCodeCFormatted = createUISourceCode("deobfuscated:c.js", "c.js",
-                    function(rawLocation) { return { lineNumber: rawLocation.lineNumber * 2, columnNumber: rawLocation.columnNumber * 2 }; },
-                    function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; });
+            var scriptMapping = {};
+            var breakpointManager = createBreakpointManager([createBreakpoint("c.js", 4, "", true)], scriptMapping);
 
-            breakpointManager.uiSourceCodeAdded(uiSourceCodeC);
+            var originalUISourceCode = createUISourceCode("c.js", "c.js");
+            var formattedUISourceCode = createUISourceCode("deobfuscated:c.js", "c.js");
+
+            scriptMapping.rawLocationToUILocation = function(rawLocation) { return rawLocation; };
+            scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: lineNumber, columnNumber: 0 }; };
+
+            breakpointManager.uiSourceCodeAdded(originalUISourceCode);
             setTimeout(format, 0);
 
             function format()
@@ -221,9 +218,12 @@
                 InspectorTest.addResult("\nFormat source.");
                 breakpointManager.reset();
 
-                breakpointManager.uiSourceCodeAdded(uiSourceCodeCFormatted);
-                breakpointManager.setBreakpoint(uiSourceCodeCFormatted, 4, "", true);
-                breakpointManager.setBreakpoint(uiSourceCodeCFormatted, 8, "", false);
+                scriptMapping.rawLocationToUILocation = function(rawLocation) { return { lineNumber: rawLocation.lineNumber * 2, columnNumber: rawLocation.columnNumber * 2 }; };
+                scriptMapping.uiLocationToRawLocation = function(uiSourceCode, lineNumber) { return { scriptId: "c.js", lineNumber: Math.floor(lineNumber / 2), columnNumber: 0 }; };
+
+                breakpointManager.uiSourceCodeAdded(formattedUISourceCode);
+                breakpointManager.setBreakpoint(formattedUISourceCode, 4, "", true);
+                breakpointManager.setBreakpoint(formattedUISourceCode, 8, "", false);
                 setTimeout(changeBreakpoints, 0);
             }
 
@@ -232,8 +232,8 @@
                 assertEquals({"c.js:2:0":""}, debuggerBreakpoints);
 
                 InspectorTest.addResult("\nChange breakpoints.");
-                breakpointManager.removeBreakpoint(uiSourceCodeCFormatted, 8);
-                breakpointManager.setBreakpoint(uiSourceCodeCFormatted, 12, "", true);
+                breakpointManager.removeBreakpoint(formattedUISourceCode, 8);
+                breakpointManager.setBreakpoint(formattedUISourceCode, 12, "", true);
                 setTimeout(reload, 0);
             }
 
@@ -244,7 +244,7 @@
                 InspectorTest.addResult("\nReload.");
                 breakpointManager.debuggerReset();
 
-                breakpointManager.uiSourceCodeAdded(uiSourceCodeCFormatted);
+                breakpointManager.uiSourceCodeAdded(formattedUISourceCode);
                 var eventData = { breakpointId: "c.js:2:0", location: { scriptId: "c.js", lineNumber: 3, columnNumber: 0 }};
                 debuggerModel.dispatchEventToListeners(WebInspector.DebuggerModel.Events.BreakpointResolved, eventData);
                 eventData = { breakpointId: "c.js:6:0", location: { scriptId: "c.js", lineNumber: 6, columnNumber: 0 }};

Modified: trunk/Source/WebCore/ChangeLog (109871 => 109872)


--- trunk/Source/WebCore/ChangeLog	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/ChangeLog	2012-03-06 08:10:28 UTC (rev 109872)
@@ -1,3 +1,28 @@
+2012-03-05  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: stop using RawSourceCode in BreakpointManager.
+        https://bugs.webkit.org/show_bug.cgi?id=80286
+
+        Reviewed by Vsevolod Vlasov.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/BreakpointManager.js:
+        (WebInspector.BreakpointManager.prototype.uiSourceCodeAdded):
+        (WebInspector.BreakpointManager.prototype.setBreakpoint):
+        (WebInspector.BreakpointManager.prototype._materializeBreakpoint):
+        (WebInspector.BreakpointManager.prototype._breakpointDebuggerLocationChanged):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel):
+        * inspector/front-end/ScriptMapping.js: Added.
+        (WebInspector.ScriptMapping):
+        (WebInspector.ScriptMapping.prototype.rawLocationToUILocation):
+        (WebInspector.ScriptMapping.prototype.uiLocationToRawLocation):
+        (WebInspector.ScriptMapping.prototype.createLiveLocation):
+        (WebInspector.ScriptMapping.prototype.uiSourceCodeList):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2012-03-05  Philippe Normand  <[email protected]>
 
         WebAudio JSC-related fixes

Modified: trunk/Source/WebCore/WebCore.gypi (109871 => 109872)


--- trunk/Source/WebCore/WebCore.gypi	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/WebCore.gypi	2012-03-06 08:10:28 UTC (rev 109872)
@@ -6234,6 +6234,7 @@
             'inspector/front-end/Script.js',
             'inspector/front-end/ScriptFormatter.js',
             'inspector/front-end/ScriptFormatterWorker.js',
+            'inspector/front-end/ScriptMapping.js',
             'inspector/front-end/ScriptsNavigator.js',
             'inspector/front-end/ScriptsPanel.js',
             'inspector/front-end/ScriptsSearchScope.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (109871 => 109872)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2012-03-06 08:10:28 UTC (rev 109872)
@@ -73233,6 +73233,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\ScriptMapping.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\ScriptsNavigator.js"
 					>
 				</File>

Modified: trunk/Source/WebCore/inspector/front-end/BreakpointManager.js (109871 => 109872)


--- trunk/Source/WebCore/inspector/front-end/BreakpointManager.js	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/inspector/front-end/BreakpointManager.js	2012-03-06 08:10:28 UTC (rev 109872)
@@ -34,8 +34,9 @@
  * @param {function(WebInspector.Breakpoint)} breakpointAddedDelegate
  * @param {function(WebInspector.Breakpoint)} breakpointRemovedDelegate
  * @param {WebInspector.DebuggerModel} debuggerModel
+ * @param {WebInspector.ScriptMapping} scriptMapping
  */
-WebInspector.BreakpointManager = function(breakpointStorage, breakpointAddedDelegate, breakpointRemovedDelegate, debuggerModel)
+WebInspector.BreakpointManager = function(breakpointStorage, breakpointAddedDelegate, breakpointRemovedDelegate, debuggerModel, scriptMapping)
 {
     this._breakpointStorage = breakpointStorage;
     this._breakpointAddedDelegate = breakpointAddedDelegate;
@@ -46,6 +47,7 @@
     this._breakpointsByUILocation = {};
 
     this._debuggerModel = debuggerModel;
+    this._scriptMapping = scriptMapping;
 
     /**
      * @type {Object.<DebuggerAgent.BreakpointId, WebInspector.Breakpoint>}
@@ -71,7 +73,7 @@
         for (var lineNumber in breakpoints) {
             var breakpoint = breakpoints[lineNumber];
             breakpoint.uiSourceCode = uiSourceCode;
-            this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode, uiSourceCode);
+            this._materializeBreakpoint(breakpoint, uiSourceCode);
             if (breakpoint._debuggerLocation)
                 this._breakpointDebuggerLocationChanged(breakpoint);
         }
@@ -100,7 +102,7 @@
         var breakpoint = new WebInspector.Breakpoint(uiSourceCode.id, lineNumber, condition, enabled, persistent);
         breakpoint.uiSourceCode = uiSourceCode;
         this._addBreakpointToUI(breakpoint);
-        this._materializeBreakpoint(breakpoint, uiSourceCode.rawSourceCode, uiSourceCode);
+        this._materializeBreakpoint(breakpoint, uiSourceCode);
     },
 
     /**
@@ -131,16 +133,15 @@
 
     /**
      * @param {WebInspector.Breakpoint} breakpoint
-     * @param {WebInspector.RawSourceCode} rawSourceCode
      * @param {WebInspector.UISourceCode} uiSourceCode
      */
-    _materializeBreakpoint: function(breakpoint, rawSourceCode, uiSourceCode)
+    _materializeBreakpoint: function(breakpoint, uiSourceCode)
     {
         if (!breakpoint.enabled || breakpoint._materialized)
             return;
 
         breakpoint._materialized = true;
-        var rawLocation = rawSourceCode.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber, 0);
+        var rawLocation = this._scriptMapping.uiLocationToRawLocation(uiSourceCode, breakpoint.lineNumber, 0);
         this._setBreakpointInDebugger(breakpoint, rawLocation);
     },
 
@@ -149,9 +150,9 @@
      */
     _breakpointDebuggerLocationChanged: function(breakpoint)
     {
-        if (!breakpoint.uiSourceCode)
+        var uiLocation = this._scriptMapping.rawLocationToUILocation(breakpoint._debuggerLocation);
+        if (!uiLocation)
             return;
-        var uiLocation = breakpoint.uiSourceCode.rawSourceCode.rawLocationToUILocation(breakpoint._debuggerLocation);
         if (uiLocation.lineNumber === breakpoint.lineNumber)
             return;
 

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2012-03-06 08:10:28 UTC (rev 109872)
@@ -30,7 +30,7 @@
 
 /**
  * @constructor
- * @extends {WebInspector.Object}
+ * @extends {WebInspector.ScriptMapping}
  */
 WebInspector.DebuggerPresentationModel = function()
 {
@@ -42,7 +42,7 @@
     this._rawSourceCodeForDocumentURL = {};
     this._presentationCallFrames = [];
 
-    this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bind(this), WebInspector.debuggerModel);
+    this._breakpointManager = new WebInspector.BreakpointManager(WebInspector.settings.breakpoints, this._breakpointAdded.bind(this), this._breakpointRemoved.bind(this), WebInspector.debuggerModel, this);
 
     this._pendingConsoleMessages = {};
     this._consoleMessageLiveLocations = [];
@@ -716,7 +716,7 @@
     }
 }
 
-WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.Object.prototype;
+WebInspector.DebuggerPresentationModel.prototype.__proto__ = WebInspector.ScriptMapping.prototype;
 
 /**
  * @constructor

Added: trunk/Source/WebCore/inspector/front-end/ScriptMapping.js (0 => 109872)


--- trunk/Source/WebCore/inspector/front-end/ScriptMapping.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/ScriptMapping.js	2012-03-06 08:10:28 UTC (rev 109872)
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @constructor
+ * @extends {WebInspector.Object}
+ */
+WebInspector.ScriptMapping = function()
+{
+}
+
+WebInspector.ScriptMapping.Events = {
+    UISourceCodeListChanged: "us-source-code-list-changed"
+}
+
+WebInspector.ScriptMapping.prototype = {
+    /**
+     * @param {DebuggerAgent.Location} rawLocation
+     * @return {WebInspector.UILocation}
+     */
+    rawLocationToUILocation: function(rawLocation) {},
+
+    /**
+     * @param {WebInspector.UISourceCode} uiSourceCode
+     * @param {number} lineNumber
+     * @param {number} columnNumber
+     * @return {DebuggerAgent.Location}
+     */
+    uiLocationToRawLocation: function(uiSourceCode, lineNumber, columnNumber) {},
+
+    /**
+     * @param {DebuggerAgent.Location} rawLocation
+     * @param {function(WebInspector.UILocation)} updateDelegate
+     * @return {WebInspector.RawSourceCode.LiveLocation}
+     */
+    createLiveLocation: function(rawLocation, updateDelegate) {},
+
+    /**
+     * @return {Array.<WebInspector.UISourceCode>}
+     */
+    uiSourceCodeList: function() {}
+}
+
+WebInspector.ScriptMapping.prototype.__proto__ = WebInspector.Object.prototype;
Property changes on: trunk/Source/WebCore/inspector/front-end/ScriptMapping.js
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (109871 => 109872)


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2012-03-06 08:10:28 UTC (rev 109872)
@@ -118,6 +118,7 @@
     <file>Script.js</file>
     <file>ScriptFormatter.js</file>
     <file>ScriptFormatterWorker.js</file>
+    <file>ScriptMapping.js</file>
     <file>ScriptsPanel.js</file>
     <file>ScriptsNavigator.js</file>
     <file>ScriptsSearchScope.js</file>

Modified: trunk/Source/WebCore/inspector/front-end/inspector.html (109871 => 109872)


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2012-03-06 08:04:31 UTC (rev 109871)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2012-03-06 08:10:28 UTC (rev 109872)
@@ -168,6 +168,7 @@
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
+    <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
     <script type="text/_javascript_" src=""
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to