Web Inspector: Table should handle row selection instead of the table delegate
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 22:44:18 +0000 (22:44 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Aug 2018 22:44:18 +0000 (22:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188534
<rdar://problem/43253335>

Reviewed by Joseph Pecoraro.

Row selection should be implemented by Table, rather than its delegate.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype.tableShouldSelectRow):
(WI.NetworkTableContentView.prototype.tableCellMouseDown): Deleted.
Prevent selection unless the clicked cell belongs to the name column.

* UserInterface/Views/ResourceCookiesContentView.js:
(WI.ResourceCookiesContentView.prototype.tableShouldSelectRow):
Always prevent selection.

* UserInterface/Views/Table.js:
(WI.Table):
(WI.Table.prototype._handleMouseDown):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/ResourceCookiesContentView.js
Source/WebInspectorUI/UserInterface/Views/Table.js

index ef94d4b..b1e1d78 100644 (file)
@@ -1,3 +1,26 @@
+2018-08-13  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Table should handle row selection instead of the table delegate
+        https://bugs.webkit.org/show_bug.cgi?id=188534
+        <rdar://problem/43253335>
+
+        Reviewed by Joseph Pecoraro.
+
+        Row selection should be implemented by Table, rather than its delegate.
+
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView.prototype.tableShouldSelectRow):
+        (WI.NetworkTableContentView.prototype.tableCellMouseDown): Deleted.
+        Prevent selection unless the clicked cell belongs to the name column.
+
+        * UserInterface/Views/ResourceCookiesContentView.js:
+        (WI.ResourceCookiesContentView.prototype.tableShouldSelectRow):
+        Always prevent selection.
+
+        * UserInterface/Views/Table.js:
+        (WI.Table):
+        (WI.Table.prototype._handleMouseDown):
+
 2018-08-12  Aditya Keerthi  <akeerthi@apple.com>
 
         [macOS] Color wells should appear pressed when presenting a color picker
index 0c9fb02..b54fbc1 100644 (file)
@@ -324,14 +324,6 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
     // Table delegate
 
-    tableCellMouseDown(table, cell, column, rowIndex, event)
-    {
-        if (column !== this._nameColumn)
-            return;
-
-        this._table.selectRow(rowIndex);
-    }
-
     tableCellContextMenuClicked(table, cell, column, rowIndex, event)
     {
         if (column !== this._nameColumn)
@@ -347,6 +339,11 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         contextMenu.appendItem(WI.UIString("Export HAR"), () => { this._exportHAR(); });
     }
 
+    tableShouldSelectRow(table, cell, column, rowIndex)
+    {
+        return column === this._nameColumn;
+    }
+
     tableSelectedRowChanged(table, rowIndex)
     {
         if (isNaN(rowIndex)) {
index 5ee044b..ac030c4 100644 (file)
@@ -58,6 +58,11 @@ WI.ResourceCookiesContentView = class ResourceCookiesContentView extends WI.Cont
 
     // Table delegate
 
+    tableShouldSelectRow(table, cell, column, rowIndex)
+    {
+        return false;
+    }
+
     tablePopulateCell(table, cell, column, rowIndex)
     {
         let cookie = this._dataSourceForTable(table)[rowIndex];
index c263239..b335a9c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -56,8 +56,7 @@ WI.Table = class Table extends WI.View
         this._scrollContainerElement.className = "data-container";
         this._scrollContainerElement.addEventListener("scroll", scrollHandler);
         this._scrollContainerElement.addEventListener("mousewheel", scrollHandler);
-        if (this._delegate.tableCellMouseDown)
-            this._scrollContainerElement.addEventListener("mousedown", this._handleMouseDown.bind(this));
+        this._scrollContainerElement.addEventListener("mousedown", this._handleMouseDown.bind(this));
         if (this._delegate.tableCellContextMenuClicked)
             this._scrollContainerElement.addEventListener("contextmenu", this._handleContextMenu.bind(this));
 
@@ -1202,7 +1201,10 @@ WI.Table = class Table extends WI.View
         let column = this._visibleColumns[columnIndex];
         let rowIndex = row.__index;
 
-        this._delegate.tableCellMouseDown(this, cell, column, rowIndex, event);
+        if (this._delegate.tableShouldSelectRow && !this._delegate.tableShouldSelectRow(this, cell, column, rowIndex))
+            return;
+
+        this.selectRow(rowIndex);
     }
 
     _handleContextMenu(event)