Changeset 84629 in webkit


Ignore:
Timestamp:
Apr 22, 2011 8:34:21 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2011-04-22 Pavel Feldman <pfeldman@google.com>

Reviewed by Yury Semikhatsky.

Web Inspector: add Save As context menu item to the TextViewer.
https://bugs.webkit.org/show_bug.cgi?id=59196

  • inspector/front-end/ResourceView.js: (WebInspector.ResourceSourceFrame.prototype.requestContent): (WebInspector.ResourceSourceFrame.prototype.suggestedFileName): (WebInspector.RevisionSourceFrame.prototype.requestContent): (WebInspector.RevisionSourceFrame.prototype.suggestedFileName):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype._createSourceFrame): (WebInspector.SourceFrameDelegateForScriptsPanel): (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.formatSourceFilesToggled): (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype._initializeTextViewer): (WebInspector.SourceFrame.prototype.populateTextAreaContextMenu): (WebInspector.SourceFrame.prototype.suggestedFileName): (WebInspector.SourceFrameDelegate.prototype.formatSourceFilesToggled): (WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
  • inspector/front-end/TextViewer.js: (WebInspector.TextViewer.prototype._contextMenu): (WebInspector.TextViewerDelegate.prototype.cancelEditing): (WebInspector.TextViewerDelegate.prototype.populateLineGutterContextMenu): (WebInspector.TextViewerDelegate.prototype.populateTextAreaContextMenu): (WebInspector.TextViewerDelegate.prototype.suggestedFileName):
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84626 r84629  
     12011-04-22  Pavel Feldman  <pfeldman@google.com>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: add Save As context menu item to the TextViewer.
     6        https://bugs.webkit.org/show_bug.cgi?id=59196
     7
     8        * inspector/front-end/ResourceView.js:
     9        (WebInspector.ResourceSourceFrame.prototype.requestContent):
     10        (WebInspector.ResourceSourceFrame.prototype.suggestedFileName):
     11        (WebInspector.RevisionSourceFrame.prototype.requestContent):
     12        (WebInspector.RevisionSourceFrame.prototype.suggestedFileName):
     13        * inspector/front-end/ScriptsPanel.js:
     14        (WebInspector.ScriptsPanel.prototype._createSourceFrame):
     15        (WebInspector.SourceFrameDelegateForScriptsPanel):
     16        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.formatSourceFilesToggled):
     17        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
     18        * inspector/front-end/SourceFrame.js:
     19        (WebInspector.SourceFrame.prototype._initializeTextViewer):
     20        (WebInspector.SourceFrame.prototype.populateTextAreaContextMenu):
     21        (WebInspector.SourceFrame.prototype.suggestedFileName):
     22        (WebInspector.SourceFrameDelegate.prototype.formatSourceFilesToggled):
     23        (WebInspector.SourceFrameDelegate.prototype.suggestedFileName):
     24        * inspector/front-end/TextViewer.js:
     25        (WebInspector.TextViewer.prototype._contextMenu):
     26        (WebInspector.TextViewerDelegate.prototype.cancelEditing):
     27        (WebInspector.TextViewerDelegate.prototype.populateLineGutterContextMenu):
     28        (WebInspector.TextViewerDelegate.prototype.populateTextAreaContextMenu):
     29        (WebInspector.TextViewerDelegate.prototype.suggestedFileName):
     30
    1312011-04-22  Mikhail Naganov  <mnaganov@chromium.org>
    232
  • trunk/Source/WebCore/inspector/front-end/ResourceView.js

    r83969 r84629  
    175175        }
    176176        this._resource.requestContent(contentLoaded.bind(this));
     177    },
     178
     179    suggestedFileName: function()
     180    {
     181        return this._resource.displayName;
    177182    }
    178183}
     
    205210        }
    206211        this._revision.requestContent(contentLoaded.bind(this));
     212    },
     213
     214    suggestedFileName: function()
     215    {
     216        return this._revision.resource.displayName;
    207217    }
    208218}
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r84623 r84629  
    279279        var select = this._filesSelectElement;
    280280        var option = document.createElement("option");
    281         option.text = sourceFile.url ? WebInspector.displayNameForURL(sourceFile.url) : WebInspector.UIString("(program)");
     281        option.text = sourceFile.displayName;
    282282        option.isContentScript = sourceFile.isContentScript;
    283283        if (sourceFile.isContentScript)
     
    568568    {
    569569        var sourceFile = this._presentationModel.sourceFile(sourceFileId);
    570         var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(this._presentationModel, sourceFileId);
     570        var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(this._presentationModel, sourceFileId, sourceFile.displayName);
    571571        var sourceFrame = new WebInspector.SourceFrame(delegate, sourceFile.url);
    572572        sourceFrame._sourceFileId = sourceFileId;
     
    10051005
    10061006
    1007 WebInspector.SourceFrameDelegateForScriptsPanel = function(model, sourceFileId)
     1007WebInspector.SourceFrameDelegateForScriptsPanel = function(model, sourceFileId, scriptName)
    10081008{
    10091009    WebInspector.SourceFrameDelegate.call(this);
     
    10111011    this._sourceFileId = sourceFileId;
    10121012    this._popoverObjectGroup = "popover";
     1013    this._scriptName = scriptName;
    10131014}
    10141015
     
    10911092    {
    10921093        return this._model.formatSourceFilesToggled();
     1094    },
     1095
     1096    suggestedFileName: function()
     1097    {
     1098        return this._scriptName;
    10931099    }
    10941100}
  • trunk/Source/WebCore/inspector/front-end/SourceFile.js

    r84625 r84629  
    6464    },
    6565
     66    get displayName()
     67    {
     68        return this.url ? WebInspector.displayNameForURL(this.url) : WebInspector.UIString("(program)");
     69    },
     70
    6671    get content()
    6772    {
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r84510 r84629  
    313313        var element = this._textViewer.element;
    314314        if (this._delegate.debuggingSupported()) {
    315             element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
    316315            element.addEventListener("mousedown", this._mouseDown.bind(this), true);
    317316            element.addEventListener("mousemove", this._mouseMove.bind(this), true);
     
    606605    },
    607606
    608     _contextMenu: function(event)
    609     {
    610         var contextMenu = new WebInspector.ContextMenu();
    611         var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
    612         if (target)
    613             this._populateLineGutterContextMenu(target.lineNumber, contextMenu);
    614         else
    615             this._populateTextAreaContextMenu(contextMenu);
    616         contextMenu.show(event);
    617     },
    618 
    619     _populateLineGutterContextMenu: function(lineNumber, contextMenu)
     607    populateLineGutterContextMenu: function(lineNumber, contextMenu)
    620608    {
    621609        contextMenu.appendItem(WebInspector.UIString("Continue to Here"), this._delegate.continueToLine.bind(this._delegate, lineNumber));
     
    662650    },
    663651
    664     _populateTextAreaContextMenu: function(contextMenu)
    665     {
    666         contextMenu.appendCheckboxItem(WebInspector.UIString("Pretty print"), this._delegate.toggleFormatSourceFiles.bind(this._delegate), this._delegate.formatSourceFilesToggled());
     652    populateTextAreaContextMenu: function(contextMenu)
     653    {
     654        if (this._delegate.debuggingSupported())
     655            contextMenu.appendCheckboxItem(WebInspector.UIString("Pretty print"), this._delegate.toggleFormatSourceFiles.bind(this._delegate), this._delegate.formatSourceFilesToggled());
     656    },
     657
     658    suggestedFileName: function()
     659    {
     660        return this._delegate.suggestedFileName();
    667661    },
    668662
     
    10271021    {
    10281022        // Should be implemented by subclasses.
     1023    },
     1024
     1025    suggestedFileName: function()
     1026    {
     1027        // Should be implemented by subclasses.
    10291028    }
    10301029}
  • trunk/Source/WebCore/inspector/front-end/TextViewer.js

    r84492 r84629  
    5757    this.element.addEventListener("dblclick", this._doubleClick.bind(this), true);
    5858    this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false);
     59    this.element.addEventListener("contextmenu", this._contextMenu.bind(this), true);
    5960
    6061    this._registerShortcuts();
     
    276277    },
    277278
     279    _contextMenu: function(event)
     280    {
     281        var selection = this._mainPanel._getSelection();
     282        if (selection && !selection.isEmpty())
     283            return; // Show default context menu for selection.
     284
     285        var contextMenu = new WebInspector.ContextMenu();
     286        var target = event.target.enclosingNodeOrSelfWithClass("webkit-line-number");
     287        if (target)
     288            this._delegate.populateLineGutterContextMenu(target.lineNumber, contextMenu);
     289        else
     290            this._delegate.populateTextAreaContextMenu(contextMenu);
     291
     292        var fileName = this._delegate.suggestedFileName();
     293        if (fileName)
     294            contextMenu.appendItem(WebInspector.UIString("Save as..."), InspectorFrontendHost.saveAs.bind(InspectorFrontendHost, fileName, this._textModel.text));
     295
     296        contextMenu.show(event);
     297    },
     298
    278299    _commitEditing: function()
    279300    {
     
    337358
    338359    cancelEditing: function()
     360    {
     361        // Should be implemented by subclasses.
     362    },
     363
     364    populateLineGutterContextMenu: function(contextMenu)
     365    {
     366        // Should be implemented by subclasses.
     367    },
     368
     369    populateTextAreaContextMenu: function(contextMenu)
     370    {
     371        // Should be implemented by subclasses.
     372    },
     373
     374    suggestedFileName: function()
    339375    {
    340376        // Should be implemented by subclasses.
Note: See TracChangeset for help on using the changeset viewer.