[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:41:48 UTC 2011


The following commit has been merged in the webkit-1.3 branch:
commit d3ae05bd1fe5cc32c9b6e8877a7dab6cd081a51e
Author: podivilov at chromium.org <podivilov at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 24 10:38:43 2011 +0000

    2011-01-21  Pavel Podivilov  <podivilov at chromium.org>
    
            Reviewed by Pavel Feldman.
    
            Web Inspector: eliminate SourceView and ScriptView classes.
            https://bugs.webkit.org/show_bug.cgi?id=52896
    
            SourceView and ScriptView delegate everything to SourceFrame and should be eliminated.
    
            * WebCore.gypi:
            * WebCore.vcproj/WebCore.vcproj:
            * inspector/front-end/GoToLineDialog.js:
            (WebInspector.GoToLineDialog.prototype._highlightSelectedLine):
            * inspector/front-end/ResourceView.js:
            (WebInspector.ResourceView.createResourceView):
            (WebInspector.ResourceView.resourceViewTypeMatchesResource):
            (WebInspector.SourceFrameContentProviderForResource):  Moved from SourceView.
            * inspector/front-end/ResourcesPanel.js:
            (WebInspector.ResourcesPanel.prototype.show):
            (WebInspector.ResourcesPanel.prototype._applyDiffMarkup):
            (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
            * inspector/front-end/ScriptView.js: Removed.
            * inspector/front-end/ScriptsPanel.js:
            (WebInspector.ScriptsPanel.prototype._scriptSourceChanged):
            (WebInspector.ScriptsPanel.prototype._sourceFrameForScriptOrResource):
            (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
            (WebInspector.ScriptsPanel.prototype._setPauseOnExceptions):
            (WebInspector.ScriptsPanel.prototype._formatScript):
            (WebInspector.SourceFrameContentProviderForScript): Moved from ScriptView.
            * inspector/front-end/SourceFrame.js:
            (WebInspector.SourceFrame):
            (WebInspector.SourceFrame.prototype.show):
            (WebInspector.SourceFrame.prototype.hide):
            (WebInspector.SourceFrame.prototype.hasContent):
            (WebInspector.SourceFrame.prototype._createTextViewer):
            (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
            (WebInspector.SourceFrame.prototype.performSearch):
            * inspector/front-end/SourceView.js: Removed.
            * inspector/front-end/WebKit.qrc:
            * inspector/front-end/inspector.html:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76497 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 2fe3b5b..2141cc1 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,44 @@
+2011-01-21  Pavel Podivilov  <podivilov at chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        Web Inspector: eliminate SourceView and ScriptView classes.
+        https://bugs.webkit.org/show_bug.cgi?id=52896
+
+        SourceView and ScriptView delegate everything to SourceFrame and should be eliminated.
+
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * inspector/front-end/GoToLineDialog.js:
+        (WebInspector.GoToLineDialog.prototype._highlightSelectedLine):
+        * inspector/front-end/ResourceView.js:
+        (WebInspector.ResourceView.createResourceView):
+        (WebInspector.ResourceView.resourceViewTypeMatchesResource):
+        (WebInspector.SourceFrameContentProviderForResource):  Moved from SourceView.
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.prototype.show):
+        (WebInspector.ResourcesPanel.prototype._applyDiffMarkup):
+        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsUpdated):
+        * inspector/front-end/ScriptView.js: Removed.
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.prototype._scriptSourceChanged):
+        (WebInspector.ScriptsPanel.prototype._sourceFrameForScriptOrResource):
+        (WebInspector.ScriptsPanel.prototype._showScriptOrResource):
+        (WebInspector.ScriptsPanel.prototype._setPauseOnExceptions):
+        (WebInspector.ScriptsPanel.prototype._formatScript):
+        (WebInspector.SourceFrameContentProviderForScript): Moved from ScriptView.
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame):
+        (WebInspector.SourceFrame.prototype.show):
+        (WebInspector.SourceFrame.prototype.hide):
+        (WebInspector.SourceFrame.prototype.hasContent):
+        (WebInspector.SourceFrame.prototype._createTextViewer):
+        (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
+        (WebInspector.SourceFrame.prototype.performSearch):
+        * inspector/front-end/SourceView.js: Removed.
+        * inspector/front-end/WebKit.qrc:
+        * inspector/front-end/inspector.html:
+
 2011-01-24  Andras Becsi  <abecsi at webkit.org>
 
         Reviewed by Csaba Osztrogonác.
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index b8028ff..35324b9 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -4716,7 +4716,6 @@
             'inspector/front-end/ScriptFormatter.js',
             'inspector/front-end/ScriptFormatterWorker.js',
             'inspector/front-end/ScriptsPanel.js',
-            'inspector/front-end/ScriptView.js',
             'inspector/front-end/ShortcutsHelp.js',
             'inspector/front-end/Section.js',
             'inspector/front-end/Settings.js',
@@ -4727,7 +4726,6 @@
             'inspector/front-end/SourceHTMLTokenizer.js',
             'inspector/front-end/SourceJavaScriptTokenizer.js',
             'inspector/front-end/SourceTokenizer.js',
-            'inspector/front-end/SourceView.js',
             'inspector/front-end/StatusBarButton.js',
             'inspector/front-end/StylesSidebarPane.js',
             'inspector/front-end/SummaryBar.js',
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index c558d8e..f2d92bb 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -65701,10 +65701,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\inspector\front-end\ScriptView.js"
-					>
-				</File>
-				<File
 					RelativePath="..\inspector\front-end\Section.js"
 					>
 				</File>
@@ -65745,10 +65741,6 @@
 					>
 				</File>
 				<File
-					RelativePath="..\inspector\front-end\SourceView.js"
-					>
-				</File>
-				<File
 					RelativePath="..\inspector\front-end\StatusBarButton.js"
 					>
 				</File>
diff --git a/Source/WebCore/inspector/front-end/GoToLineDialog.js b/Source/WebCore/inspector/front-end/GoToLineDialog.js
index c96344c..f246159 100644
--- a/Source/WebCore/inspector/front-end/GoToLineDialog.js
+++ b/Source/WebCore/inspector/front-end/GoToLineDialog.js
@@ -45,7 +45,7 @@ WebInspector.GoToLineDialog = function(view)
     this._input = dialogWindow.createChild("input");
     this._input.setAttribute("type", "text");
     this._input.setAttribute("size", 6);
-    var linesCount = view.sourceFrame.textModel.linesCount;
+    var linesCount = view.textModel.linesCount;
     if (linesCount)
         this._input.setAttribute("title", WebInspector.UIString("1 - %d", linesCount));
     var blurHandler = this._onBlur.bind(this);
@@ -120,7 +120,7 @@ WebInspector.GoToLineDialog.prototype = {
         var value = this._input.value;
         var lineNumber = parseInt(value, 10);
         if (!isNaN(lineNumber) && lineNumber > 0) {
-            lineNumber = Math.min(lineNumber, this._view.sourceFrame.textModel.linesCount);
+            lineNumber = Math.min(lineNumber, this._view.textModel.linesCount);
             this._view.highlightLine(lineNumber);
         }
     }
diff --git a/Source/WebCore/inspector/front-end/ResourceView.js b/Source/WebCore/inspector/front-end/ResourceView.js
index b69097d..5b4b701 100644
--- a/Source/WebCore/inspector/front-end/ResourceView.js
+++ b/Source/WebCore/inspector/front-end/ResourceView.js
@@ -50,7 +50,11 @@ WebInspector.ResourceView.createResourceView = function(resource)
     case WebInspector.resourceCategories.stylesheets:
     case WebInspector.resourceCategories.scripts:
     case WebInspector.resourceCategories.xhr:
-        return new WebInspector.SourceView(resource);
+        var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource);
+        var isScript = resource.type === WebInspector.Resource.Type.Script;
+        var view = new WebInspector.SourceFrame(contentProvider, resource.url, isScript);
+        view.resource = resource;
+        return view;
     case WebInspector.resourceCategories.images:
         return new WebInspector.ImageView(resource);
     case WebInspector.resourceCategories.fonts:
