Title: [261339] trunk/Source/WebInspectorUI
Revision
261339
Author
drou...@apple.com
Date
2020-05-07 15:59:07 -0700 (Thu, 07 May 2020)

Log Message

Web Inspector: Storage: double clicking on a cookie field doesn't start editing it
https://bugs.webkit.org/show_bug.cgi?id=211598

Reviewed by Timothy Hatcher.

* UserInterface/Views/CookieStorageContentView.js:
(WI.CookieStorageContentView):
(WI.CookieStorageContentView.prototype.tableCellContextMenuClicked):
(WI.CookieStorageContentView.prototype.tablePopulateCell):
(WI.CookieStorageContentView.prototype._showCookiePopover):
(WI.CookieStorageContentView.prototype._handleSetCookieButtonClick):
Add a `"dblclick"` event listener to each cell that shows a `WI.CookiePopover` for that cell
and automatically select the current value of that field in the `WI.Cookie`. Unify the few
different ways to show a `WI.CookiePopover`.

* UserInterface/Views/CookiePopover.js:
(WI.CookiePopover.prototype.show.createRow):
Provide a way to programmatically trigger the focusing of an editor once shown.

* Localizations/en.lproj/localizedStrings.js:

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (261338 => 261339)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-05-07 22:58:14 UTC (rev 261338)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-05-07 22:59:07 UTC (rev 261339)
@@ -1,3 +1,26 @@
+2020-05-07  Devin Rousso  <drou...@apple.com>
+
+        Web Inspector: Storage: double clicking on a cookie field doesn't start editing it
+        https://bugs.webkit.org/show_bug.cgi?id=211598
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/CookieStorageContentView.js:
+        (WI.CookieStorageContentView):
+        (WI.CookieStorageContentView.prototype.tableCellContextMenuClicked):
+        (WI.CookieStorageContentView.prototype.tablePopulateCell):
+        (WI.CookieStorageContentView.prototype._showCookiePopover):
+        (WI.CookieStorageContentView.prototype._handleSetCookieButtonClick):
+        Add a `"dblclick"` event listener to each cell that shows a `WI.CookiePopover` for that cell
+        and automatically select the current value of that field in the `WI.Cookie`. Unify the few
+        different ways to show a `WI.CookiePopover`.
+
+        * UserInterface/Views/CookiePopover.js:
+        (WI.CookiePopover.prototype.show.createRow):
+        Provide a way to programmatically trigger the focusing of an editor once shown.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
 2020-05-06  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: Layers: the text at the bottom of the details sidebar can get squished

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (261338 => 261339)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2020-05-07 22:58:14 UTC (rev 261338)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2020-05-07 22:59:07 UTC (rev 261339)
@@ -230,7 +230,6 @@
 localizedStrings["Call Stack"] = "Call Stack";
 localizedStrings["Call Stack Unavailable"] = "Call Stack Unavailable";
 localizedStrings["Call Trees"] = "Call Trees";
-localizedStrings["Calls"] = "Calls";
 localizedStrings["Cancel Automatic Continue"] = "Cancel Automatic Continue";
 localizedStrings["Cancel comparison"] = "Cancel comparison";
 /* Tooltip for a timestamp marker that represents when a CSS animation/transition is canceled */

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CookiePopover.js (261338 => 261339)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CookiePopover.js	2020-05-07 22:58:14 UTC (rev 261338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CookiePopover.js	2020-05-07 22:59:07 UTC (rev 261339)
@@ -98,7 +98,7 @@
         return data;
     }
 
