Title: [191071] trunk/Source/WebInspectorUI
Revision
191071
Author
joep...@webkit.org
Date
2015-10-14 14:03:05 -0700 (Wed, 14 Oct 2015)

Log Message

Web Inspector: Console SearchBar should work more like ContentBrowser FindBanner
https://bugs.webkit.org/show_bug.cgi?id=149505

Patch by João Oliveira <he...@jxs.pt> on 2015-10-13
Reviewed by Joseph Pecoraro.

Console tab now uses findBanner, adapted LogContentView to use findBanner,
and findBanner to be more agnostic to both usecases, either as fixed, on console tab,
and hideable on other inspector tabs.

* UserInterface/Views/FindBanner.css:
(.find-banner.console-find-banner):
(.find-banner.console-findbanner input[type="search"]):
* UserInterface/Views/FindBanner.js:
(WebInspector.FindBanner):
(WebInspector.FindBanner.set targetElement.delayedWork):
(WebInspector.FindBanner.prototype.set targetElement):
(WebInspector.FindBanner.prototype.get showing):
(WebInspector.FindBanner.prototype.focus):
(WebInspector.FindBanner.prototype._clearAndBlur):
(WebInspector.FindBanner.prototype.show.delayedWork):
(WebInspector.FindBanner.prototype.show):
(WebInspector.FindBanner.prototype.hide):
(WebInspector.FindBanner.prototype.get element): Deleted.
(WebInspector.FindBanner.prototype._inputFieldSearch): Deleted.
* UserInterface/Views/LogContentView.js:
(WebInspector.LogContentView):
(WebInspector.LogContentView.prototype.get navigationItems):
(WebInspector.LogContentView.prototype.handleFindEvent):
(WebInspector.LogContentView.prototype.findBannerRevealPreviousResult):
(WebInspector.LogContentView.prototype.findBannerRevealNextResult):
(WebInspector.LogContentView.prototype._filterMessageElements):
(WebInspector.LogContentView.prototype.findBannerPerformSearch):
(WebInspector.LogContentView.prototype.findBannerSearchCleared):
(WebInspector.LogContentView.prototype.revealNextSearchResult):
(WebInspector.LogContentView.prototype.revealPreviousSearchResult):
(WebInspector.LogContentView.prototype._performSearch):
(WebInspector.LogContentView.prototype.searchBarDidActivate): Deleted.
(WebInspector.LogContentView.prototype._searchTextDidChange): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (191070 => 191071)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-14 21:03:05 UTC (rev 191071)
@@ -1,3 +1,44 @@
+2015-10-13  João Oliveira  <he...@jxs.pt>
+
+        Web Inspector: Console SearchBar should work more like ContentBrowser FindBanner
+        https://bugs.webkit.org/show_bug.cgi?id=149505
+
+        Reviewed by Joseph Pecoraro.
+
+        Console tab now uses findBanner, adapted LogContentView to use findBanner,
+        and findBanner to be more agnostic to both usecases, either as fixed, on console tab,
+        and hideable on other inspector tabs.
+
+        * UserInterface/Views/FindBanner.css:
+        (.find-banner.console-find-banner):
+        (.find-banner.console-findbanner input[type="search"]):
+        * UserInterface/Views/FindBanner.js:
+        (WebInspector.FindBanner):
+        (WebInspector.FindBanner.set targetElement.delayedWork):
+        (WebInspector.FindBanner.prototype.set targetElement):
+        (WebInspector.FindBanner.prototype.get showing):
+        (WebInspector.FindBanner.prototype.focus):
+        (WebInspector.FindBanner.prototype._clearAndBlur):
+        (WebInspector.FindBanner.prototype.show.delayedWork):
+        (WebInspector.FindBanner.prototype.show):
+        (WebInspector.FindBanner.prototype.hide):
+        (WebInspector.FindBanner.prototype.get element): Deleted.
+        (WebInspector.FindBanner.prototype._inputFieldSearch): Deleted.
+        * UserInterface/Views/LogContentView.js:
+        (WebInspector.LogContentView):
+        (WebInspector.LogContentView.prototype.get navigationItems):
+        (WebInspector.LogContentView.prototype.handleFindEvent):
+        (WebInspector.LogContentView.prototype.findBannerRevealPreviousResult):
+        (WebInspector.LogContentView.prototype.findBannerRevealNextResult):
+        (WebInspector.LogContentView.prototype._filterMessageElements):
+        (WebInspector.LogContentView.prototype.findBannerPerformSearch):
+        (WebInspector.LogContentView.prototype.findBannerSearchCleared):
+        (WebInspector.LogContentView.prototype.revealNextSearchResult):
+        (WebInspector.LogContentView.prototype.revealPreviousSearchResult):
+        (WebInspector.LogContentView.prototype._performSearch):
+        (WebInspector.LogContentView.prototype.searchBarDidActivate): Deleted.
+        (WebInspector.LogContentView.prototype._searchTextDidChange): Deleted.
+
 2015-10-13  Nikita Vasilyev  <nvasil...@apple.com>
 
         REGRESSION(r189567): Web Inspector: Clipped filter icons when debugger sidebar is narrow

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.css	2015-10-14 21:03:05 UTC (rev 191071)
@@ -188,3 +188,33 @@
     margin: 0 6px;
     line-height: 21px;
 }
