B2G/gecko/browser/devtools/debugger/debugger-view.js
/**
   * Called when all the script's sources have been fetched.
   */
Called when all the script's sources have been fetched.
Called when all the script ' s sources have been fetched .
function DVGS__onFetchScriptsFinished() {
    this.empty();
    let token = DebuggerView.Scripts.searchToken;
    let lowerCaseToken = token.toLowerCase();
    if (!token) {
      DebuggerController.dispatchEvent("Debugger:GlobalSearch:TokenEmpty");
      this.hidden = true;
      return;
    }
    let globalResults = new Map();
    for (let [url, text] of this._scriptSources) {
      if (!text.toLowerCase().contains(lowerCaseToken)) {
        continue;
      }
      let lines = text.split("\n");
      let scriptResults = {
        lineResults: [],
        matchCount: 0
      };
      for (let i = 0, len = lines.length; i < len; i++) {
        let line = lines[i];
        let lowerCaseLine = line.toLowerCase();
        if (!lowerCaseLine.contains(lowerCaseToken)) {
          continue;
        }
        let lineNumber = i;
        let lineContents = [];
        lowerCaseLine.split(lowerCaseToken).reduce(function(prev, curr, index, {length}) {
          let unmatched = line.substr(prev.length, curr.length);
          lineContents.push({ string: unmatched });
          if (index !== length - 1) {
            let matched = line.substr(prev.length + curr.length, token.length);
            let range = {
              start: prev.length + curr.length,
              length: matched.length
            };
            lineContents.push({
              string: matched,
              range: range,
              match: true
            });
            scriptResults.matchCount++;
          }
          return prev + token + curr;
        }, "");
        scriptResults.lineResults.push({
          lineNumber: lineNumber,
          lineContents: lineContents
        });
      }
      if (scriptResults.matchCount) {
        globalResults.set(url, scriptResults);
      }
    }
    if (globalResults.size()) {
      this._createGlobalResultsUI(globalResults);
      this.hidden = false;
      DebuggerController.dispatchEvent("Debugger:GlobalSearch:MatchFound");
    } else {
      this.hidden = true;
      DebuggerController.dispatchEvent("Debugger:GlobalSearch:MatchNotFound");
    }
  }
function DVGS__onFetchScriptsFinished ( ) { this . empty ( ) ; let token = DebuggerView . Scripts . searchToken ; let lowerCaseToken = token . toLowerCase ( ) ; if ( ! token ) { DebuggerController . dispatchEvent ( "Debugger:GlobalSearch:TokenEmpty" ) ; this . hidden = true ; return ; } let globalResults = new Map ( ) ; for ( let [ url , text ] of this . _scriptSources ) { if ( ! text . toLowerCase ( ) . contains ( lowerCaseToken ) ) { continue ; } let lines = text . split ( "\n" ) ; let scriptResults = { lineResults : [ ] , matchCount : 0 } ; for ( let i = 0 , len = lines . length ; i < len ; i ++ ) { let line = lines [ i ] ; let lowerCaseLine = line . toLowerCase ( ) ; if ( ! lowerCaseLine . contains ( lowerCaseToken ) ) { continue ; } let lineNumber = i ; let lineContents = [ ] ; lowerCaseLine . split ( lowerCaseToken ) . reduce ( function ( prev , curr , index , { length } ) { let unmatched = line . substr ( prev . length , curr . length ) ; lineContents . push ( { string : unmatched } ) ; if ( index !== length - 1 ) { let matched = line . substr ( prev . length + curr . length , token . length ) ; let range = { start : prev . length + curr . length , length : matched . length } ; lineContents . push ( { string : matched , range : range , match : true } ) ; scriptResults . matchCount ++ ; } return prev + token + curr ; } , "" ) ; scriptResults . lineResults . push ( { lineNumber : lineNumber , lineContents : lineContents } ) ; } if ( scriptResults . matchCount ) { globalResults . set ( url , scriptResults ) ; } } if ( globalResults . size ( ) ) { this . _createGlobalResultsUI ( globalResults ) ; this . hidden = false ; DebuggerController . dispatchEvent ( "Debugger:GlobalSearch:MatchFound" ) ; } else { this . hidden = true ; DebuggerController . dispatchEvent ( "Debugger:GlobalSearch:MatchNotFound" ) ; } }
Called when all the script's sources have been fetched.
Called when all the script ' s sources have been fetched .
// Make sure we're actually searching for something. // Prepare the results map, containing search details for each script/line. // Check if the search token is not found anywhere in the script source. // Search is not case sensitive, and is tied to each line in the source.