Title: [103541] trunk
Revision
103541
Author
podivi...@chromium.org
Date
2011-12-22 07:19:40 -0800 (Thu, 22 Dec 2011)

Log Message

Web Inspector: add "install source map" to JS source frame context menu.
https://bugs.webkit.org/show_bug.cgi?id=74181

Reviewed by Pavel Feldman.

Source/WebCore:

Add "install source map" to source frame context menu when source map url is auto detected.

* English.lproj/localizedStrings.js:
* inspector/front-end/CompilerSourceMapping.js:
(WebInspector.ClosureCompilerSourceMapping.prototype.load):
(WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):
* inspector/front-end/DebuggerPresentationModel.js:
(WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):
* inspector/front-end/_javascript_SourceFrame.js:
(WebInspector._javascript_SourceFrame.prototype.populateTextAreaContextMenu):
(WebInspector._javascript_SourceFrame.prototype.cancelEditing):
* inspector/front-end/RawSourceCode.js:
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping):
(WebInspector.RawSourceCode.prototype._createUISourceCode):
* inspector/front-end/UISourceCode.js:
(WebInspector.UISourceCode):

LayoutTests:

* http/tests/inspector/compiler-source-mapping-debug.html:
* http/tests/inspector/compiler-source-mapping.html:
* inspector/debugger/scripts-panel.html:
* inspector/debugger/scripts-sorting.html:
* inspector/debugger/ui-source-code.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103540 => 103541)


