Changeset 122465 in webkit


Ignore:
Timestamp:
Jul 12, 2012 8:54:04 AM (12 years ago)
Author:
pfeldman@chromium.org
Message:

Web Inspector: beautify find bar looks, simplify search update routines.
https://bugs.webkit.org/show_bug.cgi?id=91087

Reviewed by Vsevolod Vlasov.

This change updates the looks to the one on the screenshots and simplifies match count update routines.

  • inspector/front-end/SearchController.js:

(WebInspector.SearchController.onMatchesMouseDown):
(WebInspector.SearchController):
(WebInspector.SearchController.prototype.activePanelChanged.performPanelSearch):
(WebInspector.SearchController.prototype.activePanelChanged):
(WebInspector.SearchController.prototype._updateSearchNavigationButtonState):
(WebInspector.SearchController.prototype._updateSearchMatchesCountAndCurrentMatchIndex):
(WebInspector.SearchController.prototype._onKeyDown):
(WebInspector.SearchController.prototype._onInput):
(WebInspector.SearchController.prototype._onNextButtonSearch):
(WebInspector.SearchController.prototype._onPrevButtonSearch):
(WebInspector.SearchController.prototype._performSearch):

  • inspector/front-end/inspector.css:

(#search):
(#search:focus):
(.toolbar-search-navigation-controls):
(.toolbar-search-navigation):
(.toolbar-search-navigation.enabled:hover):
(.toolbar-search-navigation.enabled, .toolbar-search-navigation.enabled:active):
(.toolbar-search):
(.toolbar-search-control):
(.search-results-matches):
(.inspector-footer):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122463 r122465  
     12012-07-12  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Web Inspector: beautify find bar looks, simplify search update routines.
     4        https://bugs.webkit.org/show_bug.cgi?id=91087
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        This change updates the looks to the one on the screenshots and simplifies match count update routines.
     9
     10        * inspector/front-end/SearchController.js:
     11        (WebInspector.SearchController.onMatchesMouseDown):
     12        (WebInspector.SearchController):
     13        (WebInspector.SearchController.prototype.activePanelChanged.performPanelSearch):
     14        (WebInspector.SearchController.prototype.activePanelChanged):
     15        (WebInspector.SearchController.prototype._updateSearchNavigationButtonState):
     16        (WebInspector.SearchController.prototype._updateSearchMatchesCountAndCurrentMatchIndex):
     17        (WebInspector.SearchController.prototype._onKeyDown):
     18        (WebInspector.SearchController.prototype._onInput):
     19        (WebInspector.SearchController.prototype._onNextButtonSearch):
     20        (WebInspector.SearchController.prototype._onPrevButtonSearch):
     21        (WebInspector.SearchController.prototype._performSearch):
     22        * inspector/front-end/inspector.css:
     23        (#search):
     24        (#search:focus):
     25        (.toolbar-search-navigation-controls):
     26        (.toolbar-search-navigation):
     27        (.toolbar-search-navigation.enabled:hover):
     28        (.toolbar-search-navigation.enabled, .toolbar-search-navigation.enabled:active):
     29        (.toolbar-search):
     30        (.toolbar-search-control):
     31        (.search-results-matches):
     32        (.inspector-footer):
     33
    1342012-07-12  Joshua Bell  <jsbell@chromium.org>
    235
  • trunk/Source/WebCore/English.lproj/localizedStrings.js

    r121911 r122465  
    720720localizedStrings["%d Bytes"] = "%d Bytes";
    721721localizedStrings["Time End"] = "Time End";
    722 localizedStrings["Search:"] = "Search:";
     722localizedStrings["Find"] = "Find";
  • trunk/Source/WebCore/inspector/front-end/ConsolePanel.js

    r98194 r122465  
    128128        this._clearCurrentSearchResultHighlight();
    129129        this._currentSearchResultIndex = index;
     130        WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this);
    130131        this._searchResults[index].highlightSearchResults(this._searchRegex);
    131132    },
  • trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js

    r120809 r122465  
    753753        {
    754754            WebInspector.searchController.updateSearchMatchesCount(this._totalSearchMatches, this);
     755            WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this);
    755756            matchesCountUpdateTimeout = null;
    756757        }
     
    834835        }
    835836
     837        WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this);
     838
    836839        if (currentView !== this.visibleView) {
    837840            this.showView(currentView);
     
    866869            showLastResult = true;
    867870        }
     871
     872        WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this);
    868873
    869874        if (currentView !== this.visibleView) {
  • trunk/Source/WebCore/inspector/front-end/SearchController.js

    r121953 r122465  
    3636{
    3737    this._element = document.createElement("div");
    38     this._element.textContent = "Search:";
    39 
    40     this._searchInputElement = this._element.createChild("input");
     38    this._element.className = "toolbar-search";
     39
     40    var labelElement = this._element.createChild("span");
     41    labelElement.textContent = WebInspector.UIString("Find");
     42
     43    this._searchControlElement = this._element.createChild("div", "toolbar-search-control");
     44
     45    this._searchInputElement = this._searchControlElement.createChild("input");
    4146    this._searchInputElement.id = "search";
    42     this._searchInputElement.type = "search";
    43     this._searchInputElement.incremental = true;
    44     this._searchInputElement.results = 0;
    45 
    46     this._searchNavigationNextElement = this._element.createChild("div", "toolbar-search-navigation toolbar-search-navigation-next hidden");
    47     this._searchNavigationNextElement.addEventListener("mousedown", this._onNextButtonSearch.bind(this), false);
     47
     48    this._matchesElement = this._searchControlElement.createChild("label", "search-results-matches");
     49    this._matchesElement.setAttribute("for", "search");
     50
     51    var searchNavigationElement = this._searchControlElement.createChild("div", "toolbar-search-navigation-controls");
     52    this._searchNavigationPrevElement = searchNavigationElement.createChild("div", "toolbar-search-navigation toolbar-search-navigation-prev");
     53    this._searchNavigationPrevElement.addEventListener("click", this._onPrevButtonSearch.bind(this), false);
     54    this._searchNavigationPrevElement.title = WebInspector.UIString("Search Previous");
     55
     56    this._searchNavigationNextElement = searchNavigationElement.createChild("div", "toolbar-search-navigation toolbar-search-navigation-next");
     57    this._searchNavigationNextElement.addEventListener("click", this._onNextButtonSearch.bind(this), false);
    4858    this._searchNavigationNextElement.title = WebInspector.UIString("Search Next");
    4959
    50     this._searchNavigationPrevElement = this._element.createChild("div", "toolbar-search-navigation toolbar-search-navigation-prev hidden");
    51     this._searchNavigationPrevElement.addEventListener("mousedown", this._onPrevButtonSearch.bind(this), false);
    52     this._searchNavigationPrevElement.title = WebInspector.UIString("Search Previous");
    53 
    54     this._matchesElement = this._element.createChild("span", "search-results-matches");
    55 
    56     this._searchInputElement.addEventListener("search", this._onSearch.bind(this), false); // when the search is emptied
    5760    this._searchInputElement.addEventListener("mousedown", this._onSearchFieldManualFocus.bind(this), false); // when the search field is manually selected
    5861    this._searchInputElement.addEventListener("keydown", this._onKeyDown.bind(this), true);
     62    this._searchInputElement.addEventListener("input", this._onInput.bind(this), false);
    5963
    6064    var closeButtonElement = this._element.createChild("span", "drawer-header-close-button");
     
    7276
    7377        if (panel === WebInspector.inspectorView.currentPanel())
    74             this._updateSearchMatchesCountAndCurrentMatchIndex(WebInspector.inspectorView.currentPanel().currentQuery && matches);
     78            this._updateSearchMatchesCountAndCurrentMatchIndex(WebInspector.inspectorView.currentPanel().currentQuery ? matches : 0, -1);
    7579    },
    7680
     
    7983        if (panel === WebInspector.inspectorView.currentPanel())
    8084            this._updateSearchMatchesCountAndCurrentMatchIndex(panel.currentSearchMatches, currentMatchIndex);
    81     },
    82 
    83     updateSearchLabel: function()
    84     {
    85         var panelName = WebInspector.inspectorView.currentPanel() && WebInspector.inspectorView.currentPanel().toolbarItemLabel;
    86         if (!panelName)
    87             return;
    88         var newLabel = WebInspector.UIString("Search %s", panelName);
    89         this._searchInputElement.setAttribute("placeholder", newLabel);
    9085    },
    9186
     
    151146    activePanelChanged: function()
    152147    {
    153         this.updateSearchLabel();
    154 
    155148        if (!this._currentQuery)
    156149            return;
     
    160153            function performPanelSearch()
    161154            {
    162                 this._updateSearchMatchesCountAndCurrentMatchIndex();
     155                this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1);
    163156
    164157                panel.currentQuery = this._currentQuery;
     
    170163        } else {
    171164            // Update to show Not found for panels that can't be searched.
    172             this._updateSearchMatchesCountAndCurrentMatchIndex();
     165            this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1);
    173166        }
    174167    },
     
    177170    {
    178171        if (enabled) {
    179             this._searchNavigationPrevElement.removeStyleClass("hidden");
    180             this._searchNavigationNextElement.removeStyleClass("hidden");
     172            this._searchNavigationPrevElement.addStyleClass("enabled");
     173            this._searchNavigationNextElement.addStyleClass("enabled");
    181174        } else {
    182             this._searchNavigationPrevElement.addStyleClass("hidden");
    183             this._searchNavigationNextElement.addStyleClass("hidden");
     175            this._searchNavigationPrevElement.removeStyleClass("enabled");
     176            this._searchNavigationNextElement.removeStyleClass("enabled");
    184177        }
    185178    },
    186179
    187180    /**
    188      * @param {?number=} matches
    189      * @param {number=} currentMatchIndex
     181     * @param {number} matches
     182     * @param {number} currentMatchIndex
    190183     */
    191184    _updateSearchMatchesCountAndCurrentMatchIndex: function(matches, currentMatchIndex)
    192185    {
    193         if (matches == null) {
    194             this._matchesElement.addStyleClass("hidden");
    195             // Make Search Nav key non-accessible when there is no active search.
    196             this._updateSearchNavigationButtonState(false);
    197             return;
    198         }
    199 
    200         if (matches) {
    201             if (matches === 1) {
    202                 if (currentMatchIndex === 0)
    203                     var matchesString = WebInspector.UIString("1 of 1 match");
    204                 else
    205                     var matchesString = WebInspector.UIString("1 match");
    206             } else {
    207                 if (typeof currentMatchIndex === "number")
    208                     var matchesString = WebInspector.UIString("%d of %d matches", currentMatchIndex + 1, matches);
    209                 else
    210                     var matchesString = WebInspector.UIString("%d matches", matches);
    211                 // Make search nav key accessible when there are more than 1 search results found.   
    212                 this._updateSearchNavigationButtonState(true);
    213             }
    214         } else {
    215             var matchesString = WebInspector.UIString("Not Found");
    216             // Make search nav key non-accessible when there is no match found.
    217             this._updateSearchNavigationButtonState(false);
    218         }
    219 
    220         this._matchesElement.removeStyleClass("hidden");
    221         this._matchesElement.textContent = matchesString;
    222         WebInspector.toolbar.resize();
     186        if (matches === 0 || currentMatchIndex >= 0)
     187            this._matchesElement.textContent = WebInspector.UIString("%d of %d", currentMatchIndex + 1, matches);
     188        this._updateSearchNavigationButtonState(matches > 0);
    223189    },
    224190
     
    247213        }
    248214
    249         if (!isEnterKey(event))
    250             return false;
    251 
    252         // Select all of the text so the user can easily type an entirely new query.
    253         event.target.select();
    254 
    255         // Only call performSearch if the Enter key was pressed. Otherwise the search
    256         // performance is poor because of searching on every key. The search field has
    257         // the incremental attribute set, so we still get incremental searches.
    258         this._onSearch(event);
    259 
    260         // Call preventDefault since this was the Enter key. This prevents a "search" event
    261         // from firing for key down. This stops performSearch from being called twice in a row.
    262         event.preventDefault();
    263     },
    264 
    265     _onSearch: function(event)
    266     {
    267         var forceSearch = event.keyIdentifier === "Enter";
    268         this._performSearch(event.target.value, forceSearch, event.shiftKey, false);
     215        if (isEnterKey(event))
     216            this._performSearch(event.target.value, true, event.shiftKey);
     217    },
     218
     219    _onInput: function(event)
     220    {
     221        this._performSearch(event.target.value, false, false);
    269222    },
    270223
     
    272225    {
    273226        // Simulate next search on search-navigation-button click.
    274         this._performSearch(this._searchInputElement.value, true, false, false);
     227        this._performSearch(this._searchInputElement.value, true, false);
     228        this._searchInputElement.focus();
    275229    },
    276230
     
    278232    {
    279233        // Simulate previous search on search-navigation-button click.
    280         this._performSearch(this._searchInputElement.value, true, true, false);
     234        this._performSearch(this._searchInputElement.value, true, true);
     235        this._searchInputElement.focus();
    281236    },
    282237
     
    284239     * @param {boolean=} forceSearch
    285240     * @param {boolean=} isBackwardSearch
    286      * @param {boolean=} repeatSearch
    287241     */
    288     _performSearch: function(query, forceSearch, isBackwardSearch, repeatSearch)
    289     {
    290         var isShortSearch = (query.length < 3);
    291 
    292         // Clear a leftover short search flag due to a non-conflicting forced search.
    293         if (isShortSearch && this._shortSearchWasForcedByKeyEvent && this._currentQuery !== query)
    294             delete this._shortSearchWasForcedByKeyEvent;
    295 
    296         // Indicate this was a forced search on a short query.
    297         if (isShortSearch && forceSearch)
    298             this._shortSearchWasForcedByKeyEvent = true;
    299 
    300         if (!query || !query.length || (!forceSearch && isShortSearch)) {
    301             // Prevent clobbering a short search forced by the user.
    302             if (this._shortSearchWasForcedByKeyEvent) {
    303                 delete this._shortSearchWasForcedByKeyEvent;
    304                 return;
    305             }
    306 
     242    _performSearch: function(query, forceSearch, isBackwardSearch)
     243    {
     244        if (!query || !query.length) {
    307245            delete this._currentQuery;
    308246
     
    314252                    panel.searchCanceled();
    315253            }
    316 
    317             this._updateSearchMatchesCountAndCurrentMatchIndex();
    318 
     254            this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1);
    319255            return;
    320256        }
    321257
    322258        var currentPanel = WebInspector.inspectorView.currentPanel();
    323         if (!repeatSearch && query === currentPanel.currentQuery && currentPanel.currentQuery === this._currentQuery) {
     259        if (query === currentPanel.currentQuery && currentPanel.currentQuery === this._currentQuery) {
    324260            // When this is the same query and a forced search, jump to the next
    325261            // search result for a good user experience.
     
    333269        }
    334270
     271        if (!forceSearch && query.length < 3 && !this._currentQuery)
     272            return;
     273
    335274        this._currentQuery = query;
    336275
    337         this._updateSearchMatchesCountAndCurrentMatchIndex();
    338 
    339         if (!currentPanel.performSearch)
    340             return;
     276        if (!currentPanel.performSearch) {
     277            this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1);
     278            return;
     279        }
    341280
    342281        currentPanel.currentQuery = query;
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r122114 r122465  
    334334            var selection = this._textEditor.lastSelection();
    335335            for (var i = 0; selection && i < this._searchResults.length; ++i) {
    336                 if (this._searchResults[i].compareTo(selection) > 0) {
     336                if (this._searchResults[i].compareTo(selection) >= 0) {
    337337                    this._currentSearchResultIndex = i - 1;
    338338                    break;
  • trunk/Source/WebCore/inspector/front-end/inspector.css

    r122332 r122465  
    265265
    266266#search {
    267     width: 205px;
    268     margin-left: 4px;
    269     margin-right: 4px;
    270     font-size: 11px;
     267    -webkit-appearance: none;
     268    border: 0;
     269    padding: 0 2px;
     270    margin: 0;
     271    width: 165px;
     272}
     273
     274#search:focus {
     275    outline: none;
     276}
     277
     278.toolbar-search-navigation-controls {
     279    position: absolute;
     280    top: 0;
     281    right: 0;
     282    height: 18px;
     283    background-image: -webkit-linear-gradient(rgb(228, 228, 228), rgb(204, 204, 204) 75%, rgb(206, 206, 206));
    271284}
    272285
    273286.toolbar-search-navigation {
    274     width: 16px;
    275     height: 16px;
     287    display: inline-block;
     288    width: 18px;
     289    height: 18px;
     290    background-repeat: no-repeat;
     291    background-position: 4px 7px;
     292    border-left: 1px solid rgb(170, 170, 170);
     293    opacity: 0.3;
     294}
     295
     296.toolbar-search-navigation.enabled:hover {
     297    border-left: 1px solid rgb(190, 190, 190);
     298    opacity: 0.9;
     299}
     300
     301.toolbar-search-navigation.enabled, .toolbar-search-navigation.enabled:active {
     302    border-left: 1px solid rgb(170, 170, 170);
     303    opacity: 0.7;
     304}
     305
     306#search:focus {
     307    outline: none;
     308}
     309
     310.toolbar-search {
     311    line-height: 19px;
     312}
     313
     314.toolbar-search-control {
     315    display: inline-block;
    276316    position: relative;
    277     top: 4px;
    278     margin: 0px 1px;
    279     background-repeat: no-repeat;
    280     display: inline-block;
    281     background-position: 2px 5px;
    282     border: 1px solid transparent;
    283 }
    284 
    285 .toolbar-search-navigation:hover {
    286     border: 1px solid rgba(120, 120, 120, 0.6);   
     317    background-color: white;
     318    border: 1px solid rgb(202, 202, 202);
     319    margin: 2px;
     320    height: 20px;
     321    border-radius: 2px;
     322    padding-right: 36px;
    287323}
    288324
     
    295331}
    296332
    297 .toolbar-search-navigation-hidden {
    298     background: none;
    299 }
    300 
    301333body.compact #search {
    302334    font-size: 11px;
     
    304336
    305337.search-results-matches {
     338    display: inline-block;
     339    min-width: 70px;
     340    min-height: 10px;
     341    text-align: right;
    306342    font-size: 11px;
    307     text-shadow: rgba(255, 255, 255, 0.5) 0 1px 0;
    308     padding-left: 4px;
     343    padding: 0 4px;
     344    color: rgb(165, 165, 165);
    309345}
    310346
     
    27862822    right: 0;
    27872823    font-size: 11px;
    2788     padding-left: 7px;
    2789     padding-bottom: 7px;
    2790 }
    2791 
    2792 .inspector-footer > div {
    2793     vertical-align: middle;
    2794 }
     2824    padding-left: 5px;
     2825}
Note: See TracChangeset for help on using the changeset viewer.