Changeset 147198 in webkit


Ignore:
Timestamp:
Mar 28, 2013 11:31:25 PM (11 years ago)
Author:
eustas@chromium.org
Message:

Web Inspector: [Cookies] CookiesTable should integrate with DataGrid context menu.
https://bugs.webkit.org/show_bug.cgi?id=113496

Reviewed by Pavel Feldman.

Integrate CookiesTable with DataGrid context menu
instead of overriding it.

  • inspector/front-end/CookiesTable.js:

Pass context menu callback to DataGrid constructor.

  • inspector/front-end/DataGrid.js:

Added context menu callback constructor parameter. Fixed JSDoc.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r147187 r147198  
     12013-03-28  Eugene Klyuchnikov  <eustas@chromium.org>
     2
     3        Web Inspector: [Cookies] CookiesTable should integrate with DataGrid context menu.
     4        https://bugs.webkit.org/show_bug.cgi?id=113496
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Integrate CookiesTable with DataGrid context menu
     9        instead of overriding it.
     10
     11        * inspector/front-end/CookiesTable.js:
     12        Pass context menu callback to DataGrid constructor.
     13        * inspector/front-end/DataGrid.js:
     14        Added context menu callback constructor parameter. Fixed JSDoc.
     15
    1162013-03-28  Philip Rogers  <pdr@google.com>
    217
  • trunk/Source/WebCore/inspector/front-end/CookiesTable.js

    r147096 r147198  
    5656
    5757    if (readOnly)
    58         this._dataGrid = new WebInspector.DataGrid(columns, null, null, refreshCallback);
    59     else {
    6058        this._dataGrid = new WebInspector.DataGrid(columns);
    61         this._dataGrid.element.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
    62     }
     59    else
     60        this._dataGrid = new WebInspector.DataGrid(columns, undefined, this._onDeleteCookie.bind(this), refreshCallback, this._onContextMenu.bind(this));
    6361
    6462    this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._rebuildTable, this);
     
    8684    {
    8785        this.clear(domain);
    88         if (this._refreshCallback)
    89             this._refreshCallback();
    90     },
    91 
    92     _handleContextMenuEvent: function(event)
    93     {
    94         var gridNode = this._dataGrid.dataGridNodeFromNode(event.target);
    95 
    96         if (!gridNode)
     86        this._refresh();
     87    },
     88
     89    /**
     90     * @param {!WebInspector.ContextMenu} contextMenu
     91     * @param {WebInspector.DataGridNode} node
     92     */
     93    _onContextMenu: function(contextMenu, node)
     94    {
     95        if (node === this._dataGrid.creationNode)
    9796            return;
    98 
    99         var contextMenu = new WebInspector.ContextMenu(event);
    100         var cookie = gridNode.cookie;
    101 
    102         if (this._refreshCallback)
    103             contextMenu.appendItem(WebInspector.UIString("Refresh"), this._refreshCallback);
    104 
    105         if (cookie) {
    106             contextMenu.appendItem(WebInspector.UIString("Delete"), this._onDeleteCookie.bind(this, gridNode));
    107             contextMenu.appendSeparator();
    108             var cookieDomain = cookie.domain();
    109            
    110             contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear all from \"%s\"" : "Clear All from \"%s\"", cookieDomain), this._clearAndRefresh.bind(this, cookieDomain));
    111         } else
    112             contextMenu.appendSeparator();
    113 
     97        var cookie = node.cookie;
     98        var domain = cookie.domain();
     99        if (domain)
     100            contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear all from \"%s\"" : "Clear All from \"%s\"", domain), this._clearAndRefresh.bind(this, domain));
    114101        contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMenuTitles() ? "Clear all" : "Clear All"), this._clearAndRefresh.bind(this, null));
    115 
    116         contextMenu.show();
    117102    },
    118103
     
    291276            this._nextSelectedCookie = neighbour.cookie;
    292277        cookie.remove();
     278        this._refresh();
     279    },
     280
     281    _refresh: function()
     282    {
    293283        if (this._refreshCallback)
    294284            this._refreshCallback();
  • trunk/Source/WebCore/inspector/front-end/DataGrid.js

    r146325 r147198  
    2828 * @extends {WebInspector.View}
    2929 * @param {!Array.<!WebInspector.DataGrid.ColumnDescriptor>} columnsArray
    30  * @param {?function(WebInspector.DataGridNode, string, string, string)=} editCallback
    31  * @param {?function(WebInspector.DataGridNode)=} deleteCallback
    32  * @param {?function()=} refreshCallback
     30 * @param {function(WebInspector.DataGridNode, string, string, string)=} editCallback
     31 * @param {function(WebInspector.DataGridNode)=} deleteCallback
     32 * @param {function()=} refreshCallback
     33 * @param {function(!WebInspector.ContextMenu, WebInspector.DataGridNode)=} contextMenuCallback
    3334 */
    34 WebInspector.DataGrid = function(columnsArray, editCallback, deleteCallback, refreshCallback)
     35WebInspector.DataGrid = function(columnsArray, editCallback, deleteCallback, refreshCallback, contextMenuCallback)
    3536{
    3637    WebInspector.View.call(this);
     
    6061    this._deleteCallback = deleteCallback;
    6162    this._refreshCallback = refreshCallback;
     63    this._contextMenuCallback = contextMenuCallback;
    6264
    6365    this._scrollContainer = document.createElement("div");
     
    942944            if (this._deleteCallback && gridNode !== this.creationNode)
    943945                contextMenu.appendItem(WebInspector.UIString("Delete"), this._deleteCallback.bind(this, gridNode));
     946            if (this._contextMenuCallback)
     947                this._contextMenuCallback(contextMenu, gridNode);
    944948        }
    945949
Note: See TracChangeset for help on using the changeset viewer.