-    show(cookie, targetElement, preferredEdges)
+    show(cookie, targetElement, preferredEdges, options = {})
     {
         console.assert(!cookie || cookie instanceof WI.Cookie, cookie);
         console.assert(targetElement instanceof Element, targetElement);
@@ -137,7 +137,7 @@
         let tableElement = popoverContentElement.appendChild(document.createElement("table"));
 
         function createRow(id, label, editorElement) {
-            id = `cookie-popover-${id}-editor`;
+            let domId = `cookie-popover-${id}-editor`;
 
             let rowElement = tableElement.appendChild(document.createElement("tr"));
 
@@ -144,14 +144,21 @@
             let headerElement = rowElement.appendChild(document.createElement("th"));
 
             let labelElement = headerElement.appendChild(document.createElement("label"));
-            labelElement.setAttribute("for", id);
+            labelElement.setAttribute("for", domId);
             labelElement.textContent = label;
 
             let dataElement = rowElement.appendChild(document.createElement("td"));
 
-            editorElement.id = id;
+            editorElement.id = domId;
             dataElement.appendChild(editorElement);
 
+            if (id === options.focusField) {
+                setTimeout(() => {
+                    editorElement.focus();
+                    editorElement.select?.();
+                });
+            }
+
             return {rowElement};
         }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js (261338 => 261339)


--- trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js	2020-05-07 22:58:14 UTC (rev 261338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js	2020-05-07 22:59:07 UTC (rev 261339)
@@ -35,6 +35,7 @@
         this._filteredCookies = [];
         this._sortComparator = null;
         this._table = null;
+        this._knownCells = new WeakSet;
 
         this._emptyFilterResultsMessageElement = null;
 
@@ -146,13 +147,9 @@
 
         contextMenu.appendSeparator();
 
-        if (InspectorBackend.hasCommand("Page.setCookie")) {
-            contextMenu.appendItem(WI.UIString("Edit"), () => {
-                console.assert(!this._editingCookie);
-                this._editingCookie = this._filteredCookies[rowIndex];
-
-                let popover = new WI.CookiePopover(this);
-                popover.show(this._editingCookie, this._table.cellForRowAndColumn(rowIndex, this._table.columns[0]), [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_X]);
+        if (InspectorBackend.hasCommand("Page.setCookie") && column.identifier !== "size") {
+            contextMenu.appendItem(WI.UIString("Edit %s").format(column.name), () => {
+                this._showCookiePopover(cell, this._filteredCookies[rowIndex], column.identifier);
             });
         }
 
@@ -200,7 +197,22 @@
     tablePopulateCell(table, cell, column, rowIndex)
     {
         let cookie = this._filteredCookies[rowIndex];
+
         cell.textContent = this._formatCookiePropertyForColumn(cookie, column);
+
+        if (!this._knownCells.has(cell)) {
+            this._knownCells.add(cell);
+
+            cell.addEventListener("dblclick", (event) => {
+                if (column.identifier === "size") {
+                    InspectorFrontendHost.beep();
+                    return;
+                }
+
+                this._showCookiePopover(cell, cookie, column.identifier);
+            });
+        }
+
         return cell;
     }
 
@@ -374,6 +386,43 @@
         this._sortComparator = (a, b) => reverseFactor * comparator(a, b);
     }
 
+    _showCookiePopover(targetElement, cookie, columnIdentifier) {
+        console.assert(!this._editingCookie);
+        this._editingCookie = cookie;
+
+        let options = {};
+        if (columnIdentifier) {
+            switch (columnIdentifier) {
+            case "name":
+            case "value":
+            case "domain":
+            case "path":
+            case "secure":
+                options.focusField = columnIdentifier;
+                break;
+
+            case "expires":
+                options.focusField = this._editingCookie.session ? "session" : "expires";
+                break;
+
+            case "httpOnly":
+                options.focusField = "http-only";
+                break;
+
+            case "sameSite":
+                options.focusField = "same-site";
+                break;
+
+            default:
+                console.assert();
+                break;
+            }
+        }
+
+        let popover = new WI.CookiePopover(this);
+        popover.show(this._editingCookie, targetElement, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MIN_X, WI.RectEdge.MAX_X], options);
+    }
+
     async _willDismissCookiePopover(popover)
     {
         let editingCookie = this._editingCookie;
@@ -416,8 +465,7 @@
 
     _handleSetCookieButtonClick(event)
     {
-        let popover = new WI.CookiePopover(this);
-        popover.show(null, this._setCookieButtonNavigationItem.element, [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_X]);
+        this._showCookiePopover(this._setCookieButtonNavigationItem.element, null, "name");
     }
 
     _refreshButtonClicked(event)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to