diff options
Diffstat (limited to 'dom/interfaces/events')
25 files changed, 1643 insertions, 0 deletions
diff --git a/dom/interfaces/events/moz.build b/dom/interfaces/events/moz.build new file mode 100644 index 000000000..fb1dc6a21 --- /dev/null +++ b/dom/interfaces/events/moz.build @@ -0,0 +1,35 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +XPIDL_SOURCES += [ + 'nsIDOMAnimationEvent.idl', + 'nsIDOMBeforeUnloadEvent.idl', + 'nsIDOMClipboardEvent.idl', + 'nsIDOMCommandEvent.idl', + 'nsIDOMCustomEvent.idl', + 'nsIDOMDataContainerEvent.idl', + 'nsIDOMDataTransfer.idl', + 'nsIDOMDragEvent.idl', + 'nsIDOMEvent.idl', + 'nsIDOMEventListener.idl', + 'nsIDOMEventTarget.idl', + 'nsIDOMFocusEvent.idl', + 'nsIDOMKeyEvent.idl', + 'nsIDOMMouseEvent.idl', + 'nsIDOMMouseScrollEvent.idl', + 'nsIDOMMutationEvent.idl', + 'nsIDOMNotifyPaintEvent.idl', + 'nsIDOMNSEvent.idl', + 'nsIDOMPaintRequest.idl', + 'nsIDOMScrollAreaEvent.idl', + 'nsIDOMSimpleGestureEvent.idl', + 'nsIDOMTransitionEvent.idl', + 'nsIDOMUIEvent.idl', + 'nsIDOMWheelEvent.idl', +] + +XPIDL_MODULE = 'dom_events' + diff --git a/dom/interfaces/events/nsIDOMAnimationEvent.idl b/dom/interfaces/events/nsIDOMAnimationEvent.idl new file mode 100644 index 000000000..2f4e527db --- /dev/null +++ b/dom/interfaces/events/nsIDOMAnimationEvent.idl @@ -0,0 +1,20 @@ +/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ +/* 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" + +/** + * Animation events are defined in: + * http://www.w3.org/TR/css3-animations/#animation-events- + * http://dev.w3.org/csswg/css3-animations/#animation-events- + */ + +[builtinclass, uuid(ce6d1db3-53b8-4ade-9baa-70f4947200a2)] +interface nsIDOMAnimationEvent : nsISupports +{ + readonly attribute DOMString animationName; + readonly attribute float elapsedTime; + readonly attribute DOMString pseudoElement; +}; diff --git a/dom/interfaces/events/nsIDOMBeforeUnloadEvent.idl b/dom/interfaces/events/nsIDOMBeforeUnloadEvent.idl new file mode 100644 index 000000000..3fe0451db --- /dev/null +++ b/dom/interfaces/events/nsIDOMBeforeUnloadEvent.idl @@ -0,0 +1,26 @@ +/* -*- Mode: IDL; 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" + +/** + * The nsIDOMBeforeUnloadEvent interface is the interface for events + * sent to handlers of the "beforeunload" event. This event is + * non-standard. Interface derived from Microsoft IE's event + * implementation. + * + * http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events.asp + * + */ + +[builtinclass, uuid(26c83933-a5a4-455e-8c46-69fa24dfa991)] +interface nsIDOMBeforeUnloadEvent : nsISupports +{ + /** + * Attribute used to pass back a return value from a beforeunload + * handler + */ + attribute DOMString returnValue; +}; diff --git a/dom/interfaces/events/nsIDOMClipboardEvent.idl b/dom/interfaces/events/nsIDOMClipboardEvent.idl new file mode 100644 index 000000000..a92093a13 --- /dev/null +++ b/dom/interfaces/events/nsIDOMClipboardEvent.idl @@ -0,0 +1,22 @@ +/* -*- 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 "domstubs.idl" +#include "nsISupports.idl" + +interface nsIDOMDataTransfer; + +[builtinclass, uuid(b54d6144-3980-4895-83c7-82f158bc1cf5)] +interface nsIDOMClipboardEvent : nsISupports +{ + readonly attribute nsIDOMDataTransfer clipboardData; + + // The constructor must be used from script to initialize + // clipboard events. + [noscript] void initClipboardEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in nsIDOMDataTransfer clipboardData); +}; diff --git a/dom/interfaces/events/nsIDOMCommandEvent.idl b/dom/interfaces/events/nsIDOMCommandEvent.idl new file mode 100644 index 000000000..3d1b8adc7 --- /dev/null +++ b/dom/interfaces/events/nsIDOMCommandEvent.idl @@ -0,0 +1,17 @@ +/* -*- Mode: IDL; 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" + +[builtinclass, uuid(73a50e55-3eaa-4a38-a588-9b68a6d65032)] +interface nsIDOMCommandEvent : nsISupports +{ + readonly attribute DOMString command; + + void initCommandEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean canCancelArg, + in DOMString command); +}; diff --git a/dom/interfaces/events/nsIDOMCustomEvent.idl b/dom/interfaces/events/nsIDOMCustomEvent.idl new file mode 100644 index 000000000..878052719 --- /dev/null +++ b/dom/interfaces/events/nsIDOMCustomEvent.idl @@ -0,0 +1,19 @@ +/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ +/* 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 nsIVariant; + +[builtinclass, uuid(5be16b03-36f9-4ca8-b2c5-0daadf3cd1b3)] +interface nsIDOMCustomEvent : nsISupports +{ + + readonly attribute nsIVariant detail; + + void initCustomEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in nsIVariant detailArg); +}; diff --git a/dom/interfaces/events/nsIDOMDataContainerEvent.idl b/dom/interfaces/events/nsIDOMDataContainerEvent.idl new file mode 100644 index 000000000..fce27fc12 --- /dev/null +++ b/dom/interfaces/events/nsIDOMDataContainerEvent.idl @@ -0,0 +1,30 @@ +/* -*- 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" +#include "nsIVariant.idl" + +[builtinclass, uuid(a9f1f528-d106-4fea-8663-2d7f64b627a9)] +interface nsIDOMDataContainerEvent : nsISupports +{ + /** + * Return the data associated with the given key. + * + * @param key the key + * @return the data associated with the key + */ + nsIVariant getData(in DOMString key); + + /** + * Set the data for the given key. + * + * @param key the data key + * @param data the data + * @throws NS_ERROR_UNEXPECTED if the method is called during event + * dispatch + */ + void setData(in DOMString key, in nsIVariant data); +}; + diff --git a/dom/interfaces/events/nsIDOMDataTransfer.idl b/dom/interfaces/events/nsIDOMDataTransfer.idl new file mode 100644 index 000000000..ada7b4fb8 --- /dev/null +++ b/dom/interfaces/events/nsIDOMDataTransfer.idl @@ -0,0 +1,150 @@ +/* -*- 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 "domstubs.idl" + +interface nsIVariant; +interface nsIDOMFileList; + +[builtinclass, uuid(655078bf-1675-4aa0-a48d-a133e864ce57)] +interface nsIDOMDataTransfer : nsISupports +{ + /** + * The actual effect that will be used, and should always be one of the + * possible values of effectAllowed. + * + * For dragstart, drag and dragleave events, the dropEffect is initialized + * to none. Any value assigned to the dropEffect will be set, but the value + * isn't used for anything. + * + * For the dragenter and dragover events, the dropEffect will be initialized + * based on what action the user is requesting. How this is determined is + * platform specific, but typically the user can press modifier keys to + * adjust which action is desired. Within an event handler for the dragenter + * and dragover events, the dropEffect should be modified if the action the + * user is requesting is not the one that is desired. + * + * For the drop and dragend events, the dropEffect will be initialized to + * the action that was desired, which will be the value that the dropEffect + * had after the last dragenter or dragover event. + * + * Possible values: + * copy - a copy of the source item is made at the new location + * move - an item is moved to a new location + * link - a link is established to the source at the new location + * none - the item may not be dropped + * + * Assigning any other value has no effect and retains the old value. + */ + attribute DOMString dropEffect; + + /* + * Specifies the effects that are allowed for this drag. You may set this in + * the dragstart event to set the desired effects for the source, and within + * the dragenter and dragover events to set the desired effects for the + * target. The value is not used for other events. + * + * Possible values: + * copy - a copy of the source item is made at the new location + * move - an item is moved to a new location + * link - a link is established to the source at the new location + * copyLink, copyMove, linkMove, all - combinations of the above + * none - the item may not be dropped + * uninitialized - the default value when the effect has not been set, + * equivalent to all. + * + * Assigning any other value has no effect and retains the old value. + */ + attribute DOMString effectAllowed; + + /** + * Holds a list of all the local files available on this data transfer. + * A dataTransfer containing no files will return an empty list, and an + * invalid index access on the resulting file list will return null. + */ + readonly attribute nsIDOMFileList files; + + /** + * Set the image to be used for dragging if a custom one is desired. Most of + * the time, this would not be set, as a default image is created from the + * node that was dragged. + * + * If the node is an HTML img element, an HTML canvas element or a XUL image + * element, the image data is used. Otherwise, image should be a visible + * node and the drag image will be created from this. If image is null, any + * custom drag image is cleared and the default is used instead. + * + * The coordinates specify the offset into the image where the mouse cursor + * should be. To center the image for instance, use values that are half the + * width and height. + * + * @param image a node to use + * @param x the horizontal offset + * @param y the vertical offset + * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified + */ + void setDragImage(in nsIDOMElement image, in long x, in long y); + + /* + * Set the drag source. Usually you would not change this, but it will + * affect which node the drag and dragend events are fired at. The + * default target is the node that was dragged. + * + * @param element drag source to use + * @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified + */ + void addElement(in nsIDOMElement element); + + /** + * The number of items being dragged. + */ + readonly attribute unsigned long mozItemCount; + + /** + * Sets the drag cursor state. Primarily used to control the cursor during + * tab drags, but could be expanded to other uses. XXX Currently implemented + * on Win32 only. + * + * Possible values: + * auto - use default system behavior. + * default - set the cursor to an arrow during the drag operation. + * + * Values other than 'default' are indentical to setting mozCursor to + * 'auto'. + */ + attribute DOMString mozCursor; + + /** + * Holds a list of the format types of the data that is stored for an item + * at the specified index. If the index is not in the range from 0 to + * itemCount - 1, an empty string list is returned. + */ + nsISupports mozTypesAt(in unsigned long index); + + /** + * Will be true when the user has cancelled the drag (typically by pressing + * Escape) and when the drag has been cancelled unexpectedly. This will be + * false otherwise, including when the drop has been rejected by its target. + * This property is only relevant for the dragend event. + */ + readonly attribute boolean mozUserCancelled; + + /** + * The node that the mouse was pressed over to begin the drag. For external + * drags, or if the caller cannot access this node, this will be null. + */ + readonly attribute nsIDOMNode mozSourceNode; + + /* + * Integer version of dropEffect, set to one of the constants in nsIDragService. + */ + [noscript] attribute unsigned long dropEffectInt; + + /* + * Integer version of effectAllowed, set to one or a combination of the + * constants in nsIDragService. + */ + [noscript] attribute unsigned long effectAllowedInt; +}; diff --git a/dom/interfaces/events/nsIDOMDragEvent.idl b/dom/interfaces/events/nsIDOMDragEvent.idl new file mode 100644 index 000000000..9f59eb51e --- /dev/null +++ b/dom/interfaces/events/nsIDOMDragEvent.idl @@ -0,0 +1,15 @@ +/* -*- 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 "domstubs.idl" +#include "nsIDOMMouseEvent.idl" + +interface nsIDOMDataTransfer; + +[builtinclass, uuid(d5c0d4c2-c646-4b4b-836e-48408b9c7b80)] +interface nsIDOMDragEvent : nsIDOMMouseEvent +{ + readonly attribute nsIDOMDataTransfer dataTransfer; +}; diff --git a/dom/interfaces/events/nsIDOMEvent.idl b/dom/interfaces/events/nsIDOMEvent.idl new file mode 100644 index 000000000..69eb9384b --- /dev/null +++ b/dom/interfaces/events/nsIDOMEvent.idl @@ -0,0 +1,221 @@ +/* -*- Mode: IDL; 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 "domstubs.idl" + +interface nsIDOMEventTarget; + +[ptr] native WidgetEvent(mozilla::WidgetEvent); +[ptr] native DOMEventPtr(mozilla::dom::Event); +[ptr] native IPCMessagePtr(IPC::Message); +[ptr] native ConstIPCMessagePtr(const IPC::Message); +[ptr] native PickleIterator(PickleIterator); +[ptr] native EventTargetPtr(mozilla::dom::EventTarget); +%{C++ +#ifdef ERROR +#undef ERROR +#endif + +#include "mozilla/EventForwards.h" +class nsPresContext; +class nsInvalidateRequestList; +namespace IPC { +class Message; +} +class PickleIterator; +namespace mozilla { +namespace dom { +class Event; +class EventTarget; +} // namespace dom +} // namespace mozilla +%} + +/** + * The nsIDOMEvent interface is the primary datatype for all events in + * the Document Object Model. + * + * For more information on this interface please see + * http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html and + * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html + */ + +[builtinclass, uuid(f58daacf-4d1a-4002-8fd7-06b614dfbcf6)] +interface nsIDOMEvent : nsISupports +{ + // PhaseType + /** + * The event isn't being dispatched. + */ + const unsigned short NONE = 0; + /** + * The current event phase is the capturing phase. + */ + const unsigned short CAPTURING_PHASE = 1; + + /** + * The event is currently being evaluated at the target EventTarget. + */ + const unsigned short AT_TARGET = 2; + + /** + * The current event phase is the bubbling phase. + */ + const unsigned short BUBBLING_PHASE = 3; + + /** + * The name of the event (case-insensitive). The name must be an XML + * name. + */ + readonly attribute DOMString type; + + /** + * Used to indicate the EventTarget to which the event was originally + * dispatched. + */ + readonly attribute nsIDOMEventTarget target; + + /** + * Used to indicate the EventTarget whose EventListeners are currently + * being processed. This is particularly useful during capturing and + * bubbling. + */ + readonly attribute nsIDOMEventTarget currentTarget; + + /** + * Used to indicate which phase of event flow is currently being + * evaluated. + */ + readonly attribute unsigned short eventPhase; + + /** + * Used to indicate whether or not an event is a bubbling event. If the + * event can bubble the value is true, else the value is false. + */ + readonly attribute boolean bubbles; + + /** + * Used to indicate whether or not an event can have its default action + * prevented. If the default action can be prevented the value is true, + * else the value is false. + */ + readonly attribute boolean cancelable; + + /** + * Used to specify the time (in milliseconds relative to the epoch) at + * which the event was created. Due to the fact that some systems may + * not provide this information the value of timeStamp may be not + * available for all events. When not available, a value of 0 will be + * returned. Examples of epoch time are the time of the system start or + * 0:0:0 UTC 1st January 1970. + */ + readonly attribute DOMTimeStamp timeStamp; + + /** + * The stopPropagation method is used prevent further propagation of an + * event during event flow. If this method is called by any + * EventListener the event will cease propagating through the tree. The + * event will complete dispatch to all listeners on the current + * EventTarget before event flow stops. This method may be used during + * any stage of event flow. + */ + void stopPropagation(); + + /** + * If an event is cancelable, the preventDefault method is used to + * signify that the event is to be canceled, meaning any default action + * normally taken by the implementation as a result of the event will + * not occur. If, during any stage of event flow, the preventDefault + * method is called the event is canceled. Any default action associated + * with the event will not occur. Calling this method for a + * non-cancelable event has no effect. Once preventDefault has been + * called it will remain in effect throughout the remainder of the + * event's propagation. This method may be used during any stage of + * event flow. + */ + void preventDefault(); + + /** + * The initEvent method is used to initialize the value of an Event + * created through the DocumentEvent interface. This method may only be + * called before the Event has been dispatched via the dispatchEvent + * method, though it may be called multiple times during that phase if + * necessary. If called multiple times the final invocation takes + * precedence. If called from a subclass of Event interface only the + * values specified in the initEvent method are modified, all other + * attributes are left unchanged. + * + * @param eventTypeArg Specifies the event type. This type may be + * any event type currently defined in this + * specification or a new event type.. The string + * must be an XML name. + * Any new event type must not begin with any + * upper, lower, or mixed case version of the + * string "DOM". This prefix is reserved for + * future DOM event sets. It is also strongly + * recommended that third parties adding their + * own events use their own prefix to avoid + * confusion and lessen the probability of + * conflicts with other new events. + * @param canBubbleArg Specifies whether or not the event can bubble. + * @param cancelableArg Specifies whether or not the event's default + * action can be prevented. + */ + [notxpcom,nostdcall] + void initEvent(in DOMString eventTypeArg, + in boolean canBubbleArg, + in boolean cancelableArg); + + /** + * Used to indicate whether preventDefault() has been called for this event. + */ + readonly attribute boolean defaultPrevented; + + /** + * Prevents other event listeners from being triggered and, + * unlike Event.stopPropagation() its effect is immediate. + */ + void stopImmediatePropagation(); + + const long ALT_MASK = 0x00000001; + const long CONTROL_MASK = 0x00000002; + const long SHIFT_MASK = 0x00000004; + const long META_MASK = 0x00000008; + + /** The original target of the event, before any retargetings. */ + readonly attribute nsIDOMEventTarget originalTarget; + /** + * The explicit original target of the event. If the event was retargeted + * for some reason other than an anonymous boundary crossing, this will be set + * to the target before the retargeting occurs. For example, mouse events + * are retargeted to their parent node when they happen over text nodes (bug + * 185889), and in that case .target will show the parent and + * .explicitOriginalTarget will show the text node. + * .explicitOriginalTarget differs from .originalTarget in that it will never + * contain anonymous content. + */ + readonly attribute nsIDOMEventTarget explicitOriginalTarget; + + /** + * @deprecated Use nsIDOMEvent::defaultPrevented. + * To be removed in bug 691151. + */ + boolean getPreventDefault(); + + readonly attribute boolean isTrusted; + attribute boolean cancelBubble; + + [noscript] void duplicatePrivateData(); + [noscript] void setTarget(in nsIDOMEventTarget aTarget); + [notxpcom] boolean IsDispatchStopped(); + [notxpcom] WidgetEvent WidgetEventPtr(); + [noscript,notxpcom] void SetTrusted(in boolean aTrusted); + [notxpcom] void Serialize(in IPCMessagePtr aMsg, + in boolean aSerializeInterfaceType); + [notxpcom] boolean Deserialize(in ConstIPCMessagePtr aMsg, in PickleIterator aIter); + [noscript,notxpcom] void SetOwner(in EventTargetPtr aOwner); + [notxpcom] DOMEventPtr InternalDOMEvent(); + [noscript] void stopCrossProcessForwarding(); +}; diff --git a/dom/interfaces/events/nsIDOMEventListener.idl b/dom/interfaces/events/nsIDOMEventListener.idl new file mode 100644 index 000000000..347ae6b61 --- /dev/null +++ b/dom/interfaces/events/nsIDOMEventListener.idl @@ -0,0 +1,29 @@ +/* -*- Mode: IDL; 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 "domstubs.idl" + +/** + * The nsIDOMEventListener interface is a callback interface for + * listening to events in the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + */ + +[scriptable, function, uuid(df31c120-ded6-11d1-bd85-00805f8ae3f4)] +interface nsIDOMEventListener : nsISupports +{ + /** + * This method is called whenever an event occurs of the type for which + * the EventListener interface was registered. + * + * @param evt The Event contains contextual information about the + * event. It also contains the stopPropagation and + * preventDefault methods which are used in determining the + * event's flow and default action. + */ + void handleEvent(in nsIDOMEvent event); +}; diff --git a/dom/interfaces/events/nsIDOMEventTarget.idl b/dom/interfaces/events/nsIDOMEventTarget.idl new file mode 100644 index 000000000..a7e3aae5a --- /dev/null +++ b/dom/interfaces/events/nsIDOMEventTarget.idl @@ -0,0 +1,304 @@ +/* -*- Mode: IDL; 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 "domstubs.idl" + +%{C++ +#include "mozilla/EventForwards.h" +#include "mozilla/dom/Nullable.h" +#include "js/TypeDecls.h" + +using mozilla::dom::Nullable; + +namespace mozilla { +class EventChainPostVisitor; +class EventChainPreVisitor; +class EventListenerManager; +namespace dom { +class EventTarget; +} // namespace dom +} // namespace mozilla + +class nsPresContext; +%} + +/** + * The nsIDOMEventTarget interface is the interface implemented by all + * event targets in the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + */ + +[ptr] native WidgetEventPtr(mozilla::WidgetEvent); +[ptr] native nsPresContextPtr(nsPresContext); +[ptr] native nsEventStatusPtr(nsEventStatus); +[ptr] native JSContextPtr(JSContext); +[ref] native EventChainPostVisitorRef(mozilla::EventChainPostVisitor); +[ref] native EventChainPreVisitorRef(mozilla::EventChainPreVisitor); +[ptr] native EventListenerManagerPtr(mozilla::EventListenerManager); +[ptr] native EventTargetPtr(mozilla::dom::EventTarget); + +interface nsIScriptContext; +interface nsIDOMEventListener; +interface nsIDOMEvent; + +[scriptable, builtinclass, uuid(9a78ac3c-9507-4d00-b2d6-10b508d2ec31)] +interface nsIDOMEventTarget : nsISupports +{ + /** + * This method allows the registration of event listeners on the event target. + * If an EventListener is added to an EventTarget while it is processing an + * event, it will not be triggered by the current actions but may be + * triggered during a later stage of event flow, such as the bubbling phase. + * + * If multiple identical EventListeners are registered on the same + * EventTarget with the same parameters the duplicate instances are + * discarded. They do not cause the EventListener to be called twice + * and since they are discarded they do not need to be removed with the + * removeEventListener method. + * + * @param type The event type for which the user is registering + * @param listener The listener parameter takes an interface + * implemented by the user which contains the methods + * to be called when the event occurs. + * @param useCapture If true, useCapture indicates that the user + * wishes to initiate capture. After initiating + * capture, all events of the specified type will be + * dispatched to the registered EventListener before + * being dispatched to any EventTargets beneath them + * in the tree. Events which are bubbling upward + * through the tree will not trigger an + * EventListener designated to use capture. + * @param wantsUntrusted If false, the listener will not receive any + * untrusted events (see above), if true, the + * listener will receive events whether or not + * they're trusted + */ + [optional_argc] void addEventListener(in DOMString type, + in nsIDOMEventListener listener, + [optional] in boolean useCapture, + [optional] in boolean wantsUntrusted); + + /** + * addSystemEventListener() adds an event listener of aType to the system + * group. Typically, core code should use system group for listening to + * content (i.e., non-chrome) element's events. If core code uses + * nsIDOMEventTarget::AddEventListener for a content node, it means + * that the listener cannot listen the event when web content calls + * stopPropagation() of the event. + * + * @param aType An event name you're going to handle. + * @param aListener An event listener. + * @param aUseCapture TRUE if you want to listen the event in capturing + * phase. Otherwise, FALSE. + * @param aWantsUntrusted TRUE if you want to handle untrusted events. + * Otherwise, FALSE. + * @return NS_OK if succeed. Otherwise, NS_ERROR_*. + */ + [noscript, optional_argc] void addSystemEventListener( + in DOMString type, + in nsIDOMEventListener listener, + [optional] in boolean aUseCapture, + [optional] in boolean aWantsUntrusted); + +%{C++ + // non-virtual so it won't affect the vtable + nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture) + { + return AddEventListener(aType, aListener, aUseCapture, false, 1); + } + // non-virtual so it won't affect the vtable + nsresult AddEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + bool aWantsUntrusted) + { + return AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted, 2); + } + // non-virtual so it won't affect the vtable + nsresult AddSystemEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture) + { + return AddSystemEventListener(aType, aListener, aUseCapture, false, 1); + } + // non-virtual so it won't affect the vtable + nsresult AddSystemEventListener(const nsAString& aType, + nsIDOMEventListener* aListener, + bool aUseCapture, + bool aWantsUntrusted) + { + return AddSystemEventListener(aType, aListener, aUseCapture, + aWantsUntrusted, 2); + } +%} + + /** + * This method allows the removal of event listeners from the event + * target. If an EventListener is removed from an EventTarget while it + * is processing an event, it will not be triggered by the current actions. + * EventListeners can never be invoked after being removed. + * Calling removeEventListener with arguments which do not identify any + * currently registered EventListener on the EventTarget has no effect. + * + * @param type Specifies the event type of the EventListener being + * removed. + * @param listener The EventListener parameter indicates the + * EventListener to be removed. + * @param useCapture Specifies whether the EventListener being + * removed was registered as a capturing listener or + * not. If a listener was registered twice, one with + * capture and one without, each must be removed + * separately. Removal of a capturing listener does + * not affect a non-capturing version of the same + * listener, and vice versa. + */ + void removeEventListener(in DOMString type, + in nsIDOMEventListener listener, + [optional] in boolean useCapture); + + /** + * removeSystemEventListener() should be used if you have used + * addSystemEventListener(). + */ + [noscript] void removeSystemEventListener( + in DOMString type, + in nsIDOMEventListener listener, + [optional] in boolean aUseCapture); + + /** + * This method allows the dispatch of events into the implementations + * event model. Events dispatched in this manner will have the same + * capturing and bubbling behavior as events dispatched directly by the + * implementation. The target of the event is the EventTarget on which + * dispatchEvent is called. + * + * @param evt Specifies the event type, behavior, and contextual + * information to be used in processing the event. + * @return Indicates whether any of the listeners which handled the + * event called preventDefault. If preventDefault was called + * the value is false, else the value is true. + * @throws INVALID_STATE_ERR: Raised if the Event's type was + * not specified by initializing the event before + * dispatchEvent was called. Specification of the Event's + * type as null or an empty string will also trigger this + * exception. + */ + boolean dispatchEvent(in nsIDOMEvent evt) + raises(DOMException); + + /** + * Returns the nsIDOMEventTarget object which should be used as the target + * of DOMEvents. + * Usually |this| is returned, but for example global object returns + * the outer object. + */ + [notxpcom, nostdcall] EventTargetPtr GetTargetForDOMEvent(); + + /** + * Returns the nsIDOMEventTarget object which should be used as the target + * of the event and when constructing event target chain. + * Usually |this| is returned, but for example global object returns + * the inner object. + */ + [notxpcom, nostdcall] EventTargetPtr GetTargetForEventTargetChain(); + + /** + * Called before the capture phase of the event flow. + * This is used to create the event target chain and implementations + * should set the necessary members of EventChainPreVisitor. + * At least aVisitor.mCanHandle must be set, + * usually also aVisitor.mParentTarget if mCanHandle is PR_TRUE. + * First one tells that this object can handle the aVisitor.mEvent event and + * the latter one is the possible parent object for the event target chain. + * @see EventDispatcher.h for more documentation about aVisitor. + * + * @param aVisitor the visitor object which is used to create the + * event target chain for event dispatching. + * + * @note Only EventDispatcher should call this method. + */ + [noscript, nostdcall] + void PreHandleEvent(in EventChainPreVisitorRef aVisitor); + + /** + * If EventChainPreVisitor.mWantsWillHandleEvent is set PR_TRUE, + * called just before possible event handlers on this object will be called. + */ + [noscript, nostdcall] + void WillHandleEvent(in EventChainPostVisitorRef aVisitor); + + /** + * Called after the bubble phase of the system event group. + * The default handling of the event should happen here. + * @param aVisitor the visitor object which is used during post handling. + * + * @see EventDispatcher.h for documentation about aVisitor. + * @note Only EventDispatcher should call this method. + */ + [noscript, nostdcall] + void PostHandleEvent(in EventChainPostVisitorRef aVisitor); + + /** + * Dispatch an event. + * @param aEvent the event that is being dispatched. + * @param aDOMEvent the event that is being dispatched, use if you want to + * dispatch nsIDOMEvent, not only WidgetEvent. + * @param aPresContext the current presentation context, can be nullptr. + * @param aEventStatus the status returned from the function, can be nullptr. + * + * @note If both aEvent and aDOMEvent are used, aEvent must be the internal + * event of the aDOMEvent. + * + * If aDOMEvent is not nullptr (in which case aEvent can be nullptr) it is used + * for dispatching, otherwise aEvent is used. + * + * @deprecated This method is here just until all the callers outside Gecko + * have been converted to use nsIDOMEventTarget::dispatchEvent. + */ + [noscript, nostdcall] + void DispatchDOMEvent(in WidgetEventPtr aEvent, + in nsIDOMEvent aDOMEvent, + in nsPresContextPtr aPresContext, + in nsEventStatusPtr aEventStatus); + + /** + * Get the script context in which the event handlers should be run. + * May return null. + * @note Caller *must* check the value of aRv. + */ + [notxpcom, nostdcall] + nsIScriptContext GetContextForEventHandlers(out nsresult aRv); +}; + +%{C++ + +#define NS_IMPL_DOMTARGET_DEFAULTS(_class) \ +mozilla::dom::EventTarget* _class::GetTargetForDOMEvent() { return this; } \ +mozilla::dom::EventTarget* _class::GetTargetForEventTargetChain() { return this; } \ +nsresult _class::WillHandleEvent(mozilla::EventChainPostVisitor& aVisitor) { return NS_OK; } + +#define NS_IMPL_REMOVE_SYSTEM_EVENT_LISTENER(aClass) \ +NS_IMETHODIMP \ +aClass::RemoveSystemEventListener(const nsAString& aType, \ + nsIDOMEventListener *aListener, \ + bool aUseCapture) \ +{ \ + mozilla::EventListenerManager* listenerManager = \ + GetExistingListenerManager(); \ + if (!listenerManager) { \ + return NS_OK; \ + } \ + mozilla::EventListenerFlags flags; \ + flags.mInSystemGroup = true; \ + flags.mCapture = aUseCapture; \ + listenerManager->RemoveEventListenerByType(aListener, aType, flags); \ + return NS_OK; \ +} + +%} diff --git a/dom/interfaces/events/nsIDOMFocusEvent.idl b/dom/interfaces/events/nsIDOMFocusEvent.idl new file mode 100644 index 000000000..78be87ee8 --- /dev/null +++ b/dom/interfaces/events/nsIDOMFocusEvent.idl @@ -0,0 +1,12 @@ +/* -*- Mode: IDL; 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 "nsIDOMUIEvent.idl" + +[builtinclass, uuid(ceab9fcd-2cae-42cb-b692-effa7ec48848)] +interface nsIDOMFocusEvent : nsIDOMUIEvent +{ + readonly attribute nsIDOMEventTarget relatedTarget; +}; diff --git a/dom/interfaces/events/nsIDOMKeyEvent.idl b/dom/interfaces/events/nsIDOMKeyEvent.idl new file mode 100644 index 000000000..ee026232a --- /dev/null +++ b/dom/interfaces/events/nsIDOMKeyEvent.idl @@ -0,0 +1,258 @@ +/* -*- Mode: IDL; 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 "nsIDOMUIEvent.idl" + +[builtinclass, uuid(2e52eb99-670d-469a-b51f-8efee2dd091d)] +interface nsIDOMKeyEvent : nsIDOMUIEvent +{ + const unsigned long DOM_VK_CANCEL = 0x03; + const unsigned long DOM_VK_HELP = 0x06; + const unsigned long DOM_VK_BACK_SPACE = 0x08; + const unsigned long DOM_VK_TAB = 0x09; + const unsigned long DOM_VK_CLEAR = 0x0C; + const unsigned long DOM_VK_RETURN = 0x0D; + // DOM_VK_ENTER has been never used for representing native key events. + // Therefore, it's removed for preventing developers being confused. + // const unsigned long DOM_VK_ENTER = 0x0E; + const unsigned long DOM_VK_SHIFT = 0x10; + const unsigned long DOM_VK_CONTROL = 0x11; + const unsigned long DOM_VK_ALT = 0x12; + const unsigned long DOM_VK_PAUSE = 0x13; + const unsigned long DOM_VK_CAPS_LOCK = 0x14; + const unsigned long DOM_VK_KANA = 0x15; + const unsigned long DOM_VK_HANGUL = 0x15; + const unsigned long DOM_VK_EISU = 0x16; // Japanese Mac keyboard only + const unsigned long DOM_VK_JUNJA = 0x17; + const unsigned long DOM_VK_FINAL = 0x18; + const unsigned long DOM_VK_HANJA = 0x19; + const unsigned long DOM_VK_KANJI = 0x19; + const unsigned long DOM_VK_ESCAPE = 0x1B; + const unsigned long DOM_VK_CONVERT = 0x1C; + const unsigned long DOM_VK_NONCONVERT = 0x1D; + const unsigned long DOM_VK_ACCEPT = 0x1E; + const unsigned long DOM_VK_MODECHANGE = 0x1F; + const unsigned long DOM_VK_SPACE = 0x20; + const unsigned long DOM_VK_PAGE_UP = 0x21; + const unsigned long DOM_VK_PAGE_DOWN = 0x22; + const unsigned long DOM_VK_END = 0x23; + const unsigned long DOM_VK_HOME = 0x24; + const unsigned long DOM_VK_LEFT = 0x25; + const unsigned long DOM_VK_UP = 0x26; + const unsigned long DOM_VK_RIGHT = 0x27; + const unsigned long DOM_VK_DOWN = 0x28; + const unsigned long DOM_VK_SELECT = 0x29; + const unsigned long DOM_VK_PRINT = 0x2A; + const unsigned long DOM_VK_EXECUTE = 0x2B; + const unsigned long DOM_VK_PRINTSCREEN = 0x2C; + const unsigned long DOM_VK_INSERT = 0x2D; + const unsigned long DOM_VK_DELETE = 0x2E; + + // DOM_VK_0 - DOM_VK_9 match their ascii values + const unsigned long DOM_VK_0 = 0x30; + const unsigned long DOM_VK_1 = 0x31; + const unsigned long DOM_VK_2 = 0x32; + const unsigned long DOM_VK_3 = 0x33; + const unsigned long DOM_VK_4 = 0x34; + const unsigned long DOM_VK_5 = 0x35; + const unsigned long DOM_VK_6 = 0x36; + const unsigned long DOM_VK_7 = 0x37; + const unsigned long DOM_VK_8 = 0x38; + const unsigned long DOM_VK_9 = 0x39; + + const unsigned long DOM_VK_COLON = 0x3A; + const unsigned long DOM_VK_SEMICOLON = 0x3B; + const unsigned long DOM_VK_LESS_THAN = 0x3C; + const unsigned long DOM_VK_EQUALS = 0x3D; + const unsigned long DOM_VK_GREATER_THAN = 0x3E; + const unsigned long DOM_VK_QUESTION_MARK = 0x3F; + const unsigned long DOM_VK_AT = 0x40; + + // DOM_VK_A - DOM_VK_Z match their ascii values + const unsigned long DOM_VK_A = 0x41; + const unsigned long DOM_VK_B = 0x42; + const unsigned long DOM_VK_C = 0x43; + const unsigned long DOM_VK_D = 0x44; + const unsigned long DOM_VK_E = 0x45; + const unsigned long DOM_VK_F = 0x46; + const unsigned long DOM_VK_G = 0x47; + const unsigned long DOM_VK_H = 0x48; + const unsigned long DOM_VK_I = 0x49; + const unsigned long DOM_VK_J = 0x4A; + const unsigned long DOM_VK_K = 0x4B; + const unsigned long DOM_VK_L = 0x4C; + const unsigned long DOM_VK_M = 0x4D; + const unsigned long DOM_VK_N = 0x4E; + const unsigned long DOM_VK_O = 0x4F; + const unsigned long DOM_VK_P = 0x50; + const unsigned long DOM_VK_Q = 0x51; + const unsigned long DOM_VK_R = 0x52; + const unsigned long DOM_VK_S = 0x53; + const unsigned long DOM_VK_T = 0x54; + const unsigned long DOM_VK_U = 0x55; + const unsigned long DOM_VK_V = 0x56; + const unsigned long DOM_VK_W = 0x57; + const unsigned long DOM_VK_X = 0x58; + const unsigned long DOM_VK_Y = 0x59; + const unsigned long DOM_VK_Z = 0x5A; + + const unsigned long DOM_VK_WIN = 0x5B; + const unsigned long DOM_VK_CONTEXT_MENU = 0x5D; + const unsigned long DOM_VK_SLEEP = 0x5F; + + // Numpad keys + const unsigned long DOM_VK_NUMPAD0 = 0x60; + const unsigned long DOM_VK_NUMPAD1 = 0x61; + const unsigned long DOM_VK_NUMPAD2 = 0x62; + const unsigned long DOM_VK_NUMPAD3 = 0x63; + const unsigned long DOM_VK_NUMPAD4 = 0x64; + const unsigned long DOM_VK_NUMPAD5 = 0x65; + const unsigned long DOM_VK_NUMPAD6 = 0x66; + const unsigned long DOM_VK_NUMPAD7 = 0x67; + const unsigned long DOM_VK_NUMPAD8 = 0x68; + const unsigned long DOM_VK_NUMPAD9 = 0x69; + const unsigned long DOM_VK_MULTIPLY = 0x6A; + const unsigned long DOM_VK_ADD = 0x6B; + const unsigned long DOM_VK_SEPARATOR = 0x6C; + const unsigned long DOM_VK_SUBTRACT = 0x6D; + const unsigned long DOM_VK_DECIMAL = 0x6E; + const unsigned long DOM_VK_DIVIDE = 0x6F; + + const unsigned long DOM_VK_F1 = 0x70; + const unsigned long DOM_VK_F2 = 0x71; + const unsigned long DOM_VK_F3 = 0x72; + const unsigned long DOM_VK_F4 = 0x73; + const unsigned long DOM_VK_F5 = 0x74; + const unsigned long DOM_VK_F6 = 0x75; + const unsigned long DOM_VK_F7 = 0x76; + const unsigned long DOM_VK_F8 = 0x77; + const unsigned long DOM_VK_F9 = 0x78; + const unsigned long DOM_VK_F10 = 0x79; + const unsigned long DOM_VK_F11 = 0x7A; + const unsigned long DOM_VK_F12 = 0x7B; + const unsigned long DOM_VK_F13 = 0x7C; + const unsigned long DOM_VK_F14 = 0x7D; + const unsigned long DOM_VK_F15 = 0x7E; + const unsigned long DOM_VK_F16 = 0x7F; + const unsigned long DOM_VK_F17 = 0x80; + const unsigned long DOM_VK_F18 = 0x81; + const unsigned long DOM_VK_F19 = 0x82; + const unsigned long DOM_VK_F20 = 0x83; + const unsigned long DOM_VK_F21 = 0x84; + const unsigned long DOM_VK_F22 = 0x85; + const unsigned long DOM_VK_F23 = 0x86; + const unsigned long DOM_VK_F24 = 0x87; + + const unsigned long DOM_VK_NUM_LOCK = 0x90; + const unsigned long DOM_VK_SCROLL_LOCK = 0x91; + + // OEM specific virtual keyCode of Windows should pass through DOM keyCode + // for compatibility with the other web browsers on Windows. + const unsigned long DOM_VK_WIN_OEM_FJ_JISHO = 0x92; + const unsigned long DOM_VK_WIN_OEM_FJ_MASSHOU = 0x93; + const unsigned long DOM_VK_WIN_OEM_FJ_TOUROKU = 0x94; + const unsigned long DOM_VK_WIN_OEM_FJ_LOYA = 0x95; + const unsigned long DOM_VK_WIN_OEM_FJ_ROYA = 0x96; + + const unsigned long DOM_VK_CIRCUMFLEX = 0xA0; + const unsigned long DOM_VK_EXCLAMATION = 0xA1; + const unsigned long DOM_VK_DOUBLE_QUOTE = 0xA2; + const unsigned long DOM_VK_HASH = 0xA3; + const unsigned long DOM_VK_DOLLAR = 0xA4; + const unsigned long DOM_VK_PERCENT = 0xA5; + const unsigned long DOM_VK_AMPERSAND = 0xA6; + const unsigned long DOM_VK_UNDERSCORE = 0xA7; + const unsigned long DOM_VK_OPEN_PAREN = 0xA8; + const unsigned long DOM_VK_CLOSE_PAREN = 0xA9; + const unsigned long DOM_VK_ASTERISK = 0xAA; + const unsigned long DOM_VK_PLUS = 0xAB; + const unsigned long DOM_VK_PIPE = 0xAC; + const unsigned long DOM_VK_HYPHEN_MINUS = 0xAD; + + const unsigned long DOM_VK_OPEN_CURLY_BRACKET = 0xAE; + const unsigned long DOM_VK_CLOSE_CURLY_BRACKET = 0xAF; + + const unsigned long DOM_VK_TILDE = 0xB0; + + const unsigned long DOM_VK_VOLUME_MUTE = 0xB5; + const unsigned long DOM_VK_VOLUME_DOWN = 0xB6; + const unsigned long DOM_VK_VOLUME_UP = 0xB7; + + const unsigned long DOM_VK_COMMA = 0xBC; + const unsigned long DOM_VK_PERIOD = 0xBE; + const unsigned long DOM_VK_SLASH = 0xBF; + const unsigned long DOM_VK_BACK_QUOTE = 0xC0; + const unsigned long DOM_VK_OPEN_BRACKET = 0xDB; // square bracket + const unsigned long DOM_VK_BACK_SLASH = 0xDC; + const unsigned long DOM_VK_CLOSE_BRACKET = 0xDD; // square bracket + const unsigned long DOM_VK_QUOTE = 0xDE; // Apostrophe + + const unsigned long DOM_VK_META = 0xE0; + const unsigned long DOM_VK_ALTGR = 0xE1; + + // OEM specific virtual keyCode of Windows should pass through DOM keyCode + // for compatibility with the other web browsers on Windows. + const unsigned long DOM_VK_WIN_ICO_HELP = 0xE3; + const unsigned long DOM_VK_WIN_ICO_00 = 0xE4; + const unsigned long DOM_VK_WIN_ICO_CLEAR = 0xE6; + const unsigned long DOM_VK_WIN_OEM_RESET = 0xE9; + const unsigned long DOM_VK_WIN_OEM_JUMP = 0xEA; + const unsigned long DOM_VK_WIN_OEM_PA1 = 0xEB; + const unsigned long DOM_VK_WIN_OEM_PA2 = 0xEC; + const unsigned long DOM_VK_WIN_OEM_PA3 = 0xED; + const unsigned long DOM_VK_WIN_OEM_WSCTRL = 0xEE; + const unsigned long DOM_VK_WIN_OEM_CUSEL = 0xEF; + const unsigned long DOM_VK_WIN_OEM_ATTN = 0xF0; + const unsigned long DOM_VK_WIN_OEM_FINISH = 0xF1; + const unsigned long DOM_VK_WIN_OEM_COPY = 0xF2; + const unsigned long DOM_VK_WIN_OEM_AUTO = 0xF3; + const unsigned long DOM_VK_WIN_OEM_ENLW = 0xF4; + const unsigned long DOM_VK_WIN_OEM_BACKTAB = 0xF5; + + // Following keys are not used on most keyboards. However, for compatibility + // with other browsers on Windows, we should define them. + const unsigned long DOM_VK_ATTN = 0xF6; + const unsigned long DOM_VK_CRSEL = 0xF7; + const unsigned long DOM_VK_EXSEL = 0xF8; + const unsigned long DOM_VK_EREOF = 0xF9; + const unsigned long DOM_VK_PLAY = 0xFA; + const unsigned long DOM_VK_ZOOM = 0xFB; + const unsigned long DOM_VK_PA1 = 0xFD; + + // OEM specific virtual keyCode of Windows should pass through DOM keyCode + // for compatibility with the other web browsers on Windows. + const unsigned long DOM_VK_WIN_OEM_CLEAR = 0xFE; + + readonly attribute unsigned long charCode; + readonly attribute unsigned long keyCode; + + readonly attribute boolean altKey; + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean metaKey; + + void initKeyEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in mozIDOMWindow viewArg, + in boolean ctrlKeyArg, + in boolean altKeyArg, + in boolean shiftKeyArg, + in boolean metaKeyArg, + in unsigned long keyCodeArg, + in unsigned long charCodeArg); + + bool getModifierState(in DOMString keyArg); + + const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00; + const unsigned long DOM_KEY_LOCATION_LEFT = 0x01; + const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02; + const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03; + + readonly attribute unsigned long location; + readonly attribute boolean repeat; + + readonly attribute DOMString key; +}; diff --git a/dom/interfaces/events/nsIDOMMouseEvent.idl b/dom/interfaces/events/nsIDOMMouseEvent.idl new file mode 100644 index 000000000..3452f32fe --- /dev/null +++ b/dom/interfaces/events/nsIDOMMouseEvent.idl @@ -0,0 +1,69 @@ +/* -*- Mode: IDL; 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 "nsIDOMUIEvent.idl" + +/** + * The nsIDOMMouseEvent interface is the datatype for all mouse events + * in the Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + */ + +[builtinclass, uuid(5bdab8d8-7933-4c5c-b6d1-ab34481237f7)] +interface nsIDOMMouseEvent : nsIDOMUIEvent +{ + readonly attribute long screenX; + readonly attribute long screenY; + + readonly attribute long mozMovementX; + readonly attribute long mozMovementY; + + readonly attribute long clientX; + readonly attribute long clientY; + + readonly attribute boolean ctrlKey; + readonly attribute boolean shiftKey; + readonly attribute boolean altKey; + readonly attribute boolean metaKey; + + readonly attribute short button; + readonly attribute unsigned short buttons; + readonly attribute nsIDOMEventTarget relatedTarget; + + void initMouseEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in mozIDOMWindow viewArg, + in long detailArg, + in long screenXArg, + in long screenYArg, + in long clientXArg, + in long clientYArg, + in boolean ctrlKeyArg, + in boolean altKeyArg, + in boolean shiftKeyArg, + in boolean metaKeyArg, + in unsigned short buttonArg, + in nsIDOMEventTarget relatedTargetArg); + + + // Finger or touch pressure event value + // ranges between 0.0 and 1.0 + readonly attribute float mozPressure; + + const unsigned short MOZ_SOURCE_UNKNOWN = 0; + const unsigned short MOZ_SOURCE_MOUSE = 1; + const unsigned short MOZ_SOURCE_PEN = 2; + const unsigned short MOZ_SOURCE_ERASER = 3; + const unsigned short MOZ_SOURCE_CURSOR = 4; + const unsigned short MOZ_SOURCE_TOUCH = 5; + const unsigned short MOZ_SOURCE_KEYBOARD = 6; + + readonly attribute unsigned short mozInputSource; + + bool getModifierState(in DOMString keyArg); +}; diff --git a/dom/interfaces/events/nsIDOMMouseScrollEvent.idl b/dom/interfaces/events/nsIDOMMouseScrollEvent.idl new file mode 100644 index 000000000..cd159680f --- /dev/null +++ b/dom/interfaces/events/nsIDOMMouseScrollEvent.idl @@ -0,0 +1,13 @@ +/* -*- Mode: IDL; 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 "nsIDOMMouseEvent.idl" + +[builtinclass, uuid(327bdd54-f772-4015-b856-9692154a066c)] +interface nsIDOMMouseScrollEvent : nsIDOMMouseEvent +{ + const long HORIZONTAL_AXIS = 1; + const long VERTICAL_AXIS = 2; +}; diff --git a/dom/interfaces/events/nsIDOMMutationEvent.idl b/dom/interfaces/events/nsIDOMMutationEvent.idl new file mode 100644 index 000000000..6b1b136f3 --- /dev/null +++ b/dom/interfaces/events/nsIDOMMutationEvent.idl @@ -0,0 +1,29 @@ +/* -*- Mode: IDL; 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" +#include "nsIDOMNode.idl" + +[builtinclass, uuid(30c9997f-bc4c-4890-b890-febb6ae3051b)] +interface nsIDOMMutationEvent : nsISupports +{ + const unsigned short MODIFICATION = 1; + const unsigned short ADDITION = 2; + const unsigned short REMOVAL = 3; + + readonly attribute nsIDOMNode relatedNode; + readonly attribute DOMString prevValue; + readonly attribute DOMString newValue; + readonly attribute DOMString attrName; + readonly attribute unsigned short attrChange; + void initMutationEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in nsIDOMNode relatedNodeArg, + in DOMString prevValueArg, + in DOMString newValueArg, + in DOMString attrNameArg, + in unsigned short attrChangeArg); +}; diff --git a/dom/interfaces/events/nsIDOMNSEvent.idl b/dom/interfaces/events/nsIDOMNSEvent.idl new file mode 100644 index 000000000..49e2ae6db --- /dev/null +++ b/dom/interfaces/events/nsIDOMNSEvent.idl @@ -0,0 +1,21 @@ +/* -*- Mode: IDL; 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 "domstubs.idl" + +%{C++ +#ifdef ERROR +#undef ERROR +#endif +%} + +[uuid(2580b4a2-6d85-4ca6-9be2-98f3406ad296)] +interface nsIDOMNSEvent : nsISupports +{ + const long ALT_MASK = 0x00000001; + const long CONTROL_MASK = 0x00000002; + const long SHIFT_MASK = 0x00000004; + const long META_MASK = 0x00000008; +}; diff --git a/dom/interfaces/events/nsIDOMNotifyPaintEvent.idl b/dom/interfaces/events/nsIDOMNotifyPaintEvent.idl new file mode 100644 index 000000000..6df07a1c8 --- /dev/null +++ b/dom/interfaces/events/nsIDOMNotifyPaintEvent.idl @@ -0,0 +1,41 @@ +/* -*- Mode: IDL; 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" +#include "nsIDOMClientRectList.idl" +#include "nsIDOMClientRect.idl" + +interface nsIDOMPaintRequestList; + +/** + * The nsIDOMNotifyPaintEvent interface is used for the MozDOMAfterPaint + * event, which fires at a window when painting has happened in + * that window. + */ +[builtinclass, uuid(63f573a0-3e4e-474b-a0c2-bb4ca93febaa)] +interface nsIDOMNotifyPaintEvent : nsISupports +{ + /** + * Get a list of rectangles which are affected. The rectangles are in CSS pixels + * relative to the viewport origin. + * If the caller is not trusted (e.g., regular Web content) then only painting + * caused by the current document is reported; in particular, painting in subdocuments + * is not reported. + */ + readonly attribute nsIDOMClientRectList clientRects; + /** + * Get the bounding box of the rectangles which are affected. The rectangle + * is in CSS pixels relative to the viewport origin. + * If the caller is not trusted (e.g., regular Web content) then only painting + * caused by the current document is reported; in particular, painting in subdocuments + * is not reported. + */ + readonly attribute nsIDOMClientRect boundingClientRect; + + readonly attribute nsISupports /* PaintRequestList */ paintRequests; + + readonly attribute unsigned long long transactionId; +}; + diff --git a/dom/interfaces/events/nsIDOMPaintRequest.idl b/dom/interfaces/events/nsIDOMPaintRequest.idl new file mode 100644 index 000000000..64f107ed9 --- /dev/null +++ b/dom/interfaces/events/nsIDOMPaintRequest.idl @@ -0,0 +1,30 @@ +/* -*- Mode: IDL; 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 "domstubs.idl" + +interface nsIDOMClientRect; + +/** + * These objects are exposed by the MozDOMAfterPaint event. Each one represents + * a request to repaint a rectangle that was generated by the browser. + */ +[uuid(9eb5268f-73a4-41da-9790-d21fcefd5ffa)] +interface nsIDOMPaintRequest : nsISupports +{ + /** + * The client rect where invalidation was triggered. + */ + readonly attribute nsIDOMClientRect clientRect; + /** + * The reason for the request, as a string. If an empty string, then we don't know + * the reason (this is common). Reasons include "scroll repaint", meaning that we + * needed to repaint the rectangle due to scrolling, and "scroll copy", meaning + * that we updated the rectangle due to scrolling but instead of painting + * manually, we were able to do a copy from another area of the screen. + */ + [binaryname(XPCOMReason)] + readonly attribute DOMString reason; +}; diff --git a/dom/interfaces/events/nsIDOMScrollAreaEvent.idl b/dom/interfaces/events/nsIDOMScrollAreaEvent.idl new file mode 100644 index 000000000..56f4c5938 --- /dev/null +++ b/dom/interfaces/events/nsIDOMScrollAreaEvent.idl @@ -0,0 +1,11 @@ +/* -*- Mode: IDL; 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 "nsIDOMUIEvent.idl" + +[builtinclass, uuid(5883e564-e676-4652-9421-7df6132016b2)] +interface nsIDOMScrollAreaEvent : nsIDOMUIEvent +{ +}; diff --git a/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl b/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl new file mode 100644 index 000000000..bc4a395bf --- /dev/null +++ b/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl @@ -0,0 +1,182 @@ +/* -*- Mode: IDL; 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 "nsIDOMMouseEvent.idl" + +/** + * The nsIDOMSimpleGestureEvent interface is the datatype for all + * Mozilla-specific simple gesture events in the Document Object Model. + * + * The following events are generated: + * + * MozSwipeGestureMayStart - Generated when the user starts a horizontal + * swipe across the input device, but before we know whether the user + * is actually scrolling past a scroll edge. + * This event asks two questions: Should a swipe really be started, and + * in which directions should the user be able to swipe? The first + * question is answered by event listeners by calling or not calling + * preventDefault() on the event. Since a swipe swallows all scroll + * events, the default action of the swipe start event is *not* to + * start a swipe. Call preventDefault() if you want a swipe to be + * started. Doing so won't necessarily result in a swipe being started, + * it only communicates an intention. Once Gecko determines whether a + * swipe should actually be started, it will send a MozSwipeGestureStart + * event. + * The second question (swipe-able directions) is answered in the + * allowedDirections field. + * + * MozSwipeGestureStart - This event signals the start of a swipe. + * It guarantees a future MozSwipeGestureEnd event that will signal + * the end of a swipe animation. + * + * MozSwipeGestureUpdate - Generated periodically while the user is + * continuing a horizontal swipe gesture. The "delta" value represents + * the current absolute gesture amount. This event may even be sent + * after a MozSwipeGesture event fired in order to allow for fluid + * completion of a swipe animation. The direction value is meaningless + * on swipe update events. + * + * MozSwipeGestureEnd - Generated when the swipe animation is completed. + * + * MozSwipeGesture - Generated when the user releases a swipe across + * across the input device. This event signals that the actual swipe + * operation is complete, even though the animation might not be finished + * yet. This event can be sent without accompanying start / update / end + * events, and it can also be handled on its own if the consumer doesn't + * want to handle swipe animation events. + * Only the direction value has any significance, the delta value is + * meaningless. + * + * MozMagnifyGestureStart - Generated when the user begins the magnify + * ("pinch") gesture. The "delta" value represents the initial + * movement. + * + * MozMagnifyGestureUpdate - Generated periodically while the user is + * continuing the magnify ("pinch") gesture. The "delta" value + * represents the movement since the last MozMagnifyGestureStart or + * MozMagnifyGestureUpdate event. + * + * MozMagnifyGesture - Generated when the user has completed the + * magnify ("pinch") gesture. If you only want to receive a single + * event when the magnify gesture is complete, you only need to hook + * this event and can safely ignore the MozMagnifyGestureStart and the + * MozMagnifyGestureUpdate events. The "delta" value is the cumulative + * amount represented by the user's gesture. + * + * MozRotateGestureStart - Generated when the user begins the rotation + * gesture. The "delta" value represents the initial rotation. + * + * MozRotateGestureUpdate - Generated periodically while the user is + * continuing the rotation gesture. The "delta" value represents the + * rotation since the last MozRotateGestureStart or + * MozRotateGestureUpdate event. + * + * MozRotateGesture - Generated when the user has completed the + * rotation gesture. If you only want to receive a single event when + * the rotation gesture is complete, you only need to hook this event + * and can safely ignore the MozRotateGestureStart and the + * MozRotateGestureUpdate events. The "delta" value is the cumulative + * amount of rotation represented by the user's gesture. + * + * MozTapGesture - Generated when the user executes a two finger + * tap gesture on the input device. Client coordinates contain the + * center point of the tap. + * (XXX On OS X, only Lion (10.7) and up) + * + * MozPressTapGesture - Generated when the user executes a press + * and tap two finger gesture (first finger down, second finger down, + * second finger up, first finger up) on the input device. + * Client coordinates contain the center pivot point of the action. + * (XXX Not implemented on Mac) + * + * MozEdgeUIGesture - Generated when the user swipes the display to + * invoke edge ui. + * (XXX Win8 only) + * + * Default behavior: + * + * Some operating systems support default behaviors for gesture events + * when they are not handled by the application. Consumers should + * use event.preventDefault() to prevent default behavior when + * consuming events. + */ + +[builtinclass, uuid(c397f9a2-4266-4291-b282-3efd6d7afc57)] +interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent +{ + /* Swipe direction constants */ + const unsigned long DIRECTION_UP = 1; + const unsigned long DIRECTION_DOWN = 2; + const unsigned long DIRECTION_LEFT = 4; + const unsigned long DIRECTION_RIGHT = 8; + + /* Rotational direction constants */ + const unsigned long ROTATION_COUNTERCLOCKWISE = 1; + const unsigned long ROTATION_CLOCKWISE = 2; + + /* Read-write value for swipe events. + * + * Reports the directions that can be swiped to; multiple directions + * should be OR'ed together. + * + * The allowedDirections field is designed to be set on SwipeGestureMayStart + * events by event listeners. Its value after event dispatch determines + * the behavior of the swipe animation that might be about to begin. + * Specifically, if the user swipes in a direction that can't be swiped + * to, the animation will have a bounce effect. + * Future SwipeGestureUpdate, SwipeGesture and SwipeGestureEnd events + * will carry the allowDirections value that was set on the SwipeMayStart + * event. Changing this field on non-SwipeGestureMayStart events doesn't + * have any effect. + */ + attribute unsigned long allowedDirections; + + /* Direction of a gesture. Diagonals are indicated by OR'ing the + * applicable constants together. + * + * Swipes gestures may occur in any direction. + * + * Magnify gestures do not have a direction. + * + * Rotation gestures will be either ROTATION_COUNTERCLOCKWISE or + * ROTATION_CLOCKWISE. + */ + readonly attribute unsigned long direction; + + /* Delta value for magnify, rotate and swipe gestures. + * + * For rotation, the value is in degrees and is positive for + * clockwise rotation and negative for counterclockwise + * rotation. + * + * For magnification, the value will be positive for a "zoom in" + * (i.e, increased magnification) and negative for a "zoom out" + * (i.e., decreased magnification). The particular units + * represented by the "delta" are currently implementation specific. + * + * XXX - The units for measuring magnification are currently + * unspecified because the units used by Mac OS X are currently + * undocumented. The values are typically in the range of 0.0 to + * 100.0, but it is only safe currently to rely on the delta being + * positive or negative. + * + * For swipe start, update and end events, the value is a fraction + * of one "page". If the resulting swipe will have DIRECTION_LEFT, the + * delta value will be positive; for DIRECTION_RIGHT, delta is negative. + * If this seems backwards to you, look at it this way: If the current + * page is pushed to the right during the animation (positive delta), + * the page left to the current page will be visible after the swipe + * (DIRECTION_LEFT). + * + * Units on Windows represent the difference between the initial + * and current/final width between the two touch points on the input + * device and are measured in pixels. + */ + readonly attribute double delta; + + /* Click count value for taps. */ + readonly attribute unsigned long clickCount; +}; diff --git a/dom/interfaces/events/nsIDOMTransitionEvent.idl b/dom/interfaces/events/nsIDOMTransitionEvent.idl new file mode 100644 index 000000000..5809d1427 --- /dev/null +++ b/dom/interfaces/events/nsIDOMTransitionEvent.idl @@ -0,0 +1,19 @@ +/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ +/* 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" + +/** + * Transition events are defined in: + * http://www.w3.org/TR/css3-transitions/#transition-events- + * http://dev.w3.org/csswg/css3-transitions/#transition-events- + */ + +[builtinclass, uuid(ee3499bf-0f14-4bb6-829c-19ad24fd4a85)] +interface nsIDOMTransitionEvent : nsISupports { + readonly attribute DOMString propertyName; + readonly attribute float elapsedTime; + readonly attribute DOMString pseudoElement; +}; diff --git a/dom/interfaces/events/nsIDOMUIEvent.idl b/dom/interfaces/events/nsIDOMUIEvent.idl new file mode 100644 index 000000000..a44fdb2f9 --- /dev/null +++ b/dom/interfaces/events/nsIDOMUIEvent.idl @@ -0,0 +1,55 @@ +/* -*- Mode: IDL; 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" +#include "nsIDOMWindow.idl" + +interface mozIDOMWindow; +interface mozIDOMWindowProxy; + +/** + * The nsIDOMUIEvent interface is the datatype for all UI events in the + * Document Object Model. + * + * For more information on this interface please see + * http://www.w3.org/TR/DOM-Level-2-Events/ + */ + +%{C++ +namespace mozilla { +namespace dom { +class Event; +} +} +%} + +[ptr] native EventPtr(mozilla::dom::Event); + +[builtinclass, uuid(85ae52eb-37fa-4fd9-a2e6-c7d0f2a521b3)] +interface nsIDOMUIEvent : nsISupports +{ + readonly attribute mozIDOMWindowProxy view; + readonly attribute long detail; + void initUIEvent(in DOMString typeArg, + in boolean canBubbleArg, + in boolean cancelableArg, + in mozIDOMWindow viewArg, + in long detailArg); + + const long SCROLL_PAGE_UP = -32768; + const long SCROLL_PAGE_DOWN = 32768; + + readonly attribute long layerX; + readonly attribute long layerY; + readonly attribute long pageX; + readonly attribute long pageY; + readonly attribute unsigned long which; + readonly attribute nsIDOMNode rangeParent; + readonly attribute long rangeOffset; + + readonly attribute boolean isChar; + + [notxpcom, nostdcall] EventPtr AsEvent(); +}; diff --git a/dom/interfaces/events/nsIDOMWheelEvent.idl b/dom/interfaces/events/nsIDOMWheelEvent.idl new file mode 100644 index 000000000..2416bc070 --- /dev/null +++ b/dom/interfaces/events/nsIDOMWheelEvent.idl @@ -0,0 +1,15 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* 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 "nsIDOMMouseEvent.idl" + +[builtinclass, uuid(d320d075-b29d-4edd-b3a3-3ffd460640de)] +interface nsIDOMWheelEvent : nsIDOMMouseEvent +{ + const unsigned long DOM_DELTA_PIXEL = 0x00; + const unsigned long DOM_DELTA_LINE = 0x01; + const unsigned long DOM_DELTA_PAGE = 0x02; +}; |