B2G/gecko/browser/devtools/debugger/debugger-view.js
/**
   * Creates per-line search results elements and adds them to the results container.
   *
   * @param object aLineResults
   *        An object containing the search results for each line in a script.
   * @return object
   *         The newly created html node representing the added search results.
   */
Creates per-line search results elements and adds them to the results container.
@param object aLineResults
An object containing the search results for each line in a script.
@return object
The newly created html node representing the added search results.
Creates per - line search results elements and adds them to the results container . @param object aLineResults An object containing the search results for each line in a script . @return object The newly created html node representing the added search results .
function DVGS__createLineSearchresultsUI(aLineResults) {
    let scriptResultsId = "search-results-" + aLineResults.scriptUrl;
    let scriptResults = document.getElementById(scriptResultsId);
    if (!scriptResults) {
      let trimFunc = DebuggerController.SourceScripts.trimUrlLength;
      let urlLabel = trimFunc(aLineResults.scriptUrl, GLOBAL_SEARCH_URL_MAX_SIZE);
      let resultsUrl = document.createElement("label");
      resultsUrl.className = "plain script-url";
      resultsUrl.setAttribute("value", urlLabel);
      let resultsCount = document.createElement("label");
      resultsCount.className = "plain match-count";
      resultsCount.setAttribute("value", "(" + aLineResults.matchCount + ")");
      let arrow = document.createElement("box");
      arrow.className = "arrow";
      let resultsHeader = document.createElement("hbox");
      resultsHeader.className = "dbg-results-header";
      resultsHeader.setAttribute("align", "center")
      resultsHeader.appendChild(arrow);
      resultsHeader.appendChild(resultsUrl);
      resultsHeader.appendChild(resultsCount);
      let resultsContainer = document.createElement("vbox");
      resultsContainer.className = "dbg-results-container";
      scriptResults = document.createElement("vbox");
      scriptResults.id = scriptResultsId;
      scriptResults.className = "dbg-script-results";
      scriptResults.header = resultsHeader;
      scriptResults.container = resultsContainer;
      scriptResults.appendChild(resultsHeader);
      scriptResults.appendChild(resultsContainer);
      this._pane.appendChild(scriptResults);
      scriptResults.expand = function DVGS_element_expand(aSkipAnimationFlag) {
        resultsContainer.setAttribute("open", "");
        arrow.setAttribute("open", "");
        if (!aSkipAnimationFlag) {
          resultsContainer.setAttribute("animated", "");
        }
        return scriptResults;
      };
      scriptResults.collapse = function DVGS_element_collapse() {
        resultsContainer.removeAttribute("animated");
        resultsContainer.removeAttribute("open");
        arrow.removeAttribute("open");
        return scriptResults;
      };
      scriptResults.toggle = function DVGS_element_toggle(e) {
        if (e instanceof Event) {
          scriptResults._userToggle = true;
        }
        scriptResults.expanded = !scriptResults.expanded;
        return scriptResults;
      };
      Object.defineProperty(scriptResults, "expanded", {
        get: function DVP_element_getExpanded() {
          return arrow.hasAttribute("open");
        },
        set: function DVP_element_setExpanded(value) {
          if (value) {
            scriptResults.expand();
          } else {
            scriptResults.collapse();
          }
        }
      });
      resultsHeader.addEventListener("click", scriptResults.toggle, false);
    }
    let lineNumber = document.createElement("label");
    lineNumber.className = "plain line-number";
    lineNumber.setAttribute("value", aLineResults.lineNumber);
    let lineContents = document.createElement("hbox");
    lineContents.setAttribute("flex", "1");
    lineContents.className = "line-contents";
    lineContents.addEventListener("click", this._onLineClick, false);
    let lineContent;
    let totalLength = 0;
    let ellipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString);
    for (lineContent of aLineResults.lineContents) {
      let string = lineContent.string;
      let match = lineContent.match;
      string = string.substr(0, GLOBAL_SEARCH_LINE_MAX_SIZE - totalLength);
      totalLength += string.length;
      let label = document.createElement("label");
      label.className = "plain string";
      label.setAttribute("value", string);
      label.setAttribute("match", match || false);
      lineContents.appendChild(label);
      if (match) {
        label.addEventListener("click", this._onMatchClick, false);
        label.setUserData("lineResults", aLineResults, null);
        label.setUserData("lineContentRange", lineContent.range, null);
        label.container = scriptResults;
      }
      if (totalLength >= GLOBAL_SEARCH_LINE_MAX_SIZE) {
        label = document.createElement("label");
        label.className = "plain string";
        label.setAttribute("value", ellipsis.data);
        lineContents.appendChild(label);
        break;
      }
    }
    let searchResult = document.createElement("hbox");
    searchResult.className = "dbg-search-result";
    searchResult.appendChild(lineNumber);
    searchResult.appendChild(lineContents);
    let resultsContainer = scriptResults.container;
    resultsContainer.appendChild(searchResult);
    return scriptResults;
  }
