B2G/gecko/browser/devtools/webconsole/webconsole.js
/**
   * Try to flush the output message queue. This takes the messages in the
   * output queue and displays them. Outputting stops at MESSAGES_IN_INTERVAL.
   * Further output is queued to happen later - see OUTPUT_INTERVAL.
   *
   * @private
   */
Try to flush the output message queue. This takes the messages in the
output queue and displays them. Outputting stops at MESSAGES_IN_INTERVAL.
Further output is queued to happen later - see OUTPUT_INTERVAL.

@private
Try to flush the output message queue . This takes the messages in the output queue and displays them . Outputting stops at MESSAGES_IN_INTERVAL . Further output is queued to happen later - see OUTPUT_INTERVAL . @private
function WCF__flushMessageQueue()
  {
    if (!this._outputTimer) {
      return;
    }
    let timeSinceFlush = Date.now() - this._lastOutputFlush;
    if (this._outputQueue.length > MESSAGES_IN_INTERVAL &&
        timeSinceFlush < THROTTLE_UPDATES) {
      this._initOutputTimer();
      return;
    }
    let toDisplay = Math.min(this._outputQueue.length, MESSAGES_IN_INTERVAL);
    if (toDisplay < 1) {
      this._outputTimerInitialized = false;
      return;
    }
    let shouldPrune = false;
    if (this._outputQueue.length > toDisplay && this._pruneOutputQueue()) {
      toDisplay = Math.min(this._outputQueue.length, toDisplay);
      shouldPrune = true;
    }
    let batch = this._outputQueue.splice(0, toDisplay);
    if (!batch.length) {
      this._outputTimerInitialized = false;
      return;
    }
    let outputNode = this.outputNode;
    let lastVisibleNode = null;
    let scrolledToBottom = Utils.isOutputScrolledToBottom(outputNode);
    let scrollBox = outputNode.scrollBoxObject.element;
    let hudIdSupportsString = WebConsoleUtils.supportsString(this.hudId);
    for (let item of batch) {
      let node = this._outputMessageFromQueue(hudIdSupportsString, item);
      if (node) {
        lastVisibleNode = node;
      }
    }
    let oldScrollHeight = 0;
    let removedNodes = 0;
    if (shouldPrune || !this._outputQueue.length) {
      oldScrollHeight = scrollBox.scrollHeight;
      let categories = Object.keys(this._pruneCategoriesQueue);
      categories.forEach(function _pruneOutput(aCategory) {
        removedNodes += this.pruneOutputIfNecessary(aCategory);
      }, this);
      this._pruneCategoriesQueue = {};
    }
    if (!this._outputQueue.length) {
      this.regroupOutput();
    }
    let isInputOutput = lastVisibleNode &&
      (lastVisibleNode.classList.contains("webconsole-msg-input") ||
       lastVisibleNode.classList.contains("webconsole-msg-output"));
    if (lastVisibleNode && (scrolledToBottom || isInputOutput)) {
      Utils.scrollToVisible(lastVisibleNode);
    }
    else if (!scrolledToBottom && removedNodes > 0 &&
             oldScrollHeight != scrollBox.scrollHeight) {
      scrollBox.scrollTop -= oldScrollHeight - scrollBox.scrollHeight;
    }
    if (this._outputQueue.length > 0) {
      this._initOutputTimer();
    }
    else {
      this._outputTimerInitialized = false;
      this._flushCallback && this._flushCallback();
    }
    this._lastOutputFlush = Date.now();
  }
function WCF__flushMessageQueue ( ) { if ( ! this . _outputTimer ) { return ; } let timeSinceFlush = Date . now ( ) - this . _lastOutputFlush ; if ( this . _outputQueue . length > MESSAGES_IN_INTERVAL && timeSinceFlush < THROTTLE_UPDATES ) { this . _initOutputTimer ( ) ; return ; } let toDisplay = Math . min ( this . _outputQueue . length , MESSAGES_IN_INTERVAL ) ; if ( toDisplay < 1 ) { this . _outputTimerInitialized = false ; return ; } let shouldPrune = false ; if ( this . _outputQueue . length > toDisplay && this . _pruneOutputQueue ( ) ) { toDisplay = Math . min ( this . _outputQueue . length , toDisplay ) ; shouldPrune = true ; } let batch = this . _outputQueue . splice ( 0 , toDisplay ) ; if ( ! batch . length ) { this . _outputTimerInitialized = false ; return ; } let outputNode = this . outputNode ; let lastVisibleNode = null ; let scrolledToBottom = Utils . isOutputScrolledToBottom ( outputNode ) ; let scrollBox = outputNode . scrollBoxObject . element ; let hudIdSupportsString = WebConsoleUtils . supportsString ( this . hudId ) ; for ( let item of batch ) { let node = this . _outputMessageFromQueue ( hudIdSupportsString , item ) ; if ( node ) { lastVisibleNode = node ; } } let oldScrollHeight = 0 ; let removedNodes = 0 ; if ( shouldPrune || ! this . _outputQueue . length ) { oldScrollHeight = scrollBox . scrollHeight ; let categories = Object . keys ( this . _pruneCategoriesQueue ) ; categories . forEach ( function _pruneOutput ( aCategory ) { removedNodes += this . pruneOutputIfNecessary ( aCategory ) ; } , this ) ; this . _pruneCategoriesQueue = { } ; } if ( ! this . _outputQueue . length ) { this . regroupOutput ( ) ; } let isInputOutput = lastVisibleNode && ( lastVisibleNode . classList . contains ( "webconsole-msg-input" ) || lastVisibleNode . classList . contains ( "webconsole-msg-output" ) ) ; if ( lastVisibleNode && ( scrolledToBottom || isInputOutput ) ) { Utils . scrollToVisible ( lastVisibleNode ) ; } else if ( ! scrolledToBottom && removedNodes > 0 && oldScrollHeight != scrollBox . scrollHeight ) { scrollBox . scrollTop -= oldScrollHeight - scrollBox . scrollHeight ; } if ( this . _outputQueue . length > 0 ) { this . _initOutputTimer ( ) ; } else { this . _outputTimerInitialized = false ; this . _flushCallback && this . _flushCallback ( ) ; } this . _lastOutputFlush = Date . now ( ) ; }
Try to flush the output message queue.
Try to flush the output message queue .
// Determine how many messages we can display now. // Try to prune the message queue. // Output the current batch of messages. // Prune messages if needed. We do not do this for every flush call to // improve performance. // Regroup messages at the end of the queue. // Scroll to the new node if it is not filtered, and if the output node is // scrolled at the bottom or if the new node is a jsterm input/output // message. // If there were pruned messages and if scroll is not at the bottom, then // we need to adjust the scroll location. // If the queue is not empty, schedule another flush.