这是indexloc提供的服务,不要输入任何密码

Changeset 46519 in webkit


Ignore:
Timestamp:
Jul 28, 2009, 9:54:00 PM (16 years ago)
Author:
timothy@apple.com
Message:

Allow creating new DOM Storage items in the Web Inspector.

2009-07-28 Joseph Pecoraro <joepeck02@gmail.com>

Inspector: Create New DOM Storage Items via DataGrid

https://bugs.webkit.org/show_bug.cgi?id=27322

Reviewed by Timothy Hatcher.

  • inspector/front-end/DOMStorageDataGrid.js: (WebInspector.DOMStorageDataGrid.prototype._startEditing): click anyway means creationNode (WebInspector.DOMStorageDataGrid.prototype._editingCommitted): fix unintended globals (WebInspector.DOMStorageDataGrid.prototype.deleteSelectedRow): creationNode is special case
  • inspector/front-end/DataGrid.js: (WebInspector.DataGrid.prototype.addCreationNode): maintain a quick ref to the single creationNode (WebInspector.CreationDataGridNode): new type of node (WebInspector.CreationDataGridNode.prototype.makeNormal): convert to a normal node
  • inspector/front-end/DatabasesPanel.js: (WebInspector.DatabasesPanel.prototype.dataGridForDOMStorage): add a creationNode to the GridData
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46518 r46519  
     12009-07-28  Joseph Pecoraro  <joepeck02@gmail.com>
     2
     3        Inspector: Create New DOM Storage Items via DataGrid
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=27322
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * inspector/front-end/DOMStorageDataGrid.js:
     10        (WebInspector.DOMStorageDataGrid.prototype._startEditing): click anyway means creationNode
     11        (WebInspector.DOMStorageDataGrid.prototype._editingCommitted): fix unintended globals
     12        (WebInspector.DOMStorageDataGrid.prototype.deleteSelectedRow): creationNode is special case
     13        * inspector/front-end/DataGrid.js:
     14        (WebInspector.DataGrid.prototype.addCreationNode): maintain a quick ref to the single creationNode
     15        (WebInspector.CreationDataGridNode): new type of node
     16        (WebInspector.CreationDataGridNode.prototype.makeNormal): convert to a normal node
     17        * inspector/front-end/DatabasesPanel.js:
     18        (WebInspector.DatabasesPanel.prototype.dataGridForDOMStorage): add a creationNode to the GridData
     19
    1202009-07-28  Joseph Pecoraro  <joepeck02@gmail.com>
    221
  • trunk/WebCore/inspector/front-end/DOMStorageDataGrid.js

    r41290 r46519  
    3939        this._startEditing(event);
    4040    },
    41    
     41
    4242    _startEditing: function(event)
    4343    {
     
    4545        if (!element)
    4646            return;
     47
    4748        this._editingNode = this.dataGridNodeFromEvent(event);
    48         if (!this._editingNode)
    49             return;
     49        if (!this._editingNode) {
     50            if (!this.creationNode)
     51                return;
     52            this._editingNode = this.creationNode;
     53        }
    5054        this._editing = true;
    51            
     55
     56        if (this._editingNode.isCreationNode) {
     57            this._editingNode.select();
     58            element = this._editingNode._element.children[0]; // Create a new node by providing a Key First
     59        }
     60
    5261        WebInspector.startEditing(element, this._editingCommitted.bind(this), this._editingCancelled.bind(this), element.textContent);
    5362        window.getSelection().setBaseAndExtent(element, 0, element, 1);
    5463    },
    55    
     64
    5665    _editingCommitted: function(element, newText)
    5766    {
    58         if (element.hasStyleClass("0-column"))
    59             columnIdentifier = 0;
    60         else
    61             columnIdentifier = 1;
    62         textBeforeEditing = this._editingNode.data[columnIdentifier];
     67        var columnIdentifier = (element.hasStyleClass("0-column") ? 0 : 1);
     68        var textBeforeEditing = this._editingNode.data[columnIdentifier];
    6369        if (textBeforeEditing == newText) {
    6470            this._editingCancelled(element);
    6571            return;
    6672        }
    67        
     73
    6874        var domStorage = WebInspector.panels.databases.visibleView.domStorage.domStorage;
    6975        if (domStorage) {
     
    8288            }
    8389        }
    84        
     90
     91        if (this._editingNode.isCreationNode)
     92            this.addCreationNode(false);
     93
    8594        this._editingCancelled(element);
    8695    },
    87    
     96
    8897    _editingCancelled: function(element, context)
    8998    {
     
    91100        this._editingNode = null;
    92101    },
    93    
     102
    94103    deleteSelectedRow: function()
    95104    {
    96105        var node = this.selectedNode;
     106        if (this.selectedNode.isCreationNode)
     107            return;
     108
    97109        var domStorage = WebInspector.panels.databases.visibleView.domStorage.domStorage;
    98110        if (node && domStorage)
  • trunk/WebCore/inspector/front-end/DataGrid.js

    r42808 r46519  
    160160
    161161        return this._dataTableBody;
     162    },
     163
     164    addCreationNode: function(hasChildren)
     165    {
     166        if (this.creationNode)
     167            this.creationNode.makeNormal();
     168
     169        var emptyData = {};
     170        for (var column in this.columns)
     171            emptyData[column] = '';
     172        this.creationNode = new WebInspector.CreationDataGridNode(emptyData, hasChildren);
     173        this.appendChild(this.creationNode);
    162174    },
    163175
     
    884896
    885897WebInspector.DataGridNode.prototype.__proto__ = WebInspector.Object.prototype;
     898
     899WebInspector.CreationDataGridNode = function(data, hasChildren)
     900{
     901    WebInspector.DataGridNode.call(this, data, hasChildren);
     902    this.isCreationNode = true;
     903}
     904
     905WebInspector.CreationDataGridNode.prototype = {
     906    makeNormal: function()
     907    {
     908        delete this.isCreationNode;
     909        delete this.makeNormal;
     910    }
     911}
     912
     913WebInspector.CreationDataGridNode.prototype.__proto__ = WebInspector.DataGridNode.prototype;
  • trunk/WebCore/inspector/front-end/DatabasesPanel.js

    r46518 r46519  
    396396        for (var i = 0; i < length; ++i)
    397397            dataGrid.appendChild(nodes[i]);
     398        dataGrid.addCreationNode(false);
    398399        if (length > 0)
    399400            nodes[0].selected = true;
Note: See TracChangeset for help on using the changeset viewer.