[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198

podivilov at chromium.org podivilov at chromium.org
Sun Feb 20 23:06:00 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit 3dcea969518547e9f6b73b3dcec9f274967a01d2
Author: podivilov at chromium.org <podivilov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 17 14:13:43 2011 +0000

    2011-01-17  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: refactoring: encapsulate lazy initialization of SourceFrame.
            https://bugs.webkit.org/show_bug.cgi?id=51738
    
            * http/tests/inspector/debugger-test2.js:
            (initialize_DebuggerTest.InspectorTest.showScriptSource):
            (initialize_DebuggerTest.InspectorTest._showScriptSource):
            * inspector/debugger-pause-in-eval-script-expected.txt:
            * inspector/debugger-pause-in-eval-script.html:
    2011-01-17  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: refactoring: encapsulate lazy initialization of SourceFrame.
            https://bugs.webkit.org/show_bug.cgi?id=51738
    
            Extract content loading logic from SourceView and ScriptView to ContentProvider implementations.
            Pass ContentProvider in SourceFrame constructor to allow SourceFrame manage it's lazy initialization.
    
            * inspector/front-end/ScriptView.js:
            (WebInspector.ScriptView):
            (WebInspector.SourceFrameContentProviderForScript):
            (WebInspector.SourceFrameContentProviderForScript.prototype.requestContent.didRequestSource):
            (WebInspector.SourceFrameContentProviderForScript.prototype.requestContent):
            (WebInspector.SourceFrameContentProviderForScript.prototype.scripts):
            * inspector/front-end/ScriptsPanel.js:
            (WebInspector.ScriptsPanel.prototype._addScript):
            (WebInspector.ScriptsPanel.prototype.sourceFrameForScript):
            (WebInspector.ScriptsPanel.prototype._sourceFrameForResource):
            * inspector/front-end/SourceFrame.js:
            (WebInspector.SourceFrame):
            (WebInspector.SourceFrame.prototype.set visible):
            (WebInspector.SourceFrame.prototype._createTextViewer):
            (WebInspector.SourceFrame.prototype._breakpointAdded):
            (WebInspector.SourceFrame.prototype._breakpoints):
            (WebInspector.SourceFrame.prototype._sourceIDForLine):
            (WebInspector.SourceFrame.prototype._sourceIDSet):
            (WebInspector.SourceFrameContentProvider):
            (WebInspector.SourceFrameContentProvider.prototype.requestContent):
            (WebInspector.SourceFrameContentProvider.prototype.scripts):
            * inspector/front-end/SourceView.js:
            (WebInspector.SourceView):
            (WebInspector.SourceView.prototype.show):
            (WebInspector.SourceView.prototype.resize):
            (WebInspector.SourceView.prototype.performSearch.didFindSearchMatches):
            (WebInspector.SourceView.prototype.performSearch):
            (WebInspector.SourceView.prototype.revealLine):
            (WebInspector.SourceView.prototype.highlightLine):
            (WebInspector.SourceView.prototype._jumpToSearchResult):
            (WebInspector.SourceFrameContentProviderForResource):
            (WebInspector.SourceFrameContentProviderForResource.prototype.requestContent):
            (WebInspector.SourceFrameContentProviderForResource.prototype.scripts):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75937 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 2e422aa..dcae2db 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,16 @@
+2011-01-17  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: refactoring: encapsulate lazy initialization of SourceFrame.
+        https://bugs.webkit.org/show_bug.cgi?id=51738
+
+        * http/tests/inspector/debugger-test2.js:
+        (initialize_DebuggerTest.InspectorTest.showScriptSource):
+        (initialize_DebuggerTest.InspectorTest._showScriptSource):
+        * inspector/debugger-pause-in-eval-script-expected.txt:
+        * inspector/debugger-pause-in-eval-script.html:
+
 2011-01-17  John Knottenbelt  <jknotten at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/LayoutTests/http/tests/inspector/debugger-test2.js b/LayoutTests/http/tests/inspector/debugger-test2.js
index da2bac3..39a0d55 100644
--- a/LayoutTests/http/tests/inspector/debugger-test2.js
+++ b/LayoutTests/http/tests/inspector/debugger-test2.js
@@ -121,21 +121,13 @@ InspectorTest._resumedScript = function()
 
 InspectorTest.showScriptSource = function(scriptName, callback)
 {
-    if (InspectorTest._scriptsAreParsed([scriptName]))
-        InspectorTest._showScriptSource(scriptName, callback);
-    else
+    if (InspectorTest._scriptsAreParsed([scriptName])) {
+        var scriptOrResource = InspectorTest._showScriptSource(scriptName);
+        callback(scriptOrResource.sourceFrame);
+    } else
         InspectorTest._addSniffer(WebInspector.debuggerModel, "_parsedScriptSource", InspectorTest.showScriptSource.bind(InspectorTest, scriptName, callback));
 };
 
-InspectorTest.waitUntilCurrentSourceFrameIsLoaded = function(callback)
-{
-    var sourceFrame = WebInspector.currentPanel.visibleView.sourceFrame;
-    if (sourceFrame._loaded)
-        callback(sourceFrame);
-    else
-        InspectorTest._addSniffer(sourceFrame, "setContent", callback.bind(null, sourceFrame));
-};
-
 InspectorTest._scriptsAreParsed = function(scripts)
 {
     var scriptSelect = document.getElementById("scripts-files");
@@ -177,8 +169,7 @@ InspectorTest._showScriptSource = function(scriptName, callback)
         scriptResource = options[pageScriptIndex].representedObject;
         scriptsPanel._showScriptOrResource(scriptResource);
     }
-
-    InspectorTest.waitUntilCurrentSourceFrameIsLoaded(callback);
+    return scriptResource;
 };
 
 InspectorTest.expandProperties = function(properties, callback)
