Title: [103805] trunk
Revision
103805
Author
podivi...@chromium.org
Date
2011-12-29 09:12:45 -0800 (Thu, 29 Dec 2011)

Log Message

Web Inspector: support sourceMappingURL magic comment.
https://bugs.webkit.org/show_bug.cgi?id=75356

Reviewed by Pavel Feldman.

Source/WebCore:

* inspector/ContentSearchUtils.cpp:
(WebCore::ContentSearchUtils::findSourceMapURL):
* inspector/ContentSearchUtils.h:
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::sourceMapURLForScript):

LayoutTests:

* http/tests/inspector/compiler-source-mapping-debug.html:
* http/tests/inspector/resources/compiled.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (103804 => 103805)


--- trunk/LayoutTests/ChangeLog	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/LayoutTests/ChangeLog	2011-12-29 17:12:45 UTC (rev 103805)
@@ -1,3 +1,13 @@
+2011-12-29  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support sourceMappingURL magic comment.
+        https://bugs.webkit.org/show_bug.cgi?id=75356
+
+        Reviewed by Pavel Feldman.
+
+        * http/tests/inspector/compiler-source-mapping-debug.html:
+        * http/tests/inspector/resources/compiled.js:
+
 2011-12-23  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: Implement CSS selector profiler

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


--- trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/LayoutTests/http/tests/inspector/compiler-source-mapping-debug.html	2011-12-29 17:12:45 UTC (rev 103805)
@@ -13,15 +13,6 @@
 
 function test()
 {
-    WebInspector.OriginalScript = WebInspector.Script;
-    WebInspector.Script = function()
-    {
-        WebInspector.OriginalScript.apply(this, arguments);
-        if (this.sourceURL.indexOf("compiled.js") !== -1)
-            this.sourceMapURL = "http://localhost:8000/inspector/resources/source-map.json";
-    }
-    WebInspector.Script.prototype = WebInspector.OriginalScript.prototype;
-
     InspectorTest.runDebuggerTestSuite([
         function testSetBreakpoint(next)
         {

Modified: trunk/LayoutTests/http/tests/inspector/resources/compiled.js (103804 => 103805)


--- trunk/LayoutTests/http/tests/inspector/resources/compiled.js	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/LayoutTests/http/tests/inspector/resources/compiled.js	2011-12-29 17:12:45 UTC (rev 103805)
@@ -1,2 +1,3 @@
 window.addEventListener("load",function(){var a=document.createElement("button");a.id="test";a.addEventListener("click",handleClick,!0);document.body.appendChild(a);a=document.createElement("div");a.id="barrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr";
 document.body.appendChild(a)});function handleClick(a){(new ClickHandler).handle(a)};function ClickHandler(){}ClickHandler.prototype.handle=function(){console.log("button clicked!")};
+//@ sourceMappingURL=source-map.json  

Modified: trunk/Source/WebCore/ChangeLog (103804 => 103805)


--- trunk/Source/WebCore/ChangeLog	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/Source/WebCore/ChangeLog	2011-12-29 17:12:45 UTC (rev 103805)
@@ -1,3 +1,16 @@
+2011-12-29  Pavel Podivilov  <podivi...@chromium.org>
+
+        Web Inspector: support sourceMappingURL magic comment.
+        https://bugs.webkit.org/show_bug.cgi?id=75356
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/ContentSearchUtils.cpp:
+        (WebCore::ContentSearchUtils::findSourceMapURL):
+        * inspector/ContentSearchUtils.h:
+        * inspector/InspectorDebuggerAgent.cpp:
+        (WebCore::InspectorDebuggerAgent::sourceMapURLForScript):
+
 2011-12-29  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: Suggest pop-over doesn't hide on tab switch

Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.cpp (103804 => 103805)


--- trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.cpp	2011-12-29 17:12:45 UTC (rev 103805)
@@ -34,6 +34,9 @@
 #include "InspectorValues.h"
 #include "RegularExpression.h"
 
+#include <wtf/BumpPointerAllocator.h>
+#include <yarr/Yarr.h>
+
 using namespace std;
 
 namespace WebCore {
@@ -137,6 +140,26 @@
     return result;
 }
 
+String findSourceMapURL(const String& content)
+{
+    DEFINE_STATIC_LOCAL(String, patternString, ("//@[\040\t]sourceMappingURL=[\040\t]*([^\\s\'\"]*)"));
+    const char* error;
+    JSC::Yarr::YarrPattern pattern(JSC::UString(patternString.impl()), false, false, &error);
+    ASSERT(!error);
+    BumpPointerAllocator regexAllocator;
+    OwnPtr<JSC::Yarr::BytecodePattern> bytecodePattern = JSC::Yarr::byteCompile(pattern, &regexAllocator);
+    ASSERT(bytecodePattern);
+
+    ASSERT(pattern.m_numSubpatterns == 1);
+    Vector<int, 4> matches;
+    matches.resize(4);
+    int result = JSC::Yarr::interpret(bytecodePattern.get(), JSC::UString(content.impl()), 0, content.length(), matches.data());
+    if (result < 0)
+        return String();
+    ASSERT(matches[2] > 0 && matches[3] > 0);
+    return content.substring(matches[2], matches[3]);
+}
+
 } // namespace ContentSearchUtils
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/inspector/ContentSearchUtils.h (103804 => 103805)


--- trunk/Source/WebCore/inspector/ContentSearchUtils.h	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/Source/WebCore/inspector/ContentSearchUtils.h	2011-12-29 17:12:45 UTC (rev 103805)
@@ -44,6 +44,8 @@
 int countRegularExpressionMatches(const RegularExpression&, const String&);
 PassRefPtr<InspectorArray> searchInTextByLines(const String& text, const String& query, const bool caseSensitive, const bool isRegex);
 
+String findSourceMapURL(const String& content);
+
 } // namespace ContentSearchUtils
 } // namespace WebCore
 

Modified: trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp (103804 => 103805)


--- trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-12-29 17:08:05 UTC (rev 103804)
+++ trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp	2011-12-29 17:12:45 UTC (rev 103805)
@@ -478,6 +478,10 @@
 {
     DEFINE_STATIC_LOCAL(String, sourceMapHttpHeader, ("X-SourceMap"));
 
+    String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source);
+    if (!sourceMapURL.isEmpty())
+        return sourceMapURL;
+
     if (script.url.isEmpty())
         return String();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to