--- trunk/LayoutTests/ChangeLog	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/ChangeLog	2011-12-22 15:19:40 UTC (rev 103541)
@@ -1,3 +1,16 @@
+2011-12-22  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: add "install source map" to JS source frame context menu.
+        https://bugs.webkit.org/show_bug.cgi?id=74181
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/compiler-source-mapping-debug.html:
+        * http/tests/inspector/compiler-source-mapping.html:
+        * inspector/debugger/scripts-panel.html:
+        * inspector/debugger/scripts-sorting.html:
+        * inspector/debugger/ui-source-code.html:
+
 2011-12-22  Branimir Lambov  <blam...@google.com>
 
         SVG: "filter" race condition may prevent SVG elements from being re-drawn

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html (103540 => 103541)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-22 15:19:40 UTC (rev 103541)
@@ -13,7 +13,6 @@
 
 function test()
 {
-
     InspectorTest.runDebuggerTestSuite([
         function testSetBreakpoint(next)
         {
@@ -22,9 +21,9 @@
             function didShowCompiled(sourceFrame)
             {
                 InspectorTest.addResult("Script source was shown.");
-                sourceFrame._model.setCompilerSourceMapping(sourceFrame._uiSourceCode, "http://localhost:8000/inspector/resources/source-map.json");
+                sourceFrame._uiSourceCode.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
+                sourceFrame._model.installCompilerSourceMapping(sourceFrame._uiSourceCode);
                 InspectorTest.showScriptSource("source1.js", didShowSource1);
-
             }
 
             function didShowSource1(sourceFrame)

Modified: trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html (103540 => 103541)


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping.html	2011-12-22 15:19:40 UTC (rev 103541)
@@ -94,13 +94,13 @@
         {
             var mappingPayload = {
                 "sections": [{
-                    "offset": { "line": 1, "column": 0 },
+                    "offset": { "line": 0, "column": 0 },
                     "map": {
                         "mappings":"AAAA,CAEC",
                         "sources":["source1.js", "source2.js"]
                     }
                 }, {
-                    "offset": { "line": 3, "column": 10 },
+                    "offset": { "line": 2, "column": 10 },
                     "map": {
                         "mappings":"AAAA,CAEC",
                         "sources":["source2.js"]

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


--- trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/inspector/debugger/scripts-panel.html	2011-12-22 15:19:40 UTC (rev 103541)
@@ -19,7 +19,7 @@
     }
     function createUISouceCode(url)
     {
-        var uiSourceCode = new WebInspector.UISourceCode(0, url, false, null, null);
+        var uiSourceCode = new WebInspector.UISourceCode(0, url, null, null);
         uiSourceCode.requestContent = function(callback)
         {
             InspectorTest.addResult("Source requested for " + url);
@@ -136,7 +136,9 @@
             var nextId = 0;
             function addOption(url, isContentScript)
             {
-                panel._addOptionToFilesSelect(new WebInspector.UISourceCode(nextId++, url, isContentScript, null, null));
+                var uiSourceCode = new WebInspector.UISourceCode(nextId++, url, null, null);
+                uiSourceCode.isContentScript = isContentScript;
+                panel._addOptionToFilesSelect(uiSourceCode);
             }
             addOption(rootURL + "foo/bar/script.js", false);
             addOption(rootURL + "foo/bar/contentScript2.js?a=1", true);

Modified: trunk/LayoutTests/inspector/debugger/scripts-sorting.html (103540 => 103541)


--- trunk/LayoutTests/inspector/debugger/scripts-sorting.html	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/inspector/debugger/scripts-sorting.html	2011-12-22 15:19:40 UTC (rev 103541)
@@ -57,7 +57,9 @@
 
     function addOption(url, isContentScript)
     {
-        WebInspector.panels.scripts._addOptionToFilesSelect(new WebInspector.UISourceCode(nextId++, url, isContentScript, null, null));
+        var uiSourceCode = new WebInspector.UISourceCode(nextId++, url, null, null);
+        uiSourceCode.isContentScript = isContentScript;
+        WebInspector.panels.scripts._addOptionToFilesSelect(uiSourceCode);
     }
 
     function dumpScriptsList()

Modified: trunk/LayoutTests/inspector/debugger/ui-source-code.html (103540 => 103541)


--- trunk/LayoutTests/inspector/debugger/ui-source-code.html	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/LayoutTests/inspector/debugger/ui-source-code.html	2011-12-22 15:19:40 UTC (rev 103541)
@@ -17,7 +17,7 @@
     InspectorTest.runTestSuite([
         function testUISourceCode(next)
         {
-            var uiSourceCode = new WebInspector.UISourceCode("id", "url", false, null, contentProvider);
+            var uiSourceCode = new WebInspector.UISourceCode("id", "url", null, contentProvider);
             function didRequestContent(callNumber, mimeType, content)
             {
                 InspectorTest.addResult("Callback " + callNumber + " is invoked.");

Modified: trunk/Source/WebCore/ChangeLog (103540 => 103541)


--- trunk/Source/WebCore/ChangeLog	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/ChangeLog	2011-12-22 15:19:40 UTC (rev 103541)
@@ -1,3 +1,29 @@
+2011-12-22  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: add "install source map" to JS source frame context menu.
+        https://bugs.webkit.org/show_bug.cgi?id=74181
+
+        Reviewed by Pavel Feldman.
+
+        Add "install source map" to source frame context menu when source map url is auto detected.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/CompilerSourceMapping.js:
+        (WebInspector.ClosureCompilerSourceMapping.prototype.load):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parseSections):
+        * inspector/front-end/DebuggerPresentationModel.js:
+        (WebInspector.DebuggerPresentationModel.prototype.installCompilerSourceMapping):
+        * inspector/front-end/_javascript_SourceFrame.js:
+        (WebInspector._javascript_SourceFrame.prototype.populateTextAreaContextMenu):
+        (WebInspector._javascript_SourceFrame.prototype.cancelEditing):
+        * inspector/front-end/RawSourceCode.js:
+        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
+        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
+        (WebInspector.RawSourceCode.prototype._createSourceMapping):
+        (WebInspector.RawSourceCode.prototype._createUISourceCode):
+        * inspector/front-end/UISourceCode.js:
+        (WebInspector.UISourceCode):
+
 2011-12-22  Branimir Lambov  <blam...@google.com>
 
         SVG: "filter" race condition may prevent SVG elements from being re-drawn

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js (103540 => 103541)


--- trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-12-22 15:19:40 UTC (rev 103541)
@@ -97,6 +97,8 @@
         try {
             // FIXME: make sendRequest async.
             var response = InspectorFrontendHost.loadResourceSynchronously(this._sourceMappingURL);
+            if (response.slice(0, 3) === ")]}")
+                response = response.substring(response.indexOf('\n'));
             this._parseMappingPayload(JSON.parse(response));
             return true
         } catch(e) {
@@ -182,7 +184,7 @@
     {
         for (var i = 0; i < sections.length; ++i) {
             var section = sections[i];
-            this._parseMap(section.map, section.offset.line - 1, section.offset.column)
+            this._parseMap(section.map, section.offset.line, section.offset.column)
         }
     },
 

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


--- trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js	2011-12-22 15:19:40 UTC (rev 103541)
@@ -337,11 +337,10 @@
 
     /**
      * @param {WebInspector.UISourceCode} uiSourceCode
-     * @param {string} sourceMappingURL
      */
-    setCompilerSourceMapping: function(uiSourceCode, sourceMappingURL)
+    installCompilerSourceMapping: function(uiSourceCode)
     {
-        var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(sourceMappingURL, uiSourceCode.url);
+        var sourceMapping = new WebInspector.ClosureCompilerSourceMapping(uiSourceCode.sourceMapURL, uiSourceCode.url);
         uiSourceCode.rawSourceCode.setCompilerSourceMapping(sourceMapping);
     },
 

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


--- trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_SourceFrame.js	2011-12-22 15:19:40 UTC (rev 103541)
@@ -147,12 +147,19 @@
     {
         WebInspector.SourceFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber);
         var selection = window.getSelection();
-        if (selection.type !== "Range" || selection.isCollapsed)
-            return;
-        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch"),
-                this._scriptsPanel.addToWatch.bind(this._scriptsPanel, selection.toString()));
+        if (selection.type === "Range" && !selection.isCollapsed) {
+            var addToWatchLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Add to watch" : "Add to Watch");
+            contextMenu.appendItem(addToWatchLabel, this._scriptsPanel.addToWatch.bind(this._scriptsPanel, selection.toString()));
+            var evaluateLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console");
+            contextMenu.appendItem(evaluateLabel, WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
+            contextMenu.appendSeparator();
+        }
 
-        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate in console" : "Evaluate in Console"), WebInspector.evaluateInConsole.bind(WebInspector, selection.toString()));
+        if (this._uiSourceCode.sourceMapURL) {
+            var installSourceMapLabel = WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Install source map" : "Install Source Map");
+            contextMenu.appendItem(installSourceMapLabel, this._model.installCompilerSourceMapping.bind(this._model, this._uiSourceCode));
+        }
+
     },
 
     afterTextChanged: function(oldRange, newRange)
@@ -198,7 +205,7 @@
     cancelEditing: function()
     {
         WebInspector.SourceFrame.prototype.cancelEditing.call(this);
-        
+
         if (!this._javaScriptSourceFrameState)
             return;
 

Modified: trunk/Source/WebCore/inspector/front-end/RawSourceCode.js (103540 => 103541)


--- trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/inspector/front-end/RawSourceCode.js	2011-12-22 15:19:40 UTC (rev 103541)
@@ -195,7 +195,7 @@
             for (var i = 0; i < sourceURLs.length; ++i) {
                 var sourceURL = sourceURLs[i];
                 var contentProvider = new WebInspector.CompilerSourceMappingContentProvider(sourceURL, this._compilerSourceMapping);
-                var uiSourceCode = new WebInspector.UISourceCode(sourceURL, sourceURL, this.isContentScript, this, contentProvider);
+                var uiSourceCode = this._createUISourceCode(sourceURL, sourceURL, contentProvider);
                 uiSourceCodeList.push(uiSourceCode);
             }
             var sourceMapping = new WebInspector.RawSourceCode.CompilerSourceMapping(this, uiSourceCodeList, this._compilerSourceMapping);
@@ -205,7 +205,7 @@
 
         var originalContentProvider = this._createContentProvider();
         if (!this._formatted) {
-            var uiSourceCode = new WebInspector.UISourceCode(this.url, this.url, this.isContentScript, this, originalContentProvider);
+            var uiSourceCode = this._createUISourceCode(this.url, this.url, originalContentProvider);
             var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
             callback(sourceMapping);
             return;
@@ -226,7 +226,7 @@
             function didFormatContent(formattedContent, mapping)
             {
                 var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
-                var uiSourceCode = new WebInspector.UISourceCode("deobfuscated:" + this.url, this.url, this.isContentScript, this, contentProvider);
+                var uiSourceCode = this._createUISourceCode("deobfuscated:" + this.url, this.url, contentProvider);
                 var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
                 callback(sourceMapping);
             }
@@ -236,6 +236,19 @@
     },
 
     /**
+     * @param {string} id
+     * @param {string} url
+     * @param {WebInspector.ContentProvider} contentProvider
+     */
+    _createUISourceCode: function(id, url, contentProvider)
+    {
+        var uiSourceCode = new WebInspector.UISourceCode(id, url, this, contentProvider);
+        uiSourceCode.isContentScript = this.isContentScript;
+        uiSourceCode.sourceMapURL = this.sourceMapURL;
+        return uiSourceCode;
+    },
+
+    /**
      * @param {WebInspector.RawSourceCode.SourceMapping} sourceMapping
      */
     _saveSourceMapping: function(sourceMapping)

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


--- trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-12-22 15:02:00 UTC (rev 103540)
+++ trunk/Source/WebCore/inspector/front-end/UISourceCode.js	2011-12-22 15:19:40 UTC (rev 103541)
@@ -33,17 +33,17 @@
  * @extends {WebInspector.Object}
  * @param {string} id
  * @param {string} url
- * @param {boolean} isContentScript
  * @param {WebInspector.RawSourceCode} rawSourceCode
  * @param {WebInspector.ContentProvider} contentProvider
  */
-WebInspector.UISourceCode = function(id, url, isContentScript, rawSourceCode, contentProvider)
+WebInspector.UISourceCode = function(id, url, rawSourceCode, contentProvider)
 {
     this._id = id;
     this._url = url;
-    this._isContentScript = isContentScript;
     this._rawSourceCode = rawSourceCode;
     this._contentProvider = contentProvider;
+    this.isContentScript = false;
+    this.sourceMapURL = "";
     /**
      * @type Array.<function(string,string)>
      */
@@ -72,14 +72,6 @@
     },
 
     /**
-     * @return {boolean}
-     */
-    get isContentScript()
-    {
-        return this._isContentScript;
-    },
-
-    /**
      * @return {WebInspector.RawSourceCode}
      */
     get rawSourceCode()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to