Web Inspector: add runtime flag to determine if inspector's source files were flattened.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 08:37:42 +0000 (08:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2013 08:37:42 +0000 (08:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111184

Patch by Andrey Lushnikov <lushnikov@chromium.org> on 2013-03-04
Reviewed by Pavel Feldman.

Source/WebCore:

- Add a file "buildSystemOnly.js" which will be included into
devtools.html only by GYP build system. This script sets a single flag
which essentially means that inspector source files were run
through a build system and flattened.
- Update "importScript" and "registerRequiredCSS" functions to correct
paths according to the "flattenImports" flag.

No new tests: no change in behaviour.

* WebCore.gypi:
* inspector/front-end/CodeMirrorTextEditor.js:
(WebInspector.CodeMirrorTextEditor):
* inspector/front-end/View.js:
(WebInspector.View.prototype.registerRequiredCSS):
* inspector/front-end/buildSystemOnly.js: Added.
* inspector/front-end/utilities.js:

Source/WebKit/chromium:

Included "buildSystemOnly.js" in devtools.html by generate_devtools_html.py script.

* WebKit.gyp:
* scripts/generate_devtools_html.py: Add script tag to include buildSystemOnly.js
(write_devtools_html):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144605 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/inspector/front-end/CodeMirrorTextEditor.js
Source/WebCore/inspector/front-end/View.js
Source/WebCore/inspector/front-end/buildSystemOnly.js [new file with mode: 0644]
Source/WebCore/inspector/front-end/utilities.js
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/WebKit.gyp
Source/WebKit/chromium/scripts/generate_devtools_html.py

index cac2bd8..0903912 100644 (file)
@@ -1,3 +1,27 @@
+2013-03-04  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        Web Inspector: add runtime flag to determine if inspector's source files were flattened.
+        https://bugs.webkit.org/show_bug.cgi?id=111184
+
+        Reviewed by Pavel Feldman.
+
+        - Add a file "buildSystemOnly.js" which will be included into
+        devtools.html only by GYP build system. This script sets a single flag
+        which essentially means that inspector source files were run
+        through a build system and flattened.
+        - Update "importScript" and "registerRequiredCSS" functions to correct
+        paths according to the "flattenImports" flag.
+
+        No new tests: no change in behaviour.
+
+        * WebCore.gypi:
+        * inspector/front-end/CodeMirrorTextEditor.js:
+        (WebInspector.CodeMirrorTextEditor):
+        * inspector/front-end/View.js:
+        (WebInspector.View.prototype.registerRequiredCSS):
+        * inspector/front-end/buildSystemOnly.js: Added.
+        * inspector/front-end/utilities.js:
+
 2013-03-04  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Fix front-end compilation
index 713fb8d..53121df 100644 (file)
             'inspector/front-end/inspectorSyntaxHighlight.css',
             'inspector/front-end/popover.css',
             '<@(webinspector_modules_js_files)',
-            '<@(webinspector_standalone_css_files)',
+            '<@(webinspector_standalone_files)',
         ],
-        'webinspector_standalone_css_files': [
+        'webinspector_standalone_files': [
             'inspector/front-end/auditsPanel.css',
             'inspector/front-end/breadcrumbList.css',
+            'inspector/front-end/buildSystemOnly.js',
             'inspector/front-end/cm/cmdevtools.css',
             'inspector/front-end/cm/codemirror.css',
             'inspector/front-end/cssNamedFlows.css',
index 282c66a..d7450a1 100644 (file)
@@ -47,8 +47,8 @@ WebInspector.CodeMirrorTextEditor = function(url, delegate)
     this._delegate = delegate;
     this._url = url;
 
-    this.registerRequiredCSS("codemirror.css");
-    this.registerRequiredCSS("cmdevtools.css");
+    this.registerRequiredCSS("cm/codemirror.css");
+    this.registerRequiredCSS("cm/cmdevtools.css");
 
     this._codeMirror = window.CodeMirror(this.element, {
         lineNumbers: true,
index 7bf3c55..e1e601f 100644 (file)
@@ -299,6 +299,8 @@ WebInspector.View.prototype = {
 
     registerRequiredCSS: function(cssFile)
     {
+        if (window.flattenImports)
+            cssFile = cssFile.split("/").reverse()[0];
         this._cssFiles.push(cssFile);
     },
 
diff --git a/Source/WebCore/inspector/front-end/buildSystemOnly.js b/Source/WebCore/inspector/front-end/buildSystemOnly.js
new file mode 100644 (file)
index 0000000..1fcd75c
--- /dev/null
@@ -0,0 +1,6 @@
+/**
+ * This flag notifies inspector that it was deployed with the help
+ * of a build system. Build system flattenes all css and js files,
+ * so in this case inspector has to correct paths for dynamic resource loading.
+ */
+window.flattenImports = true;
index 8dd2384..d415ca0 100644 (file)
@@ -982,15 +982,10 @@ function importScript(scriptName)
         return;
     var xhr = new XMLHttpRequest();
     _importedScripts[scriptName] = true;
-    try {
-        xhr.open("GET", scriptName, false);
-        xhr.send(null);
-    } catch (e) {
-        // Try to load file from the root directory
+    if (window.flattenImports)
         scriptName = scriptName.split("/").reverse()[0];
-        xhr.open("GET", scriptName, false);
-        xhr.send(null);
-    }
+    xhr.open("GET", scriptName, false);
+    xhr.send(null);
     var sourceURL = WebInspector.ParsedURL.completeURL(window.location.href, scriptName); 
     window.eval(xhr.responseText + "\n//@ sourceURL=" + sourceURL);
 }
index 6643a35..7bb871b 100644 (file)
@@ -1,3 +1,16 @@
+2013-03-04  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        Web Inspector: add runtime flag to determine if inspector's source files were flattened.
+        https://bugs.webkit.org/show_bug.cgi?id=111184
+
+        Reviewed by Pavel Feldman.
+
+        Included "buildSystemOnly.js" in devtools.html by generate_devtools_html.py script.
+
+        * WebKit.gyp:
+        * scripts/generate_devtools_html.py: Add script tag to include buildSystemOnly.js
+        (write_devtools_html):
+
 2013-03-03  Alexandre Elias  <aelias@chromium.org>
 
         [chromium] Remove WebLayerTreeView::setViewportSize call
index f78544c..e41ee41 100644 (file)
                             '<(PRODUCT_DIR)/resources/inspector/ScriptFormatterWorker.js',
                             '<(PRODUCT_DIR)/resources/inspector/devTools.css',
                             '<(PRODUCT_DIR)/resources/inspector/devtools_extension_api.js',
-                            '<@(webinspector_standalone_css_files)',
+                            '<@(webinspector_standalone_files)',
                         ],
                         'images': [
                             '<@(webinspector_image_files)',
                     'copies': [{
                         'destination': '<(PRODUCT_DIR)/resources/inspector',
                         'files': [
-                            '<@(webinspector_standalone_css_files)',
+                            '<@(webinspector_standalone_files)',
                         ],
                     }],
                 },
index 66255a8..4ea2e27 100644 (file)
@@ -57,6 +57,8 @@ def write_devtools_html(inspector_file, devtools_file, debug, debug_files):
                 devtools_file.write(generate_include_tag("devTools.css"))
                 devtools_file.write(generate_include_tag("DevTools.js"))
         devtools_file.write(line)
+        if '<head>' in line:
+            devtools_file.write(generate_include_tag("buildSystemOnly.js"))
 
 
 def main(argv):