+
+.find-banner.console-find-banner {
+    position: relative;
+    top: auto;
+    border: 0;
+}
+
+.find-banner.console-find-banner > input[type="search"] {
+    padding-top: 0;
+    margin: 1px 6px;
+    outline: none;
+    -webkit-appearance: none;
+    border: 1px solid hsla(0, 0%, 0%, 0.35);
+    border-radius: 3px;
+    background-color: hsla(0, 0%, 100%, 0.2);
+    background-clip: padding-box;
+    height: 22px;    
+}
+
+.find-banner.console-find-banner > input[type="search"]::-webkit-input-placeholder {
+    color: hsla(0, 0%, 0%, 0.35);
+}
+
+.find-banner.console-find-banner > input[type="search"]::-webkit-textfield-decoration-container {
+    margin-left: 4px;
+}
+
+.find-banner.console-find-banner > input[type="search"]:focus {
+    background-color: white;
+}

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FindBanner.js	2015-10-14 21:03:05 UTC (rev 191071)
@@ -23,26 +23,28 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.FindBanner = class FindBanner extends WebInspector.Object
+WebInspector.FindBanner = class FindBanner extends WebInspector.NavigationItem
 {
-    constructor(delegate, element)
+    constructor(delegate, className, fixed = false)
     {
         super();
 
         this._delegate = delegate || null;
 
-        this._element = element || document.createElement("div");
-        this._element.classList.add("find-banner");
+        this.element.classList.add("find-banner");
 
+        if (className)
+            this.element.classList.add(className);
+
         this._resultCountLabel = document.createElement("label");
-        this._element.appendChild(this._resultCountLabel);
+        this.element.appendChild(this._resultCountLabel);
 
         this._previousResultButton = document.createElement("button");
         this._previousResultButton.classList.add(WebInspector.FindBanner.SegmentedButtonStyleClassName);
         this._previousResultButton.classList.add(WebInspector.FindBanner.LeftSegmentButtonStyleClassName);
         this._previousResultButton.disabled = true;
         this._previousResultButton.addEventListener("click", this._previousResultButtonClicked.bind(this));
-        this._element.appendChild(this._previousResultButton);
+        this.element.appendChild(this._previousResultButton);
 
         var previousResultButtonGlyphElement = document.createElement("div");
         previousResultButtonGlyphElement.classList.add(WebInspector.FindBanner.SegmentGlyphStyleClassName);
@@ -53,7 +55,7 @@
         this._nextResultButton.classList.add(WebInspector.FindBanner.RightSegmentButtonStyleClassName);
         this._nextResultButton.disabled = true;
         this._nextResultButton.addEventListener("click", this._nextResultButtonClicked.bind(this));
-        this._element.appendChild(this._nextResultButton);
+        this.element.appendChild(this._nextResultButton);
 
         var nextResultButtonGlyphElement = document.createElement("div");
         nextResultButtonGlyphElement.classList.add(WebInspector.FindBanner.SegmentGlyphStyleClassName);
@@ -68,19 +70,23 @@
         this._inputField.addEventListener("keydown", this._inputFieldKeyDown.bind(this), false);
         this._inputField.addEventListener("keyup", this._inputFieldKeyUp.bind(this), false);
         this._inputField.addEventListener("search", this._inputFieldSearch.bind(this), false);
-        this._element.appendChild(this._inputField);
+        this.element.appendChild(this._inputField);
 
-        this._doneButton = document.createElement("button");
-        this._doneButton.textContent = WebInspector.UIString("Done");
-        this._doneButton.addEventListener("click", this._doneButtonClicked.bind(this));
-        this._element.appendChild(this._doneButton);
+        if (fixed)
+            this._clearAndBlurKeyboardShortcut = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape, this._clearAndBlur.bind(this), this.element);
+        else {
+            let doneButtonElement = document.createElement("button");
+            doneButtonElement.textContent = WebInspector.UIString("Done");
+            doneButtonElement.addEventListener("click", this._doneButtonClicked.bind(this));
+            this.element.appendChild(doneButtonElement);
+            this._hideKeyboardShortcut = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape, this.hide.bind(this), this.element);
+        }
 
         this._numberOfResults = null;
         this._searchBackwards = false;
         this._searchKeyPressed = false;
         this._previousSearchValue = "";
 
