Title: [238831] trunk/Source/WebInspectorUI
Revision
238831
Author
[email protected]
Date
2018-12-03 16:57:36 -0800 (Mon, 03 Dec 2018)

Log Message

Web Inspector: Audit: "Add Default Audits" shown when there are no filter results
https://bugs.webkit.org/show_bug.cgi?id=192105

Reviewed by Matt Baker.

* UserInterface/Views/NavigationSidebarPanel.js:
(WI.NavigationSidebarPanel):
(WI.NavigationSidebarPanel.prototype.get hasActiveFilters): Added.
(WI.NavigationSidebarPanel.prototype.suppressFilteringOnTreeElements):
(WI.NavigationSidebarPanel.prototype.showEmptyContentPlaceholder):
(WI.NavigationSidebarPanel.prototype.hideEmptyContentPlaceholder):
(WI.NavigationSidebarPanel.prototype.updateEmptyContentPlaceholder):
(WI.NavigationSidebarPanel.prototype.updateFilter):
(WI.NavigationSidebarPanel.prototype._checkForEmptyFilterResults.checkTreeOutlineForEmptyFilterResults):
(WI.NavigationSidebarPanel.prototype._filterDidChange):
(WI.NavigationSidebarPanel.prototype._updateFilter): Deleted.
(WI.NavigationSidebarPanel.prototype._createEmptyContentPlaceholderIfNeeded): Deleted.

* UserInterface/Views/AuditNavigationSidebarPanel.js:
(WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved):
Drive-by: change capitalization for consistency with other navigation sidebars.

* Localizations/en.lproj/localizedStrings.js:

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (238830 => 238831)


--- trunk/Source/WebInspectorUI/ChangeLog	2018-12-04 00:55:21 UTC (rev 238830)
+++ trunk/Source/WebInspectorUI/ChangeLog	2018-12-04 00:57:36 UTC (rev 238831)
@@ -1,5 +1,31 @@
 2018-12-03  Devin Rousso  <[email protected]>
 
+        Web Inspector: Audit: "Add Default Audits" shown when there are no filter results
+        https://bugs.webkit.org/show_bug.cgi?id=192105
+
+        Reviewed by Matt Baker.
+
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WI.NavigationSidebarPanel):
+        (WI.NavigationSidebarPanel.prototype.get hasActiveFilters): Added.
+        (WI.NavigationSidebarPanel.prototype.suppressFilteringOnTreeElements):
+        (WI.NavigationSidebarPanel.prototype.showEmptyContentPlaceholder):
+        (WI.NavigationSidebarPanel.prototype.hideEmptyContentPlaceholder):
+        (WI.NavigationSidebarPanel.prototype.updateEmptyContentPlaceholder):
+        (WI.NavigationSidebarPanel.prototype.updateFilter):
+        (WI.NavigationSidebarPanel.prototype._checkForEmptyFilterResults.checkTreeOutlineForEmptyFilterResults):
+        (WI.NavigationSidebarPanel.prototype._filterDidChange):
+        (WI.NavigationSidebarPanel.prototype._updateFilter): Deleted.
+        (WI.NavigationSidebarPanel.prototype._createEmptyContentPlaceholderIfNeeded): Deleted.
+
+        * UserInterface/Views/AuditNavigationSidebarPanel.js:
+        (WI.AuditNavigationSidebarPanel.prototype._handleAuditTestRemoved):
+        Drive-by: change capitalization for consistency with other navigation sidebars.
+
+        * Localizations/en.lproj/localizedStrings.js:
+
+2018-12-03  Devin Rousso  <[email protected]>
+
         Web Inspector: Canvas: add singular localized string for "Record first %s frames"
         https://bugs.webkit.org/show_bug.cgi?id=192189
 

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


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2018-12-04 00:55:21 UTC (rev 238830)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2018-12-04 00:57:36 UTC (rev 238831)
@@ -592,6 +592,7 @@
 localizedStrings["No Accessibility Information"] = "No Accessibility Information";
 localizedStrings["No Application Cache information available"] = "No Application Cache information available";
 localizedStrings["No Attributes"] = "No Attributes";