diff --git a/LayoutTests/inspector/debugger-pause-in-eval-script-expected.txt b/LayoutTests/inspector/debugger-pause-in-eval-script-expected.txt
index fb89c5a..018b783 100644
--- a/LayoutTests/inspector/debugger-pause-in-eval-script-expected.txt
+++ b/LayoutTests/inspector/debugger-pause-in-eval-script-expected.txt
@@ -3,8 +3,8 @@ Tests that debugger will stop on "debugger" statement in a function that was add
 Debugger was enabled.
 Evaluated script in console.
 Script execution paused.
-Execution line number: 4
-Execution line text:     debugger;
+Call stack:
+    0) testFunction (:4)
 Script execution resumed.
 Debugger was disabled.
 
diff --git a/LayoutTests/inspector/debugger-pause-in-eval-script.html b/LayoutTests/inspector/debugger-pause-in-eval-script.html
index be4e7ea..575cf67 100644
--- a/LayoutTests/inspector/debugger-pause-in-eval-script.html
+++ b/LayoutTests/inspector/debugger-pause-in-eval-script.html
@@ -20,15 +20,9 @@ var test = function()
         InspectorTest.waitUntilPaused(step2);
     }
 
-    function step2()
+    function step2(callFrames)
     {
-        InspectorTest.waitUntilCurrentSourceFrameIsLoaded(step3);
-    }
-
-    function step3(sourceFrame)
-    {
-        InspectorTest.addResult("Execution line number: " + sourceFrame.executionLine);
-        InspectorTest.addResult("Execution line text: " + sourceFrame._textModel.line(sourceFrame.executionLine - 1));
+        InspectorTest.captureStackTrace(callFrames);
         InspectorTest.completeDebuggerTest();
     }
 }
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2e509cf..ada7216 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,47 @@
+2011-01-17  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: refactoring: encapsulate lazy initialization of SourceFrame.
+        https://bugs.webkit.org/show_bug.cgi?id=51738
+
+        Extract content loading logic from SourceView and ScriptView to ContentProvider implementations.
+        Pass ContentProvider in SourceFrame constructor to allow SourceFrame manage it's lazy initialization.
+
+        * inspector/front-end/ScriptView.js:
+        (WebInspector.ScriptView):
+        (WebInspector.SourceFrameContentProviderForScript):
+        (WebInspector.SourceFrameContentProviderForScript.prototype.requestContent.didRequestSource):
+        (WebInspector.SourceFrameContentProviderForScript.prototype.requestContent):
+        (WebInspector.SourceFrameContentProviderForScript.prototype.scripts):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._addScript):
+        (WebInspector.ScriptsPanel.prototype.sourceFrameForScript):
+        (WebInspector.ScriptsPanel.prototype._sourceFrameForResource):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.prototype.set visible):
+        (WebInspector.SourceFrame.prototype._createTextViewer):
+        (WebInspector.SourceFrame.prototype._breakpointAdded):
+        (WebInspector.SourceFrame.prototype._breakpoints):
+        (WebInspector.SourceFrame.prototype._sourceIDForLine):
+        (WebInspector.SourceFrame.prototype._sourceIDSet):
+        (WebInspector.SourceFrameContentProvider):
+        (WebInspector.SourceFrameContentProvider.prototype.requestContent):
+        (WebInspector.SourceFrameContentProvider.prototype.scripts):
+        * inspector/front-end/SourceView.js:
+        (WebInspector.SourceView):
+        (WebInspector.SourceView.prototype.show):
+        (WebInspector.SourceView.prototype.resize):
+        (WebInspector.SourceView.prototype.performSearch.didFindSearchMatches):
+        (WebInspector.SourceView.prototype.performSearch):
+        (WebInspector.SourceView.prototype.revealLine):
+        (WebInspector.SourceView.prototype.highlightLine):
+        (WebInspector.SourceView.prototype._jumpToSearchResult):
+        (WebInspector.SourceFrameContentProviderForResource):
+        (WebInspector.SourceFrameContentProviderForResource.prototype.requestContent):
+        (WebInspector.SourceFrameContentProviderForResource.prototype.scripts):
+
 2011-01-17  John Knottenbelt  <jknotten at chromium.org>
 
         Reviewed by Jeremy Orlow.
