Title: [94577] trunk
Revision
94577
Author
[email protected]
Date
2011-09-06 10:36:19 -0700 (Tue, 06 Sep 2011)

Log Message

Web Inspector: implement source map v3 consumer.
https://bugs.webkit.org/show_bug.cgi?id=67205

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/debugger/compiler-source-mapping.html

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/CompilerSourceMapping.js: Added.
(WebInspector.CompilerSourceMapping):
(WebInspector.CompilerSourceMapping.prototype.compiledLocationToSourceLocation):
(WebInspector.CompilerSourceMapping.prototype.sourceLocationToCompiledLocation):
(WebInspector.CompilerSourceMapping.prototype.get sources):
(WebInspector.ClosureCompilerSourceMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype.compiledLocationToSourceLocation):
(WebInspector.ClosureCompilerSourceMapping.prototype.sourceLocationToCompiledLocation):
(WebInspector.ClosureCompilerSourceMapping.prototype.get sources):
(WebInspector.ClosureCompilerSourceMapping.prototype._findMapping):
(WebInspector.ClosureCompilerSourceMapping.prototype._parsePayload):
(WebInspector.ClosureCompilerSourceMapping.prototype._isSeparator):
(WebInspector.ClosureCompilerSourceMapping.prototype._decodeVLQ):
(WebInspector.ClosureCompilerSourceMapping.StringCharIterator):
(WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.next):
(WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.peek):
(WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.hasNext):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

LayoutTests:

* inspector/debugger/compiler-source-mapping-expected.txt: Added.
* inspector/debugger/compiler-source-mapping.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (94576 => 94577)


--- trunk/LayoutTests/ChangeLog	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/LayoutTests/ChangeLog	2011-09-06 17:36:19 UTC (rev 94577)
@@ -1,3 +1,13 @@
+2011-08-30  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: implement source map v3 consumer.
+        https://bugs.webkit.org/show_bug.cgi?id=67205
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/debugger/compiler-source-mapping-expected.txt: Added.
+        * inspector/debugger/compiler-source-mapping.html: Added.
+
 2011-09-06  Philippe Normand  <[email protected]>
 
         Unreviewed, unskip tests now passing because bug 61523 was fixed.
@@ -25,6 +35,33 @@
         * platform/qt/fast/css/focus-ring-multiline-writingmode-vertical-expected.png: Renamed from LayoutTests/platform/qt-linux/fast/css/focus-ring-multiline-writingmode-vertical-expected.png.
         * platform/qt/fast/css/focus-ring-multiline-writingmode-vertical-expected.txt: Renamed from LayoutTests/platform/qt-linux/fast/css/focus-ring-multiline-writingmode-vertical-expected.txt.
 
+2011-09-06  Philippe Normand  <[email protected]>
+
+        Unreviewed, unskip tests now passing because bug 61523 was fixed.
+
+        * platform/gtk/Skipped:
+
+2011-09-06  Csaba Osztrogonác  <[email protected]>
+
+        [Qt][Mac] Unreviewed gardening.
+
+        * platform/qt-mac/Skipped: Skip one more failing test.
+
+2011-09-06  Alexander Pavlov  <[email protected]>
+
+        [Chromium] Unreviewed, update expectation for inspector/elements/elements-panel-styles.html,
+        which no longer looks flaky.
+        https://bugs.webkit.org/show_bug.cgi?id=63056
+
+        * platform/chromium/test_expectations.txt:
+
+2011-09-06  Csaba Osztrogonác  <[email protected]>
+
+        [Qt] Unreviewed gardening after r94331.
+
+        * platform/qt/fast/css/focus-ring-multiline-writingmode-vertical-expected.png: Renamed from LayoutTests/platform/qt-linux/fast/css/focus-ring-multiline-writingmode-vertical-expected.png.
+        * platform/qt/fast/css/focus-ring-multiline-writingmode-vertical-expected.txt: Renamed from LayoutTests/platform/qt-linux/fast/css/focus-ring-multiline-writingmode-vertical-expected.txt.
+
 2011-09-05  Pavel Podivilov  <[email protected]>
 
         Web Inspector: re-implement RawSourceCode.