-        this._hideKeyboardShortcut = new WebInspector.KeyboardShortcut(null, WebInspector.KeyboardShortcut.Key.Escape, this.hide.bind(this), this._element);
         this._populateFindKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "E", this._populateSearchQueryFromSelection.bind(this));
         this._populateFindKeyboardShortcut.implicitlyPreventsDefault = false;
         this._findNextKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "G", this._nextResultButtonClicked.bind(this));
@@ -103,11 +109,6 @@
         this._delegate = newDelegate || null;
     }
 
-    get element()
-    {
-        return this._element;
-    }
-
     get inputField()
     {
         return this._inputField;
@@ -157,7 +158,7 @@
         function delayedWork()
         {
             oldTargetElement.classList.remove(WebInspector.FindBanner.NoTransitionStyleClassName);
-            this._element.classList.remove(WebInspector.FindBanner.NoTransitionStyleClassName);
+            this.element.classList.remove(WebInspector.FindBanner.NoTransitionStyleClassName);
         }
 
         if (this._targetElement) {
@@ -167,8 +168,8 @@
             this._targetElement.classList.remove(WebInspector.FindBanner.SupportsFindBannerStyleClassName);
             this._targetElement.classList.remove(WebInspector.FindBanner.ShowingFindBannerStyleClassName);
 
-            this._element.classList.add(WebInspector.FindBanner.NoTransitionStyleClassName);
-            this._element.classList.remove(WebInspector.FindBanner.ShowingStyleClassName);
+            this.element.classList.add(WebInspector.FindBanner.NoTransitionStyleClassName);
+            this.element.classList.remove(WebInspector.FindBanner.ShowingStyleClassName);
 
             // Delay so we can remove the no transition style class after the other style changes are committed.
             setTimeout(delayedWork.bind(this), 0);
@@ -182,9 +183,31 @@
 
     get showing()
     {
-        return this._element.classList.contains(WebInspector.FindBanner.ShowingStyleClassName);
+        return this.element.classList.contains(WebInspector.FindBanner.ShowingStyleClassName);
     }
 
+    focus()
+    {
+        // FIXME: Workaround for: <https://webkit.org/b/149504> Caret missing from <input> after clearing text and calling select()
+        if (!this._inputField.value.length)
+            this._inputField.focus();
+        else
+            this._inputField.select();
+    }
+
+    _clearAndBlur()
+    {
+        this.numberOfResults = null;
+
+        this._inputField.value = "";
+        this._previousSearchValue = "";
+
+        if (this._delegate.findBannerSearchCleared)
+            this._delegate.findBannerSearchCleared();
+        if (this._delegate.findBannerWantsToClearAndBlur)
+            this._delegate.findBannerWantsToClearAndBlur();
+    }
+
     show()
     {
         console.assert(this._targetElement);
@@ -195,13 +218,13 @@
         if (!this._targetElement.parentNode)
             return;
 
-        if (this._element.parentNode !== this._targetElement.parentNode)
-            this._targetElement.parentNode.insertBefore(this._element, this._targetElement);
+        if (this.element.parentNode !== this._targetElement.parentNode)
+            this._targetElement.parentNode.insertBefore(this.element, this._targetElement);
 
         function delayedWork()
         {
             this._targetElement.classList.add(WebInspector.FindBanner.ShowingFindBannerStyleClassName);
-            this._element.classList.add(WebInspector.FindBanner.ShowingStyleClassName);
+            this.element.classList.add(WebInspector.FindBanner.ShowingStyleClassName);
 
             this._inputField.select();
         }
@@ -222,7 +245,7 @@
         this._inputField.blur();
 
         this._targetElement.classList.remove(WebInspector.FindBanner.ShowingFindBannerStyleClassName);
-        this._element.classList.remove(WebInspector.FindBanner.ShowingStyleClassName);
+        this.element.classList.remove(WebInspector.FindBanner.ShowingStyleClassName);
 
         this.dispatchEventToListeners(WebInspector.FindBanner.Event.DidHide);
     }
@@ -276,7 +299,6 @@
             }
         } else {
             this.numberOfResults = null;
-
             if (this._delegate && typeof this._delegate.findBannerSearchCleared === "function")
                 this._delegate.findBannerSearchCleared(this);
         }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.css	2015-10-14 21:03:05 UTC (rev 191071)
