Changeset 122465 in webkit
- Timestamp:
- Jul 12, 2012 8:54:04 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r122463 r122465 1 2012-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 1 34 2012-07-12 Joshua Bell <jsbell@chromium.org> 2 35 -
trunk/Source/WebCore/English.lproj/localizedStrings.js
r121911 r122465 720 720 localizedStrings["%d Bytes"] = "%d Bytes"; 721 721 localizedStrings["Time End"] = "Time End"; 722 localizedStrings[" Search:"] = "Search:";722 localizedStrings["Find"] = "Find"; -
trunk/Source/WebCore/inspector/front-end/ConsolePanel.js
r98194 r122465 128 128 this._clearCurrentSearchResultHighlight(); 129 129 this._currentSearchResultIndex = index; 130 WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this); 130 131 this._searchResults[index].highlightSearchResults(this._searchRegex); 131 132 }, -
trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js
r120809 r122465 753 753 { 754 754 WebInspector.searchController.updateSearchMatchesCount(this._totalSearchMatches, this); 755 WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this); 755 756 matchesCountUpdateTimeout = null; 756 757 } … … 834 835 } 835 836 837 WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this); 838 836 839 if (currentView !== this.visibleView) { 837 840 this.showView(currentView); … … 866 869 showLastResult = true; 867 870 } 871 872 WebInspector.searchController.updateCurrentMatchIndex(this._currentSearchResultIndex, this); 868 873 869 874 if (currentView !== this.visibleView) { -
trunk/Source/WebCore/inspector/front-end/SearchController.js
r121953 r122465 36 36 { 37 37 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"); 41 46 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); 48 58 this._searchNavigationNextElement.title = WebInspector.UIString("Search Next"); 49 59 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 emptied57 60 this._searchInputElement.addEventListener("mousedown", this._onSearchFieldManualFocus.bind(this), false); // when the search field is manually selected 58 61 this._searchInputElement.addEventListener("keydown", this._onKeyDown.bind(this), true); 62 this._searchInputElement.addEventListener("input", this._onInput.bind(this), false); 59 63 60 64 var closeButtonElement = this._element.createChild("span", "drawer-header-close-button"); … … 72 76 73 77 if (panel === WebInspector.inspectorView.currentPanel()) 74 this._updateSearchMatchesCountAndCurrentMatchIndex(WebInspector.inspectorView.currentPanel().currentQuery && matches);78 this._updateSearchMatchesCountAndCurrentMatchIndex(WebInspector.inspectorView.currentPanel().currentQuery ? matches : 0, -1); 75 79 }, 76 80 … … 79 83 if (panel === WebInspector.inspectorView.currentPanel()) 80 84 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);90 85 }, 91 86 … … 151 146 activePanelChanged: function() 152 147 { 153 this.updateSearchLabel();154 155 148 if (!this._currentQuery) 156 149 return; … … 160 153 function performPanelSearch() 161 154 { 162 this._updateSearchMatchesCountAndCurrentMatchIndex( );155 this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1); 163 156 164 157 panel.currentQuery = this._currentQuery; … … 170 163 } else { 171 164 // Update to show Not found for panels that can't be searched. 172 this._updateSearchMatchesCountAndCurrentMatchIndex( );165 this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1); 173 166 } 174 167 }, … … 177 170 { 178 171 if (enabled) { 179 this._searchNavigationPrevElement. removeStyleClass("hidden");180 this._searchNavigationNextElement. removeStyleClass("hidden");172 this._searchNavigationPrevElement.addStyleClass("enabled"); 173 this._searchNavigationNextElement.addStyleClass("enabled"); 181 174 } else { 182 this._searchNavigationPrevElement. addStyleClass("hidden");183 this._searchNavigationNextElement. addStyleClass("hidden");175 this._searchNavigationPrevElement.removeStyleClass("enabled"); 176 this._searchNavigationNextElement.removeStyleClass("enabled"); 184 177 } 185 178 }, 186 179 187 180 /** 188 * @param { ?number=} matches189 * @param {number =} currentMatchIndex181 * @param {number} matches 182 * @param {number} currentMatchIndex 190 183 */ 191 184 _updateSearchMatchesCountAndCurrentMatchIndex: function(matches, currentMatchIndex) 192 185 { 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); 223 189 }, 224 190 … … 247 213 } 248 214 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); 269 222 }, 270 223 … … 272 225 { 273 226 // 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(); 275 229 }, 276 230 … … 278 232 { 279 233 // 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(); 281 236 }, 282 237 … … 284 239 * @param {boolean=} forceSearch 285 240 * @param {boolean=} isBackwardSearch 286 * @param {boolean=} repeatSearch287 241 */ 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) { 307 245 delete this._currentQuery; 308 246 … … 314 252 panel.searchCanceled(); 315 253 } 316 317 this._updateSearchMatchesCountAndCurrentMatchIndex(); 318 254 this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1); 319 255 return; 320 256 } 321 257 322 258 var currentPanel = WebInspector.inspectorView.currentPanel(); 323 if ( !repeatSearch &&query === currentPanel.currentQuery && currentPanel.currentQuery === this._currentQuery) {259 if (query === currentPanel.currentQuery && currentPanel.currentQuery === this._currentQuery) { 324 260 // When this is the same query and a forced search, jump to the next 325 261 // search result for a good user experience. … … 333 269 } 334 270 271 if (!forceSearch && query.length < 3 && !this._currentQuery) 272 return; 273 335 274 this._currentQuery = query; 336 275 337 this._updateSearchMatchesCountAndCurrentMatchIndex();338 339 if (!currentPanel.performSearch)340 return;276 if (!currentPanel.performSearch) { 277 this._updateSearchMatchesCountAndCurrentMatchIndex(0, -1); 278 return; 279 } 341 280 342 281 currentPanel.currentQuery = query; -
trunk/Source/WebCore/inspector/front-end/SourceFrame.js
r122114 r122465 334 334 var selection = this._textEditor.lastSelection(); 335 335 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) { 337 337 this._currentSearchResultIndex = i - 1; 338 338 break; -
trunk/Source/WebCore/inspector/front-end/inspector.css
r122332 r122465 265 265 266 266 #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)); 271 284 } 272 285 273 286 .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; 276 316 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; 287 323 } 288 324 … … 295 331 } 296 332 297 .toolbar-search-navigation-hidden {298 background: none;299 }300 301 333 body.compact #search { 302 334 font-size: 11px; … … 304 336 305 337 .search-results-matches { 338 display: inline-block; 339 min-width: 70px; 340 min-height: 10px; 341 text-align: right; 306 342 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); 309 345 } 310 346 … … 2786 2822 right: 0; 2787 2823 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.