Changeset 112414 in webkit


Ignore:
Timestamp:
Mar 28, 2012 11:13:47 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Add context menu for snippets control.
https://bugs.webkit.org/show_bug.cgi?id=82475

Reviewed by Pavel Feldman.

This is a preliminary implementation of snippets control using context menu.
We might want to add a more discoverable one before taking snippets out of experiments.

  • English.lproj/localizedStrings.js:
  • inspector/front-end/ScriptsNavigator.js:

(WebInspector.ScriptsNavigator.prototype._showScriptFoldersSettingChanged):
(WebInspector.ScriptsNavigator.prototype._createSnippetsTree):
(WebInspector.ScriptsNavigator.prototype._handleSnippetContextMenuEvent):
(WebInspector.ScriptsNavigator.prototype._showSnippetContextMenu):
(WebInspector.ScriptsNavigator.prototype._handleEvaluateSnippet):
(WebInspector.ScriptsNavigator.prototype._handleRenameSnippet):
(WebInspector.ScriptsNavigator.prototype._handleRemoveSnippet):
(WebInspector.ScriptsNavigator.prototype._handleCreateSnippet):
(WebInspector.NavigatorScriptTreeElement.prototype.get navigator):
(WebInspector.NavigatorScriptTreeElement.prototype.onattach):
(WebInspector.NavigatorScriptTreeElement.prototype.onenter):
(WebInspector.NavigatorScriptTreeElement.prototype._handleContextMenuEvent):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r112413 r112414  
     12012-03-28  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Add context menu for snippets control.
     4        https://bugs.webkit.org/show_bug.cgi?id=82475
     5
     6        Reviewed by Pavel Feldman.
     7
     8        This is a preliminary implementation of snippets control using context menu.
     9        We might want to add a more discoverable one before taking snippets out of experiments.
     10
     11        * English.lproj/localizedStrings.js:
     12        * inspector/front-end/ScriptsNavigator.js:
     13        (WebInspector.ScriptsNavigator.prototype._showScriptFoldersSettingChanged):
     14        (WebInspector.ScriptsNavigator.prototype._createSnippetsTree):
     15        (WebInspector.ScriptsNavigator.prototype._handleSnippetContextMenuEvent):
     16        (WebInspector.ScriptsNavigator.prototype._showSnippetContextMenu):
     17        (WebInspector.ScriptsNavigator.prototype._handleEvaluateSnippet):
     18        (WebInspector.ScriptsNavigator.prototype._handleRenameSnippet):
     19        (WebInspector.ScriptsNavigator.prototype._handleRemoveSnippet):
     20        (WebInspector.ScriptsNavigator.prototype._handleCreateSnippet):
     21        (WebInspector.NavigatorScriptTreeElement.prototype.get navigator):
     22        (WebInspector.NavigatorScriptTreeElement.prototype.onattach):
     23        (WebInspector.NavigatorScriptTreeElement.prototype.onenter):
     24        (WebInspector.NavigatorScriptTreeElement.prototype._handleContextMenuEvent):
     25
    1262012-03-28  Vsevolod Vlasov  <vsevik@chromium.org>
    227
  • trunk/Source/WebCore/inspector/front-end/ScriptsNavigator.js

    r112413 r112414  
    226226        this.dispatchEventToListeners(WebInspector.ScriptsPanel.FileSelector.Events.FileSelected, uiSourceCode);
    227227    },
    228    
     228
    229229    /**
    230230     * @param {WebInspector.UISourceCode} uiSourceCode
     
    246246        this._scriptTreeElementsByUISourceCode.remove(uiSourceCode);
    247247    },
    248    
     248
    249249    _showScriptFoldersSettingChanged: function()
    250250    {
     
    255255        for (var i = 0; i < uiSourceCodes.length; ++i)
    256256            this.addUISourceCode(uiSourceCodes[i]);
    257        
     257
    258258        if (this._lastSelectedUISourceCode)
    259259            this.revealUISourceCode(this._lastSelectedUISourceCode);
    260260    },
    261    
     261
    262262    _createSnippetsTree: function()
    263263    {
     
    266266        snippetsView.element.addStyleClass("fill");
    267267        snippetsView.element.addStyleClass("navigator-container");
     268        snippetsView.element.addEventListener("contextmenu", this._handleSnippetContextMenuEvent.bind(this), false);
    268269        var snippetsOutlineElement = document.createElement("div");
    269270        snippetsOutlineElement.addStyleClass("outline-disclosure");
     
    277278    },
    278279
     280    /**
     281     * @param {Event} event
     282     */
     283    _handleSnippetContextMenuEvent: function(event)
     284    {
     285        this._showSnippetContextMenu(event);
     286    },
     287
     288    /**
     289     * @param {Event} event
     290     * @param {WebInspector.UISourceCode=} uiSourceCode
     291     */
     292    _showSnippetContextMenu: function(event, uiSourceCode)
     293    {
     294        var contextMenu = new WebInspector.ContextMenu();
     295        if (uiSourceCode) {
     296            contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Evaluate snippet" : "Evaluate Snippet"), this._handleEvaluateSnippet.bind(this, uiSourceCode));
     297            contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Rename snippet" : "Rename Snippet"), this._handleRenameSnippet.bind(this, uiSourceCode));
     298            contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Remove snippet" : "Remove Snippet"), this._handleRemoveSnippet.bind(this, uiSourceCode));
     299            contextMenu.appendSeparator();
     300        }
     301        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Create snippet" : "Create Snippet"), this._handleCreateSnippet.bind(this));
     302        contextMenu.show(event);
     303    },
     304
     305    /**
     306     * @param {WebInspector.UISourceCode} uiSourceCode
     307     * @param {Event} event
     308     */
     309    _handleEvaluateSnippet: function(uiSourceCode, event)
     310    {
     311        // FIXME: To be implemented.
     312    },
     313
     314    /**
     315     * @param {WebInspector.UISourceCode} uiSourceCode
     316     * @param {Event} event
     317     */
     318    _handleRenameSnippet: function(uiSourceCode, event)
     319    {
     320        // FIXME: To be implemented.
     321    },
     322
     323    /**
     324     * @param {WebInspector.UISourceCode} uiSourceCode
     325     * @param {Event} event
     326     */
     327    _handleRemoveSnippet: function(uiSourceCode, event)
     328    {
     329        // FIXME: To be implemented.
     330    },
     331
     332    /**
     333     * @param {Event} event
     334     */
     335    _handleCreateSnippet: function(event)
     336    {
     337        // FIXME: To be implemented.
     338    },
    279339
    280340    reset: function()
     
    427487       return result;
    428488   },
    429    
     489
    430490   searchStarted: function()
    431491   {
     
    582642WebInspector.NavigatorScriptTreeElement.prototype = {
    583643    /**
     644     * @type {WebInspector.ScriptsNavigator}
     645     */
     646    get navigator()
     647    {
     648        return this._navigator;
     649    },
     650
     651    /**
    584652     * @type {WebInspector.UISourceCode}
    585653     */
     
    589657    },
    590658
     659    onattach: function()
     660    {
     661        WebInspector.BaseNavigatorTreeElement.prototype.onattach.call(this);
     662        if (this._uiSourceCode.isSnippet)
     663            this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), false);
     664    },
     665
    591666    /**
    592667     * @param {Event} event
     
    600675    {
    601676        this._navigator.scriptSelected(this.uiSourceCode);
     677    },
     678
     679    /**
     680     * @param {Event} event
     681     */
     682    _handleContextMenuEvent: function(event)
     683    {
     684        this.navigator._showSnippetContextMenu(event, this.uiSourceCode);
    602685    }
    603686}
Note: See TracChangeset for help on using the changeset viewer.