@@ -185,12 +185,6 @@
     display: none;
 }
 
-.search-bar.log-search-bar > input[type="search"] {
-    width: 150px;
-    border: 1px solid hsla(0, 0%, 0%, 0.35);
-    padding-left: 4px;
-}
-
 .search-in-progress .console-item.filtered-out-by-search {
     display: none;
 }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2015-10-14 21:03:05 UTC (rev 191071)
@@ -57,8 +57,8 @@
         this._logViewController = new WebInspector._javascript_LogViewController(this.messagesElement, this.element, this.prompt, this, "console-prompt-history");
         this._lastMessageView = null;
 
-        this._searchBar = new WebInspector.SearchBar("log-search-bar", WebInspector.UIString("Filter Console Log"), this);
-        this._searchBar.addEventListener(WebInspector.SearchBar.Event.TextChanged, this._searchTextDidChange, this);
+        this._findBanner = new WebInspector.FindBanner(this, "console-find-banner", true);
+        this._findBanner.inputField.placeholder = WebInspector.UIString("Filter Console Log");
 
         var scopeBarItems = [
             new WebInspector.ScopeBarItem(WebInspector.LogContentView.Scopes.All, WebInspector.UIString("All"), true),
@@ -91,7 +91,7 @@
 
     get navigationItems()
     {
-        var navigationItems = [this._searchBar, this._scopeBar, this._clearLogNavigationItem];
+        let navigationItems = [this._findBanner, this._scopeBar, this._clearLogNavigationItem];
         if (WebInspector.isShowingSplitConsole())
             navigationItems.push(this._showConsoleTabNavigationItem);
         return navigationItems;
@@ -188,7 +188,7 @@
         if (!this.visible)
             return;
 
-        this._searchBar.focus();
+        this._findBanner.focus();
     }
 
     get supportsSave()
@@ -217,6 +217,11 @@
         event.preventDefault();
     }
 
+    findBannerRevealPreviousResult()
+    {
+        this.highlightPreviousSearchMatch();
+    }
+
     highlightPreviousSearchMatch()
     {
         if (!this.searchInProgress || isEmptyObject(this._searchMatches))
@@ -226,6 +231,11 @@
         this._highlightSearchMatchAtIndex(index - 1);
     }
 
