Web Inspector: In a DataGrid, store value of columnIdentifier to DOM node representin...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2014 15:40:29 +0000 (15:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Jan 2014 15:40:29 +0000 (15:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=127613

Patch by Diego Pino Garcia <dpino@igalia.com> on 2014-01-28
Reviewed by Timothy Hatcher.

* UserInterface/DOMStorageContentView.js:
(WebInspector.DOMStorageContentView.prototype._editingCallback):
* UserInterface/DataGrid.js:
(WebInspector.DataGrid):
(WebInspector.DataGrid.prototype._keyDown):
(WebInspector.DataGrid.prototype._contextMenuInDataTable):
(WebInspector.DataGridNode.prototype.createCell):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/DOMStorageContentView.js
Source/WebInspectorUI/UserInterface/DataGrid.js

index 3d1b9a3..f3dd9be 100644 (file)
@@ -1,3 +1,18 @@
+2014-01-28  Diego Pino Garcia  <dpino@igalia.com>
+
+        Web Inspector: In a DataGrid, store value of columnIdentifier to DOM node representing a cell
+        https://bugs.webkit.org/show_bug.cgi?id=127613
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/DOMStorageContentView.js:
+        (WebInspector.DOMStorageContentView.prototype._editingCallback):
+        * UserInterface/DataGrid.js:
+        (WebInspector.DataGrid):
+        (WebInspector.DataGrid.prototype._keyDown):
+        (WebInspector.DataGrid.prototype._contextMenuInDataTable):
+        (WebInspector.DataGridNode.prototype.createCell):
+
 2014-01-27  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Feature Check all Protocol Generated Interfaces to get JSContext Inspection working
 2014-01-27  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Feature Check all Protocol Generated Interfaces to get JSContext Inspection working
index d31db92..31ba7fa 100644 (file)
@@ -215,7 +215,7 @@ WebInspector.DOMStorageContentView.prototype = {
     _editingCallback: function(editingNode, columnIdentifier, oldText, newText)
     {
         var domStorage = this.representedObject;
     _editingCallback: function(editingNode, columnIdentifier, oldText, newText)
     {
         var domStorage = this.representedObject;
-        if (columnIdentifier === 0) {
+        if (columnIdentifier === "0") {
             if (oldText)
                 domStorage.removeItem(oldText);
 
             if (oldText)
                 domStorage.removeItem(oldText);
 
index 2becbd6..82121e8 100644 (file)
@@ -153,6 +153,7 @@ WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
         var column = columns[columnIdentifier];
         var td = document.createElement("td");
         td.className = columnIdentifier + "-column";
         var column = columns[columnIdentifier];
         var td = document.createElement("td");
         td.className = columnIdentifier + "-column";
+        td.__columnIdentifier = columnIdentifier;
         var group = this.groups[columnIdentifier];
         if (group)
             td.classList.add("column-group-" + group);
         var group = this.groups[columnIdentifier];
         if (group)
             td.classList.add("column-group-" + group);
@@ -343,8 +344,7 @@ WebInspector.DataGrid.prototype = {
         // FIXME: We need more column identifiers here throughout this function.
         // Not needed yet since only editable DataGrid is DOM Storage, which is Key - Value.
 
         // FIXME: We need more column identifiers here throughout this function.
         // Not needed yet since only editable DataGrid is DOM Storage, which is Key - Value.
 
-        // FIXME: Better way to do this than regular expressions?
-        var columnIdentifier = parseInt(element.className.match(/\b(\d+)-column\b/)[1], 10);
+        var columnIdentifier = element.__columnIdentifier;
 
         var textBeforeEditing = this._editingNode.data[columnIdentifier] || "";
         var currentEditingNode = this._editingNode;
 
         var textBeforeEditing = this._editingNode.data[columnIdentifier] || "";
         var currentEditingNode = this._editingNode;
@@ -901,8 +901,6 @@ WebInspector.DataGrid.prototype = {
         } else if (isEnterKey(event)) {
             if (this._editCallback) {
                 handled = true;
         } else if (isEnterKey(event)) {
             if (this._editCallback) {
                 handled = true;
-                // The first child of the selected element is the <td class="0-column">,
-                // and that's what we want to edit.
                 this._startEditing(this.selectedNode._element.children[0]);
             }
         }
                 this._startEditing(this.selectedNode._element.children[0]);
             }
         }
@@ -1137,7 +1135,7 @@ WebInspector.DataGrid.prototype = {
                     contextMenu.appendItem(WebInspector.UIString("Add New"), this._startEditing.bind(this, event.target));
                 else {
                     var element = event.target.enclosingNodeOrSelfWithNodeName("td");
                     contextMenu.appendItem(WebInspector.UIString("Add New"), this._startEditing.bind(this, event.target));
                 else {
                     var element = event.target.enclosingNodeOrSelfWithNodeName("td");
-                    var columnIdentifier = parseInt(element.className.match(/\b(\d+)-column\b/)[1], 10);
+                    var columnIdentifier = element.__columnIdentifier;
                     var columnTitle = this.dataGrid.columns[columnIdentifier].title;
                     contextMenu.appendItem(WebInspector.UIString("Edit ā€œ%sā€").format(columnTitle), this._startEditing.bind(this, event.target));
                 }
                     var columnTitle = this.dataGrid.columns[columnIdentifier].title;
                     contextMenu.appendItem(WebInspector.UIString("Edit ā€œ%sā€").format(columnTitle), this._startEditing.bind(this, event.target));
                 }
@@ -1518,6 +1516,7 @@ WebInspector.DataGridNode.prototype = {
     {
         var cell = document.createElement("td");
         cell.className = columnIdentifier + "-column";
     {
         var cell = document.createElement("td");
         cell.className = columnIdentifier + "-column";
+        cell.__columnIdentifier = columnIdentifier;
 
         var alignment = this.dataGrid.aligned[columnIdentifier];
         if (alignment)
 
         var alignment = this.dataGrid.aligned[columnIdentifier];
         if (alignment)