Added: trunk/LayoutTests/inspector/debugger/compiler-source-mapping-expected.txt (0 => 94577)


--- trunk/LayoutTests/inspector/debugger/compiler-source-mapping-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/compiler-source-mapping-expected.txt	2011-09-06 17:36:19 UTC (rev 94577)
@@ -0,0 +1,5 @@
+Tests ClosureCompilerSourceMapping.
+
+
+Running: testSimpleMapping
+
Property changes on: trunk/LayoutTests/inspector/debugger/compiler-source-mapping-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/inspector/debugger/compiler-source-mapping.html (0 => 94577)


--- trunk/LayoutTests/inspector/debugger/compiler-source-mapping.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/debugger/compiler-source-mapping.html	2011-09-06 17:36:19 UTC (rev 94577)
@@ -0,0 +1,54 @@
+<html>
+<head>
+<script src=""
+
+<script>
+
+function test()
+{
+    function checkMapping(compiledLineNumber, compiledColumnNumber, sourceURL, sourceLineNumber, sourceColumnNumber, mapping)
+    {
+        var sourceLocation = mapping.compiledLocationToSourceLocation(compiledLineNumber, compiledColumnNumber);
+        InspectorTest.assertEquals(sourceURL, sourceLocation.sourceURL);
+        InspectorTest.assertEquals(sourceLineNumber, sourceLocation.lineNumber);
+        InspectorTest.assertEquals(sourceColumnNumber, sourceLocation.columnNumber);
+    }
+
+    InspectorTest.runTestSuite([
+        function testSimpleMapping(next)
+        {
+            // example.js:
+            // 0         1         2         3
+            // 012345678901234567890123456789012345
+            // function add(variable_x, variable_y)
+            // {
+            //     return variable_x + variable_y;
+            // }
+            // example-compiled.js:
+            // 0         1         2         3
+            // 012345678901234567890123456789012345
+            // function add(a,b){return a+b};
+            var mappingPayload = {
+                "mappings":"AAASA,QAAAA,IAAG,CAACC,CAAD,CAAaC,CAAb,CACZ,CACI,MAAOD,EAAP,CAAoBC,CADxB;",
+                "sources":["example.js"]
+            };
+            var mapping = new WebInspector.ClosureCompilerSourceMapping(mappingPayload);
+            checkMapping(0, 9, "example.js", 0, 9, mapping);
+            checkMapping(0, 13, "example.js", 0, 13, mapping);
+            checkMapping(0, 15, "example.js", 0, 25, mapping);
+            checkMapping(0, 18, "example.js", 2, 4, mapping);
+            checkMapping(0, 25, "example.js", 2, 11, mapping);
+            checkMapping(0, 27, "example.js", 2, 24, mapping);
+            next();
+        }
+    ]);
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests ClosureCompilerSourceMapping.</p>
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/debugger/compiler-source-mapping.html
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (94576 => 94577)


--- trunk/Source/WebCore/ChangeLog	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/Source/WebCore/ChangeLog	2011-09-06 17:36:19 UTC (rev 94577)
@@ -1,3 +1,34 @@
+2011-08-30  Pavel Podivilov  <[email protected]>
+
+        Web Inspector: implement source map v3 consumer.
+        https://bugs.webkit.org/show_bug.cgi?id=67205
+
+        Reviewed by Yury Semikhatsky.
+
+        Test: inspector/debugger/compiler-source-mapping.html
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/CompilerSourceMapping.js: Added.
+        (WebInspector.CompilerSourceMapping):
+        (WebInspector.CompilerSourceMapping.prototype.compiledLocationToSourceLocation):
+        (WebInspector.CompilerSourceMapping.prototype.sourceLocationToCompiledLocation):
+        (WebInspector.CompilerSourceMapping.prototype.get sources):
+        (WebInspector.ClosureCompilerSourceMapping):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.compiledLocationToSourceLocation):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.sourceLocationToCompiledLocation):
+        (WebInspector.ClosureCompilerSourceMapping.prototype.get sources):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._findMapping):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._parsePayload):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._isSeparator):
+        (WebInspector.ClosureCompilerSourceMapping.prototype._decodeVLQ):
+        (WebInspector.ClosureCompilerSourceMapping.StringCharIterator):
+        (WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.next):
+        (WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.peek):
+        (WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype.hasNext):
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2011-09-05  Pavel Podivilov  <[email protected]>
 
         Web Inspector: re-implement RawSourceCode.

