B2G/gecko/browser/devtools/webconsole/webconsole.js
/**
   * Completes the current typed text in the inputNode. Completion is performed
   * only if the selection/cursor is at the end of the string. If no completion
   * is found, the current inputNode value and cursor/selection stay.
   *
   * @param int aType possible values are
   *    - this.COMPLETE_FORWARD: If there is more than one possible completion
   *          and the input value stayed the same compared to the last time this
   *          function was called, then the next completion of all possible
   *          completions is used. If the value changed, then the first possible
   *          completion is used and the selection is set from the current
   *          cursor position to the end of the completed text.
   *          If there is only one possible completion, then this completion
   *          value is used and the cursor is put at the end of the completion.
   *    - this.COMPLETE_BACKWARD: Same as this.COMPLETE_FORWARD but if the
   *          value stayed the same as the last time the function was called,
   *          then the previous completion of all possible completions is used.
   *    - this.COMPLETE_HINT_ONLY: If there is more than one possible
   *          completion and the input value stayed the same compared to the
   *          last time this function was called, then the same completion is
   *          used again. If there is only one possible completion, then
   *          the inputNode.value is set to this value and the selection is set
   *          from the current cursor position to the end of the completed text.
   * @param function aCallback
   *        Optional function invoked when the autocomplete properties are
   *        updated.
   * @returns boolean true if there existed a completion for the current input,
   *          or false otherwise.
   */
Completes the current typed text in the inputNode. Completion is performed
only if the selection/cursor is at the end of the string. If no completion
is found, the current inputNode value and cursor/selection stay.

@param int aType possible values are
- this.COMPLETE_FORWARD: If there is more than one possible completion
and the input value stayed the same compared to the last time this
function was called, then the next completion of all possible
completions is used. If the value changed, then the first possible
completion is used and the selection is set from the current
cursor position to the end of the completed text.
If there is only one possible completion, then this completion
value is used and the cursor is put at the end of the completion.
- this.COMPLETE_BACKWARD: Same as this.COMPLETE_FORWARD but if the
value stayed the same as the last time the function was called,
then the previous completion of all possible completions is used.
- this.COMPLETE_HINT_ONLY: If there is more than one possible
completion and the input value stayed the same compared to the
last time this function was called, then the same completion is
used again. If there is only one possible completion, then
the inputNode.value is set to this value and the selection is set
from the current cursor position to the end of the completed text.
@param function aCallback
Optional function invoked when the autocomplete properties are
updated.
@returns boolean true if there existed a completion for the current input,
or false otherwise.
Completes the current typed text in the inputNode . Completion is performed only if the selection / cursor is at the end of the string . If no completion is found the current inputNode value and cursor / selection stay . @param int aType possible values are - this . COMPLETE_FORWARD : If there is more than one possible completion and the input value stayed the same compared to the last time this function was called then the next completion of all possible completions is used . If the value changed then the first possible completion is used and the selection is set from the current cursor position to the end of the completed text . If there is only one possible completion then this completion value is used and the cursor is put at the end of the completion . - this . COMPLETE_BACKWARD : Same as this . COMPLETE_FORWARD but if the value stayed the same as the last time the function was called then the previous completion of all possible completions is used . - this . COMPLETE_HINT_ONLY : If there is more than one possible completion and the input value stayed the same compared to the last time this function was called then the same completion is used again . If there is only one possible completion then the inputNode . value is set to this value and the selection is set from the current cursor position to the end of the completed text . @param function aCallback Optional function invoked when the autocomplete properties are updated . @returns boolean true if there existed a completion for the current input or false otherwise .
function JSTF_complete(aType, aCallback)
  {
    let inputNode = this.inputNode;
    let inputValue = inputNode.value;
    if (!inputValue) {
      this.clearCompletion();
      return false;
    }
    if (inputNode.selectionStart == inputNode.selectionEnd &&
        inputNode.selectionEnd != inputValue.length) {
      this.clearCompletion();
      return false;
    }
    if (this.lastCompletion.value != inputValue) {
      this._updateCompletionResult(aType, aCallback);
      return false;
    }
    let popup = this.autocompletePopup;
    let accepted = false;
    if (aType != this.COMPLETE_HINT_ONLY && popup.itemCount == 1) {
      this.acceptProposedCompletion();
      accepted = true;
    }
    else if (aType == this.COMPLETE_BACKWARD) {
      popup.selectPreviousItem();
    }
    else if (aType == this.COMPLETE_FORWARD) {
      popup.selectNextItem();
    }
    aCallback && aCallback(this);
    return accepted || popup.itemCount > 0;
  }
function JSTF_complete ( aType , aCallback ) { let inputNode = this . inputNode ; let inputValue = inputNode . value ; if ( ! inputValue ) { this . clearCompletion ( ) ; return false ; } if ( inputNode . selectionStart == inputNode . selectionEnd && inputNode . selectionEnd != inputValue . length ) { this . clearCompletion ( ) ; return false ; } if ( this . lastCompletion . value != inputValue ) { this . _updateCompletionResult ( aType , aCallback ) ; return false ; } let popup = this . autocompletePopup ; let accepted = false ; if ( aType != this . COMPLETE_HINT_ONLY && popup . itemCount == 1 ) { this . acceptProposedCompletion ( ) ; accepted = true ; } else if ( aType == this . COMPLETE_BACKWARD ) { popup . selectPreviousItem ( ) ; } else if ( aType == this . COMPLETE_FORWARD ) { popup . selectNextItem ( ) ; } aCallback && aCallback ( this ) ; return accepted || popup . itemCount > 0 ; }
Completes the current typed text in the inputNode.
Completes the current typed text in the inputNode .
// If the inputNode has no value, then don't try to complete on it. // Only complete if the selection is empty and at the end of the input. // Update the completion results.