+    findBannerRevealNextResult()
+    {
+        this.highlightNextSearchMatch();
+    }
+
     highlightNextSearchMatch()
     {
         if (!this.searchInProgress || isEmptyObject(this._searchMatches))
@@ -235,7 +245,7 @@
         this._highlightSearchMatchAtIndex(index);
     }
 
-    searchBarWantsToLoseFocus(searchBar)
+    findBannerWantsToClearAndBlur(findBanner)
     {
         if (this._selectedMessages.length)
             this.messagesElement.focus();
@@ -243,13 +253,6 @@
             this.prompt.focus();
     }
 
-    searchBarDidActivate(searchBar)
-    {
-        if (!isEmptyObject(this._searchMatches))
-            this._highlightSearchMatchAtIndex(0);
-        this.prompt.focus();
-    }
-
     // Private
 
     _formatMessagesAsData(onlySelected)
@@ -694,7 +697,7 @@
             }
         }, this);
 
-        this._performSearch();
+        this._performSearch("");
     }
 
     _keyDown(event)
@@ -849,18 +852,31 @@
             focusableElements[i].removeAttribute("tabindex");
     }
 
-    _searchTextDidChange(event)
+    findBannerPerformSearch(findBanner, searchTerms)
     {
-        this._performSearch();
+        this._performSearch(searchTerms);
     }
 
-    _performSearch()
+    findBannerSearchCleared()
     {
+        this._performSearch("");
+    }
+
+    revealNextSearchResult()
+    {
+        this.findBannerRevealNextResult();
+    }
+
+    revealPreviousSearchResult()
+    {
+        this.findBannerRevealPreviousResult();
+    }
+
+    _performSearch(searchTerms)
+    {
         if (!isEmptyObject(this._searchHighlightDOMChanges))
             WebInspector.revertDomChanges(this._searchHighlightDOMChanges);
 
-        var searchTerms = this._searchBar.text;
-
         if (searchTerms === "") {
             delete this._selectedSearchMatch;
             this._matchingSearchElements = [];
@@ -873,6 +889,7 @@
         this._searchHighlightDOMChanges = [];
         this._searchMatches = [];
         this._selectedSearchMathIsValid = false;
+        let numberOfResults = 0;
 
         var searchRegex = new RegExp(searchTerms.escapeForRegExp(), "gi");
         this._unfilteredMessageElements().forEach(function(message) {
@@ -880,6 +897,7 @@
             var text = message.textContent;
             var match = searchRegex.exec(text);
             while (match) {
+                numberOfResults++;
                 matchRanges.push({ offset: match.index, length: match[0].length });
                 match = searchRegex.exec(text);
             }
@@ -898,6 +916,8 @@
             this._selectedSearchMatch.highlight.classList.remove(WebInspector.LogContentView.SelectedStyleClassName);
             delete this._selectedSearchMatch;
         }
+
+        this._findBanner.numberOfResults = numberOfResults;
     }
 
     _highlightRanges(message, matchRanges)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Main.css (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/Main.css	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Main.css	2015-10-14 21:03:05 UTC (rev 191071)
@@ -187,11 +187,7 @@
     display: none;
 }
 
-#split-content-browser > .navigation-bar > :matches(.hierarchical-path, .log-search-bar, .log-scope-bar) {
-    pointer-events: none;
-}
-
-#split-content-browser > .navigation-bar > :matches(.log-search-bar, .log-scope-bar) > :matches(li, input) {
+#split-content-browser > .navigation-bar > .log-scope-bar > li {
     pointer-events: all;
 }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css (191070 => 191071)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css	2015-10-14 20:52:04 UTC (rev 191070)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css	2015-10-14 21:03:05 UTC (rev 191071)
@@ -43,5 +43,6 @@
     color: hsla(0, 0%, 0%, 0.35);
 }
 
-.search-bar > input[type="search"]:focus { background-color: white; }
-.search-bar > input[type="search"]:not(:placeholder-shown) { background-color: white; } /* Needs to be a separate rule. See http://webkit.org/b/118162 */
+.search-bar > input[type="search"]:focus {
+    background-color: white;
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to