+localizedStrings["No Audits"] = "No Audits";
 localizedStrings["No Box Model Information"] = "No Box Model Information";
 localizedStrings["No Canvas Contexts"] = "No Canvas Contexts";
 localizedStrings["No Canvas Selected"] = "No Canvas Selected";
@@ -612,7 +613,6 @@
 localizedStrings["No Search Results"] = "No Search Results";
 localizedStrings["No Watch Expressions"] = "No Watch Expressions";
 localizedStrings["No audit selected"] = "No audit selected";
-localizedStrings["No audits"] = "No audits";
 localizedStrings["No matching ARIA role"] = "No matching ARIA role";
 localizedStrings["No preview available"] = "No preview available";
 localizedStrings["No request cookies."] = "No request cookies.";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js (238830 => 238831)


--- trunk/Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js	2018-12-04 00:55:21 UTC (rev 238830)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/AuditNavigationSidebarPanel.js	2018-12-04 00:57:36 UTC (rev 238831)
@@ -101,6 +101,14 @@
         WI.auditManager.removeEventListener(null, null, this);
     }
 
+    updateFilter()
+    {
+        super.updateFilter();
+
+        if (!this.hasActiveFilters)
+            this._updateNoAuditsPlaceholder();
+    }
+
     applyFiltersToTreeElement(treeElement)
     {
         super.applyFiltersToTreeElement(treeElement);
@@ -149,6 +157,30 @@
         this._startStopButtonNavigationItem.enabled = WI.auditManager.tests.length && WI.auditManager.runningState !== WI.AuditManager.RunningState.Stopping;
     }
 
+    _updateNoAuditsPlaceholder()
+    {
+        if (WI.auditManager.tests.length)
+            return;
+
+        let contentPlaceholder = WI.createMessageTextView(WI.UIString("No Audits"));
+
+        let defaultButtonElement = contentPlaceholder.appendChild(document.createElement("button"));
+        defaultButtonElement.textContent = WI.UIString("Add Default Audits");
+        defaultButtonElement.addEventListener("click", () => {
+            WI.auditManager.addDefaultTestsIfNeeded();
+        });
+
+        contentPlaceholder = this.showEmptyContentPlaceholder(contentPlaceholder);
+
+        if (WI.auditManager.results.length) {
+            console.assert(this.contentTreeOutline.children[0] === this._resultsFolderTreeElement);
+
+            // Move the placeholder to be the first element in the content area, where it will
+            // be styled such that only the button is visible.
+            this.contentView.element.insertBefore(contentPlaceholder, this.contentView.element.firstChild);
+        }
+    }
+
     _handleAuditTestAdded(event)
     {
         this._addTest(event.data.test);
@@ -168,27 +200,8 @@
 
         this.element.classList.toggle("has-tests", !!WI.auditManager.tests.length);
 
-        if (!WI.auditManager.tests.length) {
-            let contentPlaceholder = WI.createMessageTextView(WI.UIString("No audits"));
-
-            let defaultButtonElement = contentPlaceholder.appendChild(document.createElement("button"));
-            defaultButtonElement.textContent = WI.UIString("Add Default Audits");
-            defaultButtonElement.addEventListener("click", () => {
-                WI.auditManager.addDefaultTestsIfNeeded();
-            });
-
-            contentPlaceholder = this.showEmptyContentPlaceholder(contentPlaceholder);
-
-            if (WI.auditManager.results.length) {
-                console.assert(this.contentTreeOutline.children[0] === this._resultsFolderTreeElement);
-
-                // Move the placeholder to be the first element in the content area, where it will
-                // be styled such that only the button is visible.
-                this.contentView.element.insertBefore(contentPlaceholder, this.contentView.element.firstChild);
-            }
-        }
-
         this._updateStartStopButtonNavigationItemState();
+        this._updateNoAuditsPlaceholder();
     }
 
     _handleAuditTestScheduled(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (238830 => 238831)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2018-12-04 00:55:21 UTC (rev 238830)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2018-12-04 00:57:36 UTC (rev 238831)
@@ -56,7 +56,7 @@
         this._filterBar.filters = this._filtersSetting.value;
 
         this._emptyContentPlaceholderElements = new Map;
-        this._emptyFilterResults = new Map;
+        this._emptyFilterResults = new Set;
 
         this._shouldAutoPruneStaleTopLevelResourceTreeElements = shouldAutoPruneStaleTopLevelResourceTreeElements || false;
 
@@ -72,6 +72,9 @@
 
     // Public
 
+    get filterBar() { return this._filterBar; }
+    get hasActiveFilters() { return this._filterBar.hasActiveFilters(); }
+
     closed()
     {
         window.removeEventListener("resize", this._boundUpdateContentOverflowShadowVisibility);
@@ -106,11 +109,6 @@
         return this._contentBrowser.currentRepresentedObjects[0] || null;
     }
 
-    get filterBar()
-    {
-        return this._filterBar;
-    }
-
     get restoringState()
     {
         return this._restoringState;
@@ -153,7 +151,7 @@
         for (let treeElement of treeElements)
             treeElement[WI.NavigationSidebarPanel.SuppressFilteringSymbol] = true;
 
-        this._updateFilter();
+        this.updateFilter();
     }
 
     treeElementForRepresentedObject(representedObject)
@@ -265,10 +263,13 @@
 
         treeOutline = treeOutline || this._contentTreeOutline;
 
-        let emptyContentPlaceholderElement = this._createEmptyContentPlaceholderIfNeeded(treeOutline, message);
-        if (emptyContentPlaceholderElement.parentNode)
-            return emptyContentPlaceholderElement;
+        let emptyContentPlaceholderElement = this._emptyContentPlaceholderElements.get(treeOutline);
+        if (emptyContentPlaceholderElement)
+            emptyContentPlaceholderElement.remove();
 
+        emptyContentPlaceholderElement = message instanceof Node ? message : WI.createMessageTextView(message);
+        this._emptyContentPlaceholderElements.set(treeOutline, emptyContentPlaceholderElement);
+
         let emptyContentPlaceholderParentElement = treeOutline.element.parentNode;
         emptyContentPlaceholderParentElement.appendChild(emptyContentPlaceholderElement);
 
@@ -286,6 +287,7 @@
             return;
 
         emptyContentPlaceholderElement.remove();
+        this._emptyContentPlaceholderElements.delete(treeOutline);
 
         this._updateContentOverflowShadowVisibility();
     }
