Changeset 80356 in webkit


Ignore:
Timestamp:
Mar 4, 2011 8:40:58 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-03-04 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: extract all code that depends on source mapping from SourceFrame.
https://bugs.webkit.org/show_bug.cgi?id=55464

  • http/tests/inspector/debugger-test.js: (initialize_DebuggerTest):
  • inspector/debugger/debug-inlined-scripts.html:
  • inspector/debugger/debugger-breakpoints-not-activated-on-reload.html:
  • inspector/debugger/debugger-pause-on-breakpoint.html:
  • inspector/debugger/source-frame.html:

2011-03-04 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: extract all code that depends on source mapping from SourceFrame.
https://bugs.webkit.org/show_bug.cgi?id=55464

Extract all dependencies on DebuggerModel and ScriptsPanel to a delegate class
to encapsulate source mapping aspects from SourceFrame.

  • inspector/front-end/ResourceView.js: (WebInspector.ResourceView.createResourceView): (WebInspector.SourceFrameDelegateForResourcesPanel): (WebInspector.SourceFrameDelegateForResourcesPanel.prototype.requestContent):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype._createSourceFrame): (WebInspector.SourceFrameDelegateForScriptsPanel):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame): (WebInspector.SourceFrame.prototype.show): (WebInspector.SourceFrame.prototype._createTextViewer): (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint.didEditBreakpointCondition): (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint): (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition.didEditBreakpointCondition): (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition): (WebInspector.SourceFrame.prototype._contextMenu.else.setBreakpointEnabled): (WebInspector.SourceFrame.prototype._contextMenu): (WebInspector.SourceFrame.prototype._mouseDown): (WebInspector.SourceFrame.prototype._mouseMove): (WebInspector.SourceFrame.prototype._hidePopup): (WebInspector.SourceFrame.prototype._mouseHover): (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup): (WebInspector.SourceFrame.prototype._showPopup): (WebInspector.SourceFrame.prototype._doubleClick): (WebInspector.SourceFrame.prototype._didEditLine): (WebInspector.SourceFrameDelegate): (WebInspector.SourceFrameDelegate.prototype.requestContent): (WebInspector.SourceFrameDelegate.prototype.debuggingSupported): (WebInspector.SourceFrameDelegate.prototype.setBreakpoint): (WebInspector.SourceFrameDelegate.prototype.removeBreakpoint): (WebInspector.SourceFrameDelegate.prototype.updateBreakpoint): (WebInspector.SourceFrameDelegate.prototype.findBreakpoint): (WebInspector.SourceFrameDelegate.prototype.continueToLine): (WebInspector.SourceFrameDelegate.prototype.canEditScriptSource): (WebInspector.SourceFrameDelegate.prototype.editScriptSource): (WebInspector.SourceFrameDelegate.prototype.debuggerPaused): (WebInspector.SourceFrameDelegate.prototype.evaluate): (WebInspector.SourceFrameDelegate.prototype.releaseEvaluationResult):
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r80355 r80356  
     12011-03-04  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: extract all code that depends on source mapping from SourceFrame.
     6        https://bugs.webkit.org/show_bug.cgi?id=55464
     7
     8        * http/tests/inspector/debugger-test.js:
     9        (initialize_DebuggerTest):
     10        * inspector/debugger/debug-inlined-scripts.html:
     11        * inspector/debugger/debugger-breakpoints-not-activated-on-reload.html:
     12        * inspector/debugger/debugger-pause-on-breakpoint.html:
     13        * inspector/debugger/source-frame.html:
     14
    1152011-03-04  Andrey Kosyakov  <caseq@chromium.org>
    216
  • trunk/LayoutTests/http/tests/inspector/debugger-test.js

    r80338 r80356  
    183183};
    184184
     185InspectorTest.setBreakpoint = function(sourceFrame, lineNumber, condition, enabled)
     186{
     187    sourceFrame._delegate.setBreakpoint(lineNumber, condition, enabled);
     188};
     189
     190
    185191InspectorTest.expandProperties = function(properties, callback)
    186192{
  • trunk/LayoutTests/inspector/debugger/debug-inlined-scripts.html

    r79880 r80356  
    3131        InspectorTest.addResult("Script source was shown.");
    3232        WebInspector.panels.scripts._resourceForURL = function() { return new WebInspector.Resource(); };
    33         sourceFrame._setBreakpoint(2, "", true);
    34         sourceFrame._setBreakpoint(9, "", true);
     33        InspectorTest.setBreakpoint(sourceFrame, 2, "", true);
     34        InspectorTest.setBreakpoint(sourceFrame, 9, "", true);
    3535        InspectorTest.waitUntilPaused(step3);
    3636        InspectorTest.reloadPage(InspectorTest.completeDebuggerTest.bind(InspectorTest));
  • trunk/LayoutTests/inspector/debugger/debugger-breakpoints-not-activated-on-reload.html

    r78808 r80356  
    2525    {
    2626        InspectorTest.addResult("Main resource was shown.");
    27         sourceFrame._setBreakpoint(8, "", true);
     27        InspectorTest.setBreakpoint(sourceFrame, 8, "", true);
    2828        WebInspector.panels.scripts.toggleBreakpointsButton.element.click();
    2929        InspectorTest.reloadPage(step4);
  • trunk/LayoutTests/inspector/debugger/debugger-pause-on-breakpoint.html

    r78808 r80356  
    2323    {
    2424        InspectorTest.addResult("Script source was shown.");
    25         sourceFrame._setBreakpoint(8, "", true);
     25        InspectorTest.setBreakpoint(sourceFrame, 8, "", true);
    2626        InspectorTest.runTestFunctionAndWaitUntilPaused(step3);
    2727    }
  • trunk/LayoutTests/inspector/debugger/source-frame.html

    r79311 r80356  
    2222                InspectorTest.addResult("Script source was shown.");
    2323                InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addBreakpoint", didAddBreakpoint);
    24                 sourceFrame._setBreakpoint(17, "", true);
     24                InspectorTest.setBreakpoint(sourceFrame, 17, "", true);
    2525            }
    2626
  • trunk/Source/WebCore/ChangeLog

    r80355 r80356  
     12011-03-04  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: extract all code that depends on source mapping from SourceFrame.
     6        https://bugs.webkit.org/show_bug.cgi?id=55464
     7
     8        Extract all dependencies on DebuggerModel and ScriptsPanel to a delegate class
     9        to encapsulate source mapping aspects from SourceFrame.
     10
     11        * inspector/front-end/ResourceView.js:
     12        (WebInspector.ResourceView.createResourceView):
     13        (WebInspector.SourceFrameDelegateForResourcesPanel):
     14        (WebInspector.SourceFrameDelegateForResourcesPanel.prototype.requestContent):
     15        * inspector/front-end/ScriptsPanel.js:
     16        (WebInspector.ScriptsPanel.prototype._createSourceFrame):
     17        (WebInspector.SourceFrameDelegateForScriptsPanel):
     18        * inspector/front-end/SourceFrame.js:
     19        (WebInspector.SourceFrame):
     20        (WebInspector.SourceFrame.prototype.show):
     21        (WebInspector.SourceFrame.prototype._createTextViewer):
     22        (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint.didEditBreakpointCondition):
     23        (WebInspector.SourceFrame.prototype._contextMenu.addConditionalBreakpoint):
     24        (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition.didEditBreakpointCondition):
     25        (WebInspector.SourceFrame.prototype._contextMenu.else.editBreakpointCondition):
     26        (WebInspector.SourceFrame.prototype._contextMenu.else.setBreakpointEnabled):
     27        (WebInspector.SourceFrame.prototype._contextMenu):
     28        (WebInspector.SourceFrame.prototype._mouseDown):
     29        (WebInspector.SourceFrame.prototype._mouseMove):
     30        (WebInspector.SourceFrame.prototype._hidePopup):
     31        (WebInspector.SourceFrame.prototype._mouseHover):
     32        (WebInspector.SourceFrame.prototype._showPopup.showObjectPopup):
     33        (WebInspector.SourceFrame.prototype._showPopup):
     34        (WebInspector.SourceFrame.prototype._doubleClick):
     35        (WebInspector.SourceFrame.prototype._didEditLine):
     36        (WebInspector.SourceFrameDelegate):
     37        (WebInspector.SourceFrameDelegate.prototype.requestContent):
     38        (WebInspector.SourceFrameDelegate.prototype.debuggingSupported):
     39        (WebInspector.SourceFrameDelegate.prototype.setBreakpoint):
     40        (WebInspector.SourceFrameDelegate.prototype.removeBreakpoint):
     41        (WebInspector.SourceFrameDelegate.prototype.updateBreakpoint):
     42        (WebInspector.SourceFrameDelegate.prototype.findBreakpoint):
     43        (WebInspector.SourceFrameDelegate.prototype.continueToLine):
     44        (WebInspector.SourceFrameDelegate.prototype.canEditScriptSource):
     45        (WebInspector.SourceFrameDelegate.prototype.editScriptSource):
     46        (WebInspector.SourceFrameDelegate.prototype.debuggerPaused):
     47        (WebInspector.SourceFrameDelegate.prototype.evaluate):
     48        (WebInspector.SourceFrameDelegate.prototype.releaseEvaluationResult):
     49
    1502011-03-04  Andrey Kosyakov  <caseq@chromium.org>
    251
  • trunk/Source/WebCore/inspector/front-end/ResourceView.js

    r78472 r80356  
    5151    case WebInspector.resourceCategories.scripts:
    5252    case WebInspector.resourceCategories.xhr:
    53         var contentProvider = new WebInspector.SourceFrameContentProviderForResource(resource);
    54         var isScript = resource.type === WebInspector.Resource.Type.Script;
    55         var view = new WebInspector.SourceFrame(contentProvider, resource.url, isScript);
     53        var delegate = new WebInspector.SourceFrameDelegateForResourcesPanel(resource);
     54        var view = new WebInspector.SourceFrame(delegate, resource.url);
    5655        view.resource = resource;
    5756        return view;
     
    121120
    122121
    123 WebInspector.SourceFrameContentProviderForResource = function(resource)
     122WebInspector.SourceFrameDelegateForResourcesPanel = function(resource)
    124123{
    125     WebInspector.SourceFrameContentProvider.call(this);
     124    WebInspector.SourceFrameDelegate.call(this);
    126125    this._resource = resource;
    127126}
     
    129128//This is a map from resource.type to mime types
    130129//found in WebInspector.SourceTokenizer.Registry.
    131 WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType = {
     130WebInspector.SourceFrameDelegateForResourcesPanel.DefaultMIMETypeForResourceType = {
    132131    0: "text/html",
    133132    1: "text/css",
     
    135134}
    136135
    137 WebInspector.SourceFrameContentProviderForResource.prototype = {
     136WebInspector.SourceFrameDelegateForResourcesPanel.prototype = {
    138137    requestContent: function(callback)
    139138    {
    140139        function contentLoaded(text)
    141140        {
    142             var mimeType = WebInspector.SourceFrameContentProviderForResource.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;
    143             if (this._resource.type !== WebInspector.Resource.Type.Script) {
    144                 // WebKit html lexer normalizes line endings and scripts are passed to VM with "\n" line endings.
    145                 // However, resource content has original line endings, so we have to normalize line endings here.
    146                 text = text.replace(/\r\n/g, "\n");
    147             }
     141            var mimeType = WebInspector.SourceFrameDelegateForResourcesPanel.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;
    148142            var sourceMapping = new WebInspector.IdenticalSourceMapping();
    149             var scripts = WebInspector.debuggerModel.scriptsForURL(this._resource.url);
    150             var scriptRanges = WebInspector.ScriptFormatter.findScriptRanges(text.lineEndings(), scripts);
    151             callback(mimeType, new WebInspector.SourceFrameContent(text, sourceMapping, scriptRanges));
     143            callback(mimeType, new WebInspector.SourceFrameContent(text, sourceMapping, []));
    152144        }
    153145        this._resource.requestContent(contentLoaded.bind(this));
     
    155147}
    156148
    157 WebInspector.SourceFrameContentProviderForResource.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;
     149WebInspector.SourceFrameDelegateForResourcesPanel.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype;
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r80342 r80356  
    581581    {
    582582        var script = this._scriptForSourceFileId(sourceFileId);
    583         var contentProvider;
    584         var isScript;
    585         if (script.resource) {
    586             contentProvider = new WebInspector.SourceFrameContentProviderForResource(script.resource);
    587             isScript = script.resource.type === WebInspector.Resource.Type.Script;
    588         } else {
    589             contentProvider = new WebInspector.SourceFrameContentProviderForScript(script);
    590             isScript = !script.lineOffset && !script.columnOffset;
    591         }
    592         sourceFrame = new WebInspector.SourceFrame(contentProvider, script.sourceURL, isScript);
     583        var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(script);
     584        var sourceFrame = new WebInspector.SourceFrame(delegate, script.sourceURL);
    593585        sourceFrame._sourceFileId = sourceFileId;
    594586        sourceFrame.addEventListener(WebInspector.SourceFrame.Events.Loaded, this._sourceFrameLoaded, this);
     
    10481040
    10491041
    1050 WebInspector.SourceFrameContentProviderForScript = function(script)
     1042WebInspector.SourceFrameDelegateForScriptsPanel = function(script)
    10511043{
    1052     WebInspector.SourceFrameContentProvider.call(this);
     1044    WebInspector.SourceFrameDelegate.call(this);
    10531045    this._script = script;
     1046    this._popoverObjectGroup = "popover";
    10541047}
    10551048
    1056 WebInspector.SourceFrameContentProviderForScript.prototype = {
     1049WebInspector.SourceFrameDelegateForScriptsPanel.prototype = {
    10571050    requestContent: function(callback)
    10581051    {
    1059         var scripts = [this._script];
    1060         if (this._script.sourceURL)
    1061             scripts = WebInspector.debuggerModel.scriptsForURL(this._script.sourceURL);
    1062         scripts.sort(function(x, y) { return x.lineOffset - y.lineOffset || x.columnOffset - y.columnOffset; });
    1063 
     1052        function didGetTextAndScriptRanges(mimeType, text, scriptRanges)
     1053        {
     1054            this._content = new WebInspector.SourceFrameContent(text, new WebInspector.IdenticalSourceMapping(), scriptRanges);
     1055            callback(mimeType, this._content);
     1056        }
     1057
     1058        if (this._script.resource)
     1059            this._loadResourceContent(this._script.resource, didGetTextAndScriptRanges.bind(this));
     1060        else
     1061            this._loadAndConcatenateScriptsContent(didGetTextAndScriptRanges.bind(this));
     1062    },
     1063
     1064    _loadResourceContent: function(resource, callback)
     1065    {
     1066        function didRequestContent(text)
     1067        {
     1068            var mimeType = "text/javascript";
     1069            if (resource.type !== WebInspector.Resource.Type.Script) {
     1070                mimeType = "text/html";
     1071                // WebKit html lexer normalizes line endings and scripts are passed to VM with "\n" line endings.
     1072                // However, resource content has original line endings, so we have to normalize line endings here.
     1073                text = text.replace(/\r\n/g, "\n");
     1074            }
     1075            var scripts = this._scripts();
     1076            var scriptRanges = WebInspector.ScriptFormatter.findScriptRanges(text.lineEndings(), scripts);
     1077            callback(mimeType, text, scriptRanges);
     1078        }
     1079        resource.requestContent(didRequestContent.bind(this));
     1080    },
     1081
     1082    _loadAndConcatenateScriptsContent: function(callback)
     1083    {
     1084        var scripts = this._scripts();
    10641085        var scriptsLeft = scripts.length;
    10651086        var sources = [];
     
    10701091                return;
    10711092            var result = this._buildSource(scripts, sources);
    1072             var sourceMapping = new WebInspector.IdenticalSourceMapping();
    1073             callback(result.mimeType, new WebInspector.SourceFrameContent(result.source, sourceMapping, result.scriptRanges));
    1074 
     1093            callback(result.mimeType, result.source, result.scriptRanges);
    10751094        }
    10761095        for (var i = 0; i < scripts.length; ++i)
     
    11251144        }
    11261145        return { mimeType: mimeType, source: source, scriptRanges: scriptRanges };
     1146    },
     1147
     1148    _scripts: function()
     1149    {
     1150        var scripts = [this._script];
     1151        if (this._script.sourceURL)
     1152            scripts = WebInspector.debuggerModel.scriptsForURL(this._script.sourceURL);
     1153        scripts.sort(function(x, y) { return x.lineOffset - y.lineOffset || x.columnOffset - y.columnOffset; });
     1154        return scripts;
     1155    },
     1156
     1157    debuggingSupported: function()
     1158    {
     1159        return true;
     1160    },
     1161
     1162    setBreakpoint: function(lineNumber, condition, enabled)
     1163    {
     1164        var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
     1165        if (this._script.sourceURL)
     1166            WebInspector.debuggerModel.setBreakpoint(this._script.sourceURL, location.lineNumber, location.columnNumber, condition, enabled);
     1167        else if (location.sourceID)
     1168            WebInspector.debuggerModel.setBreakpointBySourceId(location.sourceID, location.lineNumber, location.columnNumber, condition, enabled);
     1169        else
     1170            return;
     1171
     1172        if (!WebInspector.panels.scripts.breakpointsActivated)
     1173            WebInspector.panels.scripts.toggleBreakpointsClicked();
     1174    },
     1175
     1176    removeBreakpoint: function(breakpointId)
     1177    {
     1178        WebInspector.debuggerModel.removeBreakpoint(breakpointId);
     1179    },
     1180
     1181    updateBreakpoint: function(breakpointId, condition, enabled)
     1182    {
     1183        WebInspector.debuggerModel.updateBreakpoint(breakpointId, condition, enabled);
     1184    },
     1185
     1186    findBreakpoint: function(lineNumber)
     1187    {
     1188        var url = this._script.sourceURL;
     1189        var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
     1190        function filter(breakpoint)
     1191        {
     1192            if (breakpoint.url) {
     1193                if (breakpoint.url !== url)
     1194                    return false;
     1195            } else {
     1196                if (breakpoint.sourceID !== location.sourceID)
     1197                    return false;
     1198            }
     1199            var lineNumber = breakpoint.locations.length ? breakpoint.locations[0].lineNumber : breakpoint.lineNumber;
     1200            return lineNumber === location.lineNumber;
     1201        }
     1202        return WebInspector.debuggerModel.queryBreakpoints(filter)[0];
     1203    },
     1204
     1205    continueToLine: function(lineNumber)
     1206    {
     1207        var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
     1208        if (location.sourceID)
     1209            WebInspector.debuggerModel.continueToLocation(location.sourceID, location.lineNumber, location.columnNumber);
     1210    },
     1211
     1212    canEditScriptSource: function()
     1213    {
     1214        return Preferences.canEditScriptSource && !this._script.lineOffset && !this._script.columnOffset;
     1215    },
     1216
     1217    editScriptSource: function(text)
     1218    {
     1219        WebInspector.debuggerModel.editScriptSource(this._script.sourceID, text);
     1220    },
     1221
     1222    debuggerPaused: function()
     1223    {
     1224        return WebInspector.panels.scripts.paused;
     1225    },
     1226
     1227    evaluateInSelectedCallFrame: function(string, callback)
     1228    {
     1229        function didEvaluateInSelectedCallFrame(result)
     1230        {
     1231            if (!result.isError() && this.debuggerPaused())
     1232                callback(result);
     1233        }
     1234        WebInspector.panels.scripts.evaluateInSelectedCallFrame(string, this._popoverObjectGroup, false, didEvaluateInSelectedCallFrame.bind(this));
     1235    },
     1236
     1237    releaseEvaluationResult: function()
     1238    {
     1239        RuntimeAgent.releaseObjectGroup(0, this._popoverObjectGroup);
    11271240    }
    11281241}
    11291242
    1130 WebInspector.SourceFrameContentProviderForScript.prototype.__proto__ = WebInspector.SourceFrameContentProvider.prototype;
     1243WebInspector.SourceFrameDelegateForScriptsPanel.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype;
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r80349 r80356  
    2929 */
    3030
    31 WebInspector.SourceFrame = function(contentProvider, url, isScript)
     31WebInspector.SourceFrame = function(delegate, url)
    3232{
    3333    WebInspector.View.call(this);
     
    3535    this.element.addStyleClass("script-view");
    3636
    37     this._contentProvider = contentProvider;
     37    this._delegate = delegate;
    3838    this._url = url;
    39     this._isScript = isScript;
    4039
    4140    this._textModel = new WebInspector.TextEditorModel();
     
    4847    this._rowMessages = {};
    4948    this._messageBubbles = {};
    50 
    51     this._popoverObjectGroup = "popover";
    5249}
    5350
     
    6461        if (!this._contentRequested) {
    6562            this._contentRequested = true;
    66             this._contentProvider.requestContent(this._createTextViewer.bind(this));
     63            this._delegate.requestContent(this._createTextViewer.bind(this));
    6764        }
    6865
     
    196193
    197194        var element = this._textViewer.element;
    198         element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
    199         element.addEventListener("mousedown", this._mouseDown.bind(this), true);
    200         element.addEventListener("mousemove", this._mouseMove.bind(this), true);
    201         element.addEventListener("scroll", this._scroll.bind(this), true);
    202         element.addEventListener("dblclick", this._doubleClick.bind(this), true);
     195        if (this._delegate.debuggingSupported()) {
     196            element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
     197            element.addEventListener("mousedown", this._mouseDown.bind(this), true);
     198            element.addEventListener("mousemove", this._mouseMove.bind(this), true);
     199            element.addEventListener("dblclick", this._doubleClick.bind(this), true);
     200            element.addEventListener("scroll", this._scroll.bind(this), true);
     201        }
    203202        this.element.appendChild(element);
    204203
     
    479478    _contextMenu: function(event)
    480479    {
    481         if (!WebInspector.panels.scripts)
    482             return;
    483 
    484480        var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
    485481        if (!target)
    486482            return;
    487         var textViewerLineNumber = target.lineNumber;
     483        var lineNumber = target.lineNumber;
    488484
    489485        var contextMenu = new WebInspector.ContextMenu();
    490486
    491         contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._continueToLine.bind(this, textViewerLineNumber));
    492 
    493         var breakpoint = this._findBreakpoint(textViewerLineNumber);
     487        contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._delegate.continueToLine.bind(this._delegate, lineNumber));
     488
     489        var breakpoint = this._delegate.findBreakpoint(lineNumber);
    494490        if (!breakpoint) {
    495491            // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
    496             contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._setBreakpoint.bind(this, textViewerLineNumber, "", true));
     492            contextMenu.appendItem(WebInspector.UIString("Add Breakpoint"), this._delegate.setBreakpoint.bind(this._delegate, lineNumber, "", true));
    497493
    498494            function addConditionalBreakpoint()
    499495            {
    500                 this.addBreakpoint(textViewerLineNumber, true, true, true);
     496                this.addBreakpoint(lineNumber, true, true, true);
    501497                function didEditBreakpointCondition(committed, condition)
    502498                {
    503                     this.removeBreakpoint(textViewerLineNumber);
     499                    this.removeBreakpoint(lineNumber);
    504500                    if (committed)
    505                         this._setBreakpoint(textViewerLineNumber, condition, true);
     501                        this._delegate.setBreakpoint(lineNumber, condition, true);
    506502                }
    507                 this._editBreakpointCondition(textViewerLineNumber, "", didEditBreakpointCondition.bind(this));
     503                this._editBreakpointCondition(lineNumber, "", didEditBreakpointCondition.bind(this));
    508504            }
    509505            contextMenu.appendItem(WebInspector.UIString("Add Conditional Breakpoint…"), addConditionalBreakpoint.bind(this));
    510506        } else {
    511507            // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
    512             function removeBreakpoint()
    513             {
    514                 WebInspector.debuggerModel.removeBreakpoint(breakpoint.id);
    515             }
    516             contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), removeBreakpoint);
     508            contextMenu.appendItem(WebInspector.UIString("Remove Breakpoint"), this._delegate.removeBreakpoint.bind(this._delegate, breakpoint.id));
    517509            function editBreakpointCondition()
    518510            {
     
    520512                {
    521513                    if (committed)
    522                         WebInspector.debuggerModel.updateBreakpoint(breakpoint.id, condition, breakpoint.enabled);
     514                        this._delegate.updateBreakpoint(breakpoint.id, condition, breakpoint.enabled);
    523515                }
    524                 this._editBreakpointCondition(textViewerLineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this));
     516                this._editBreakpointCondition(lineNumber, breakpoint.condition, didEditBreakpointCondition.bind(this));
    525517            }
    526518            contextMenu.appendItem(WebInspector.UIString("Edit Breakpoint…"), editBreakpointCondition.bind(this));
    527519            function setBreakpointEnabled(enabled)
    528520            {
    529                 WebInspector.debuggerModel.updateBreakpoint(breakpoint.id, breakpoint.condition, enabled);
     521                this._delegate.updateBreakpoint(breakpoint.id, breakpoint.condition, enabled);
    530522            }
    531523            if (breakpoint.enabled)
     
    551543        if (!target)
    552544            return;
    553         var textViewerLineNumber = target.lineNumber;
    554 
    555         var breakpoint = this._findBreakpoint(textViewerLineNumber);
     545        var lineNumber = target.lineNumber;
     546
     547        var breakpoint = this._delegate.findBreakpoint(lineNumber);
    556548        if (breakpoint) {
    557549            if (event.shiftKey)
    558                 WebInspector.debuggerModel.updateBreakpoint(breakpoint.id, breakpoint.condition, !breakpoint.enabled);
     550                this._delegate.updateBreakpoint(breakpoint.id, breakpoint.condition, !breakpoint.enabled);
    559551            else
    560                 WebInspector.debuggerModel.removeBreakpoint(breakpoint.id);
     552                this._delegate.removeBreakpoint(breakpoint.id);
    561553        } else
    562             this._setBreakpoint(textViewerLineNumber, "", true);
     554            this._delegate.setBreakpoint(lineNumber, "", true);
    563555        event.preventDefault();
    564556    },
     
    586578
    587579        // Now that cleanup routines are set up above, leave this in case we are not on a break.
    588         if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused)
     580        if (!this._delegate.debuggerPaused())
    589581            return;
    590582
     
    625617        this._popup.hide();
    626618        delete this._popup;
    627         RuntimeAgent.releaseObjectGroup(0, this._popoverObjectGroup);
     619        this._delegate.releaseEvaluationResult();
    628620    },
    629621
     
    631623    {
    632624        delete this._hoverTimer;
    633 
    634         if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused)
    635             return;
    636625
    637626        var lineRow = element.enclosingNodeOrSelfWithClass("webkit-line-content");
     
    674663        function showObjectPopup(result)
    675664        {
    676             if (!WebInspector.panels.scripts.paused)
    677                 return;
    678 
    679665            var popupContentElement = null;
    680666            if (result.type !== "object" && result.type !== "node" && result.type !== "array") {
     
    711697        }
    712698
    713         function evaluateCallback(result)
    714         {
    715             if (result.isError())
    716                 return;
    717             if (!WebInspector.panels.scripts.paused)
    718                 return;
    719             showObjectPopup.call(this, result);
    720         }
    721         WebInspector.panels.scripts.evaluateInSelectedCallFrame(element.textContent, this._popoverObjectGroup, false, evaluateCallback.bind(this));
     699        this._delegate.evaluateInSelectedCallFrame(element.textContent, showObjectPopup.bind(this));
    722700    },
    723701
     
    765743    },
    766744
    767     _evalSelectionInCallFrame: function(event)
    768     {
    769         if (!WebInspector.panels.scripts || !WebInspector.panels.scripts.paused)
    770             return;
    771 
    772         var selection = this.element.contentWindow.getSelection();
    773         if (!selection.rangeCount)
    774             return;
    775 
    776         var expression = selection.getRangeAt(0).toString().trim();
    777         WebInspector.panels.scripts.evaluateInSelectedCallFrame(expression, "console", function(result) {
    778             WebInspector.showConsole();
    779             var commandMessage = new WebInspector.ConsoleCommand(expression);
    780             WebInspector.console.addMessage(commandMessage);
    781             WebInspector.console.addMessage(new WebInspector.ConsoleCommandResult(result, commandMessage));
    782         });
    783     },
    784 
    785745    resize: function()
    786746    {
     
    804764    },
    805765
    806     _continueToLine: function(lineNumber)
    807     {
    808         var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
    809         if (location.sourceID)
    810             WebInspector.debuggerModel.continueToLocation(location.sourceID, location.lineNumber, location.columnNumber);
    811     },
    812 
    813766    _doubleClick: function(event)
    814767    {
    815         if (!Preferences.canEditScriptSource || !this._isScript)
     768        if (!this._delegate.canEditScriptSource())
    816769            return;
    817770
     
    833786                lines.push(oldLines[i]);
    834787        }
    835         var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
    836         WebInspector.debuggerModel.editScriptSource(location.sourceID, lines.join("\n"));
    837     },
    838 
    839     _setBreakpoint: function(lineNumber, condition, enabled)
    840     {
    841         var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
    842         if (this._url)
    843             WebInspector.debuggerModel.setBreakpoint(this._url, location.lineNumber, location.columnNumber, condition, enabled);
    844         else if (location.sourceID)
    845             WebInspector.debuggerModel.setBreakpointBySourceId(location.sourceID, location.lineNumber, location.columnNumber, condition, enabled);
    846         else
    847             return;
    848 
    849         if (!WebInspector.panels.scripts.breakpointsActivated)
    850             WebInspector.panels.scripts.toggleBreakpointsClicked();
    851     },
    852 
    853     _findBreakpoint: function(lineNumber)
    854     {
    855         var url = this._url;
    856         var location = this._content.sourceFrameLineNumberToActualLocation(lineNumber);
    857         function filter(breakpoint)
    858         {
    859             if (breakpoint.url) {
    860                 if (breakpoint.url !== url)
    861                     return false;
    862             } else {
    863                 if (breakpoint.sourceID !== location.sourceID)
    864                     return false;
    865             }
    866             var lineNumber = breakpoint.locations.length ? breakpoint.locations[0].lineNumber : breakpoint.lineNumber;
    867             return lineNumber === location.lineNumber;
    868         }
    869         return WebInspector.debuggerModel.queryBreakpoints(filter)[0];
     788        this._delegate.editScriptSource(lines.join("\n"));
    870789    }
    871790}
     
    874793
    875794
    876 WebInspector.SourceFrameContentProvider = function()
     795WebInspector.SourceFrameDelegate = function()
    877796{
    878797}
    879798
    880 WebInspector.SourceFrameContentProvider.prototype = {
     799WebInspector.SourceFrameDelegate.prototype = {
    881800    requestContent: function(callback)
     801    {
     802        // Should be implemented by subclasses.
     803    },
     804
     805    debuggingSupported: function()
     806    {
     807        return false;
     808    },
     809
     810    setBreakpoint: function(lineNumber, condition, enabled)
     811    {
     812        // Should be implemented by subclasses.
     813    },
     814
     815    removeBreakpoint: function(breakpointId)
     816    {
     817        // Should be implemented by subclasses.
     818    },
     819
     820    updateBreakpoint: function(breakpointId, condition, enabled)
     821    {
     822        // Should be implemented by subclasses.
     823    },
     824
     825    findBreakpoint: function(lineNumber)
     826    {
     827        // Should be implemented by subclasses.
     828    },
     829
     830    continueToLine: function(lineNumber)
     831    {
     832        // Should be implemented by subclasses.
     833    },
     834
     835    canEditScriptSource: function()
     836    {
     837        return false;
     838    },
     839
     840    editScriptSource: function(text)
     841    {
     842        // Should be implemented by subclasses.
     843    },
     844
     845    debuggerPaused: function()
     846    {
     847        // Should be implemented by subclasses.
     848    },
     849
     850    evaluateInSelectedCallFrame: function(string)
     851    {
     852        // Should be implemented by subclasses.
     853    },
     854
     855    releaseEvaluationResult: function()
    882856    {
    883857        // Should be implemented by subclasses.
Note: See TracChangeset for help on using the changeset viewer.