@@ -68,7 +72,7 @@ WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource)
     case WebInspector.resourceCategories.stylesheets:
     case WebInspector.resourceCategories.scripts:
     case WebInspector.resourceCategories.xhr:
-        return resourceView.__proto__ === WebInspector.SourceView.prototype;
+        return resourceView.__proto__ === WebInspector.SourceFrame.prototype;
     case WebInspector.resourceCategories.images:
         return resourceView.__proto__ === WebInspector.ImageView.prototype;
     case WebInspector.resourceCategories.fonts:
@@ -115,3 +119,37 @@ WebInspector.ResourceView.existingResourceViewForResource = function(resource)
         return null;
     return resource._resourcesView;
 }
+
+
+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)
+    {
+        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.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;
diff --git a/Source/WebCore/inspector/front-end/ResourcesPanel.js b/Source/WebCore/inspector/front-end/ResourcesPanel.js
index 7e1fcc0..6d9c6af 100644
--- a/Source/WebCore/inspector/front-end/ResourcesPanel.js
+++ b/Source/WebCore/inspector/front-end/ResourcesPanel.js
@@ -102,7 +102,7 @@ WebInspector.ResourcesPanel.prototype = {
     {
         WebInspector.Panel.prototype.show.call(this);
 
-        if (this.visibleView instanceof WebInspector.ResourceView)
+        if (this.visibleView.resource)
             this._showResourceView(this.visibleView.resource);
 
         if (this._initializedDefaultSelection)
@@ -378,7 +378,7 @@ WebInspector.ResourcesPanel.prototype = {
         var view = WebInspector.ResourceView.resourceViewForResource(resource);
 
         // Consider rendering diff markup here.
-        if (resource.baseRevision && view instanceof WebInspector.SourceView) {
+        if (resource.baseRevision && view instanceof WebInspector.SourceFrame) {
             function callback(baseContent)
             {
                 if (baseContent)
@@ -413,7 +413,7 @@ WebInspector.ResourcesPanel.prototype = {
             } else
                 offset = i - right[i].row;
         }
-        view.sourceFrame.markDiff(diffData);
+        view.markDiff(diffData);
     },
 
     showDatabase: function(database, tableName)
@@ -690,7 +690,7 @@ WebInspector.ResourcesPanel.prototype = {
         var views = [];
 
         const visibleView = this.visibleView;
-        if (visibleView instanceof WebInspector.ResourceView && visibleView.performSearch)
+        if (visibleView.performSearch)
             views.push(visibleView);
 
         function callback(resourceTreeElement)
@@ -1076,7 +1076,7 @@ WebInspector.FrameResourceTreeElement.prototype = {
 
     _errorsWarningsUpdated: function()
     {
-        // FIXME: move to the Script/SourceView.
+        // FIXME: move to the SourceFrame.
         if (!this._resource.warnings && !this._resource.errors) {
             var view = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
             if (view && view.clearMessages)
diff --git a/Source/WebCore/inspector/front-end/ScriptView.js b/Source/WebCore/inspector/front-end/ScriptView.js
deleted file mode 100644
index f631fcc..0000000
--- a/Source/WebCore/inspector/front-end/ScriptView.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 Apple 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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.
- */
-
-WebInspector.ScriptView = function(script)
-{
-    WebInspector.View.call(this);
-
-    this.element.addStyleClass("script-view");
-
-    var contentProvider = new WebInspector.SourceFrameContentProviderForScript(script);
-    this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, "", true);
-}
-
-WebInspector.ScriptView.prototype = {
-    // 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,
-    addMessage: WebInspector.SourceView.prototype.addMessage,
-    clearMessages: WebInspector.SourceView.prototype.clearMessages,
-    searchCanceled: WebInspector.SourceView.prototype.searchCanceled,
-    performSearch: WebInspector.SourceView.prototype.performSearch,
-    jumpToFirstSearchResult: WebInspector.SourceView.prototype.jumpToFirstSearchResult,
-    jumpToLastSearchResult: WebInspector.SourceView.prototype.jumpToLastSearchResult,
-    jumpToNextSearchResult: WebInspector.SourceView.prototype.jumpToNextSearchResult,
-    jumpToPreviousSearchResult: WebInspector.SourceView.prototype.jumpToPreviousSearchResult,
-    showingFirstSearchResult: WebInspector.SourceView.prototype.showingFirstSearchResult,
-    showingLastSearchResult: WebInspector.SourceView.prototype.showingLastSearchResult,
-    _jumpToSearchResult: WebInspector.SourceView.prototype._jumpToSearchResult,
-    resize: WebInspector.SourceView.prototype.resize
-}
-
-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 a74f80d..63a4085 100644
--- a/Source/WebCore/inspector/front-end/ScriptsPanel.js
+++ b/Source/WebCore/inspector/front-end/ScriptsPanel.js
@@ -258,10 +258,10 @@ WebInspector.ScriptsPanel.prototype = {
         var oldSource = event.data.oldSource;
 
         var script = WebInspector.debuggerModel.scriptForSourceID(sourceID);
-        var oldView = script._scriptView;
+        var oldView = script._sourceFrame
         if (oldView) {
-            script._scriptView = new WebInspector.ScriptView(script);
-            this.viewRecreated(oldView, script._scriptView);
+            delete script._sourceFrame;
+            this.viewRecreated(oldView, this._sourceFrameForScriptOrResource(script));
         }
         if (script.resource) {
             var revertHandle = WebInspector.debuggerModel.editScriptSource.bind(WebInspector.debuggerModel, sourceID, oldSource);
@@ -484,43 +484,17 @@ WebInspector.ScriptsPanel.prototype = {
             this.sidebarPanes.callstack.handleShortcut(event);
     },
 
-    scriptViewForScript: function(script)
-    {
-        if (!script)
-            return null;
-        if (!script._scriptView)
-            script._scriptView = new WebInspector.ScriptView(script);
-        return script._scriptView;
-    },
-
-    sourceFrameForScript: function(script)
-    {
-        var view = this.scriptViewForScript(script);
-        if (!view)
-            return null;
-
-        // Setting up the source frame requires that we be attached.
-        if (!this.element.parentNode)
-            this.attach();
-
-        return view.sourceFrame;
-    },
-
     _sourceFrameForScriptOrResource: function(scriptOrResource)
     {
+        if (scriptOrResource._sourceFrame)
+            return scriptOrResource._sourceFrame;
         if (scriptOrResource instanceof WebInspector.Resource)
-            return this._sourceFrameForResource(scriptOrResource);
-        if (scriptOrResource instanceof WebInspector.Script)
-            return this.sourceFrameForScript(scriptOrResource);
-    },
-
-    _sourceFrameForResource: function(resource)
-    {
-        var view = WebInspector.ResourceView.resourceViewForResource(resource);
-        if (!view)
-            return null;
-
-        return view.sourceFrame;
+            scriptOrResource._sourceFrame = WebInspector.ResourceView.resourceViewForResource(scriptOrResource);
+        else if (scriptOrResource instanceof WebInspector.Script) {
+            var contentProvider = new WebInspector.SourceFrameContentProviderForScript(scriptOrResource);
+            scriptOrResource._sourceFrame = new WebInspector.SourceFrame(contentProvider, scriptOrResource.sourceURL, true);
+        }
+        return scriptOrResource._sourceFrame;
     },
 
     _showScriptOrResource: function(scriptOrResource, options)
@@ -531,12 +505,7 @@ WebInspector.ScriptsPanel.prototype = {
         if (!scriptOrResource)
             return;
 
-        var view;
-        if (scriptOrResource instanceof WebInspector.Resource)
-            view = WebInspector.ResourceView.resourceViewForResource(scriptOrResource);
-        else if (scriptOrResource instanceof WebInspector.Script)
-            view = this.scriptViewForScript(scriptOrResource);
-
+        var view = this._sourceFrameForScriptOrResource(scriptOrResource);
         if (!view)
             return;
 
@@ -738,7 +707,7 @@ WebInspector.ScriptsPanel.prototype = {
                 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on all exceptions.\nClick to Pause on uncaught exceptions.");
             else if (pauseOnExceptionsState == WebInspector.ScriptsPanel.PauseOnExceptionsState.PauseOnUncaughtExceptions)
                 this._pauseOnExceptionButton.title = WebInspector.UIString("Pause on uncaught exceptions.\nClick to Not pause on exceptions.");
-    
+
             this._pauseOnExceptionButton.state = pauseOnExceptionsState;
             WebInspector.settings.pauseOnExceptionState = pauseOnExceptionsState;
         }
@@ -824,8 +793,8 @@ WebInspector.ScriptsPanel.prototype = {
 
     _formatScript: function()
     {
-        if (this.visibleView && this.visibleView.sourceFrame)
-            this.visibleView.sourceFrame.formatSource();
+        if (this.visibleView)
+            this.visibleView.formatSource();
     },
 
     _enableDebugging: function()
@@ -1043,3 +1012,41 @@ WebInspector.ScriptsPanel.prototype = {
 }
 
 WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.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/SourceFrame.js b/Source/WebCore/inspector/front-end/SourceFrame.js
index 933f548..ce3531f 100644
--- a/Source/WebCore/inspector/front-end/SourceFrame.js
+++ b/Source/WebCore/inspector/front-end/SourceFrame.js
@@ -28,17 +28,22 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.SourceFrame = function(parentElement, contentProvider, url, isScript)
+WebInspector.SourceFrame = function(contentProvider, url, isScript)
 {
-    this._parentElement = parentElement;
+    WebInspector.View.call(this);
+
+    this.element.addStyleClass("script-view");
+
     this._contentProvider = contentProvider;
     this._url = url;
     this._isScript = isScript;
 
-
     this._textModel = new WebInspector.TextEditorModel();
     this._textModel.replaceTabsWithSpaces = true;
 
+    this._currentSearchResultIndex = -1;
+    this._searchResults = [];
+
     this._messages = [];
     this._rowMessages = {};
     this._messageBubbles = {};
@@ -48,31 +53,43 @@ WebInspector.SourceFrame = function(parentElement, contentProvider, url, isScrip
 
 WebInspector.SourceFrame.prototype = {
 
-    set visible(visible)
+    show: function(parentElement)
     {
+        WebInspector.View.prototype.show.call(this, parentElement);
+
         if (!this._contentRequested) {
             this._contentRequested = true;
             this._contentProvider.requestContent(this._createTextViewer.bind(this));
         }
 
-        if (visible) {
-            if (this._textViewer && this._scrollTop)
+        if (this._textViewer) {
+            if (this._scrollTop)
                 this._textViewer.element.scrollTop = this._scrollTop;
-            if (this._textViewer && this._scrollLeft)
+            if (this._scrollLeft)
                 this._textViewer.element.scrollLeft = this._scrollLeft;
-            if (this._textViewer)
-                this._textViewer.resize();
-        } else {
-            this._hidePopup();
-            this._clearLineHighlight();
-            if (this._textViewer) {
-                this._scrollTop = this._textViewer.element.scrollTop;
-                this._scrollLeft = this._textViewer.element.scrollLeft;
-                this._textViewer.freeCachedElements();
-            }
+            this._textViewer.resize();
+        }
+    },
+
+    hide: function()
+    {
+        WebInspector.View.prototype.hide.call(this);
+
+        this._hidePopup();
+        this._clearLineHighlight();
+
+        if (this._textViewer) {
+            this._scrollTop = this._textViewer.element.scrollTop;
+            this._scrollLeft = this._textViewer.element.scrollLeft;
+            this._textViewer.freeCachedElements();
         }
     },
 
+    hasContent: function()
+    {
+        return true;
+    },
+
     markDiff: function(diffData)
     {
         if (this._diffLines && this._textViewer)
@@ -166,7 +183,7 @@ WebInspector.SourceFrame.prototype = {
         element.addEventListener("mousemove", this._mouseMove.bind(this), true);
         element.addEventListener("scroll", this._scroll.bind(this), true);
         element.addEventListener("dblclick", this._doubleClick.bind(this), true);
-        this._parentElement.appendChild(element);
+        this.element.appendChild(element);
 
         this._textViewer.beginUpdates();
 
@@ -240,7 +257,7 @@ WebInspector.SourceFrame.prototype = {
                 // Silent catch.
             }
 
-            callback(this._searchResults.length);
+            callback(this, this._searchResults.length);
         }
 
         if (this._textViewer)
@@ -910,7 +927,7 @@ WebInspector.SourceFrame.prototype = {
     }
 }
 
-WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype;
+WebInspector.SourceFrame.prototype.__proto__ = WebInspector.View.prototype;
 
 
 WebInspector.SourceFrameContentProvider = function()
diff --git a/Source/WebCore/inspector/front-end/SourceView.js b/Source/WebCore/inspector/front-end/SourceView.js
deleted file mode 100644
index a2e7982..0000000
--- a/Source/WebCore/inspector/front-end/SourceView.js
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007, 2008 Apple 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:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  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.
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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.
- */
-
-WebInspector.SourceView = function(resource)
-{
-    WebInspector.ResourceView.call(this, resource);
-
-    this.element.addStyleClass("source");
-
-    var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource);
-    var isScript = resource.type === WebInspector.Resource.Type.Script;
-    this.sourceFrame = new WebInspector.SourceFrame(this.element, contentProvider, resource.url, isScript);
-}
-
-WebInspector.SourceView.prototype = {
-    show: function(parentElement)
-    {
-        WebInspector.View.prototype.show.call(this, parentElement);
-        this.sourceFrame.visible = true;
-    },
-
-    hide: function()
-    {
-        this.sourceFrame.visible = false;
-        WebInspector.View.prototype.hide.call(this);
-    },
-
-    resize: function()
-    {
-        this.sourceFrame.resize();
-    },
-
-    get scrollTop()
-    {
-        return this.sourceFrame.scrollTop;
-    },
-
-    set scrollTop(scrollTop)
-    {
-        this.sourceFrame.scrollTop = scrollTop;
-    },
-
-    hasContent: function()
-    {
-        return true;
-    },
-
-    // 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.
-
-    searchCanceled: function()
-    {
-        this.sourceFrame.searchCanceled();
-    },
-
-    performSearch: function(query, finishedCallback)
-    {
-        this.sourceFrame.performSearch(query, finishedCallback.bind(null, this));
-    },
-
-    jumpToFirstSearchResult: function()
-    {
-        this.sourceFrame.jumpToFirstSearchResult();
-    },
-
-    jumpToLastSearchResult: function()
-    {
-        this.sourceFrame.jumpToLastSearchResult();
-    },
-
-    jumpToNextSearchResult: function()
-    {
-        this.sourceFrame.jumpToNextSearchResult();
-    },
-
-    jumpToPreviousSearchResult: function()
-    {
-        this.sourceFrame.jumpToPreviousSearchResult();
-    },
-
-    showingFirstSearchResult: function()
-    {
-        this.sourceFrame.showingFirstSearchResult();
-    },
-
-    showingLastSearchResult: function()
-    {
-        this.sourceFrame.showingLastSearchResult();
-    },
-
-    revealLine: function(lineNumber)
-    {
-        this.sourceFrame.revealLine(lineNumber);
-    },
-
-    highlightLine: function(lineNumber)
-    {
-        this.sourceFrame.highlightLine(lineNumber);
-    },
-
-    addMessage: function(msg)
-    {
-        this.sourceFrame.addMessage(msg);
-    },
-
-    clearMessages: function()
-    {
-        this.sourceFrame.clearMessages();
-    }
-}
-
-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)
-    {
-        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.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;
diff --git a/Source/WebCore/inspector/front-end/WebKit.qrc b/Source/WebCore/inspector/front-end/WebKit.qrc
index edc1861..e8401e4 100644
--- a/Source/WebCore/inspector/front-end/WebKit.qrc
+++ b/Source/WebCore/inspector/front-end/WebKit.qrc
@@ -84,7 +84,6 @@
     <file>ScriptFormatter.js</file>
     <file>ScriptFormatterWorker.js</file>
     <file>ScriptsPanel.js</file>
-    <file>ScriptView.js</file>
     <file>Section.js</file>
     <file>Settings.js</file>
     <file>ShortcutsHelp.js</file>
@@ -95,7 +94,6 @@
     <file>SourceHTMLTokenizer.js</file>
     <file>SourceJavaScriptTokenizer.js</file>
     <file>SourceTokenizer.js</file>
-    <file>SourceView.js</file>
     <file>StatusBarButton.js</file>
     <file>StylesSidebarPane.js</file>
     <file>SummaryBar.js</file>
diff --git a/Source/WebCore/inspector/front-end/inspector.html b/Source/WebCore/inspector/front-end/inspector.html
index 0e0b9e9..aff8572 100644
--- a/Source/WebCore/inspector/front-end/inspector.html
+++ b/Source/WebCore/inspector/front-end/inspector.html
@@ -101,6 +101,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ElementsPanel.js"></script>
     <script type="text/javascript" src="NetworkPanel.js"></script>
     <script type="text/javascript" src="InjectedFakeWorker.js"></script>
+    <script type="text/javascript" src="SourceFrame.js"></script>
+    <script type="text/javascript" src="ResourceView.js"></script>
     <script type="text/javascript" src="ScriptsPanel.js"></script>
     <script type="text/javascript" src="ResourcesPanel.js"></script>
     <script type="text/javascript" src="ProfilesPanel.js"></script>
@@ -120,8 +122,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="ResourceCookiesView.js"></script>
     <script type="text/javascript" src="ResourceTimingView.js"></script>
     <script type="text/javascript" src="NetworkItemView.js"></script>
-    <script type="text/javascript" src="ResourceView.js"></script>
-    <script type="text/javascript" src="SourceFrame.js"></script>
     <script type="text/javascript" src="ScriptFormatter.js"></script>
     <script type="text/javascript" src="DOMSyntaxHighlighter.js"></script>
     <script type="text/javascript" src="TextEditorModel.js"></script>
@@ -131,12 +131,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     <script type="text/javascript" src="SourceCSSTokenizer.js"></script>
     <script type="text/javascript" src="SourceHTMLTokenizer.js"></script>
     <script type="text/javascript" src="SourceJavaScriptTokenizer.js"></script>
-    <script type="text/javascript" src="SourceView.js"></script>
     <script type="text/javascript" src="FontView.js"></script>
     <script type="text/javascript" src="ImageView.js"></script>
     <script type="text/javascript" src="DatabaseTableView.js"></script>
     <script type="text/javascript" src="DatabaseQueryView.js"></script>
-    <script type="text/javascript" src="ScriptView.js"></script>
     <script type="text/javascript" src="ProfileDataGridTree.js"></script>
     <script type="text/javascript" src="BottomUpProfileDataGridTree.js"></script>
     <script type="text/javascript" src="TopDownProfileDataGridTree.js"></script>

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list