Title: [124026] trunk/Source/WebCore
Revision
124026
Author
[email protected]
Date
2012-07-30 08:12:23 -0700 (Mon, 30 Jul 2012)

Log Message

Web Inspector: support --line-numbers mapping for SASS
https://bugs.webkit.org/show_bug.cgi?id=92400

Reviewed by Vsevolod Vlasov.

There is --debug-info and --line-numbers ways of referencing the source scss file, adding support for --line-numbers here.

* inspector/front-end/SASSSourceMapping.js:
(WebInspector.SASSSourceMapping.prototype._resourceAdded.didRequestContent):
(WebInspector.SASSSourceMapping.prototype._resourceAdded):
(_bindUISourceCode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124025 => 124026)


--- trunk/Source/WebCore/ChangeLog	2012-07-30 14:32:16 UTC (rev 124025)
+++ trunk/Source/WebCore/ChangeLog	2012-07-30 15:12:23 UTC (rev 124026)
@@ -1,3 +1,17 @@
+2012-07-30  Pavel Feldman  <[email protected]>
+
+        Web Inspector: support --line-numbers mapping for SASS
+        https://bugs.webkit.org/show_bug.cgi?id=92400
+
+        Reviewed by Vsevolod Vlasov.
+
+        There is --debug-info and --line-numbers ways of referencing the source scss file, adding support for --line-numbers here.
+
+        * inspector/front-end/SASSSourceMapping.js:
+        (WebInspector.SASSSourceMapping.prototype._resourceAdded.didRequestContent):
+        (WebInspector.SASSSourceMapping.prototype._resourceAdded):
+        (_bindUISourceCode):
+
 2012-07-30  Keishi Hattori  <[email protected]>
 
         Implement datalist UI for input type color for Chromium

Modified: trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js (124025 => 124026)


--- trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js	2012-07-30 14:32:16 UTC (rev 124025)
+++ trunk/Source/WebCore/inspector/front-end/SASSSourceMapping.js	2012-07-30 15:12:23 UTC (rev 124026)
@@ -80,29 +80,54 @@
             if (!content)
                 return;
             var lines = content.split(/\r?\n/);
-            var regex = /@media\s\-sass\-debug\-info{filename{font-family:([^}]+)}line{font-family:\\[0]+([^}]*)}}/i;
+            var debugInfoRegex = /@media\s\-sass\-debug\-info{filename{font-family:([^}]+)}line{font-family:\\[0]+([^}]*)}}/i;
+            var lineNumbersRegex = /\/\*\s+line\s+([0-9]+),\s+([^*\/]+)/;
             for (var lineNumber = 0; lineNumber < lines.length; ++lineNumber) {
-                var match = regex.exec(lines[lineNumber]);
-                if (!match)
+                var match = debugInfoRegex.exec(lines[lineNumber]);
+                if (match) {
+                    var url = "" "$1");
+                    var line = parseInt(decodeURI(match[2].replace(/(..)/g, "%$1")), 10);
+                    this._bindUISourceCode(url, line, resource.url, lineNumber);
                     continue;
-                var url = "" "$1");
-                var uiSourceCode = this._uiSourceCodeForURL[url];
-                if (!uiSourceCode) {
-                    uiSourceCode = new WebInspector.SASSSource(url);
-                    this._uiSourceCodeForURL[url] = uiSourceCode;
-                    this._uiSourceCodes.push(uiSourceCode);
-                    this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
-                    WebInspector.cssModel.setSourceMapping(resource.url, this);
                 }
-                var line = parseInt(decodeURI(match[2].replace(/(..)/g, "%$1")), 10) - 1;
-                var rawLocationString = resource.url + ":" + (lineNumber + 1);
-                this._uiLocations[rawLocationString] = new WebInspector.UILocation(uiSourceCode, line, 0);
+                match = lineNumbersRegex.exec(lines[lineNumber]);
+                if (match) {
+                    var fileName = match[2].trim();
+                    var line = parseInt(match[1], 10);
+                    var url = ""
+                    if (url.endsWith("/" + resource.parsedURL.lastPathComponent))
+                        url = "" url.length - resource.parsedURL.lastPathComponent.length) + fileName;
+                    else
+                        url = ""
+                    this._bindUISourceCode(url, line, resource.url, lineNumber);
+                    continue;
+                }
             }
         }
         resource.requestContent(didRequestContent.bind(this));
     },
 
     /**
+     * @param {string} url
+     * @param {number} line
+     * @param {string} rawURL
+     * @param {number} rawLine
+     */
+    _bindUISourceCode: function(url, line, rawURL, rawLine)
+    {
+        var uiSourceCode = this._uiSourceCodeForURL[url];
+        if (!uiSourceCode) {
+            uiSourceCode = new WebInspector.SASSSource(url);
+            this._uiSourceCodeForURL[url] = uiSourceCode;
+            this._uiSourceCodes.push(uiSourceCode);
+            this.dispatchEventToListeners(WebInspector.UISourceCodeProvider.Events.UISourceCodeAdded, uiSourceCode);
+            WebInspector.cssModel.setSourceMapping(rawURL, this);
+        }
+        var rawLocationString = rawURL + ":" + (rawLine + 1);  // Next line after mapping metainfo
+        this._uiLocations[rawLocationString] = new WebInspector.UILocation(uiSourceCode, line - 1, 0);
+    },
+
+    /**
      * @param {WebInspector.RawLocation} rawLocation
      * @return {WebInspector.UILocation}
      */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to