@@ -297,7 +299,7 @@
         if (!treeOutline.children.length) {
             // No tree elements, so no results.
             this.showEmptyContentPlaceholder(message, treeOutline);
-        } else if (!this._emptyFilterResults.get(treeOutline)) {
+        } else if (!this._emptyFilterResults.has(treeOutline)) {
             // There are tree elements, and not all of them are hidden by the filter.
             this.hideEmptyContentPlaceholder(treeOutline);
         }
@@ -305,7 +307,45 @@
 
     updateFilter()
     {
-        this._updateFilter();
+        let selectedTreeElement;
+        for (let treeOutline of this.contentTreeOutlines) {
+            if (treeOutline.hidden || treeOutline[WI.NavigationSidebarPanel.SuppressFilteringSymbol])
+                continue;
+
+            selectedTreeElement = treeOutline.selectedTreeElement;
+            if (selectedTreeElement)
+                break;
+        }
+
+        let filters = this._filterBar.filters;
+        this._textFilterRegex = simpleGlobStringToRegExp(filters.text, "i");
+        this._filtersSetting.value = filters;
+        this._filterFunctions = filters.functions;
+
+        // Don't populate if we don't have any active filters.
+        // We only need to populate when a filter needs to reveal.
+        let dontPopulate = !this._filterBar.hasActiveFilters() && !this.shouldFilterPopulate();
+
+        // Update all trees that allow filtering.
+        for (let treeOutline of this.contentTreeOutlines) {
+            if (treeOutline.hidden || treeOutline[WI.NavigationSidebarPanel.SuppressFilteringSymbol])
+                continue;
+
+            let currentTreeElement = treeOutline.children[0];
+            while (currentTreeElement && !currentTreeElement.root) {
+                if (!currentTreeElement[WI.NavigationSidebarPanel.SuppressFilteringSymbol]) {
+                    const currentTreeElementWasHidden = currentTreeElement.hidden;
+                    this.applyFiltersToTreeElement(currentTreeElement);
+                    if (currentTreeElementWasHidden !== currentTreeElement.hidden)
+                        this._treeElementWasFiltered(currentTreeElement);
+                }
+
+                currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, dontPopulate);
+            }
+        }
+
+        this._checkForEmptyFilterResults();
+        this._updateContentOverflowShadowVisibility();
     }
 
     resetFilter()
