Changeset 80102 in webkit
- Timestamp:
- Mar 2, 2011 1:40:17 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80099 r80102 1 2011-02-25 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: factor search logic out of inspector.js 6 https://bugs.webkit.org/show_bug.cgi?id=54965 7 8 * WebCore.gypi: 9 * WebCore.vcproj/WebCore.vcproj: 10 * inspector/front-end/ElementsPanel.js: 11 (WebInspector.ElementsPanel.prototype.searchCanceled): 12 (WebInspector.ElementsPanel.prototype.switchToAndFocus): 13 (WebInspector.ElementsPanel.prototype._updateMatchesCount): 14 * inspector/front-end/Panel.js: 15 (WebInspector.Panel.prototype.searchCanceled): 16 (WebInspector.Panel.prototype.performSearch.updateMatchesCount): 17 * inspector/front-end/ScriptsPanel.js: 18 (WebInspector.ScriptsPanel.prototype.searchCanceled): 19 (WebInspector.ScriptsPanel.prototype.performSearch.finishedCallback): 20 (WebInspector.ScriptsPanel.prototype.performSearch): 21 * inspector/front-end/SearchController.js: Added. 22 (WebInspector.SearchController): 23 (WebInspector.SearchController.prototype.updateSearchMatchesCount): 24 (WebInspector.SearchController.prototype.updateSearchLabel): 25 (WebInspector.SearchController.prototype.cancelSearch): 26 (WebInspector.SearchController.prototype.handleShortcut): 27 (WebInspector.SearchController.prototype.activePanelChanged.performPanelSearch): 28 (WebInspector.SearchController.prototype.activePanelChanged): 29 (WebInspector.SearchController.prototype._updateSearchMatchesCount): 30 (WebInspector.SearchController.prototype._focusSearchField): 31 (WebInspector.SearchController.prototype._onSearchFieldManualFocus): 32 (WebInspector.SearchController.prototype._onKeyDown): 33 (WebInspector.SearchController.prototype._onSearch): 34 (WebInspector.SearchController.prototype._performSearch): 35 * inspector/front-end/WebKit.qrc: 36 * inspector/front-end/inspector.html: 37 * inspector/front-end/inspector.js: 38 (WebInspector.set currentPanel): 39 (WebInspector.set attached): 40 (WebInspector.doLoadedDone): 41 (WebInspector.documentKeyDown): 42 1 43 2011-03-02 Renata Hodovan <reni@webkit.org> 2 44 -
trunk/Source/WebCore/WebCore.gypi
r80096 r80102 4797 4797 'inspector/front-end/ScriptFormatterWorker.js', 4798 4798 'inspector/front-end/ScriptsPanel.js', 4799 'inspector/front-end/SearchController.js', 4799 4800 'inspector/front-end/ShortcutsHelp.js', 4800 4801 'inspector/front-end/ShowMoreDataGridNode.js', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r80041 r80102 66002 66002 </File> 66003 66003 <File 66004 RelativePath="..\inspector\front-end\SearchController.js" 66005 > 66006 </File> 66007 <File 66004 66008 RelativePath="..\inspector\front-end\Section.js" 66005 66009 > -
trunk/Source/WebCore/inspector/front-end/ElementsPanel.js
r80003 r80102 223 223 this._hideSearchHighlights(); 224 224 225 WebInspector. updateSearchMatchesCount(0, this);225 WebInspector.searchController.updateSearchMatchesCount(0, this); 226 226 227 227 delete this._currentSearchResultIndex; … … 265 265 { 266 266 // Reset search restore. 267 WebInspector. cancelSearch();267 WebInspector.searchController.cancelSearch(); 268 268 WebInspector.currentPanel = this; 269 269 this.focusedDOMNode = node; … … 272 272 _updateMatchesCount: function() 273 273 { 274 WebInspector. updateSearchMatchesCount(this._searchResults.length, this);274 WebInspector.searchController.updateSearchMatchesCount(this._searchResults.length, this); 275 275 this._matchesCountUpdateTimeout = null; 276 276 this._updatedMatchCountOnce = true; -
trunk/Source/WebCore/inspector/front-end/Panel.js
r79306 r80102 111 111 } 112 112 113 WebInspector. updateSearchMatchesCount(0, this);113 WebInspector.searchController.updateSearchMatchesCount(0, this); 114 114 115 115 if (this._currentSearchChunkIntervalIdentifier) { … … 140 140 function updateMatchesCount() 141 141 { 142 WebInspector. updateSearchMatchesCount(this._totalSearchMatches, this);142 WebInspector.searchController.updateSearchMatchesCount(this._totalSearchMatches, this); 143 143 matchesCountUpdateTimeout = null; 144 144 } -
trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js
r79873 r80102 985 985 searchCanceled: function() 986 986 { 987 WebInspector.updateSearchMatchesCount(0, this);988 989 987 if (this._searchView) 990 988 this._searchView.searchCanceled(); … … 996 994 performSearch: function(query) 997 995 { 996 WebInspector.searchController.updateSearchMatchesCount(0, this); 997 998 998 if (!this.visibleView) 999 999 return; … … 1010 1010 return; 1011 1011 1012 WebInspector. updateSearchMatchesCount(searchMatches, this);1012 WebInspector.searchController.updateSearchMatchesCount(searchMatches, this); 1013 1013 view.jumpToFirstSearchResult(); 1014 1014 } -
trunk/Source/WebCore/inspector/front-end/WebKit.qrc
r79311 r80102 88 88 <file>ScriptFormatterWorker.js</file> 89 89 <file>ScriptsPanel.js</file> 90 <file>SearchController.js</file> 90 91 <file>Section.js</file> 91 92 <file>Settings.js</file> -
trunk/Source/WebCore/inspector/front-end/inspector.html
r79311 r80102 158 158 <script type="text/javascript" src="CookieParser.js"></script> 159 159 <script type="text/javascript" src="Toolbar.js"></script> 160 <script type="text/javascript" src="SearchController.js"></script> 160 161 </head> 161 162 <body class="detached"> -
trunk/Source/WebCore/inspector/front-end/inspector.js
r79853 r80102 154 154 this._currentPanel = x; 155 155 156 this.updateSearchLabel();157 158 156 if (x) { 159 157 x.show(); 160 161 if (this.currentQuery) { 162 if (x.performSearch) { 163 function performPanelSearch() 164 { 165 this.updateSearchMatchesCount(); 166 167 x.currentQuery = this.currentQuery; 168 x.performSearch(this.currentQuery); 169 } 170 171 // Perform the search on a timeout so the panel switches fast. 172 setTimeout(performPanelSearch.bind(this), 0); 173 } else { 174 // Update to show Not found for panels that can't be searched. 175 this.updateSearchMatchesCount(); 176 } 177 } 178 } 179 158 WebInspector.searchController.activePanelChanged(); 159 } 180 160 for (var panelName in WebInspector.panels) { 181 161 if (WebInspector.panels[panelName] === x) { … … 249 229 this._attached = x; 250 230 251 this.updateSearchLabel();252 253 231 var dockToggleButton = document.getElementById("dock-status-bar-item"); 254 232 var body = document.body; … … 263 241 dockToggleButton.title = WebInspector.UIString("Dock to main window."); 264 242 } 265 if (this.drawer) 266 this.drawer.resize(); 267 if (this.toolbar) 268 this.toolbar.resize(); 243 244 // This may be called before onLoadedDone, hence the bulk of inspector objects may 245 // not be created yet. 246 if (WebInspector.searchController) 247 WebInspector.searchController.updateSearchLabel(); 269 248 }, 270 249 … … 495 474 496 475 this.breakpointManager = new WebInspector.BreakpointManager(); 476 this.searchController = new WebInspector.SearchController(); 497 477 498 478 this.panels = {}; … … 534 514 errorWarningCount.addEventListener("click", this.showConsole.bind(this), false); 535 515 this._updateErrorAndWarningCounts(); 536 537 var searchField = document.getElementById("search");538 searchField.addEventListener("search", this.performSearch.bind(this), false); // when the search is emptied539 searchField.addEventListener("mousedown", this._searchFieldManualFocus.bind(this), false); // when the search field is manually selected540 searchField.addEventListener("keydown", this._searchKeyDown.bind(this), true);541 516 542 517 this.extensionServer.initExtensions(); … … 769 744 } 770 745 746 WebInspector.searchController.handleShortcut(event); 747 if (event.handled) { 748 event.preventDefault(); 749 return; 750 } 751 771 752 var isMac = WebInspector.isMac(); 772 753 switch (event.keyIdentifier) { … … 793 774 794 775 this.drawer.visible = !this.drawer.visible; 795 break;796 797 case "U+0046": // F key798 if (isMac)799 var isFindKey = event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;800 else801 var isFindKey = event.ctrlKey && !event.metaKey && !event.altKey && !event.shiftKey;802 803 if (isFindKey) {804 WebInspector.focusSearchField();805 event.preventDefault();806 }807 break;808 809 case "F3":810 if (!isMac) {811 WebInspector.focusSearchField();812 event.preventDefault();813 }814 break;815 816 case "U+0047": // G key817 if (isMac && event.metaKey && !event.ctrlKey && !event.altKey) {818 if (event.shiftKey) {819 if (this.currentPanel.jumpToPreviousSearchResult)820 this.currentPanel.jumpToPreviousSearchResult();821 } else if (this.currentPanel.jumpToNextSearchResult)822 this.currentPanel.jumpToNextSearchResult();823 event.preventDefault();824 }825 776 break; 826 777 … … 989 940 forceComplete: forceComplete 990 941 }; 991 }992 993 WebInspector.updateSearchLabel = function()994 {995 if (!this.currentPanel)996 return;997 998 var newLabel = WebInspector.UIString("Search %s", this.currentPanel.toolbarItemLabel);999 if (this.attached)1000 document.getElementById("search").setAttribute("placeholder", newLabel);1001 else {1002 document.getElementById("search").removeAttribute("placeholder");1003 document.getElementById("search-toolbar-label").textContent = newLabel;1004 }1005 }1006 1007 WebInspector.focusSearchField = function()1008 {1009 var searchField = document.getElementById("search");1010 searchField.focus();1011 searchField.select();1012 942 } 1013 943 … … 1469 1399 } 1470 1400 1471 WebInspector._searchFieldManualFocus = function(event)1472 {1473 this.currentFocusElement = event.target;1474 this._previousFocusElement = event.target;1475 }1476 1477 WebInspector._searchKeyDown = function(event)1478 {1479 // Escape Key will clear the field and clear the search results1480 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.code) {1481 // If focus belongs here and text is empty - nothing to do, return unhandled.1482 if (event.target.value === "" && this.currentFocusElement === this.previousFocusElement)1483 return;1484 event.preventDefault();1485 event.stopPropagation();1486 // When search was selected manually and is currently blank, we'd like Esc stay unhandled1487 // and hit console drawer handler.1488 event.target.value = "";1489 1490 this.performSearch(event);1491 this.currentFocusElement = this.previousFocusElement;1492 if (this.currentFocusElement === event.target)1493 this.currentFocusElement.select();1494 return false;1495 }1496 1497 if (!isEnterKey(event))1498 return false;1499 1500 // Select all of the text so the user can easily type an entirely new query.1501 event.target.select();1502 1503 // Only call performSearch if the Enter key was pressed. Otherwise the search1504 // performance is poor because of searching on every key. The search field has1505 // the incremental attribute set, so we still get incremental searches.1506 this.performSearch(event);1507 1508 // Call preventDefault since this was the Enter key. This prevents a "search" event1509 // from firing for key down. This stops performSearch from being called twice in a row.1510 event.preventDefault();1511 }1512 1513 WebInspector.performSearch = function(event)1514 {1515 var forceSearch = event.keyIdentifier === "Enter";1516 this.doPerformSearch(event.target.value, forceSearch, event.shiftKey, false);1517 }1518 1519 WebInspector.cancelSearch = function()1520 {1521 document.getElementById("search").value = "";1522 this.doPerformSearch("");1523 }1524 1525 WebInspector.doPerformSearch = function(query, forceSearch, isBackwardSearch, repeatSearch)1526 {1527 var isShortSearch = (query.length < 3);1528 1529 // Clear a leftover short search flag due to a non-conflicting forced search.1530 if (isShortSearch && this.shortSearchWasForcedByKeyEvent && this.currentQuery !== query)1531 delete this.shortSearchWasForcedByKeyEvent;1532 1533 // Indicate this was a forced search on a short query.1534 if (isShortSearch && forceSearch)1535 this.shortSearchWasForcedByKeyEvent = true;1536 1537 if (!query || !query.length || (!forceSearch && isShortSearch)) {1538 // Prevent clobbering a short search forced by the user.1539 if (this.shortSearchWasForcedByKeyEvent) {1540 delete this.shortSearchWasForcedByKeyEvent;1541 return;1542 }1543 1544 delete this.currentQuery;1545 1546 for (var panelName in this.panels) {1547 var panel = this.panels[panelName];1548 var hadCurrentQuery = !!panel.currentQuery;1549 delete panel.currentQuery;1550 if (hadCurrentQuery && panel.searchCanceled)1551 panel.searchCanceled();1552 }1553 1554 this.updateSearchMatchesCount();1555 1556 return;1557 }1558 1559 if (!repeatSearch && query === this.currentPanel.currentQuery && this.currentPanel.currentQuery === this.currentQuery) {1560 // When this is the same query and a forced search, jump to the next1561 // search result for a good user experience.1562 if (forceSearch) {1563 if (!isBackwardSearch && this.currentPanel.jumpToNextSearchResult)1564 this.currentPanel.jumpToNextSearchResult();1565 else if (isBackwardSearch && this.currentPanel.jumpToPreviousSearchResult)1566 this.currentPanel.jumpToPreviousSearchResult();1567 }1568 return;1569 }1570 1571 this.currentQuery = query;1572 1573 this.updateSearchMatchesCount();1574 1575 if (!this.currentPanel.performSearch)1576 return;1577 1578 this.currentPanel.currentQuery = query;1579 this.currentPanel.performSearch(query);1580 }1581 1582 1401 WebInspector.frontendReused = function() 1583 1402 { … … 1589 1408 { 1590 1409 WebInspector.panels.elements.addNodesToSearchResult(nodeIds); 1591 }1592 1593 WebInspector.updateSearchMatchesCount = function(matches, panel)1594 {1595 if (!panel)1596 panel = this.currentPanel;1597 1598 panel.currentSearchMatches = matches;1599 1600 if (panel !== this.currentPanel)1601 return;1602 1603 if (!this.currentPanel.currentQuery) {1604 document.getElementById("search-results-matches").addStyleClass("hidden");1605 return;1606 }1607 1608 if (matches) {1609 if (matches === 1)1610 var matchesString = WebInspector.UIString("1 match");1611 else1612 var matchesString = WebInspector.UIString("%d matches", matches);1613 } else1614 var matchesString = WebInspector.UIString("Not Found");1615 1616 var matchesToolbarElement = document.getElementById("search-results-matches");1617 matchesToolbarElement.removeStyleClass("hidden");1618 matchesToolbarElement.textContent = matchesString;1619 1410 } 1620 1411
Note: See TracChangeset
for help on using the changeset viewer.