Changeset 98339 in webkit


Ignore:
Timestamp:
Oct 25, 2011 6:49:24 AM (12 years ago)
Author:
vsevik@chromium.org
Message:

Web Inspector: Resources panel: display the current search match index in the toolbar.
https://bugs.webkit.org/show_bug.cgi?id=66050

Reviewed by Pavel Feldman.

Source/WebCore:

Test: http/tests/inspector/search/resources-search-match-index.html

  • inspector/front-end/ResourcesPanel.js:

(WebInspector.ResourcesPanel.prototype.performSearch.callback):
(WebInspector.ResourcesPanel.prototype.performSearch):
(WebInspector.ResourcesPanel.prototype._showSearchResult.callback):
(WebInspector.ResourcesPanel.prototype._showSearchResult):
(WebInspector.BaseStorageTreeElement.prototype.get searchMatchesCount):
(WebInspector.ResourcesSearchController):
(WebInspector.ResourcesSearchController.prototype.nextSearchResult):
(WebInspector.ResourcesSearchController.prototype.previousSearchResult):
(WebInspector.ResourcesSearchController.prototype._searchResult):
(WebInspector.SearchResultsTreeElementsTraverser.prototype.next):
(WebInspector.SearchResultsTreeElementsTraverser.prototype.previous):
(WebInspector.SearchResultsTreeElementsTraverser.prototype.matchIndex):
(WebInspector.SearchResultsTreeElementsTraverser.prototype._elementSearchMatchesCount):
(WebInspector.SearchResultsTreeElementsTraverser.prototype._traverseNext):
(WebInspector.SearchResultsTreeElementsTraverser.prototype._traversePrevious):

  • inspector/front-end/treeoutline.js:

LayoutTests:

  • http/tests/inspector/search/resources-search-match-index-expected.txt: Added.
  • http/tests/inspector/search/resources-search-match-index.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r98338 r98339  
     12011-10-25  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Resources panel: display the current search match index in the toolbar.
     4        https://bugs.webkit.org/show_bug.cgi?id=66050
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * http/tests/inspector/search/resources-search-match-index-expected.txt: Added.
     9        * http/tests/inspector/search/resources-search-match-index.html: Added.
     10
    1112011-10-25  Csaba Osztrogonác  <ossy@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r98333 r98339  
     12011-10-25  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Web Inspector: Resources panel: display the current search match index in the toolbar.
     4        https://bugs.webkit.org/show_bug.cgi?id=66050
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Test: http/tests/inspector/search/resources-search-match-index.html
     9
     10        * inspector/front-end/ResourcesPanel.js:
     11        (WebInspector.ResourcesPanel.prototype.performSearch.callback):
     12        (WebInspector.ResourcesPanel.prototype.performSearch):
     13        (WebInspector.ResourcesPanel.prototype._showSearchResult.callback):
     14        (WebInspector.ResourcesPanel.prototype._showSearchResult):
     15        (WebInspector.BaseStorageTreeElement.prototype.get searchMatchesCount):
     16        (WebInspector.ResourcesSearchController):
     17        (WebInspector.ResourcesSearchController.prototype.nextSearchResult):
     18        (WebInspector.ResourcesSearchController.prototype.previousSearchResult):
     19        (WebInspector.ResourcesSearchController.prototype._searchResult):
     20        (WebInspector.SearchResultsTreeElementsTraverser.prototype.next):
     21        (WebInspector.SearchResultsTreeElementsTraverser.prototype.previous):
     22        (WebInspector.SearchResultsTreeElementsTraverser.prototype.matchIndex):
     23        (WebInspector.SearchResultsTreeElementsTraverser.prototype._elementSearchMatchesCount):
     24        (WebInspector.SearchResultsTreeElementsTraverser.prototype._traverseNext):
     25        (WebInspector.SearchResultsTreeElementsTraverser.prototype._traversePrevious):
     26        * inspector/front-end/treeoutline.js:
     27
    1282011-10-25  Andrey Kosyakov  <caseq@chromium.org>
    229
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r98228 r98339  
    647647
    648648            WebInspector.searchController.updateSearchMatchesCount(totalMatchesCount, this);
    649             this._searchController = new WebInspector.ResourcesSearchController(this.resourcesListTreeElement);
     649            this._searchController = new WebInspector.ResourcesSearchController(this.resourcesListTreeElement, totalMatchesCount);
    650650
    651651            if (this.sidebarTree.selectedTreeElement && this.sidebarTree.selectedTreeElement.searchMatchesCount)
     
    695695            if (this._lastSearchResultIndex != -1)
    696696                this.visibleView.jumpToSearchResult(this._lastSearchResultIndex);
     697            WebInspector.searchController.updateCurrentMatchIndex(searchResult.currentMatchIndex, this);
    697698        }
    698699
     
    895896    },
    896897
     898    get searchMatchesCount()
     899    {
     900        return 0;
     901    },
     902
    897903    isEventWithinDisclosureTriangle: function(event)
    898904    {
     
    15891595/**
    15901596 * @constructor
     1597 * @param {WebInspector.BaseStorageTreeElement} rootElement
     1598 * @param {number} matchesCount
    15911599 */
    1592 WebInspector.ResourcesSearchController = function(rootElement)
     1600WebInspector.ResourcesSearchController = function(rootElement, matchesCount)
    15931601{
    15941602    this._root = rootElement;
     1603    this._matchesCount = matchesCount;
    15951604    this._traverser = new WebInspector.SearchResultsTreeElementsTraverser(rootElement);
    15961605    this._lastTreeElement = null;
     
    15991608
    16001609WebInspector.ResourcesSearchController.prototype = {
     1610    /**
     1611     * @param {WebInspector.BaseStorageTreeElement} currentTreeElement
     1612     */
    16011613    nextSearchResult: function(currentTreeElement)
    16021614    {
    16031615        if (!currentTreeElement)
    1604             return this._searchResult(this._traverser.first(), 0);
     1616            return this._searchResult(this._traverser.first(), 0, 1);
    16051617
    16061618        if (!currentTreeElement.searchMatchesCount)
     
    16111623
    16121624        if (this._lastIndex == currentTreeElement.searchMatchesCount - 1)
    1613             return this._searchResult(this._traverser.next(currentTreeElement), 0);
    1614 
    1615         return this._searchResult(currentTreeElement, this._lastIndex + 1);
    1616     },
    1617 
     1625            return this._searchResult(this._traverser.next(currentTreeElement), 0, this._currentMatchIndex % this._matchesCount + 1);
     1626
     1627        return this._searchResult(currentTreeElement, this._lastIndex + 1, this._currentMatchIndex + 1);
     1628    },
     1629
     1630    /**
     1631     * @param {WebInspector.BaseStorageTreeElement} currentTreeElement
     1632     */
    16181633    previousSearchResult: function(currentTreeElement)
    16191634    {
    16201635        if (!currentTreeElement) {
    16211636            var treeElement = this._traverser.last();
    1622             return this._searchResult(treeElement, treeElement.searchMatchesCount - 1);
    1623         }
    1624 
    1625         if (currentTreeElement.searchMatchesCount && this._lastTreeElement === currentTreeElement && this._lastIndex > 0)
    1626             return this._searchResult(currentTreeElement, this._lastIndex - 1);
     1637            return this._searchResult(treeElement, treeElement.searchMatchesCount - 1, this._matchesCount);
     1638        }
     1639
     1640        if (currentTreeElement.searchMatchesCount && this._lastTreeElement === currentTreeElement) {
     1641            if (this._lastIndex > 0)
     1642                return this._searchResult(currentTreeElement, this._lastIndex - 1, this._currentMatchIndex - 1);
     1643            else {
     1644                var treeElement = this._traverser.previous(currentTreeElement);
     1645                var currentMatchIndex = this._currentMatchIndex - 1 ? this._currentMatchIndex - 1 : this._matchesCount;
     1646                return this._searchResult(treeElement, treeElement.searchMatchesCount - 1, currentMatchIndex);
     1647            }
     1648        }
    16271649
    16281650        var treeElement = this._traverser.previous(currentTreeElement)
     
    16301652    },
    16311653
    1632     _searchResult: function(treeElement, index)
     1654    /**
     1655     * @param {WebInspector.BaseStorageTreeElement} treeElement
     1656     * @param {number} index
     1657     * @param {number=} currentMatchIndex
     1658     * @return {Object}
     1659     */
     1660    _searchResult: function(treeElement, index, currentMatchIndex)
    16331661    {
    16341662        this._lastTreeElement = treeElement;
    16351663        this._lastIndex = index;
    1636         return {treeElement: treeElement, index: index};
     1664        if (!currentMatchIndex)
     1665            currentMatchIndex = this._traverser.matchIndex(treeElement, index);
     1666        this._currentMatchIndex = currentMatchIndex;
     1667        return {treeElement: treeElement, index: index, currentMatchIndex: currentMatchIndex};
    16371668    }
    16381669}
     
    16401671/**
    16411672 * @constructor
     1673 * @param {WebInspector.BaseStorageTreeElement} rootElement
    16421674 */
    16431675WebInspector.SearchResultsTreeElementsTraverser = function(rootElement)
     
    16471679
    16481680WebInspector.SearchResultsTreeElementsTraverser.prototype = {
     1681    /**
     1682     * @return {WebInspector.BaseStorageTreeElement}
     1683     */
    16491684    first: function()
    16501685    {
     
    16521687    },
    16531688
     1689    /**
     1690     * @return {WebInspector.BaseStorageTreeElement}
     1691     */
    16541692    last: function()
    16551693    {
     
    16571695    },
    16581696
     1697    /**
     1698     * @param {WebInspector.BaseStorageTreeElement} startTreeElement
     1699     * @return {WebInspector.BaseStorageTreeElement}
     1700     */
    16591701    next: function(startTreeElement)
    16601702    {
     
    16621704        do {
    16631705            treeElement = this._traverseNext(treeElement) || this._root;
    1664         } while (treeElement != startTreeElement && !this._elementHasSearchResults(treeElement));
     1706        } while (treeElement != startTreeElement && !this._elementSearchMatchesCount(treeElement));
    16651707        return treeElement;
    16661708    },
    16671709
     1710    /**
     1711     * @param {WebInspector.BaseStorageTreeElement} startTreeElement
     1712     * @return {WebInspector.BaseStorageTreeElement}
     1713     */
    16681714    previous: function(startTreeElement)
    16691715    {
     
    16711717        do {
    16721718            treeElement = this._traversePrevious(treeElement) || this._lastTreeElement();
    1673         } while (treeElement != startTreeElement && !this._elementHasSearchResults(treeElement));
     1719        } while (treeElement != startTreeElement && !this._elementSearchMatchesCount(treeElement));
    16741720        return treeElement;
    16751721    },
    16761722
     1723    /**
     1724     * @param {WebInspector.BaseStorageTreeElement} startTreeElement
     1725     * @param {number} index
     1726     * @return {number}
     1727     */
     1728    matchIndex: function(startTreeElement, index)
     1729    {
     1730        var matchIndex = 1;
     1731        var treeElement = this._root;
     1732        while (treeElement != startTreeElement) {
     1733            matchIndex += this._elementSearchMatchesCount(treeElement);
     1734            treeElement = this._traverseNext(treeElement) || this._root;
     1735            if (treeElement === this._root)
     1736                return 0;
     1737        }
     1738        return matchIndex + index;
     1739    },
     1740
     1741    /**
     1742     * @param {WebInspector.BaseStorageTreeElement} treeElement
     1743     * @return {number}
     1744     */
     1745    _elementSearchMatchesCount: function(treeElement)
     1746    {
     1747        return treeElement.searchMatchesCount;
     1748    },
     1749
     1750    /**
     1751     * @param {WebInspector.BaseStorageTreeElement} treeElement
     1752     * @return {WebInspector.BaseStorageTreeElement}
     1753     */
    16771754    _traverseNext: function(treeElement)
    16781755    {
    1679         return treeElement.traverseNextTreeElement(false, this._root, true);
    1680     },
    1681 
    1682     _elementHasSearchResults: function(treeElement)
    1683     {
    1684         return treeElement instanceof WebInspector.FrameResourceTreeElement && treeElement.searchMatchesCount;
    1685     },
    1686 
     1756        return /** @type {WebInspector.BaseStorageTreeElement} */ treeElement.traverseNextTreeElement(false, this._root, true);
     1757    },
     1758
     1759    /**
     1760     * @param {WebInspector.BaseStorageTreeElement} treeElement
     1761     * @return {WebInspector.BaseStorageTreeElement}
     1762     */
    16871763    _traversePrevious: function(treeElement)
    16881764    {
    1689         return treeElement.traversePreviousTreeElement(false, this._root, true);
    1690     },
    1691 
     1765        return /** @type {WebInspector.BaseStorageTreeElement} */ treeElement.traversePreviousTreeElement(false, true);
     1766    },
     1767
     1768    /**
     1769     * @return {WebInspector.BaseStorageTreeElement}
     1770     */
    16921771    _lastTreeElement: function()
    16931772    {
  • trunk/Source/WebCore/inspector/front-end/treeoutline.js

    r96949 r98339  
    888888}
    889889
     890/**
     891 * @param {boolean} skipHidden
     892 * @param {(TreeOutline|TreeElement)=} stayWithin
     893 * @param {boolean=} dontPopulate
     894 * @param {Object=} info
     895 * @return {TreeElement}
     896 */
    890897TreeElement.prototype.traverseNextTreeElement = function(skipHidden, stayWithin, dontPopulate, info)
    891898{
     
    923930}
    924931
     932/**
     933 * @param {boolean} skipHidden
     934 * @param {boolean=} dontPopulate
     935 * @return {TreeElement}
     936 */
    925937TreeElement.prototype.traversePreviousTreeElement = function(skipHidden, dontPopulate)
    926938{
Note: See TracChangeset for help on using the changeset viewer.