@@ -514,7 +554,7 @@
 
             if (unfilteredTreeElementFound || !filterableTreeElementFound) {
                 this.hideEmptyContentPlaceholder(treeOutline);
-                this._emptyFilterResults.set(treeOutline, false);
+                this._emptyFilterResults.delete(treeOutline);
                 return;
             }
 
@@ -528,7 +568,7 @@
 
             // All top level tree elements are hidden, so filtering hid everything. Show a message.
             this.showEmptyContentPlaceholder(message, treeOutline);
-            this._emptyFilterResults.set(treeOutline, true);
+            this._emptyFilterResults.add(treeOutline);
         }
 
         for (let treeOutline of this.contentTreeOutlines) {
@@ -541,52 +581,9 @@
 
     _filterDidChange()
     {
-        this._updateFilter();
+        this.updateFilter();
     }
 
-    _updateFilter()
-    {
-        let selectedTreeElement;
-        for (let treeOutline of this.contentTreeOutlines) {
-            if (treeOutline.hidden || treeOutline[WI.NavigationSidebarPanel.SuppressFilteringSymbol])
-                continue;
-
-            selectedTreeElement = treeOutline.selectedTreeElement;
-            if (selectedTreeElement)
-                break;
-        }
-
-        let filters = this._filterBar.filters;
-        this._textFilterRegex = simpleGlobStringToRegExp(filters.text, "i");
-        this._filtersSetting.value = filters;
-        this._filterFunctions = filters.functions;
-
-        // Don't populate if we don't have any active filters.
-        // We only need to populate when a filter needs to reveal.
-        let dontPopulate = !this._filterBar.hasActiveFilters() && !this.shouldFilterPopulate();
-
-        // Update all trees that allow filtering.
-        for (let treeOutline of this.contentTreeOutlines) {
-            if (treeOutline.hidden || treeOutline[WI.NavigationSidebarPanel.SuppressFilteringSymbol])
-                continue;
-
-            let currentTreeElement = treeOutline.children[0];
-            while (currentTreeElement && !currentTreeElement.root) {
-                if (!currentTreeElement[WI.NavigationSidebarPanel.SuppressFilteringSymbol]) {
-                    const currentTreeElementWasHidden = currentTreeElement.hidden;
-                    this.applyFiltersToTreeElement(currentTreeElement);
-                    if (currentTreeElementWasHidden !== currentTreeElement.hidden)
-                        this._treeElementWasFiltered(currentTreeElement);
-                }
-
-                currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, dontPopulate);
-            }
-        }
-
-        this._checkForEmptyFilterResults();
-        this._updateContentOverflowShadowVisibility();
-    }
-
     _treeElementAddedOrChanged(event)
     {
         // Don't populate if we don't have any active filters.
@@ -734,18 +731,6 @@
         }
     }
 
-    _createEmptyContentPlaceholderIfNeeded(treeOutline, message)
-    {
-        let emptyContentPlaceholderElement = this._emptyContentPlaceholderElements.get(treeOutline);
-        if (emptyContentPlaceholderElement)
-            return emptyContentPlaceholderElement;
-
-        emptyContentPlaceholderElement = message instanceof Node ? message : WI.createMessageTextView(message);
-        this._emptyContentPlaceholderElements.set(treeOutline, emptyContentPlaceholderElement);
-
-        return emptyContentPlaceholderElement;
-    }
-
     _treeElementWasFiltered(treeElement)
     {
         if (treeElement.selected || treeElement.hidden)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to