diff --git a/Source/WebCore/inspector/front-end/ScriptView.js b/Source/WebCore/inspector/front-end/ScriptView.js
index e441a50..d6c1c59 100644
--- a/Source/WebCore/inspector/front-end/ScriptView.js
+++ b/Source/WebCore/inspector/front-end/ScriptView.js
@@ -29,55 +29,15 @@ WebInspector.ScriptView = function(script)
 
     this.element.addStyleClass("script-view");
 
-    this.script = script;
-
-    this._frameNeedsSetup = true;
-    this._sourceFrameSetup = false;
-    this.sourceFrame = new WebInspector.SourceFrame(this.element, [script], WebInspector.panels.scripts.canEditScripts());
+    var contentProvider = new WebInspector.SourceFrameContentProviderForScript(script);
+    this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", WebInspector.panels.scripts.canEditScripts());
 }
 
 WebInspector.ScriptView.prototype = {
-    show: function(parentElement)
-    {
-        WebInspector.View.prototype.show.call(this, parentElement);
-        this.setupSourceFrameIfNeeded();
-        this.sourceFrame.visible = true;
-        this.resize();
-    },
-
-    setupSourceFrameIfNeeded: function()
-    {
-        if (!this._frameNeedsSetup)
-            return;
-        delete this._frameNeedsSetup;
-
-        this.attach();
-
-        function didRequestSource(source)
-        {
-            source = source || WebInspector.UIString("<source is not available>");
-            this.sourceFrame.setContent("text/javascript", this._prependWhitespace(source));
-            this._sourceFrameSetup = true;
-        }
-        this.script.requestSource(didRequestSource.bind(this));
-    },
-
-    _prependWhitespace: function(content) {
-        var prefix = "";
-        for (var i = 0; i < this.script.startingLine - 1; ++i)
-            prefix += "\n";
-        return prefix + content;
-    },
-
-    attach: function()
-    {
-        if (!this.element.parentNode)
-            document.getElementById("script-resource-views").appendChild(this.element);
-    },
-
     // The following methods are pulled from SourceView, since they are
     // generic and work with ScriptView just fine.
 
+    show: WebInspector.SourceView.prototype.show,
     hide: WebInspector.SourceView.prototype.hide,
     revealLine: WebInspector.SourceView.prototype.revealLine,
     highlightLine: WebInspector.SourceView.prototype.highlightLine,
@@ -96,3 +56,41 @@ WebInspector.ScriptView.prototype = {
 }
 
 WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype;
+
+
+WebInspector.SourceFrameContentProviderForScript = function(script)
+{
+    WebInspector.SourceFrameContentProvider.call(this);
+    this._script = script;
+}
+
+WebInspector.SourceFrameContentProviderForScript.prototype = {
+    requestContent: function(callback)
+    {
+        if (this._script.source) {
+            callback("text/javascript", this._script.source);
+            return;
+        }
+
+        function didRequestSource(content)
+        {
+            var source;
+            if (content) {
+                var prefix = "";
+                for (var i = 0; i < this._script.startingLine - 1; ++i)
+                    prefix += "\n";
+                source = prefix + content;
+            } else
+                source = WebInspector.UIString("<source is not available>");
+            callback("text/javascript", source);
+        }
+        this._script.requestSource(didRequestSource.bind(this));
+    },
+
+    scripts: function()
+    {
+        return [this._script];
+    }
+}
+
+WebInspector.SourceFrameContentProviderForScript.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;
diff --git a/Source/WebCore/inspector/front-end/ScriptsPanel.js b/Source/WebCore/inspector/front-end/ScriptsPanel.js
index a04970e..82c1b39 100644
--- a/Source/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js
@@ -256,9 +256,6 @@ WebInspector.ScriptsPanel.prototype = {
             if (resource.finished) {
                 // Resource is finished, bind the script right away.
                 script.resource = resource;
-                var view = WebInspector.ResourceView.existingResourceViewForResource(resource);
-                if (view && view.sourceFrame)
-                    view.sourceFrame.addScript(script);
             } else {
                 // Resource is not finished, bind the script later.
                 if (!resource._scriptsPendingResourceLoad) {
@@ -536,7 +533,6 @@ WebInspector.ScriptsPanel.prototype = {
         if (!this.element.parentNode)
             this.attach();
 
-        view.setupSourceFrameIfNeeded();
         return view.sourceFrame;
     },
 
@@ -554,10 +550,6 @@ WebInspector.ScriptsPanel.prototype = {
         if (!view)
             return null;
 
-        if (!view.setupSourceFrameIfNeeded)
-            return null;
-
-        view.setupSourceFrameIfNeeded();
         return view.sourceFrame;
     },
 
diff --git a/Source/WebCore/inspector/front-end/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js
index 3d1c926..af10f1e 100644
--- a/Source/WebCore/inspector/front-end/SourceFrame.js
+++ b/Source/WebCore/inspector/front-end/SourceFrame.js
@@ -28,12 +28,11 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts)
+WebInspector.SourceFrame = function(parentElement, contentProvider, url, canEditScripts)
 {
     this._parentElement = parentElement;
-    this._scripts = {};
-    for (var i = 0; i < scripts.length; ++i)
-        this._scripts[scripts[i].sourceID] = scripts[i];
+    this._contentProvider = contentProvider;
+    this._url = url;
     this._canEditScripts = canEditScripts;
 
     this._textModel = new WebInspector.TextEditorModel();
@@ -43,7 +42,6 @@ WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts)
     this._rowMessages = {};
     this._messageBubbles = {};
 
-    this._loaded = false;
     this._popoverObjectGroup = "popover";
 }
 
@@ -51,14 +49,18 @@ WebInspector.SourceFrame.prototype = {
 
     set visible(visible)
     {
-        this._visible = visible;
-        this._createViewerIfNeeded();
+        if (!this._contentRequested) {
+            this._contentRequested = true;
+            this._contentProvider.requestContent(this._createTextViewer.bind(this));
+        }
 
         if (visible) {
             if (this._textViewer && this._scrollTop)
                 this._textViewer.element.scrollTop = this._scrollTop;
             if (this._textViewer && this._scrollLeft)
                 this._textViewer.element.scrollLeft = this._scrollLeft;
+            if (this._textViewer)
+                this._textViewer.resize();
         } else {
             this._hidePopup();
             if (this._textViewer) {
@@ -114,11 +116,6 @@ WebInspector.SourceFrame.prototype = {
             this._addMessageToSource(msg);
     },
 
-    addScript: function(script)
-    {
-        this._scripts[script.sourceID] = script;
-    },
-
     clearMessages: function()
     {
         for (var line in this._messageBubbles) {
@@ -139,16 +136,6 @@ WebInspector.SourceFrame.prototype = {
             this._textViewer.revalidateDecorationsAndPaint();
     },
 
-    setContent: function(mimeType, content, url)
-    {
-        this._loaded = true;
-        this._textModel.setText(null, content);
-        this._mimeType = mimeType;
-        this._content = content;
-        this._url = url;
-        this._createViewerIfNeeded();
-    },
-
     get textModel()
     {
         return this._textModel;
@@ -181,10 +168,10 @@ WebInspector.SourceFrame.prototype = {
             delete this._lineToHighlight;
     },
 
-    _createViewerIfNeeded: function()
+    _createTextViewer: function(mimeType, content)
     {
-        if (!this._visible || !this._loaded || this._textViewer)
-            return;
+        this._content = content;
+        this._textModel.setText(null, content);
 
         this._textViewer = new WebInspector.TextViewer(this._textModel, WebInspector.platform, this._url);
         var element = this._textViewer.element;
@@ -196,7 +183,7 @@ WebInspector.SourceFrame.prototype = {
 
         this._textViewer.beginUpdates();
 
-        this._textViewer.mimeType = this._mimeType;
+        this._textViewer.mimeType = mimeType;
         this._addExistingMessagesToSource();
         this._updateExecutionLine();
         this._updateDiffDecorations();
@@ -419,7 +406,7 @@ WebInspector.SourceFrame.prototype = {
     {
         var breakpoint = event.data;
 
-        if (breakpoint.sourceID in this._scripts)
+        if (breakpoint.sourceID in this._sourceIDSet())
             this._addBreakpoint(breakpoint);
     },
 
@@ -846,8 +833,8 @@ WebInspector.SourceFrame.prototype = {
 
     _breakpoints: function()
     {
-        var scripts = this._scripts;
-        return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in scripts; });
+        var sourceIDSet = this._sourceIDSet();
+        return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in sourceIDSet; });
     },
 
     _findBreakpoint: function(lineNumber)
@@ -860,15 +847,42 @@ WebInspector.SourceFrame.prototype = {
     {
         var sourceIDForLine = null;
         var closestStartingLine = 0;
-        for (var sourceID in this._scripts) {
-            var script = this._scripts[sourceID];
-            if (script.startingLine <= lineNumber && script.startingLine >= closestStartingLine) {
-                closestStartingLine = script.startingLine;
-                sourceIDForLine = sourceID;
+        var scripts = this._contentProvider.scripts();
+        for (var i = 0; i < scripts.length; ++i) {
+            var startingLine = scripts[i].startingLine;
+            if (startingLine <= lineNumber && startingLine >= closestStartingLine) {
+                closestStartingLine = startingLine;
+                sourceIDForLine = scripts[i].sourceID;
             }
         }
         return sourceIDForLine;
+    },
+
+    _sourceIDSet: function()
+    {
+        var scripts = this._contentProvider.scripts();
+        var sourceIDSet = {};
+        for (var i = 0; i < scripts.length; ++i)
+            sourceIDSet[scripts[i].sourceID] = true;
+        return sourceIDSet;
     }
 }
 
 WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
+
+
+WebInspector.SourceFrameContentProvider = function()
+{
+}
+
+WebInspector.SourceFrameContentProvider.prototype = {
+    requestContent: function(callback)
+    {
+        // Should be implemented by subclasses.
+    },
+
+    scripts: function()
+    {
+        // Should be implemented by subclasses.
+    }
+}
diff --git a/Source/WebCore/inspector/front-end/SourceView.js b/Source/WebCore/inspector/front-end/SourceView.js
index 1e4ef5d..e78ff94 100644
--- a/Source/WebCore/inspector/front-end/SourceView.js
+++ b/Source/WebCore/inspector/front-end/SourceView.js
@@ -32,28 +32,16 @@ WebInspector.SourceView = function(resource)
 
     this.element.addStyleClass("source");
 
-    var scripts = WebInspector.debuggerModel.scriptsForURL(resource.url);
+    var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource);
     var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script;
-    this.sourceFrame = new WebInspector.SourceFrame(this.element, scripts, canEditScripts);
-    resource.addEventListener("finished", this._resourceLoadingFinished, this);
-    this._frameNeedsSetup = true;
-}
-
-// This is a map from resource.type to mime types
-// found in WebInspector.SourceTokenizer.Registry.
-WebInspector.SourceView.DefaultMIMETypeForResourceType = {
-    0: "text/html",
-    1: "text/css",
-    4: "text/javascript"
+    this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, canEditScripts);
 }
 
 WebInspector.SourceView.prototype = {
     show: function(parentElement)
     {
-        WebInspector.ResourceView.prototype.show.call(this, parentElement);
-        this.setupSourceFrameIfNeeded();
+        WebInspector.View.prototype.show.call(this, parentElement);
         this.sourceFrame.visible = true;
-        this.resize();
     },
 
     hide: function()
@@ -66,8 +54,7 @@ WebInspector.SourceView.prototype = {
 
     resize: function()
     {
-        if (this.sourceFrame)
-            this.sourceFrame.resize();
+        this.sourceFrame.resize();
     },
 
     get scrollTop()
@@ -80,42 +67,11 @@ WebInspector.SourceView.prototype = {
         this.sourceFrame.scrollTop = scrollTop;
     },
 
-
-    setupSourceFrameIfNeeded: function()
-    {
-        if (!this._frameNeedsSetup)
-            return;
-
-        delete this._frameNeedsSetup;
-        this.resource.requestContent(this._contentLoaded.bind(this));
-    },
-
     hasContent: function()
     {
         return true;
     },
 
-    _contentLoaded: function(content)
-    {
-        var mimeType = this._canonicalMimeType(this.resource);
-        this.sourceFrame.setContent(mimeType, content, this.resource.url);
-        this._sourceFrameSetupFinished();
-    },
-
-    _canonicalMimeType: function(resource)
-    {
-        return WebInspector.SourceView.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType;
-    },
-
-    _resourceLoadingFinished: function(event)
-    {
-        this._frameNeedsSetup = true;
-        this._sourceFrameSetup = false;
-        if (this.visible)
-            this.setupSourceFrameIfNeeded();
-        this.resource.removeEventListener("finished", this._resourceLoadingFinished, this);
-    },
-
     // The rest of the methods in this prototype need to be generic enough to work with a ScriptView.
     // The ScriptView prototype pulls these methods into it's prototype to avoid duplicate code.
 
@@ -138,7 +94,6 @@ WebInspector.SourceView.prototype = {
             if (this._searchResults)
                 finishedCallback(this, this._searchResults.length);
         }
-
         this.sourceFrame.findSearchMatches(query, didFindSearchMatches.bind(this));
     },
 
@@ -188,13 +143,11 @@ WebInspector.SourceView.prototype = {
 
     revealLine: function(lineNumber)
     {
-        this.setupSourceFrameIfNeeded();
         this.sourceFrame.revealLine(lineNumber);
     },
 
     highlightLine: function(lineNumber)
     {
-        this.setupSourceFrameIfNeeded();
         this.sourceFrame.highlightLine(lineNumber);
     },
 
@@ -215,17 +168,41 @@ WebInspector.SourceView.prototype = {
             return;
 
         this.sourceFrame.markAndRevealRange(foundRange);
-    },
+    }
+}
 
-    _sourceFrameSetupFinished: function()
+WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype;
+
+
+WebInspector.SourceFrameContentProviderForResource = function(resource)
+{
+    WebInspector.SourceFrameContentProvider.call(this);
+    this._resource = resource;
+}
+
+//This is a map from resource.type to mime types
+//found in WebInspector.SourceTokenizer.Registry.
+WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType = {
+ 0: "text/html",
+ 1: "text/css",
+ 4: "text/javascript"
+}
+
+WebInspector.SourceFrameContentProviderForResource.prototype = {
+    requestContent: function(callback)
     {
-        this._sourceFrameSetup = true;
-        this.resize();
-        if (this._delayedFindSearchMatches) {
-            this._delayedFindSearchMatches();
-            delete this._delayedFindSearchMatches;
+        function contentLoaded(content)
+        {
+            var mimeType = WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;
+            callback(mimeType, content);
         }
+        this._resource.requestContent(contentLoaded.bind(this));
+    },
+
+    scripts: function()
+    {
+        return WebInspector.debuggerModel.scriptsForURL(this._resource.url);
     }
 }
 
-WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype;
+WebInspector.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list