Changeset 76488 in webkit


Ignore:
Timestamp:
Jan 24, 2011 12:44:20 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-01-21 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: move search functions from SourceView to SourceFrame.
https://bugs.webkit.org/show_bug.cgi?id=52895

This is the last step before eliminating SourceView and ScriptView since
this classes just delegate everything to SourceFrame.

  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype.set visible): (WebInspector.SourceFrame.prototype._clearLineHighlight): (WebInspector.SourceFrame.prototype._createTextViewer): (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches): (WebInspector.SourceFrame.prototype.performSearch): (WebInspector.SourceFrame.prototype.searchCanceled): (WebInspector.SourceFrame.prototype.jumpToFirstSearchResult): (WebInspector.SourceFrame.prototype.jumpToLastSearchResult): (WebInspector.SourceFrame.prototype.jumpToNextSearchResult): (WebInspector.SourceFrame.prototype.jumpToPreviousSearchResult): (WebInspector.SourceFrame.prototype.showingFirstSearchResult): (WebInspector.SourceFrame.prototype.showingLastSearchResult): (WebInspector.SourceFrame.prototype._jumpToSearchResult):
  • inspector/front-end/SourceView.js: (WebInspector.SourceView.prototype.hide): (WebInspector.SourceView.prototype.searchCanceled): (WebInspector.SourceView.prototype.performSearch): (WebInspector.SourceView.prototype.jumpToFirstSearchResult): (WebInspector.SourceView.prototype.jumpToLastSearchResult): (WebInspector.SourceView.prototype.jumpToNextSearchResult): (WebInspector.SourceView.prototype.jumpToPreviousSearchResult): (WebInspector.SourceView.prototype.showingFirstSearchResult): (WebInspector.SourceView.prototype.showingLastSearchResult): (WebInspector.SourceView.prototype.clearMessages):
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76487 r76488  
     12011-01-21  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: move search functions from SourceView to SourceFrame.
     6        https://bugs.webkit.org/show_bug.cgi?id=52895
     7
     8        This is the last step before eliminating SourceView and ScriptView since
     9        this classes just delegate everything to SourceFrame.
     10
     11        * inspector/front-end/SourceFrame.js:
     12        (WebInspector.SourceFrame.prototype.set visible):
     13        (WebInspector.SourceFrame.prototype._clearLineHighlight):
     14        (WebInspector.SourceFrame.prototype._createTextViewer):
     15        (WebInspector.SourceFrame.prototype.performSearch.doFindSearchMatches):
     16        (WebInspector.SourceFrame.prototype.performSearch):
     17        (WebInspector.SourceFrame.prototype.searchCanceled):
     18        (WebInspector.SourceFrame.prototype.jumpToFirstSearchResult):
     19        (WebInspector.SourceFrame.prototype.jumpToLastSearchResult):
     20        (WebInspector.SourceFrame.prototype.jumpToNextSearchResult):
     21        (WebInspector.SourceFrame.prototype.jumpToPreviousSearchResult):
     22        (WebInspector.SourceFrame.prototype.showingFirstSearchResult):
     23        (WebInspector.SourceFrame.prototype.showingLastSearchResult):
     24        (WebInspector.SourceFrame.prototype._jumpToSearchResult):
     25        * inspector/front-end/SourceView.js:
     26        (WebInspector.SourceView.prototype.hide):
     27        (WebInspector.SourceView.prototype.searchCanceled):
     28        (WebInspector.SourceView.prototype.performSearch):
     29        (WebInspector.SourceView.prototype.jumpToFirstSearchResult):
     30        (WebInspector.SourceView.prototype.jumpToLastSearchResult):
     31        (WebInspector.SourceView.prototype.jumpToNextSearchResult):
     32        (WebInspector.SourceView.prototype.jumpToPreviousSearchResult):
     33        (WebInspector.SourceView.prototype.showingFirstSearchResult):
     34        (WebInspector.SourceView.prototype.showingLastSearchResult):
     35        (WebInspector.SourceView.prototype.clearMessages):
     36
    1372011-01-24  Sheriff Bot  <webkit.review.bot@gmail.com>
    238
  • trunk/Source/WebCore/inspector/front-end/SourceFrame.js

    r76341 r76488  
    6565        } else {
    6666            this._hidePopup();
     67            this._clearLineHighlight();
    6768            if (this._textViewer) {
    6869                this._scrollTop = this._textViewer.element.scrollTop;
     
    145146    },
    146147
    147     clearLineHighlight: function()
     148    _clearLineHighlight: function()
    148149    {
    149150        if (this._textViewer)
     
    178179        }
    179180
    180         if (this._pendingMarkRange) {
    181             var range = this._pendingMarkRange;
    182             this.markAndRevealRange(range);
    183             delete this._pendingMarkRange;
    184         }
    185 
    186181        if (this._lineToHighlight) {
    187182            this.highlightLine(this._lineToHighlight);
     
    224219    },
    225220
    226     findSearchMatches: function(query, finishedCallback)
    227     {
    228         function doFindSearchMatches()
     221    performSearch: function(query, callback)
     222    {
     223        // Call searchCanceled since it will reset everything we need before doing a new search.
     224        this.searchCanceled();
     225
     226        function doFindSearchMatches(query)
    229227        {
    230             var ranges = [];
     228            this._currentSearchResultIndex = -1;
     229            this._searchResults = [];
    231230
    232231            // First do case-insensitive search.
    233232            var regexObject = createSearchRegex(query);
    234             this._collectRegexMatches(regexObject, ranges);
     233            this._collectRegexMatches(regexObject, this._searchResults);
    235234
    236235            // Then try regex search if user knows the / / hint.
    237236            try {
    238237                if (/^\/.*\/$/.test(query))
    239                     this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), ranges);
     238                    this._collectRegexMatches(new RegExp(query.substring(1, query.length - 1)), this._searchResults);
    240239            } catch (e) {
    241240                // Silent catch.
    242241            }
    243             finishedCallback(ranges);
     242
     243            callback(this._searchResults.length);
    244244        }
    245245
    246246        if (this._textViewer)
    247             doFindSearchMatches.call(this);
     247            doFindSearchMatches.call(this, query);
    248248        else
    249             this._delayedFindSearchMatches = doFindSearchMatches.bind(this);
    250     },
    251 
    252     cancelFindSearchMatches: function()
     249            this._delayedFindSearchMatches = doFindSearchMatches.bind(this, query);
     250
     251    },
     252
     253    searchCanceled: function()
    253254    {
    254255        delete this._delayedFindSearchMatches;
     256        if (!this._textViewer)
     257            return;
     258
     259        this._currentSearchResultIndex = -1;
     260        this._searchResults = [];
     261        this._textViewer.markAndRevealRange(null);
     262    },
     263
     264    jumpToFirstSearchResult: function()
     265    {
     266        this._jumpToSearchResult(0);
     267    },
     268
     269    jumpToLastSearchResult: function()
     270    {
     271        this._jumpToSearchResult(this._searchResults.length - 1);
     272    },
     273
     274    jumpToNextSearchResult: function()
     275    {
     276        this._jumpToSearchResult(this._currentSearchResultIndex + 1);
     277    },
     278
     279    jumpToPreviousSearchResult: function()
     280    {
     281        this._jumpToSearchResult(this._currentSearchResultIndex - 1);
     282    },
     283
     284    showingFirstSearchResult: function()
     285    {
     286        return this._searchResults.length &&  this._currentSearchResultIndex === 0;
     287    },
     288
     289    showingLastSearchResult: function()
     290    {
     291        return this._searchResults.length && this._currentSearchResultIndex === (this._searchResults.length - 1);
     292    },
     293
     294    _jumpToSearchResult: function(index)
     295    {
     296        if (!this._textViewer || !this._searchResults.length)
     297            return;
     298        this._currentSearchResultIndex = (index + this._searchResults.length) % this._searchResults.length;
     299        this._textViewer.markAndRevealRange(this._searchResults[this._currentSearchResultIndex]);
    255300    },
    256301
     
    270315        }
    271316        return ranges;
    272     },
    273 
    274     markAndRevealRange: function(range)
    275     {
    276         if (this._textViewer)
    277             this._textViewer.markAndRevealRange(range);
    278         else
    279             this._pendingMarkRange = range;
    280     },
    281 
    282     clearMarkedRange: function()
    283     {
    284         if (this._textViewer) {
    285             this._textViewer.markAndRevealRange(null);
    286         } else
    287             delete this._pendingMarkRange;
    288317    },
    289318
  • trunk/Source/WebCore/inspector/front-end/SourceView.js

    r76341 r76488  
    4848    {
    4949        this.sourceFrame.visible = false;
    50         this.sourceFrame.clearLineHighlight();
    5150        WebInspector.View.prototype.hide.call(this);
    52         this._currentSearchResultIndex = -1;
    5351    },
    5452
     
    7876    searchCanceled: function()
    7977    {
    80         this._currentSearchResultIndex = -1;
    81         this._searchResults = [];
    82         this.sourceFrame.clearMarkedRange();
    83         this.sourceFrame.cancelFindSearchMatches();
     78        this.sourceFrame.searchCanceled();
    8479    },
    8580
    8681    performSearch: function(query, finishedCallback)
    8782    {
    88         // Call searchCanceled since it will reset everything we need before doing a new search.
    89         this.searchCanceled();
    90 
    91         function didFindSearchMatches(searchResults)
    92         {
    93             this._searchResults = searchResults;
    94             if (this._searchResults)
    95                 finishedCallback(this, this._searchResults.length);
    96         }
    97         this.sourceFrame.findSearchMatches(query, didFindSearchMatches.bind(this));
     83        this.sourceFrame.performSearch(query, finishedCallback.bind(null, this));
    9884    },
    9985
    10086    jumpToFirstSearchResult: function()
    10187    {
    102         if (!this._searchResults || !this._searchResults.length)
    103             return;
    104         this._currentSearchResultIndex = 0;
    105         this._jumpToSearchResult(this._currentSearchResultIndex);
     88        this.sourceFrame.jumpToFirstSearchResult();
    10689    },
    10790
    10891    jumpToLastSearchResult: function()
    10992    {
    110         if (!this._searchResults || !this._searchResults.length)
    111             return;
    112         this._currentSearchResultIndex = (this._searchResults.length - 1);
    113         this._jumpToSearchResult(this._currentSearchResultIndex);
     93        this.sourceFrame.jumpToLastSearchResult();
    11494    },
    11595
    11696    jumpToNextSearchResult: function()
    11797    {
    118         if (!this._searchResults || !this._searchResults.length)
    119             return;
    120         if (++this._currentSearchResultIndex >= this._searchResults.length)
    121             this._currentSearchResultIndex = 0;
    122         this._jumpToSearchResult(this._currentSearchResultIndex);
     98        this.sourceFrame.jumpToNextSearchResult();
    12399    },
    124100
    125101    jumpToPreviousSearchResult: function()
    126102    {
    127         if (!this._searchResults || !this._searchResults.length)
    128             return;
    129         if (--this._currentSearchResultIndex < 0)
    130             this._currentSearchResultIndex = (this._searchResults.length - 1);
    131         this._jumpToSearchResult(this._currentSearchResultIndex);
     103        this.sourceFrame.jumpToPreviousSearchResult();
    132104    },
    133105
    134106    showingFirstSearchResult: function()
    135107    {
    136         return (this._currentSearchResultIndex === 0);
     108        this.sourceFrame.showingFirstSearchResult();
    137109    },
    138110
    139111    showingLastSearchResult: function()
    140112    {
    141         return (this._searchResults && this._currentSearchResultIndex === (this._searchResults.length - 1));
     113        this.sourceFrame.showingLastSearchResult();
    142114    },
    143115
     
    160132    {
    161133        this.sourceFrame.clearMessages();
    162     },
    163 
    164     _jumpToSearchResult: function(index)
    165     {
    166         var foundRange = this._searchResults[index];
    167         if (!foundRange)
    168             return;
    169 
    170         this.sourceFrame.markAndRevealRange(foundRange);
    171134    }
    172135}
Note: See TracChangeset for help on using the changeset viewer.