function DVGS__createLineSearchresultsUI ( aLineResults ) { let scriptResultsId = "search-results-" + aLineResults . scriptUrl ; let scriptResults = document . getElementById ( scriptResultsId ) ; if ( ! scriptResults ) { let trimFunc = DebuggerController . SourceScripts . trimUrlLength ; let urlLabel = trimFunc ( aLineResults . scriptUrl , GLOBAL_SEARCH_URL_MAX_SIZE ) ; let resultsUrl = document . createElement ( "label" ) ; resultsUrl . className = "plain script-url" ; resultsUrl . setAttribute ( "value" , urlLabel ) ; let resultsCount = document . createElement ( "label" ) ; resultsCount . className = "plain match-count" ; resultsCount . setAttribute ( "value" , "(" + aLineResults . matchCount + ")" ) ; let arrow = document . createElement ( "box" ) ; arrow . className = "arrow" ; let resultsHeader = document . createElement ( "hbox" ) ; resultsHeader . className = "dbg-results-header" ; resultsHeader . setAttribute ( "align" , "center" ) resultsHeader . appendChild ( arrow ) ; resultsHeader . appendChild ( resultsUrl ) ; resultsHeader . appendChild ( resultsCount ) ; let resultsContainer = document . createElement ( "vbox" ) ; resultsContainer . className = "dbg-results-container" ; scriptResults = document . createElement ( "vbox" ) ; scriptResults . id = scriptResultsId ; scriptResults . className = "dbg-script-results" ; scriptResults . header = resultsHeader ; scriptResults . container = resultsContainer ; scriptResults . appendChild ( resultsHeader ) ; scriptResults . appendChild ( resultsContainer ) ; this . _pane . appendChild ( scriptResults ) ; scriptResults . expand = function DVGS_element_expand ( aSkipAnimationFlag ) { resultsContainer . setAttribute ( "open" , "" ) ; arrow . setAttribute ( "open" , "" ) ; if ( ! aSkipAnimationFlag ) { resultsContainer . setAttribute ( "animated" , "" ) ; } return scriptResults ; } ; scriptResults . collapse = function DVGS_element_collapse ( ) { resultsContainer . removeAttribute ( "animated" ) ; resultsContainer . removeAttribute ( "open" ) ; arrow . removeAttribute ( "open" ) ; return scriptResults ; } ; scriptResults . toggle = function DVGS_element_toggle ( e ) { if ( e instanceof Event ) { scriptResults . _userToggle = true ; } scriptResults . expanded = ! scriptResults . expanded ; return scriptResults ; } ; Object . defineProperty ( scriptResults , "expanded" , { get : function DVP_element_getExpanded ( ) { return arrow . hasAttribute ( "open" ) ; } , set : function DVP_element_setExpanded ( value ) { if ( value ) { scriptResults . expand ( ) ; } else { scriptResults . collapse ( ) ; } } } ) ; resultsHeader . addEventListener ( "click" , scriptResults . toggle , false ) ; } let lineNumber = document . createElement ( "label" ) ; lineNumber . className = "plain line-number" ; lineNumber . setAttribute ( "value" , aLineResults . lineNumber ) ; let lineContents = document . createElement ( "hbox" ) ; lineContents . setAttribute ( "flex" , "1" ) ; lineContents . className = "line-contents" ; lineContents . addEventListener ( "click" , this . _onLineClick , false ) ; let lineContent ; let totalLength = 0 ; let ellipsis = Services . prefs . getComplexValue ( "intl.ellipsis" , Ci . nsIPrefLocalizedString ) ; for ( lineContent of aLineResults . lineContents ) { let string = lineContent . string ; let match = lineContent . match ; string = string . substr ( 0 , GLOBAL_SEARCH_LINE_MAX_SIZE - totalLength ) ; totalLength += string . length ; let label = document . createElement ( "label" ) ; label . className = "plain string" ; label . setAttribute ( "value" , string ) ; label . setAttribute ( "match" , match || false ) ; lineContents . appendChild ( label ) ; if ( match ) { label . addEventListener ( "click" , this . _onMatchClick , false ) ; label . setUserData ( "lineResults" , aLineResults , null ) ; label . setUserData ( "lineContentRange" , lineContent . range , null ) ; label . container = scriptResults ; } if ( totalLength >= GLOBAL_SEARCH_LINE_MAX_SIZE ) { label = document . createElement ( "label" ) ; label . className = "plain string" ; label . setAttribute ( "value" , ellipsis . data ) ; lineContents . appendChild ( label ) ; break ; } } let searchResult = document . createElement ( "hbox" ) ; searchResult . className = "dbg-search-result" ; searchResult . appendChild ( lineNumber ) ; searchResult . appendChild ( lineContents ) ; let resultsContainer = scriptResults . container ; resultsContainer . appendChild ( searchResult ) ; return scriptResults ; }
Creates per-line search results elements and adds them to the results container.
Creates per - line search results elements and adds them to the results container .
// Create the script results container if not available yet. /**
       * Expands the element, showing all the added details.
       *
       * @param boolean aSkipAnimationFlag
       *        Pass true to not show an opening animation.
       * @return object
       *         The same element.
       */ /**
       * Collapses the element, hiding all the added details.
       * @return object
       *         The same element.
       */ /**
       * Toggles between the element collapse/expand state.
       * @return object
       *         The same element.
       */ /**
       * Returns if the element is expanded.
       * @return boolean
       *         True if the element is expanded.
       */ /**
       * Called when a header in the search results container is clicked.
       */ // Return the element for later use if necessary.