UrlbarView Reference

class UrlbarView(input)

Receives and displays address bar autocomplete results.

Arguments:
  • input (UrlbarInput) – The UrlbarInput instance belonging to this UrlbarView instance.

UrlbarView.UrlbarView
UrlbarView.chromeWindow

The top chrome window. this.window is the owner of the view’s panel which can be a content window for smartbar, so use the window exposed by the input to consistently get the chrome window for gBrowser and other APIs.

UrlbarView.isOpen

Whether the panel is open.

UrlbarView.selectedElement
UrlbarView.selectedResult
UrlbarView.visibleRowCount
UrlbarView.autoOpen(options)

This can be used to open the view automatically as a consequence of specific user actions. For Top Sites searches (without a search string) the view is opened only for mouse or keyboard interactions. If the user abandoned a search (there is a search string) the view is reopened, and we try to use cached results to reduce flickering, then a new query is started to refresh results.

Arguments:
  • options (object) – Options object

  • options.event (Event) – The event associated with the call to autoOpen.

  • options.suppressFocusBorder (boolean) – If true, we hide the focus border when the panel is opened. This is true by default to avoid flashing the border when the unfocused address bar is clicked.

Returns:

boolean – Whether the view was opened.

UrlbarView.clearSelection()

Clears selection, regardless of view status.

UrlbarView.close(options)

Closes the view, cancelling the query if necessary.

Arguments:
  • options (object) – Options object

  • options.elementPicked (boolean) – True if the view is being closed because a result was picked.

  • options.showFocusBorder (boolean) – True if the Urlbar focus border should be shown after the view is closed.

UrlbarView.getFirstSelectableElement()

Returns the first keyboard-selectable element in the view.

Returns:

Element – The first selectable element in the view.

UrlbarView.getLastSelectableElement()

Returns the last keyboard-selectable element in the view.

Returns:

Element – The last selectable element in the view.

UrlbarView.getResultAtIndex(index)
Arguments:
  • index (number) – The index from which to fetch the result.

Returns:

UrlbarResult – The result at index. Null if the view is closed or if there are no results.

UrlbarView.getResultFromElement(element)

Returns the result of the row containing the given element, or the result of the element if it itself is a row.

Arguments:
  • element (Element) – An element in the view.

Returns:

UrlbarResult – The result of the element’s row.

UrlbarView.handleEvent(event)

Passes DOM events for the view to the on_<event type> methods.

Arguments:
  • event (Event) – DOM event from the <view>.

UrlbarView.invalidateResultMenuCommands()

Clears the result menu commands cache, removing the cached commands for all results. This is useful when the commands for one or more results change while the results remain in the view.

UrlbarView.maybeRollupPopups()

Depending on the pref, rolls up all popups in the window. If the moz-urlbar is in the overflow panel, it does nothing to avoid closing the overflow panel.

UrlbarView.onQueryResultRemoved(index)

Handles removing a result from the view when it is removed from the query, and attempts to select the new result on the same row.

This assumes that the result rows are in index order.

Arguments:
  • index (number) – The index of the result that has been removed.

UrlbarView.resultIsSelected(result)
Arguments:
  • result (UrlbarResult) – A result.

Returns:

boolean – True if the given result is selected.

UrlbarView.selectBy(amount, options)

Moves the view selection forward or backward.

Arguments:
  • amount (number) – The number of steps to move.

  • options (object) – Options object

  • options.reverse (boolean) – Set to true to select the previous item. By default the next item will be selected.

  • options.userPressedTab (boolean) – Set to true if the user pressed Tab to select a result. Default false.

UrlbarView.shouldSpaceActivateSelectedElement()
Returns:

boolean – Whether the SPACE key should activate the selected element (if any) instead of adding to the input value.