Modified: trunk/Source/WebCore/WebCore.gypi (94576 => 94577)


--- trunk/Source/WebCore/WebCore.gypi	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/Source/WebCore/WebCore.gypi	2011-09-06 17:36:19 UTC (rev 94577)
@@ -6313,6 +6313,7 @@
             'inspector/front-end/CallStackSidebarPane.js',
             'inspector/front-end/Checkbox.js',
             'inspector/front-end/Color.js',
+            'inspector/front-end/CompilerSourceMapping.js',
             'inspector/front-end/ConsoleMessage.js',
             'inspector/front-end/ConsoleModel.js',
             'inspector/front-end/ConsolePanel.js',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (94576 => 94577)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-09-06 17:36:19 UTC (rev 94577)
@@ -68901,6 +68901,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\inspector\front-end\CompilerSourceMapping.js"
+					>
+				</File>
+				<File
 					RelativePath="..\inspector\front-end\ConsoleMessage.js"
 					>
 				</File>

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


--- trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	                        (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js	2011-09-06 17:36:19 UTC (rev 94577)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2011 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
+ */
+WebInspector.CompilerSourceMapping = function()
+{
+}
+
+WebInspector.CompilerSourceMapping.prototype = {
+    compiledLocationToSourceLocation: function(lineNumber, columnNumber)
+    {
+        // Should be implemented by subclasses.
+    },
+
+    sourceLocationToCompiledLocation: function(sourceURL, lineNumber, columnNumber)
+    {
+        // Should be implemented by subclasses.
+    },
+
+    sources: function()
+    {
+        // Should be implemented by subclasses.
+    }
+}
+
+/**
+ * Implements Source Map V3 consumer. See http://code.google.com/p/closure-compiler/wiki/SourceMaps
+ * for format description.
+ * @extends {WebInspector.CompilerSourceMapping}
+ * @constructor
+ */
+WebInspector.ClosureCompilerSourceMapping = function(payload)
+{
+    if (!WebInspector.ClosureCompilerSourceMapping.prototype._base64Map) {
+        base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+        WebInspector.ClosureCompilerSourceMapping.prototype._base64Map = {};
+        for (var i = 0; i < base64Digits.length; ++i)
+            WebInspector.ClosureCompilerSourceMapping.prototype._base64Map[base64Digits.charAt(i)] = i;
+    }
+
+    this._sources = payload.sources;
+    this._mappings = this._parsePayload(payload);
+}
+
+WebInspector.ClosureCompilerSourceMapping.prototype = {
+    compiledLocationToSourceLocation: function(lineNumber, columnNumber)
+    {
+        var mapping = this._findMapping(lineNumber, columnNumber);
+        var sourceURL = this._sources[mapping[2]];
+        return { sourceURL: sourceURL, lineNumber: mapping[3], columnNumber: mapping[4] };
+    },
+
+    sourceLocationToCompiledLocation: function(sourceURL, lineNumber, columnNumber)
+    {
+    },
+
+    sources: function()
+    {
+        return this._sources;
+    },
+
+    _findMapping: function(lineNumber, columnNumber)
+    {
+        var first = 0;
+        var count = this._mappings.length;
+        while (count > 1) {
+          var step = count >> 1;
+          var middle = first + step;
+          var mapping = this._mappings[middle];
+          if (lineNumber < mapping[0] || (lineNumber == mapping[0] && columnNumber < mapping[1]))
+              count = step;
+          else {
+              first = middle;
+              count -= step;
+          }
+        }
+        return this._mappings[first];
+    },
+
+    _parsePayload: function(payload)
+    {
+        var mappings = [];
+        var stringCharIterator = new WebInspector.ClosureCompilerSourceMapping.StringCharIterator(payload.mappings);
+
+        var lineNumber = 0;
+        var columnNumber = 0;
+        var sourceIndex = 0;
+        var sourceLineNumber = 0;
+        var sourceColumnNumber = 0;
+        var nameIndex = 0;
+        do {
+            columnNumber += this._decodeVLQ(stringCharIterator);
+            if (this._isSeparator(stringCharIterator.peek()))
+                continue;
+            sourceIndex += this._decodeVLQ(stringCharIterator);
+            sourceLineNumber += this._decodeVLQ(stringCharIterator);
+            sourceColumnNumber += this._decodeVLQ(stringCharIterator);
+            var mapping = [lineNumber, columnNumber, sourceIndex, sourceLineNumber, sourceColumnNumber];
+            if (!this._isSeparator(stringCharIterator.peek())) {
+                nameIndex += this._decodeVLQ(stringCharIterator);
+                mapping.push(nameIndex);
+            }
+            mappings.push(mapping);
+            if (stringCharIterator.next() === ";") {
+                lineNumber += 1;
+                columnNumber = 0;
+            }
+        } while(stringCharIterator.hasNext());
+        return mappings;
+    },
+
+    _isSeparator: function(char)
+    {
+        return char === "," || char === ";";
+    },
+
+    _decodeVLQ: function(stringCharIterator)
+    {
+        // Read unsigned value.
+        var result = 0;
+        var shift = 0;
+        do {
+            var digit = this._base64Map[stringCharIterator.next()];
+            result += (digit & this._VLQ_BASE_MASK) << shift;
+            shift += this._VLQ_BASE_SHIFT;
+        } while (digit & this._VLQ_CONTINUATION_MASK);
+
+        // Fix the sign.
+        var negative = result & 1;
+        result >>= 1;
+        return negative ? -result : result;
+    },
+
+    _VLQ_BASE_SHIFT: 5,
+    _VLQ_BASE_MASK: (1 << 5) - 1,
+    _VLQ_CONTINUATION_MASK: 1 << 5
+}
+
+/**
+ * @constructor
+ */
+WebInspector.ClosureCompilerSourceMapping.StringCharIterator = function(string)
+{
+    this._string = string;
+    this._position = 0;
+}
+
+WebInspector.ClosureCompilerSourceMapping.StringCharIterator.prototype = {
+    next: function()
+    {
+        return this._string.charAt(this._position++);
+    },
+
+    peek: function()
+    {
+        return this._string.charAt(this._position);
+    },
+
+    hasNext: function()
+    {
+        return this._position < this._string.length;
+    }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/CompilerSourceMapping.js
___________________________________________________________________

Added: svn:eol-style

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


--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc	2011-09-06 17:36:19 UTC (rev 94577)
@@ -15,6 +15,7 @@
     <file>CallStackSidebarPane.js</file>
     <file>Checkbox.js</file>
     <file>Color.js</file>
+    <file>CompilerSourceMapping.js</file>
     <file>ConsoleMessage.js</file>
     <file>ConsoleModel.js</file>
     <file>ConsolePanel.js</file>

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


--- trunk/Source/WebCore/inspector/front-end/inspector.html	2011-09-06 16:41:56 UTC (rev 94576)
+++ trunk/Source/WebCore/inspector/front-end/inspector.html	2011-09-06 17:36:19 UTC (rev 94577)
@@ -161,6 +161,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