/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

interface nsIAccessible;
interface nsIAccessibleDocument;

webidl Node;

%{C++
#define NS_ACCESSIBLE_EVENT_TOPIC "accessible-event"
%}

/**
 * An interface for accessibility events listened to
 * by in-process accessibility clients, which can be used
 * to find out how to get accessibility and DOM interfaces for
 * the event and its target. To listen to in-process accessibility invents,
 * make your object an nsIObserver, and listen for accessible-event by
 * using code something like this:
 *   nsCOMPtr<nsIObserverService> observerService =
 *     do_GetService("@mozilla.org/observer-service;1", &rv);
 *   if (NS_SUCCEEDED(rv))
 *     rv = observerService->AddObserver(this, "accessible-event", PR_TRUE);
 */
[scriptable, builtinclass, uuid(20c69a40-6c2c-42a3-a578-6f4473aab9dd)]
interface nsIAccessibleEvent : nsISupports
{
  /**
   * An object has been created.
   */
  const unsigned long EVENT_SHOW = 0x0001;

  /**
   * An object has been destroyed.
   */
  const unsigned long EVENT_HIDE = 0x0002;

  /**
   * An object's children have changed
   */
  const unsigned long EVENT_REORDER = 0x0003;

  /**
   * An object has received the keyboard focus.
   */
  const unsigned long EVENT_FOCUS = 0x0004;

  /**
   * An object's state has changed.
   */
  const unsigned long EVENT_STATE_CHANGE = 0x0005;

  /**
   * An object's Name property has changed.
   */
  const unsigned long EVENT_NAME_CHANGE = 0x0006;

  /**
   * An object's Description property has changed.
   */
  const unsigned long EVENT_DESCRIPTION_CHANGE = 0x0007;

  /**
   * An object's numeric Value has changed.
   */
  const unsigned long EVENT_VALUE_CHANGE = 0x0008;

  /**
   * The selection within a container object has changed.
   */
  const unsigned long EVENT_SELECTION = 0x0009;

  /**
   * An item within a container object has been added to the selection.
   */
  const unsigned long EVENT_SELECTION_ADD = 0x000A;

  /**
   * An item within a container object has been removed from the selection.
   */
  const unsigned long EVENT_SELECTION_REMOVE = 0x000B;

  /**
   * Numerous selection changes have occurred within a container object.
   */
  const unsigned long EVENT_SELECTION_WITHIN = 0x000C;

  /**
   * An alert has been generated. Server applications send this event when a
   * user needs to know that a user interface element has changed.
   */
  const unsigned long EVENT_ALERT = 0x000D;

  /**
   * A menu item on the menu bar has been selected.
   */
  const unsigned long EVENT_MENU_START = 0x000E;

  /**
   * A menu from the menu bar has been closed.
   */
  const unsigned long EVENT_MENU_END = 0x000F;

  /**
   * A pop-up menu has been displayed.
   */
  const unsigned long EVENT_MENUPOPUP_START = 0x0010;

  /**
   * A pop-up menu has been closed.
   */
  const unsigned long EVENT_MENUPOPUP_END = 0x0011;

  /**
   * An application is about to enter drag-and-drop mode
   */
  const unsigned long EVENT_DRAGDROP_START = 0x0012;

  /**
   * Scrolling has started on a scroll bar
   */
  const unsigned long EVENT_SCROLLING_START = 0x0013;

  /**
   * Scrolling has ended on a scroll bar
   */
  const unsigned long EVENT_SCROLLING_END = 0x0014;

  /**
   * The loading of the document has completed.
   */
  const unsigned long EVENT_DOCUMENT_LOAD_COMPLETE = 0x0015;

  /**
   * The document contents are being reloaded.
   */
  const unsigned long EVENT_DOCUMENT_RELOAD = 0x0016;

  /**
   * The loading of the document was interrupted.
   */
  const unsigned long EVENT_DOCUMENT_LOAD_STOPPED = 0x0017;

  /**
   * A text object's attributes changed.
   * Also see EVENT_OBJECT_ATTRIBUTE_CHANGED.
   */
  const unsigned long EVENT_TEXT_ATTRIBUTE_CHANGED = 0x0018;

  /**
   * The caret has moved to a new position.
   */
  const unsigned long EVENT_TEXT_CARET_MOVED = 0x0019;

  /**
   * Text was inserted.
   */
  const unsigned long EVENT_TEXT_INSERTED = 0x001A;

  /**
   * Text was removed.
   */
  const unsigned long EVENT_TEXT_REMOVED = 0x001B;

  /**
   * The text selection changed.
   */
  const unsigned long EVENT_TEXT_SELECTION_CHANGED = 0x001C;

  const unsigned long EVENT_WINDOW_ACTIVATE = 0x001D;
  const unsigned long EVENT_WINDOW_DEACTIVATE = 0x001E;
  const unsigned long EVENT_WINDOW_MAXIMIZE = 0x001F;
  const unsigned long EVENT_WINDOW_MINIMIZE = 0x0020;
  const unsigned long EVENT_WINDOW_RESTORE = 0x0021;

  /**
   * An object's attributes changed. Also see EVENT_TEXT_ATTRIBUTE_CHANGED.
   */
  const unsigned long EVENT_OBJECT_ATTRIBUTE_CHANGED = 0x0022;

  /**
   * An object's text Value has changed.
   */
  const unsigned long EVENT_TEXT_VALUE_CHANGE = 0x0023;

  /**
   * An accessible's viewport is scrolling.
   */
  const unsigned long EVENT_SCROLLING = 0x0024;

  /**
   * An accessible is making an explicit announcement.
   */
  const unsigned long EVENT_ANNOUNCEMENT = 0x0025;

  /**
   * A live region has been introduced. Mac only.
   */
  const unsigned long EVENT_LIVE_REGION_ADDED = 0x0026;

  /**
   * A live region has been removed (aria-live attribute changed). Mac Only.
   */
  const unsigned long EVENT_LIVE_REGION_REMOVED = 0x0027;

  /**
   * A reorder event that has been coalesced into a mutation
   * of an ancestor's subtree.
   */
  const unsigned long EVENT_INNER_REORDER = 0x0028;

  /**
   * Help make sure event map does not get out-of-line.
   */
  const unsigned long EVENT_LAST_ENTRY = 0x0029;

  /**
   * The type of event, based on the enumerated event values
   * defined in this interface.
   */
  readonly attribute unsigned long eventType;

  /**
   * The nsIAccessible associated with the event.
   * May return null if no accessible is available
   */
  readonly attribute nsIAccessible accessible;

  /**
   * The nsIAccessibleDocument that the event target nsIAccessible
   * resides in. This can be used to get the DOM window,
   * the DOM document and the window handler, among other things.
   */
  readonly attribute nsIAccessibleDocument accessibleDocument;

  /**
   * The Node associated with the event
   * May return null if accessible for event has been shut down
   */
  readonly attribute Node DOMNode;

  /**
   * Returns true if the event was caused by explicit user input,
   * as opposed to purely originating from a timer or mouse movement
   */
  readonly attribute boolean isFromUserInput;
};
