diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/interfaces/base | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/interfaces/base')
32 files changed, 4909 insertions, 0 deletions
diff --git a/dom/interfaces/base/domstubs.idl b/dom/interfaces/base/domstubs.idl new file mode 100644 index 000000000..4422b791e --- /dev/null +++ b/dom/interfaces/base/domstubs.idl @@ -0,0 +1,81 @@ +/* -*- 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" + +%{C++ +class nsWrapperCache; +%} + +[ptr] native nsWrapperCachePtr(nsWrapperCache); + +typedef unsigned long long DOMTimeStamp; +typedef double DOMHighResTimeStamp; + +// Core +interface nsIDOMAttr; +interface nsIDOMCDATASection; +interface nsIDOMCharacterData; +interface nsIDOMComment; +interface nsIDOMDOMImplementation; +interface nsIDOMDocument; +interface nsIDOMDocumentFragment; +interface nsIDOMDocumentType; +interface nsIDOMElement; +interface nsIDOMNode; +interface nsIDOMNodeList; +interface nsIDOMProcessingInstruction; +interface nsIDOMText; +interface nsIDOMClientRect; +interface nsIDOMClientRectList; + +// Needed for raises() in our IDL +interface DOMException; + +// Style Sheets +interface nsIDOMStyleSheetList; +interface nsIDOMStyleSheet; +interface nsIDOMMediaList; + +// Base +interface nsIDOMWindow; +interface nsIDOMWindowCollection; +interface nsIDOMNavigator; +interface nsIDOMScreen; + +// Events +interface nsIDOMEvent; +interface nsIDOMEventTarget; +interface nsIDOMEventListener; + +// HTML +interface nsIDOMHTMLElement; +interface nsIDOMHTMLFormElement; +interface nsIDOMHTMLCollection; +interface nsIDOMHTMLHeadElement; + +// CSS +interface nsIDOMCSSValue; +interface nsIDOMCSSPrimitiveValue; +interface nsIDOMCSSRule; +interface nsIDOMCSSRuleList; +interface nsIDOMCSSKeyframeRule; +interface nsIDOMCSSFontFeatureValuesRule; +interface nsIDOMCSSStyleSheet; +interface nsIDOMCSSStyleDeclaration; +interface nsIDOMCounter; +interface nsIDOMRect; +interface nsIDOMCSSStyleRule; +interface nsIDOMCSSStyleRuleCollection; + +// Range +interface nsIDOMRange; + +// Crypto +interface nsIDOMCrypto; + +// Used font face (for inspector) +interface nsIDOMFontFace; +interface nsIDOMFontFaceList; diff --git a/dom/interfaces/base/moz.build b/dom/interfaces/base/moz.build new file mode 100644 index 000000000..e96fc0158 --- /dev/null +++ b/dom/interfaces/base/moz.build @@ -0,0 +1,42 @@ +# -*- 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 += [ + 'domstubs.idl', + 'nsIBrowser.idl', + 'nsIBrowserDOMWindow.idl', + 'nsIContentPermissionPrompt.idl', + 'nsIContentPrefService.idl', + 'nsIContentPrefService2.idl', + 'nsIContentURIGrouper.idl', + 'nsIDOMChromeWindow.idl', + 'nsIDOMClientRect.idl', + 'nsIDOMClientRectList.idl', + 'nsIDOMConstructor.idl', + 'nsIDOMCrypto.idl', + 'nsIDOMGlobalPropertyInitializer.idl', + 'nsIDOMHistory.idl', + 'nsIDOMLocation.idl', + 'nsIDOMModalContentWindow.idl', + 'nsIDOMNavigator.idl', + 'nsIDOMScreen.idl', + 'nsIDOMWindow.idl', + 'nsIDOMWindowCollection.idl', + 'nsIDOMWindowUtils.idl', + 'nsIFocusManager.idl', + 'nsIIdleObserver.idl', + 'nsIQueryContentEventResult.idl', + 'nsIRemoteBrowser.idl', + 'nsIServiceWorkerManager.idl', + 'nsIStructuredCloneContainer.idl', + 'nsITabChild.idl', + 'nsITabParent.idl', + 'nsITextInputProcessor.idl', + 'nsITextInputProcessorCallback.idl', +] + +XPIDL_MODULE = 'dom_base' + diff --git a/dom/interfaces/base/nsIBrowser.idl b/dom/interfaces/base/nsIBrowser.idl new file mode 100644 index 000000000..44ae9b0a2 --- /dev/null +++ b/dom/interfaces/base/nsIBrowser.idl @@ -0,0 +1,46 @@ +/* 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 nsIDOMElement; + +[scriptable, uuid(14e5a0cb-e223-4202-95e8-fe53275193ea)] +interface nsIBrowser : nsISupports +{ + /** + * Gets a related browser for a given browser (if any). If this exists, then + * we should attempt to use the same content parent as its frameLoader + * for any new tab parents. + */ + readonly attribute nsIDOMElement relatedBrowser; + + /* + * Called by the child to inform the parent that links are dropped into + * content area. + * + * @param linksCount length of links + * @param links a flat array of url, name, and type for each link + */ + void dropLinks(in unsigned long linksCount, + [array, size_is(linksCount)] in wstring links); + + /** + * Swapping of frameloaders are usually initiated from a frameloader owner + * or other components operating on frameloader owners. This is done by calling + * swapFrameLoaders at MozFrameLoaderOwner webidl interface. + * + * This function aimed to provide the other way around - + * if the swapping is initiated from frameloader itself or other platform level + * components, it uses this interface to delegate the swapping request to + * frameloader owners and ask them to re-initiate frameloader swapping, so that + * frameloader owners such as <xul:browser> can setup their properties and / + * or listeners properly on swapping. + */ + void swapBrowsers(in nsIBrowser aOtherBrowser); + + /** + * Close the browser (usually means to remove a tab). + */ + void closeBrowser(); +}; diff --git a/dom/interfaces/base/nsIBrowserDOMWindow.idl b/dom/interfaces/base/nsIBrowserDOMWindow.idl new file mode 100644 index 000000000..bc64bf783 --- /dev/null +++ b/dom/interfaces/base/nsIBrowserDOMWindow.idl @@ -0,0 +1,129 @@ +/* -*- 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" + +interface mozIDOMWindowProxy; +interface nsIDOMWindow; +interface nsIURI; +interface nsIFrameLoaderOwner; + +[scriptable, uuid(e774db14-79ac-4156-a7a3-aa3fd0a22c10)] +interface nsIOpenURIInFrameParams : nsISupports +{ + attribute DOMString referrer; + attribute boolean isPrivate; + + [implicit_jscontext] + readonly attribute jsval openerOriginAttributes; +}; + +[scriptable, uuid(9d17f3dd-672b-451e-afd2-b1115df780d5)] + +/** + * The C++ source has access to the browser script source through + * nsIBrowserDOMWindow. It is intended to be attached to the chrome DOMWindow + * of a toplevel browser window (a XUL window). A DOMWindow that does not + * happen to be a browser chrome window will simply have no access to any such + * interface. + */ +interface nsIBrowserDOMWindow : nsISupports +{ + /** + * Values for openURI's aWhere parameter. + */ + /** + * Do whatever the default is based on application state, user preferences, + * and the value of the aContext parameter to openURI. + */ + const short OPEN_DEFAULTWINDOW = 0; + /** + * Open in the "current window". If aOpener is provided, this should be the + * top window in aOpener's window hierarchy, but exact behavior is + * application-dependent. If aOpener is not provided, it's up to the + * application to decide what constitutes a "current window". + */ + const short OPEN_CURRENTWINDOW = 1; + /** + * Open in a new window. + */ + const short OPEN_NEWWINDOW = 2; + /** + * Open in a new content tab in the toplevel browser window corresponding to + * this nsIBrowserDOMWindow. + */ + const short OPEN_NEWTAB = 3; + /** + * Open in an existing content tab based on the URI. If a match can't be + * found, revert to OPEN_NEWTAB behavior. + */ + const short OPEN_SWITCHTAB = 4; + + /** + * Values for openURI's aFlags parameter. This is a bitflags field. + * + * The 0x1 bit decides the behavior of OPEN_DEFAULTWINDOW, and the 0x4 bit + * controls whether or not to set the window.opener property on the newly + * opened window. + * + * NOTE: The 0x2 bit is ignored for backwards compatibility with addons, as + * OPEN_NEW used to have the value 2. The values 0 and 2 are treated + * the same way internally. + */ + /** + * internal open new window + */ + const long OPEN_NEW = 0x0; + /** + * external link (load request from another application, xremote, etc). + */ + const long OPEN_EXTERNAL = 0x1; + + /** + * Don't set the window.opener property on the window which is being opened + */ + const long OPEN_NO_OPENER = 0x4; + + /** + * Load a URI + + * @param aURI the URI to open. null is allowed. If null is passed in, no + * load will be done, though the window the load would have + * happened in will be returned. + * @param aWhere see possible values described above. + * @param aOpener window requesting the open (can be null). + * @param aFlags flags which control the behavior of the load. The + * OPEN_EXTERNAL/OPEN_NEW flag is only used when + * aWhere == OPEN_DEFAULTWINDOW. + * @return the window into which the URI was opened. + */ + mozIDOMWindowProxy + openURI(in nsIURI aURI, in mozIDOMWindowProxy aOpener, + in short aWhere, in long aFlags); + + /** + * As above, but return the nsIFrameLoaderOwner for the new window. + // XXXbz is this the right API? + // See bug 537428 + */ + nsIFrameLoaderOwner openURIInFrame(in nsIURI aURI, in nsIOpenURIInFrameParams params, + in short aWhere, in long aFlags); + + /** + * @param aWindow the window to test. + * @return whether the window is the main content window for any + * currently open tab in this toplevel browser window. + */ + boolean isTabContentWindow(in nsIDOMWindow aWindow); + + /** + * This function is responsible for calling + * nsIContentViewer::PermitUnload on each frame in the window. It + * returns true if closing the window is allowed. See canClose() in + * BrowserUtils.jsm for a simple implementation of this method. + */ + boolean canClose(); +}; + diff --git a/dom/interfaces/base/nsIContentPermissionPrompt.idl b/dom/interfaces/base/nsIContentPermissionPrompt.idl new file mode 100644 index 000000000..8a593e37e --- /dev/null +++ b/dom/interfaces/base/nsIContentPermissionPrompt.idl @@ -0,0 +1,119 @@ +/* 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 nsIPrincipal; +interface mozIDOMWindow; +interface nsIDOMElement; +interface nsIArray; + +/** + * Interface provides the request type and its access. + */ +[scriptable, uuid(ef4db3b8-ca9c-4b1d-8f81-fd88ec32af13)] +interface nsIContentPermissionType : nsISupports { + /** + * The type of the permission request, such as + * "geolocation". + */ + readonly attribute ACString type; + + /** + * The access of the permission request, such as + * "read". + */ + readonly attribute ACString access; + + /** + * The array of available options. + */ + readonly attribute nsIArray options; // ["choice1", "choice2"] +}; + +/** + * Interface provides the callback type. + */ +[scriptable, uuid(5fb5bb60-7069-11e4-9803-0800200c9a66)] +interface nsIContentPermissionRequestCallback : nsISupports { + /** + * The callback of the visibility result. + */ + void notifyVisibility(in boolean isVisible); +}; + +/** + * Interface provides the way to get the visibility and + * the notification. + */ +[scriptable, uuid(f8577124-6a5f-486f-ae04-c5bcae911eb5)] +interface nsIContentPermissionRequester : nsISupports { + /** + * The function to get the visibility. + */ + void getVisibility(in nsIContentPermissionRequestCallback callback); + + /** + * The callback to get the notification of visibility change. + */ + attribute nsIContentPermissionRequestCallback onVisibilityChange; +}; + +/** + * Interface allows access to a content to request + * permission to perform a privileged operation such as + * geolocation. + */ +[scriptable, uuid(875733da-0ac0-4a26-8c76-70a30876be46)] +interface nsIContentPermissionRequest : nsISupports { + /** + * The array will include the request types. Elements of this array are + * nsIContentPermissionType object. + */ + readonly attribute nsIArray types; + + /* + * The principal of the permission request. + */ + readonly attribute nsIPrincipal principal; + + /** + * The window or element that the permission request was + * originated in. Typically the element will be non-null + * in when using out of process content. window or + * element can be null but not both. + */ + readonly attribute mozIDOMWindow window; + readonly attribute nsIDOMElement element; + + /** + * The requester to get the required information of + * the window. + */ + readonly attribute nsIContentPermissionRequester requester; + + /** + * allow or cancel the request + */ + + void cancel(); + void allow([optional] in jsval choices); // {"type1": "choice1", "type2": "choiceA"} +}; + +/** + * Interface provides a way for the application to handle + * the UI prompts associated with geo position. + */ +[scriptable, function, uuid(F72DE90D-E954-4E69-9A61-917303029301)] +interface nsIContentPermissionPrompt : nsISupports { + /** + * Called when a request has been made to access + * privileged content apis + */ + void prompt(in nsIContentPermissionRequest request); +}; + +%{C++ +#define NS_CONTENT_PERMISSION_PROMPT_CONTRACTID "@mozilla.org/content-permission/prompt;1" +%} diff --git a/dom/interfaces/base/nsIContentPrefService.idl b/dom/interfaces/base/nsIContentPrefService.idl new file mode 100644 index 000000000..9c3cf3665 --- /dev/null +++ b/dom/interfaces/base/nsIContentPrefService.idl @@ -0,0 +1,263 @@ +/* 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; +interface nsIPropertyBag2; +interface nsIContentURIGrouper; +interface nsILoadContext; +interface mozIStorageConnection; + +[scriptable, uuid(43635c53-b445-4c4e-8cc5-562697299b55)] +interface nsIContentPrefObserver : nsISupports +{ + /** + * Called when a content pref is set to a different value. + * + * @param aGroup the group to which the pref belongs, or null + * if it's a global pref (applies to all sites) + * @param aName the name of the pref that was set + * @param aValue the new value of the pref + * @param aIsPrivate an optional flag determining whether the + * original context is private or not + */ + void onContentPrefSet(in AString aGroup, + in AString aName, + in nsIVariant aValue, + [optional] in boolean aIsPrivate); + + /** + * Called when a content pref is removed. + * + * @param aGroup the group to which the pref belongs, or null + * if it's a global pref (applies to all sites) + * @param aName the name of the pref that was removed + * @param aIsPrivate an optional flag determining whether the + * original context is private or not + */ + void onContentPrefRemoved(in AString aGroup, + in AString aName, + [optional] in boolean aIsPrivate); +}; + +[scriptable, function, uuid(c1b3d6df-5373-4606-8494-8bcf14a7fc62)] +interface nsIContentPrefCallback : nsISupports +{ + void onResult(in nsIVariant aResult); +}; + +/** + * @deprecated Please use nsIContentPrefService2 instead. + */ +[scriptable, uuid(e3f772f3-023f-4b32-b074-36cf0fd5d414)] +interface nsIContentPrefService : nsISupports +{ + /** + * Get a pref. + * + * Besides the regular string, integer, boolean, etc. values, this method + * may return null (nsIDataType::VTYPE_EMPTY), which means the pref is set + * to NULL in the database, as well as undefined (nsIDataType::VTYPE_VOID), + * which means there is no record for this pref in the database. + * + * This method can be called from content processes in electrolysis builds. + * We have a whitelist of values that can be read in such a way. + * + * @param aGroup the group for which to get the pref, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to get the global pref (applies to all sites) + * @param aName the name of the pref to get + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search in memory or in + * permanent storage for it), obtained from a relevant + * window or channel. + * @param aCallback an optional nsIContentPrefCallback to receive the + * result. If desired, JavaScript callers can instead + * provide a function to call upon completion + * + * @returns the value of the pref + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + nsIVariant getPref(in nsIVariant aGroup, in AString aName, + in nsILoadContext aPrivacyContext, + [optional] in nsIContentPrefCallback aCallback); + + /** + * Set a pref. + * + * This method can be called from content processes in electrolysis builds. + * We have a whitelist of values that can be set in such a way. + * + * @param aGroup the group for which to set the pref, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to set the global pref (applies to all sites) + * @param aName the name of the pref to set + * @param aValue the new value of the pref + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to store it in memory or in + * permanent storage), obtained from a relevant + * window or channel. + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + void setPref(in nsIVariant aGroup, in AString aName, in nsIVariant aValue, in nsILoadContext aPrivacyContext); + + /** + * Check whether or not a pref exists. + * + * @param aGroup the group for which to check for the pref, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to check for the global pref (applies to all sites) + * @param aName the name of the pref to check for + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search in memory or in + * permanent storage for it), obtained from a relevant + * window or channel. + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + boolean hasPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); + + /** + * Check whether or not the value of a pref (or its non-existance) is cached. + * + * @param aGroup the group for which to check for the pref, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to check for the global pref (applies to all sites) + * @param aName the name of the pref to check for + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search in memory or in + * permanent storage for it), obtained from a relevant + * window or channel. + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + boolean hasCachedPref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); + + /** + * Remove a pref. + * + * @param aGroup the group for which to remove the pref, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to remove the global pref (applies to all sites) + * @param aName the name of the pref to remove + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search in memory or in + * permanent storage for it), obtained from a relevant + * window or channel. + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + void removePref(in nsIVariant aGroup, in AString aName, in nsILoadContext aContext); + + /** + * Remove all grouped prefs. Useful for removing references to the sites + * the user has visited when the user clears their private data. + * + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to remove prefs in memory or + * in permanent storage), obtained from a relevant + * window or channel. + */ + void removeGroupedPrefs(in nsILoadContext aContext); + + /** + * Remove all prefs with the given name. + * + * @param aName the setting name for which to remove prefs + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the prefs (ie. whether to remove prefs in memory or + * in permanent storage), obtained from a relevant + * window or channel. + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + void removePrefsByName(in AString aName, in nsILoadContext aContext); + + /** + * Get the prefs that apply to the given site. + * + * @param aGroup the group for which to retrieve prefs, as an nsIURI + * from which the hostname will be used, a string + * (typically in the format of a hostname), or null + * to get the global prefs (apply to all sites) + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search for prefs in memory + * or in permanent storage), obtained from a relevant + * window or channel. + * + * @returns a property bag of prefs + * @throws NS_ERROR_ILLEGAL_VALUE if aGroup is not a string, nsIURI, or null + */ + nsIPropertyBag2 getPrefs(in nsIVariant aGroup, in nsILoadContext aContext); + + /** + * Get the prefs with the given name. + * + * @param aName the setting name for which to retrieve prefs + * @param aPrivacyContext + * a context from which to determine the privacy status + * of the pref (ie. whether to search for prefs in memory + * or in permanent storage), obtained from a relevant + * window or channel. + * + * @returns a property bag of prefs + * @throws NS_ERROR_ILLEGAL_VALUE if aName is null or an empty string + */ + nsIPropertyBag2 getPrefsByName(in AString aName, in nsILoadContext aContext); + + /** + * Add an observer. + * + * @param aName the setting to observe, or null to add + * a generic observer that observes all settings + * @param aObserver the observer to add + */ + void addObserver(in AString aName, in nsIContentPrefObserver aObserver); + + /** + * Remove an observer. + * + * @param aName the setting being observed, or null to remove + * a generic observer that observes all settings + * @param aObserver the observer to remove + */ + void removeObserver(in AString aName, in nsIContentPrefObserver aObserver); + + /** + * The component that the service uses to determine the groups to which + * URIs belong. By default this is the "hostname grouper", which groups + * URIs by full hostname (a.k.a. site). + */ + readonly attribute nsIContentURIGrouper grouper; + + /** + * The database connection to the content preferences database. + * Useful for accessing and manipulating preferences in ways that are caller- + * specific or for which there is not yet a generic method, although generic + * functionality useful to multiple callers should generally be added to this + * unfrozen interface. Also useful for testing the database creation + * and migration code. + */ + readonly attribute mozIStorageConnection DBConnection; +}; + +%{C++ +// The contractID for the generic implementation built in to xpcom. +#define NS_CONTENT_PREF_SERVICE_CONTRACTID "@mozilla.org/content-pref/service;1" +%} diff --git a/dom/interfaces/base/nsIContentPrefService2.idl b/dom/interfaces/base/nsIContentPrefService2.idl new file mode 100644 index 000000000..4ac1e21d8 --- /dev/null +++ b/dom/interfaces/base/nsIContentPrefService2.idl @@ -0,0 +1,405 @@ +/* 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; +interface nsIContentPrefObserver; +interface nsIContentPrefCallback2; +interface nsILoadContext; +interface nsIContentPref; + +/** + * Content Preferences + * + * Content preferences allow the application to associate arbitrary data, or + * "preferences", with specific domains, or web "content". Specifically, a + * content preference is a structure with three values: a domain with which the + * preference is associated, a name that identifies the preference within its + * domain, and a value. (See nsIContentPref below.) + * + * For example, if you want to remember the user's preference for a certain zoom + * level on www.mozilla.org pages, you might store a preference whose domain is + * "www.mozilla.org", whose name is "zoomLevel", and whose value is the numeric + * zoom level. + * + * A preference need not have a domain, and in that case the preference is + * called a "global" preference. This interface doesn't impart any special + * significance to global preferences; they're simply name-value pairs that + * aren't associated with any particular domain. As a consumer of this + * interface, you might choose to let a global preference override all non- + * global preferences of the same name, for example, for whatever definition of + * "override" is appropriate for your use case. + * + * + * Domain Parameters + * + * Many methods of this interface accept a "domain" parameter. Domains may be + * specified either exactly, like "example.com", or as full URLs, like + * "http://example.com/foo/bar". In the latter case the API extracts the full + * domain from the URL, so if you specify "http://foo.bar.example.com/baz", the + * domain is taken to be "foo.bar.example.com", not "example.com". + * + * + * Private-Browsing Context Parameters + * + * Many methods also accept a "context" parameter. This parameter relates to + * private browsing and determines the kind of storage that a method uses, + * either the usual permanent storage or temporary storage set aside for private + * browsing sessions. + * + * Pass null to unconditionally use permanent storage. Pass an nsILoadContext + * to use storage appropriate to the context's usePrivateBrowsing attribute: if + * usePrivateBrowsing is true, temporary private-browsing storage is used, and + * otherwise permanent storage is used. A context can be obtained from the + * window or channel whose content pertains to the preferences being modified or + * retrieved. + * + * + * Callbacks + * + * The methods of callback objects are always called asynchronously. + * + * Observers are called after callbacks are called, but they are called in the + * same turn of the event loop as callbacks. + * + * See nsIContentPrefCallback2 below for more information about callbacks. + */ + +[scriptable, uuid(bed98666-d995-470f-bebd-62476d318576)] +interface nsIContentPrefService2 : nsISupports +{ + /** + * Gets all the preferences with the given name. + * + * @param name The preferences' name. + * @param context The private-browsing context, if any. + * @param callback handleResult is called once for each preference unless + * no such preferences exist, in which case handleResult + * is not called at all. + */ + void getByName(in AString name, + in nsILoadContext context, + in nsIContentPrefCallback2 callback); + + /** + * Gets the preference with the given domain and name. + * + * @param domain The preference's domain. + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @param callback handleResult is called once unless no such preference + * exists, in which case handleResult is not called at all. + */ + void getByDomainAndName(in AString domain, + in AString name, + in nsILoadContext context, + in nsIContentPrefCallback2 callback); + + /** + * Gets all preferences with the given name whose domains are either the same + * as or subdomains of the given domain. + * + * @param domain The preferences' domain. + * @param name The preferences' name. + * @param context The private-browsing context, if any. + * @param callback handleResult is called once for each preference. If no + * such preferences exist, handleResult is not called at all. + */ + void getBySubdomainAndName(in AString domain, + in AString name, + in nsILoadContext context, + in nsIContentPrefCallback2 callback); + + /** + * Gets the preference with no domain and the given name. + * + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @param callback handleResult is called once unless no such preference + * exists, in which case handleResult is not called at all. + */ + void getGlobal(in AString name, + in nsILoadContext context, + in nsIContentPrefCallback2 callback); + + /** + * Synchronously retrieves from the in-memory cache the preference with the + * given domain and name. + * + * In addition to caching preference values, the cache also keeps track of + * preferences that are known not to exist. If the preference is known not to + * exist, the value attribute of the returned object will be undefined + * (nsIDataType::VTYPE_VOID). + * + * If the preference is neither cached nor known not to exist, then null is + * returned, and get() must be called to determine whether the preference + * exists. + * + * @param domain The preference's domain. + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @return The preference, or null if no such preference is known to + * exist. + */ + nsIContentPref getCachedByDomainAndName(in AString domain, + in AString name, + in nsILoadContext context); + + /** + * Synchronously retrieves from the in-memory cache all preferences with the + * given name whose domains are either the same as or subdomains of the given + * domain. + * + * The preferences are returned in an array through the out-parameter. If a + * preference for a particular subdomain is known not to exist, then an object + * corresponding to that preference will be present in the array, and, as with + * getCachedByDomainAndName, its value attribute will be undefined. + * + * @param domain The preferences' domain. + * @param name The preferences' name. + * @param context The private-browsing context, if any. + * @param len The length of the returned array. + * @param prefs The array of preferences. + */ + void getCachedBySubdomainAndName(in AString domain, + in AString name, + in nsILoadContext context, + [optional] out unsigned long len, + [retval,array,size_is(len)] out nsIContentPref prefs); + + /** + * Synchronously retrieves from the in-memory cache the preference with no + * domain and the given name. + * + * As with getCachedByDomainAndName, if the preference is cached then it is + * returned; if the preference is known not to exist, then the value attribute + * of the returned object will be undefined; if the preference is neither + * cached nor known not to exist, then null is returned. + * + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @return The preference, or null if no such preference is known to + * exist. + */ + nsIContentPref getCachedGlobal(in AString name, + in nsILoadContext context); + + /** + * Sets a preference. + * + * @param domain The preference's domain. + * @param name The preference's name. + * @param value The preference's value. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the preference has been + * stored. + */ + void set(in AString domain, + in AString name, + in nsIVariant value, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Sets a preference with no domain. + * + * @param name The preference's name. + * @param value The preference's value. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the preference has been + * stored. + */ + void setGlobal(in AString name, + in nsIVariant value, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes the preference with the given domain and name. + * + * @param domain The preference's domain. + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeByDomainAndName(in AString domain, + in AString name, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all the preferences with the given name whose domains are either + * the same as or subdomains of the given domain. + * + * @param domain The preferences' domain. + * @param name The preferences' name. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeBySubdomainAndName(in AString domain, + in AString name, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes the preference with no domain and the given name. + * + * @param name The preference's name. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeGlobal(in AString name, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all preferences with the given domain. + * + * @param domain The preferences' domain. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeByDomain(in AString domain, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all preferences whose domains are either the same as or subdomains + * of the given domain. + * + * @param domain The preferences' domain. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeBySubdomain(in AString domain, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all preferences with the given name regardless of domain, including + * global preferences with the given name. + * + * @param name The preferences' name. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeByName(in AString name, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all non-global preferences -- in other words, all preferences that + * have a domain. + * + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeAllDomains(in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all non-global preferences created after and including |since|. + * + * @param since Timestamp in milliseconds. + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeAllDomainsSince(in unsigned long long since, + in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Removes all global preferences -- in other words, all preferences that have + * no domain. + * + * @param context The private-browsing context, if any. + * @param callback handleCompletion is called when the operation completes. + */ + void removeAllGlobals(in nsILoadContext context, + [optional] in nsIContentPrefCallback2 callback); + + /** + * Registers an observer that will be notified whenever a preference with the + * given name is set or removed. + * + * When a set or remove method is called, observers are called after the set + * or removal completes and after the method's callback is called, and they + * are called in the same turn of the event loop as the callback. + * + * The service holds a strong reference to the observer, so the observer must + * be removed later to avoid leaking it. + * + * @param name The name of the preferences to observe. Pass null to + * observe all preference changes regardless of name. + * @param observer The observer. + */ + void addObserverForName(in AString name, + in nsIContentPrefObserver observer); + + /** + * Unregisters an observer for the given name. + * + * @param name The name for which the observer was registered. Pass null + * if the observer was added with a null name. + * @param observer The observer. + */ + void removeObserverForName(in AString name, + in nsIContentPrefObserver observer); + + /** + * Extracts and returns the domain from the given string representation of a + * URI. This is how the API extracts domains from URIs passed to it. + * + * @param str The string representation of a URI, like + * "http://example.com/foo/bar". + * @return If the given string is a valid URI, the domain of that URI is + * returned. Otherwise, the string itself is returned. + */ + AString extractDomain(in AString str); +}; + +/** + * The callback used by the above methods. + */ +[scriptable, uuid(1a12cf41-79e8-4d0f-9899-2f7b27c5d9a1)] +interface nsIContentPrefCallback2 : nsISupports +{ + /** + * For the retrieval methods, this is called once for each retrieved + * preference. It is not called for other methods. + * + * @param pref The retrieved preference. + */ + void handleResult(in nsIContentPref pref); + + /** + * Called when an error occurs. This may be called multiple times before + * handleCompletion is called. + * + * @param error A number in Components.results describing the error. + */ + void handleError(in nsresult error); + + /** + * Called when the method finishes. This will be called exactly once for + * each method invocation, and afterward no other callback methods will be + * called. + * + * @param reason One of the COMPLETE_* values indicating the manner in which + * the method completed. + */ + void handleCompletion(in unsigned short reason); + + const unsigned short COMPLETE_OK = 0; + const unsigned short COMPLETE_ERROR = 1; +}; + +[scriptable, function, uuid(9f24948d-24b5-4b1b-b554-7dbd58c1d792)] +interface nsIContentPref : nsISupports +{ + readonly attribute AString domain; + readonly attribute AString name; + readonly attribute nsIVariant value; +}; diff --git a/dom/interfaces/base/nsIContentURIGrouper.idl b/dom/interfaces/base/nsIContentURIGrouper.idl new file mode 100644 index 000000000..9224450f9 --- /dev/null +++ b/dom/interfaces/base/nsIContentURIGrouper.idl @@ -0,0 +1,23 @@ +/* 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 "nsIURI.idl" + +[scriptable, uuid(4bb38cb4-c3cb-4d17-9799-1b3132b39723)] +interface nsIContentURIGrouper : nsISupports +{ + /** + * Determine the group to which the URI belongs. + * + * @param aURI the URI to group + * + * @returns the group to which the URI belongs + */ + AString group(in nsIURI aURI); +}; + +%{C++ +// The contractID for the generic implementation built in to xpcom. +#define NS_HOSTNAME_GROUPER_SERVICE_CONTRACTID "@mozilla.org/content-pref/hostname-grouper;1" +%} diff --git a/dom/interfaces/base/nsIDOMChromeWindow.idl b/dom/interfaces/base/nsIDOMChromeWindow.idl new file mode 100644 index 000000000..600aa46eb --- /dev/null +++ b/dom/interfaces/base/nsIDOMChromeWindow.idl @@ -0,0 +1,81 @@ +/* -*- 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 nsIBrowserDOMWindow; +interface nsIDOMElement; +interface nsIDOMEvent; +interface nsIMessageBroadcaster; +interface mozIDOMWindowProxy; + +[scriptable, uuid(78bdcb41-1efa-409f-aaba-70842213f80f)] +interface nsIDOMChromeWindow : nsISupports +{ + const unsigned short STATE_MAXIMIZED = 1; + const unsigned short STATE_MINIMIZED = 2; + const unsigned short STATE_NORMAL = 3; + const unsigned short STATE_FULLSCREEN = 4; + + readonly attribute unsigned short windowState; + + /** + * browserDOMWindow provides access to yet another layer of + * utility functions implemented by chrome script. It will be null + * for DOMWindows not corresponding to browsers. + */ + attribute nsIBrowserDOMWindow browserDOMWindow; + + void getAttention(); + + void getAttentionWithCycleCount(in long aCycleCount); + + void setCursor(in DOMString cursor); + + void maximize(); + void minimize(); + void restore(); + + /** + * Notify a default button is loaded on a dialog or a wizard. + * defaultButton is the default button. + */ + void notifyDefaultButtonLoaded(in nsIDOMElement defaultButton); + + readonly attribute nsIMessageBroadcaster messageManager; + + /** + * Returns the message manager identified by the given group name that + * manages all frame loaders belonging to that group. + */ + nsIMessageBroadcaster getGroupMessageManager(in AString group); + + /** + * On some operating systems, we must allow the window manager to + * handle window dragging. This function tells the window manager to + * start dragging the window. This function will fail unless called + * while the left mouse button is held down, callers must check this. + * + * The optional panel argument should be set when moving a panel. + * + * Returns NS_ERROR_NOT_IMPLEMENTED (and thus throws in JS) if the OS + * doesn't support this. + */ + void beginWindowMove(in nsIDOMEvent mouseDownEvent, [optional] in nsIDOMElement panel); + + /** + * These methods provide a way to specify the opener value for the content in + * the window before the content itself is created. This is important in order + * to set the DocGroup of a document, as the opener must be set before the + * document is created. + * + * SetOpenerForInitialContentBrowser is used to set which opener will be used, + * and TakeOpenerForInitialContentBrowser is used by nsXULElement in order to + * take the value set earlier, and null out the value in the + * nsIDOMChromeWindow. + */ + void setOpenerForInitialContentBrowser(in mozIDOMWindowProxy aOpener); + mozIDOMWindowProxy takeOpenerForInitialContentBrowser(); +}; diff --git a/dom/interfaces/base/nsIDOMClientRect.idl b/dom/interfaces/base/nsIDOMClientRect.idl new file mode 100644 index 000000000..905d68661 --- /dev/null +++ b/dom/interfaces/base/nsIDOMClientRect.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 "domstubs.idl" + +[uuid(B2F824C4-D9D3-499B-8D3B-45C8245497C6)] +interface nsIDOMClientRect : nsISupports +{ + readonly attribute float left; + readonly attribute float top; + readonly attribute float right; + readonly attribute float bottom; + readonly attribute float width; + readonly attribute float height; +}; diff --git a/dom/interfaces/base/nsIDOMClientRectList.idl b/dom/interfaces/base/nsIDOMClientRectList.idl new file mode 100644 index 000000000..2056fe362 --- /dev/null +++ b/dom/interfaces/base/nsIDOMClientRectList.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 "domstubs.idl" + +[uuid(f474c567-cbcb-458f-abad-ae42363da287)] +interface nsIDOMClientRectList : nsISupports +{ + readonly attribute unsigned long length; + nsIDOMClientRect item(in unsigned long index); +}; diff --git a/dom/interfaces/base/nsIDOMConstructor.idl b/dom/interfaces/base/nsIDOMConstructor.idl new file mode 100644 index 000000000..1eddf5739 --- /dev/null +++ b/dom/interfaces/base/nsIDOMConstructor.idl @@ -0,0 +1,13 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 sw=2 et 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 "domstubs.idl" + +[scriptable, uuid(0ccbcf19-d1b4-489e-984c-cd8c43672bb9)] +interface nsIDOMDOMConstructor : nsISupports +{ + AString toString(); +}; + diff --git a/dom/interfaces/base/nsIDOMCrypto.idl b/dom/interfaces/base/nsIDOMCrypto.idl new file mode 100644 index 000000000..3df047934 --- /dev/null +++ b/dom/interfaces/base/nsIDOMCrypto.idl @@ -0,0 +1,14 @@ +/* -*- 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" + +interface nsIGlobalObject; + +[uuid(48d7f7fd-bb85-4c04-9b8b-5cd9131acdef)] +interface nsIDOMCrypto : nsISupports +{ + [notxpcom] void init(in nsIGlobalObject parent); +}; diff --git a/dom/interfaces/base/nsIDOMGlobalPropertyInitializer.idl b/dom/interfaces/base/nsIDOMGlobalPropertyInitializer.idl new file mode 100644 index 000000000..3c931824d --- /dev/null +++ b/dom/interfaces/base/nsIDOMGlobalPropertyInitializer.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 "nsISupports.idl" + +interface mozIDOMWindow; + +[scriptable, uuid(5842e275-797f-4afb-b7e0-e29f0cb312ae)] +interface nsIDOMGlobalPropertyInitializer : nsISupports +{ + /* + * Initialize the global property. + * + * @param window the global object on which the property is being retrieved. + * + * @returns a JS Object to use use as the property's value. + */ + jsval init(in mozIDOMWindow window); +}; diff --git a/dom/interfaces/base/nsIDOMHistory.idl b/dom/interfaces/base/nsIDOMHistory.idl new file mode 100644 index 000000000..b520b6212 --- /dev/null +++ b/dom/interfaces/base/nsIDOMHistory.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 "domstubs.idl" + +[uuid(55226663-fe68-48ba-addf-08e32eaab569)] +interface nsIDOMHistory : nsISupports +{ + // Empty interface that exists only for extension backwards compat +}; diff --git a/dom/interfaces/base/nsIDOMLocation.idl b/dom/interfaces/base/nsIDOMLocation.idl new file mode 100644 index 000000000..d6577582f --- /dev/null +++ b/dom/interfaces/base/nsIDOMLocation.idl @@ -0,0 +1,33 @@ +/* -*- 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" + +[scriptable, uuid(79de76e5-994e-4f6b-81aa-42d9adb6e67e)] +interface nsIDOMLocation : nsISupports +{ + /** + * These properties refer to the current location of the document. + * This will correspond to the URI shown in the location bar, which + * can be different from the documentURI of the document. + */ + attribute DOMString hash; + attribute DOMString host; + attribute DOMString hostname; + attribute DOMString href; + attribute DOMString pathname; + attribute DOMString port; + attribute DOMString protocol; + attribute DOMString search; + + readonly attribute DOMString origin; + + void reload([optional] in boolean forceget); + void replace(in DOMString url); + void assign(in DOMString url); + + DOMString toString(); + nsIDOMLocation valueOf(); +}; diff --git a/dom/interfaces/base/nsIDOMModalContentWindow.idl b/dom/interfaces/base/nsIDOMModalContentWindow.idl new file mode 100644 index 000000000..c1ba87ed9 --- /dev/null +++ b/dom/interfaces/base/nsIDOMModalContentWindow.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" + +interface nsIVariant; +interface nsIArray; + +[scriptable, uuid(3f4cb2d0-5f7e-44a9-9f4f-370945f8db08)] +interface nsIDOMModalContentWindow : nsISupports +{ + /** + * Readonly attribute containing an arbitrary JS value passed by the + * code that opened the modal content window. A security check is + * performed at access time, per spec. + */ + readonly attribute nsIVariant dialogArguments; + + /** + * The return value that will be returned to the function that + * opened the modal content window. + */ + attribute nsIVariant returnValue; +}; diff --git a/dom/interfaces/base/nsIDOMNavigator.idl b/dom/interfaces/base/nsIDOMNavigator.idl new file mode 100644 index 000000000..5fd16b8ae --- /dev/null +++ b/dom/interfaces/base/nsIDOMNavigator.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 "domstubs.idl" + +interface nsIIdleObserver; + +[uuid(f1101fbb-d119-4cb8-845b-6bbae8a151c7)] +interface nsIDOMNavigator : nsISupports +{ + readonly attribute DOMString appCodeName; + readonly attribute DOMString appName; + readonly attribute DOMString appVersion; + readonly attribute DOMString language; + readonly attribute DOMString platform; + readonly attribute DOMString oscpu; + readonly attribute DOMString vendor; + readonly attribute DOMString vendorSub; + readonly attribute DOMString product; + readonly attribute DOMString productSub; + readonly attribute DOMString userAgent; + readonly attribute DOMString buildID; + readonly attribute DOMString doNotTrack; +}; diff --git a/dom/interfaces/base/nsIDOMScreen.idl b/dom/interfaces/base/nsIDOMScreen.idl new file mode 100644 index 000000000..1f1cab79d --- /dev/null +++ b/dom/interfaces/base/nsIDOMScreen.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 "nsIDOMEventTarget.idl" + +[builtinclass, uuid(82c7924b-4b46-4e5a-a8d2-6edb5fc0a60d)] +interface nsIDOMScreen : nsIDOMEventTarget +{ + readonly attribute long top; + readonly attribute long left; + readonly attribute long width; + readonly attribute long height; + readonly attribute long pixelDepth; + readonly attribute long colorDepth; + readonly attribute long availWidth; + readonly attribute long availHeight; + readonly attribute long availLeft; + readonly attribute long availTop; + + /** + * Returns the current screen orientation. + * Can be: landscape-primary, landscape-secondary, + * portrait-primary or portrait-secondary. + */ + [binaryname(SlowMozOrientation)] + readonly attribute DOMString mozOrientation; +}; diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl new file mode 100644 index 000000000..b41458a12 --- /dev/null +++ b/dom/interfaces/base/nsIDOMWindow.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 nsIControllers; +interface nsIDOMBlob; +interface nsIDOMLocation; +interface nsIDOMOfflineResourceList; +interface nsIPrompt; +interface nsISelection; +interface nsIVariant; + +/** + * Empty interface for compatibility with older versions. + * @deprecated Use WebIDL for script visible features, + * nsPIDOMWindow for C++ callers. + */ + +[scriptable, uuid(b8343993-0383-4add-9930-ad176b189240)] +interface nsIDOMWindow : nsISupports {}; + +/** + * Empty interface for compatibility with older versions. + * @deprecated Use nsIDOMWindow instead + */ +[scriptable, uuid(8c589e65-3237-4cd1-8bad-c5c47135e79b)] +interface nsIDOMWindowInternal : nsIDOMWindow {}; diff --git a/dom/interfaces/base/nsIDOMWindowCollection.idl b/dom/interfaces/base/nsIDOMWindowCollection.idl new file mode 100644 index 000000000..ed48ae18f --- /dev/null +++ b/dom/interfaces/base/nsIDOMWindowCollection.idl @@ -0,0 +1,32 @@ +/* -*- 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 mozIDOMWindowProxy; + +/** + * The nsIDOMWindowCollection interface is an interface for a + * collection of DOM window objects. + */ + +[uuid(8d64f457-fb8c-49ea-a359-cef30eed9774)] +interface nsIDOMWindowCollection : nsISupports +{ + /** + * Accessor for the number of windows in this collection. + */ + readonly attribute unsigned long length; + + /** + * Method for accessing an item in this collection by index. + */ + mozIDOMWindowProxy item(in unsigned long index); + + /** + * Method for accessing an item in this collection by window name. + */ + mozIDOMWindowProxy namedItem(in DOMString name); +}; diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl new file mode 100644 index 000000000..70ec7e0ae --- /dev/null +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -0,0 +1,2009 @@ +/* -*- 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" + +/** + * nsIDOMWindowUtils is intended for infrequently-used methods related + * to the current nsIDOMWindow. Some of the methods may require + * elevated privileges; the method implementations should contain the + * necessary security checks. Access this interface by calling + * getInterface on a DOMWindow. + * + * WARNING: Do not use 'out jsval' parameters in this file. + * SpecialPowers, which is used to access nsIDOMWindowUtils + * in plain mochitests, does not know how to handle them. + * (Use 'jsval' return values instead.) + */ + +%{C++ +#include "nsColor.h" +class gfxContext; +struct nsRect; +%} + +[ref] native nsConstRect(const nsRect); +native nscolor(nscolor); +[ptr] native gfxContext(gfxContext); +typedef unsigned long long nsViewID; + +interface nsICycleCollectorListener; +interface nsIDOMNode; +interface nsIDOMNodeList; +interface nsIDOMElement; +interface nsIDOMHTMLCanvasElement; +interface nsIDOMEvent; +interface nsIDOMStyleSheet; +interface nsITransferable; +interface nsIQueryContentEventResult; +interface nsIDOMWindow; +interface nsIFile; +interface nsIDOMClientRect; +interface nsIURI; +interface nsIDOMEventTarget; +interface nsIRunnable; +interface nsITranslationNodeList; +interface nsIJSRAIIHelper; +interface nsIContentPermissionRequest; +interface nsIObserver; + +[scriptable, uuid(c471d440-004b-4c50-a6f2-747db5f443b6)] +interface nsIDOMWindowUtils : nsISupports { + + /** + * Image animation mode of the window. When this attribute's value + * is changed, the implementation should set all images in the window + * to the given value. That is, when set to kDontAnimMode, all images + * will stop animating. The attribute's value must be one of the + * animationMode values from imgIContainer. + * @note Images may individually override the window's setting after + * the window's mode is set. Therefore images given different modes + * since the last setting of the window's mode may behave + * out of line with the window's overall mode. + * @note The attribute's value is the window's overall mode. It may + * for example continue to report kDontAnimMode after all images + * have subsequently been individually animated. + * @note Only images immediately in this window are affected; + * this is not recursive to subwindows. + * @see imgIContainer + */ + attribute unsigned short imageAnimationMode; + + /** + * Whether the charset of the window's current document has been forced by + * the user. + * Cannot be accessed from unprivileged context (not content-accessible) + */ + readonly attribute boolean docCharsetIsForced; + + /** + * Get current cursor type from this window + * @return the current value of nsCursor + */ + short getCursorType(); + + /** + * Function to get metadata associated with the window's current document + * @param aName the name of the metadata. This should be all lowercase. + * @return the value of the metadata, or the empty string if it's not set + * + * Will throw a DOM security error if called without chrome privileges. + */ + AString getDocumentMetadata(in AString aName); + + /** + * Force an immediate redraw of this window. The parameter specifies + * the number of times to redraw, and the return value is the length, + * in milliseconds, that the redraws took. If aCount is not specified + * or is 0, it is taken to be 1. + */ + unsigned long redraw([optional] in unsigned long aCount); + + /** + * Force a synchronous layer transaction for this window if necessary. + */ + void updateLayerTree(); + + /** + * Get the last used layer transaction id for this window's refresh driver. + */ + readonly attribute unsigned long long lastTransactionId; + + /** + * Information retrieved from the <meta name="viewport"> tag. + * See nsContentUtils::GetViewportInfo for more information. + */ + void getViewportInfo(in uint32_t aDisplayWidth, in uint32_t aDisplayHeight, + out double aDefaultZoom, out boolean aAllowZoom, + out double aMinZoom, out double aMaxZoom, + out uint32_t aWidth, out uint32_t aHeight, + out boolean aAutoSize); + + /** + * Information about the window size in device pixels. + */ + void getContentViewerSize(out uint32_t aDisplayWidth, out uint32_t aDisplayHeight); + + /** + * For any scrollable element, this allows you to override the + * visible region and draw more than what is visible, which is + * useful for asynchronous drawing. The "displayport" will be + * <xPx, yPx, widthPx, heightPx> in units of CSS pixels, + * regardless of the size of the enclosing container. This + * will *not* trigger reflow. + * + * For the root scroll area, pass in the root document element. + * For scrollable elements, pass in the container element (for + * instance, the element with overflow: scroll). + * + * <x, y> is relative to the top-left of what would normally be + * the visible area of the element. This means that the pixels + * rendered to the displayport take scrolling into account, + * for example. + * + * It's legal to set a displayport that extends beyond the overflow + * area in any direction (left/right/top/bottom). + * + * It's also legal to set a displayport that extends beyond the + * area's bounds. No pixels are rendered outside the area bounds. + * + * The caller of this method must have chrome privileges. + * + * Calling this will always force a recomposite, so it should be + * avoided if at all possible. Client code should do checks before + * calling this so that duplicate sets are not made with the same + * displayport. + * + * aPriority is recorded along with the displayport rectangle. If this + * method is called with a lower priority than the current priority, the + * call is ignored. + */ + void setDisplayPortForElement(in float aXPx, in float aYPx, + in float aWidthPx, in float aHeightPx, + in nsIDOMElement aElement, + in uint32_t aPriority); + /** + * An alternate way to represent a displayport rect as a set of margins and a + * base rect to apply those margins to. A consumer of pixels may ask for as + * many extra pixels as it would like in each direction. Layout then sets + * the base rect to the "visible rect" of the element, which is just the + * subrect of the element that is drawn (it does not take in account content + * covering the element). + * + * If both a displayport rect and displayport margins with corresponding base + * rect are set with the same priority then the margins will take precendence. + * + * Specifying an alignment value will ensure that after the base rect has + * been expanded by the displayport margins, it will be further expanded so + * that each edge is located at a multiple of the "alignment" value. + * + * Note that both the margin values and alignment are treated as values in + * ScreenPixels. Refer to layout/base/Units.h for a description of this unit. + * The base rect values are in app units. + */ + void setDisplayPortMarginsForElement(in float aLeftMargin, + in float aTopMargin, + in float aRightMargin, + in float aBottomMargin, + in nsIDOMElement aElement, + in uint32_t aPriority); + + void setDisplayPortBaseForElement(in int32_t aX, + in int32_t aY, + in int32_t aWidth, + in int32_t aHeight, + in nsIDOMElement aElement); + + /** + * Get/set the resolution at which rescalable web content is drawn. + * + * Setting a new resolution does *not* trigger reflow. This API is + * entirely separate from textZoom and fullZoom; a resolution scale + * can be applied together with both textZoom and fullZoom. + * + * The effect of this API is for gfx code to allocate more or fewer + * pixels for rescalable content by a factor of |resolution| in + * both dimensions. The scale at which the content is displayed does + * not change; if that is desired, use setResolutionAndScaleTo() instead. + * + * The caller of this method must have chrome privileges. + */ + void setResolution(in float aResolution); + + void getResolution(out float aResolution); + + /** + * Similar to setResolution(), but also scales the content by the + * amount of the resolution, so that it is displayed at a + * correspondingly larger or smaller size, without the need for + * the caller to set an additional transform. + * + * This can be used to implement a non-reflowing scale-zoom, e.g. + * for pinch-zoom on mobile platforms. + * + * The caller of this method must have chrome privileges. + */ + void setResolutionAndScaleTo(in float aResolution); + + /** + * Set a resolution on the presShell which is the "restored" from history. + * The display dimensions are compared to their current values and used + * to scale the resolution value if necessary, e.g. if the device was + * rotated between saving and restoring of the session data. + * This resolution should be used when painting for the first time. Calling + * this too late may have no effect. + */ + void setRestoreResolution(in float aResolution, + in uint32_t aDisplayWidth, + in uint32_t aDisplayHeight); + + /** + * Whether the resolution has been set by the user. + * This gives a way to check whether the provided resolution is the default + * value or restored from a previous session. + * + * Can only be accessed with chrome privileges. + */ + readonly attribute boolean isResolutionSet; + + /** + * Whether the next paint should be flagged as the first paint for a document. + * This gives a way to track the next paint that occurs after the flag is + * set. The flag gets cleared after the next paint. + * + * Can only be accessed with chrome privileges. + */ + attribute boolean isFirstPaint; + + void getPresShellId(out uint32_t aPresShellId); + + /** + * Following modifiers are for sent*Event() except sendNative*Event(). + * NOTE: MODIFIER_ALT, MODIFIER_CONTROL, MODIFIER_SHIFT and MODIFIER_META + * are must be same values as nsIDOMNSEvent::*_MASK for backward + * compatibility. + */ + const long MODIFIER_ALT = 0x0001; + const long MODIFIER_CONTROL = 0x0002; + const long MODIFIER_SHIFT = 0x0004; + const long MODIFIER_META = 0x0008; + const long MODIFIER_ALTGRAPH = 0x0010; + const long MODIFIER_CAPSLOCK = 0x0020; + const long MODIFIER_FN = 0x0040; + const long MODIFIER_FNLOCK = 0x0080; + const long MODIFIER_NUMLOCK = 0x0100; + const long MODIFIER_SCROLLLOCK = 0x0200; + const long MODIFIER_SYMBOL = 0x0400; + const long MODIFIER_SYMBOLLOCK = 0x0800; + const long MODIFIER_OS = 0x1000; + + /** Synthesize a mouse event. The event types supported are: + * mousedown, mouseup, mousemove, mouseover, mouseout, mousecancel, + * contextmenu, MozMouseHittest + * + * Events are sent in coordinates offset by aX and aY from the window. + * + * Note that additional events may be fired as a result of this call. For + * instance, typically a click event will be fired as a result of a + * mousedown and mouseup in sequence. + * + * Normally at this level of events, the mouseover and mouseout events are + * only fired when the window is entered or exited. For inter-element + * mouseover and mouseout events, a movemove event fired on the new element + * should be sufficient to generate the correct over and out events as well. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * The event is dispatched via the toplevel window, so it could go to any + * window under the toplevel window, in some cases it could never reach this + * window at all. + * + * NOTE: mousecancel is used to represent the vanishing of an input device + * such as a pen leaving its digitizer by synthesizing a WidgetMouseEvent, + * whose mMessage is eMouseExitFromWidget and mExitFrom is + * WidgetMouseEvent::eTopLevel. + * + * @param aType event type + * @param aX x offset in CSS pixels + * @param aY y offset in CSS pixels + * @param aButton button to synthesize + * @param aClickCount number of clicks that have been performed + * @param aModifiers modifiers pressed, using constants defined as MODIFIER_* + * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds + * during dispatch + * @param aPressure touch input pressure: 0.0 -> 1.0 + * @param aInputSourceArg input source, see nsIDOMMouseEvent for values, + * defaults to mouse input. + * @param aIsDOMEventSynthesized controls nsIDOMEvent.isSynthesized value + * that helps identifying test related events, + * defaults to true + * @param aIsWidgetEventSynthesized controls WidgetMouseEvent.mReason value + * defaults to false (WidgetMouseEvent::eReal) + * + * returns true if the page called prevent default on this event + */ + [optional_argc] + boolean sendMouseEvent(in AString aType, + in float aX, + in float aY, + in long aButton, + in long aClickCount, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame, + [optional] in float aPressure, + [optional] in unsigned short aInputSourceArg, + [optional] in boolean aIsDOMEventSynthesized, + [optional] in boolean aIsWidgetEventSynthesized, + [optional] in long aButtons); + + + /** Synthesize a pointer event. The event types supported are: + * pointerdown, pointerup, pointermove, pointerover, pointerout + * + * Events are sent in coordinates offset by aX and aY from the window. + * + * Note that additional events may be fired as a result of this call. For + * instance, typically a click event will be fired as a result of a + * mousedown and mouseup in sequence. + * + * Normally at this level of events, the pointerover and pointerout events are + * only fired when the window is entered or exited. For inter-element + * pointerover and pointerout events, a movemove event fired on the new element + * should be sufficient to generate the correct over and out events as well. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * The event is dispatched via the toplevel window, so it could go to any + * window under the toplevel window, in some cases it could never reach this + * window at all. + * + * @param aType event type + * @param aX x offset in CSS pixels + * @param aY y offset in CSS pixels + * @param aButton button to synthesize + * @param aClickCount number of clicks that have been performed + * @param aModifiers modifiers pressed, using constants defined as MODIFIER_* + * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds + * during dispatch + * @param aPressure touch input pressure: 0.0 -> 1.0 + * @param aInputSourceArg input source, see nsIDOMMouseEvent for values, + * defaults to mouse input. + * @param aPointerId A unique identifier for the pointer causing the event. default is 0 + * @param aWidth The width (magnitude on the X axis), default is 0 + * @param aHeight The height (magnitude on the Y axis), default is 0 + * @param aTilt The plane angle between the Y-Z plane + * and the plane containing both the transducer (e.g. pen stylus) axis and the Y axis. default is 0 + * @param aTiltX The plane angle between the X-Z plane + * and the plane containing both the transducer (e.g. pen stylus) axis and the X axis. default is 0 + * @param aIsPrimary Indicates if the pointer represents the primary pointer of this pointer type. + * @param aIsSynthesized controls nsIDOMEvent.isSynthesized value + * that helps identifying test related events, + * defaults to true + * + * returns true if the page called prevent default on this event + */ + + [optional_argc] + boolean sendPointerEvent(in AString aType, + in float aX, + in float aY, + in long aButton, + in long aClickCount, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame, + [optional] in float aPressure, + [optional] in unsigned short aInputSourceArg, + [optional] in long aPointerId, + [optional] in long aWidth, + [optional] in long aHeight, + [optional] in long aTiltX, + [optional] in long aTiltY, + [optional] in boolean aIsPrimary, + [optional] in boolean aIsSynthesized); + + /** Synthesize a touch event. The event types supported are: + * touchstart, touchend, touchmove, and touchcancel + * + * Events are sent in coordinates offset by aX and aY from the window. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * The event is dispatched via the toplevel window, so it could go to any + * window under the toplevel window, in some cases it could never reach this + * window at all. + * + * @param aType event type + * @param xs array of offsets in CSS pixels for each touch to be sent + * @param ys array of offsets in CSS pixels for each touch to be sent + * @param rxs array of radii in CSS pixels for each touch to be sent + * @param rys array of radii in CSS pixels for each touch to be sent + * @param rotationAngles array of angles in degrees for each touch to be sent + * @param forces array of forces (floats from 0 to 1) for each touch to be sent + * @param count number of touches in this set + * @param aModifiers modifiers pressed, using constants defined as MODIFIER_* + * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds + * during dispatch + * + * returns true if the page called prevent default on this touch event + */ + boolean sendTouchEvent(in AString aType, + [array, size_is(count)] in uint32_t aIdentifiers, + [array, size_is(count)] in int32_t aXs, + [array, size_is(count)] in int32_t aYs, + [array, size_is(count)] in uint32_t aRxs, + [array, size_is(count)] in uint32_t aRys, + [array, size_is(count)] in float aRotationAngles, + [array, size_is(count)] in float aForces, + in uint32_t count, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame); + + /** The same as sendMouseEvent but ensures that the event is dispatched to + * this DOM window or one of its children. + */ + [optional_argc] + void sendMouseEventToWindow(in AString aType, + in float aX, + in float aY, + in long aButton, + in long aClickCount, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame, + [optional] in float aPressure, + [optional] in unsigned short aInputSourceArg, + [optional] in boolean aIsDOMEventSynthesized, + [optional] in boolean aIsWidgetEventSynthesized, + [optional] in long aButtons); + + /** The same as sendPointerEvent but ensures that the event + * is dispatched to this DOM window or one of its children. + */ + [optional_argc] + void sendPointerEventToWindow(in AString aType, + in float aX, + in float aY, + in long aButton, + in long aClickCount, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame, + [optional] in float aPressure, + [optional] in unsigned short aInputSourceArg, + [optional] in long aPointerId, + [optional] in long aWidth, + [optional] in long aHeight, + [optional] in long aTiltX, + [optional] in long aTiltY, + [optional] in boolean aIsPrimary, + [optional] in boolean aIsSynthesized); + + /** The same as sendTouchEvent but ensures that the event is dispatched to + * this DOM window or one of its children. + */ + boolean sendTouchEventToWindow(in AString aType, + [array, size_is(count)] in uint32_t aIdentifiers, + [array, size_is(count)] in int32_t aXs, + [array, size_is(count)] in int32_t aYs, + [array, size_is(count)] in uint32_t aRxs, + [array, size_is(count)] in uint32_t aRys, + [array, size_is(count)] in float aRotationAngles, + [array, size_is(count)] in float aForces, + in uint32_t count, + in long aModifiers, + [optional] in boolean aIgnoreRootScrollFrame); + + /** Synthesize a wheel event for a window. The event types supported is only + * wheel. + * + * Events are sent in coordinates offset by aX and aY from the window. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * @param aX x offset in CSS pixels + * @param aY y offset in CSS pixels + * @param aDeltaX deltaX value. + * @param aDeltaY deltaY value. + * @param aDeltaZ deltaZ value. + * @param aDeltaMode deltaMode value which must be one of + * nsIDOMWheelEvent::DOM_DELTA_*. + * @param aModifiers modifiers pressed, using constants defined as + * MODIFIER_* + * @param aLineOrPageDeltaX If you set this value non-zero for + * DOM_DELTA_PIXEL event, EventStateManager will + * dispatch NS_MOUSE_SCROLL event for horizontal + * scroll. + * @param aLineOrPageDeltaY If you set this value non-zero for + * DOM_DELTA_PIXEL event, EventStateManager will + * dispatch NS_MOUSE_SCROLL event for vertical + * scroll. + * @param aOptions Set following flags. + */ + const unsigned long WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE = 0x0001; + // @deprecated Use WHEEL_EVENT_CAUSED_BY_NO_LINE_OR_PAGE_DELTA_DEVICE. + const unsigned long WHEEL_EVENT_CAUSED_BY_PIXEL_ONLY_DEVICE = 0x0001; + const unsigned long WHEEL_EVENT_CAUSED_BY_MOMENTUM = 0x0002; + const unsigned long WHEEL_EVENT_CUSTOMIZED_BY_USER_PREFS = 0x0004; + // If any of the following flags is specified this method will throw an + // exception in case the relevant overflowDelta has an unexpected value. + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_ZERO = 0x0010; + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_POSITIVE = 0x0020; + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_X_NEGATIVE = 0x0040; + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_ZERO = 0x0100; + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_POSITIVE = 0x0200; + const unsigned long WHEEL_EVENT_EXPECTED_OVERFLOW_DELTA_Y_NEGATIVE = 0x0400; + void sendWheelEvent(in float aX, + in float aY, + in double aDeltaX, + in double aDeltaY, + in double aDeltaZ, + in unsigned long aDeltaMode, + in long aModifiers, + in long aLineOrPageDeltaX, + in long aLineOrPageDeltaY, + in unsigned long aOptions); + + /** + * Synthesize a key event to the window. The event types supported are: + * keydown, keyup, keypress + * + * Key events generally end up being sent to the focused node. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * @param aType event type + * @param aKeyCode key code + * @param aCharCode character code + * @param aModifiers modifiers pressed, using constants defined as MODIFIER_* + * @param aAdditionalFlags special flags for the key event, see KEY_FLAG_*. + * + * @return false if the event had preventDefault() called on it, + * true otherwise. In other words, true if and only if the + * default action was taken. + */ + + // If this is set, preventDefault() the event before dispatch. + const unsigned long KEY_FLAG_PREVENT_DEFAULT = 0x0001; + + // If this is set, the mIsSynthesizedForTests flag is set to false + // on the key event. Otherwise it is true. + const unsigned long KEY_FLAG_NOT_SYNTHESIZED_FOR_TESTS = 0x0002; + + // if one of these flags is set, the KeyboardEvent.location will be the value. + // Otherwise, it will be computed from aKeyCode. + const unsigned long KEY_FLAG_LOCATION_STANDARD = 0x0010; + const unsigned long KEY_FLAG_LOCATION_LEFT = 0x0020; + const unsigned long KEY_FLAG_LOCATION_RIGHT = 0x0040; + const unsigned long KEY_FLAG_LOCATION_NUMPAD = 0x0080; + + boolean sendKeyEvent(in AString aType, + in long aKeyCode, + in long aCharCode, + in long aModifiers, + [optional] in unsigned long aAdditionalFlags); + + /** + * See nsIWidget::SynthesizeNativeKeyEvent + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * When you use this for tests, use the constants defined in NativeKeyCodes.js + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified with a "keyevent" + * topic. + */ + void sendNativeKeyEvent(in long aNativeKeyboardLayout, + in long aNativeKeyCode, + in long aModifierFlags, + in AString aCharacters, + in AString aUnmodifiedCharacters, + [optional] in nsIObserver aObserver); + + /** + * See nsIWidget::SynthesizeNativeMouseEvent + * + * Will be called on the widget that contains aElement. + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified with a "mouseevent" + * topic. + */ + void sendNativeMouseEvent(in long aScreenX, + in long aScreenY, + in long aNativeMessage, + in long aModifierFlags, + in nsIDOMElement aElement, + [optional] in nsIObserver aObserver); + /** + * See nsIWidget::SynthesizeNativeMouseMove and sendNativeMouseEvent + */ + void sendNativeMouseMove(in long aScreenX, + in long aScreenY, + in nsIDOMElement aElement, + [optional] in nsIObserver aObserver); + + /** + * The values for sendNativeMouseScrollEvent's aAdditionalFlags. + */ + + /** + * If MOUSESCROLL_PREFER_WIDGET_AT_POINT is set, widget will dispatch + * the event to a widget which is under the cursor. Otherwise, dispatch to + * a default target on the platform. E.g., on Windows, it's focused window. + */ + const unsigned long MOUSESCROLL_PREFER_WIDGET_AT_POINT = 0x00000001; + + /** + * Interpret the scroll delta values as lines rather than pixels. + */ + const unsigned long MOUSESCROLL_SCROLL_LINES = 0x00000002; + + /** + * The platform specific values of aAdditionalFlags. Must be over 0x00010000. + */ + + /** + * If MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL is set and aNativeMessage is + * WM_VSCROLL or WM_HSCROLL, widget will set the window handle to the lParam + * instead of NULL. + */ + const unsigned long MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL = 0x00010000; + + /** + * See nsIWidget::SynthesizeNativeMouseScrollEvent + * + * Will be called on the widget that contains aElement. + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified with a + * "mousescrollevent" topic. + * + * @param aNativeMessage + * On Windows: WM_MOUSEWHEEL (0x020A), WM_MOUSEHWHEEL(0x020E), + * WM_VSCROLL (0x0115) or WM_HSCROLL (0x114). + */ + void sendNativeMouseScrollEvent(in long aScreenX, + in long aScreenY, + in unsigned long aNativeMessage, + in double aDeltaX, + in double aDeltaY, + in double aDeltaZ, + in unsigned long aModifierFlags, + in unsigned long aAdditionalFlags, + in nsIDOMElement aElement, + [optional] in nsIObserver aObserver); + + /** + * Touch states for sendNativeTouchPoint. These values match + * nsIWidget's TouchPointerState. + */ + + // The pointer is in a hover state above the digitizer + const long TOUCH_HOVER = 0x01; + // The pointer is in contact with the digitizer + const long TOUCH_CONTACT = 0x02; + // The pointer has been removed from the digitizer detection area + const long TOUCH_REMOVE = 0x04; + // The pointer has been canceled. Will cancel any pending os level + // gestures that would be triggered as a result of completion of the + // input sequence. This may not cancel moz platform related events + // that might get tirggered by input already delivered. + const long TOUCH_CANCEL = 0x08; + + /** + * Create a new or update an existing touch point on the digitizer. + * To trigger os level gestures, individual touch points should + * transition through a complete set of touch states which should be + * sent as individual calls. For example: + * tap - msg1:TOUCH_CONTACT, msg2:TOUCH_REMOVE + * drag - msg1-n:TOUCH_CONTACT (moving), msgn+1:TOUCH_REMOVE + * hover drag - msg1-n:TOUCH_HOVER (moving), msgn+1:TOUCH_REMOVE + * + * Widget support: Windows 8.0+, Winrt/Win32. Gonk supports CONTACT, REMOVE, + * and CANCEL but no HOVER. Other widgets will throw. + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified with a "touchpoint" + * topic. + * + * @param aPointerId The touch point id to create or update. + * @param aTouchState one or more of the touch states listed above + * @param aScreenX, aScreenY screen coords of this event + * @param aPressure 0.0 -> 1.0 float val indicating pressure + * @param aOrientation 0 -> 359 degree value indicating the + * orientation of the pointer. Use 90 for normal taps. + */ + void sendNativeTouchPoint(in unsigned long aPointerId, + in unsigned long aTouchState, + in long aScreenX, + in long aScreenY, + in double aPressure, + in unsigned long aOrientation, + [optional] in nsIObserver aObserver); + + /** + * Simulates native touch based taps on the input digitizer. Events + * triggered by this call are injected at the os level. Events do not + * bypass widget level input processing and as such can be used to + * test widget event logic and async pan-zoom controller functionality. + * Cannot be accessed from an unprivileged context. + * + * Long taps (based on the aLongTap parameter) will be completed + * asynchrnously after the call returns. Long tap delay is based on + * the ui.click_hold_context_menus.delay pref or 1500 msec if pref + * is not set. + * + * Widget support: Windows 8.0+, Winrt/Win32. Other widgets will + * throw. + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified, with a "touchtap" + * topic. + * + * @param aScreenX, aScreenY screen coords of this event + * @param aLongTap true if the tap should be long, false for a short + * tap. + */ + void sendNativeTouchTap(in long aScreenX, + in long aScreenY, + in boolean aLongTap, + [optional] in nsIObserver aObserver); + + /** + * Cancel any existing touch points or long tap delays. Calling this is safe + * even if you're sure there aren't any pointers recorded. You should call + * this when tests shut down to reset the digitizer driver. Not doing so can + * leave the digitizer in an undetermined state which can screw up subsequent + * tests and native input. + * + * NOTE: The synthesized native event will be fired asynchronously, and upon + * completion the observer, if provided, will be notified with a "cleartouch" + * topic. + */ + void clearNativeTouchSequence([optional] in nsIObserver aObserver); + + /** + * See nsIWidget::ActivateNativeMenuItemAt + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + */ + void activateNativeMenuItemAt(in AString indexString); + + /** + * See nsIWidget::ForceUpdateNativeMenuAt + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + */ + void forceUpdateNativeMenuAt(in AString indexString); + + /** + * Returns the current selection as plaintext. Note that the result may be + * different from the result of sendQueryContentEvent(QUERY_SELECTED_TEXT). + * This result is computed by native API with transferable data. In other + * words, when the OS treats the selection as plaintext, it treats current + * selection as this result. + */ + AString GetSelectionAsPlaintext(); + + /** + * Focus the element aElement. The element should be in the same document + * that the window is displaying. Pass null to blur the element, if any, + * that currently has focus, and focus the document. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * @param aElement the element to focus + * + * Do not use this method. Just use element.focus if available or + * nsIFocusManager::SetFocus instead. + * + */ + void focus(in nsIDOMElement aElement); + + /** + * Force a garbage collection followed by a cycle collection. + * + * Will throw a DOM security error if called without chrome privileges in + * non-debug builds. Available to all callers in debug builds. + * + * @param aListener listener that receives information about the CC graph + * (see @mozilla.org/cycle-collector-logger;1 for a logger + * component) + * @param aExtraForgetSkippableCalls indicates how many times + * nsCycleCollector_forgetSkippable will + * be called before running cycle collection. + * -1 prevents the default + * nsCycleCollector_forgetSkippable call + * which happens after garbage collection. + */ + void garbageCollect([optional] in nsICycleCollectorListener aListener, + [optional] in long aExtraForgetSkippableCalls); + + /** + * Force a cycle collection without garbage collection. + * + * Will throw a DOM security error if called without chrome privileges in + * non-debug builds. Available to all callers in debug builds. + * + * @param aListener listener that receives information about the CC graph + * (see @mozilla.org/cycle-collector-logger;1 for a logger + * component) + * @param aExtraForgetSkippableCalls indicates how many times + * nsCycleCollector_forgetSkippable will + * be called before running cycle collection. + * -1 prevents the default + * nsCycleCollector_forgetSkippable call + * which happens after garbage collection. + */ + void cycleCollect([optional] in nsICycleCollectorListener aListener, + [optional] in long aExtraForgetSkippableCalls); + + /** + * Trigger whichever GC or CC timer is currently active and waiting to fire. + * Don't do this too much for initiating heavy actions, like the start of a IGC. + */ + void runNextCollectorTimer(); + + /** Synthesize a simple gesture event for a window. The event types + * supported are: MozSwipeGestureMayStart, MozSwipeGestureStart, + * MozSwipeGestureUpdate, MozSwipeGestureEnd, MozSwipeGesture, + * MozMagnifyGestureStart, MozMagnifyGestureUpdate, MozMagnifyGesture, + * MozRotateGestureStart, MozRotateGestureUpdate, MozRotateGesture, + * MozPressTapGesture, MozTapGesture, and MozEdgeUIGesture. + * + * Cannot be accessed from unprivileged context (not + * content-accessible) Will throw a DOM security error if called + * without chrome privileges. + * + * @param aType event type + * @param aX x offset in CSS pixels + * @param aY y offset in CSS pixels + * @param aDirection direction, using constants defined in nsIDOMSimpleGestureEvent + * @param aDelta amount of magnification or rotation for magnify and rotation events + * @param aModifiers modifiers pressed, using constants defined in nsIDOMNSEvent + * @param aClickCount For tap gestures, the number of taps. + */ + void sendSimpleGestureEvent(in AString aType, + in float aX, + in float aY, + in unsigned long aDirection, + in double aDelta, + in long aModifiers, + [optional] in unsigned long aClickCount); + + /** + * Retrieve the element at point aX, aY in the window's document. + * + * @param aIgnoreRootScrollFrame whether or not to ignore the root scroll + * frame when retrieving the element. If false, this method returns + * null for coordinates outside of the viewport. + * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs. + */ + nsIDOMElement elementFromPoint(in float aX, + in float aY, + in boolean aIgnoreRootScrollFrame, + in boolean aFlushLayout); + + /** + * Retrieve all nodes that intersect a rect in the window's document. + * + * @param aX x reference for the rectangle in CSS pixels + * @param aY y reference for the rectangle in CSS pixels + * @param aTopSize How much to expand up the rectangle + * @param aRightSize How much to expand right the rectangle + * @param aBottomSize How much to expand down the rectangle + * @param aLeftSize How much to expand left the rectangle + * @param aIgnoreRootScrollFrame whether or not to ignore the root scroll + * frame when retrieving the element. If false, this method returns + * null for coordinates outside of the viewport. + * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs. + */ + nsIDOMNodeList nodesFromRect(in float aX, + in float aY, + in float aTopSize, + in float aRightSize, + in float aBottomSize, + in float aLeftSize, + in boolean aIgnoreRootScrollFrame, + in boolean aFlushLayout); + + + /** + * Get a list of nodes that have meaningful textual content to + * be translated. The implementation of this algorithm is in flux + * as we experiment and refine which approach works best. + * + * This method requires chrome privileges. + */ + nsITranslationNodeList getTranslationNodes(in nsIDOMNode aRoot); + + /** + * Compare the two canvases, returning the number of differing pixels and + * the maximum difference in a channel. This will throw an error if + * the dimensions of the two canvases are different. + * + * This method requires chrome privileges. + */ + uint32_t compareCanvases(in nsIDOMHTMLCanvasElement aCanvas1, + in nsIDOMHTMLCanvasElement aCanvas2, + out unsigned long aMaxDifference); + + /** + * Returns true if a MozAfterPaint event has been queued but not yet + * fired. + */ + readonly attribute boolean isMozAfterPaintPending; + + /** + * Suppresses/unsuppresses user initiated event handling in window's document + * and subdocuments. + * + * @throw NS_ERROR_DOM_SECURITY_ERR if called without chrome privileges and + * NS_ERROR_FAILURE if window doesn't have a document. + */ + void suppressEventHandling(in boolean aSuppress); + + void clearMozAfterPaintEvents(); + + /** + * Disable or enable non synthetic test mouse events on *all* windows. + * + * Cannot be accessed from unprivileged context (not content-accessible). + * Will throw a DOM security error if called without chrome privileges. + * + * @param aDisable If true, disable all non synthetic test mouse events + * on all windows. Otherwise, enable them. + */ + void disableNonTestMouseEvents(in boolean aDisable); + + /** + * Returns the scroll position of the window's currently loaded document. + * + * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs. + * @see nsIDOMWindow::scrollX/Y + */ + void getScrollXY(in boolean aFlushLayout, out long aScrollX, out long aScrollY); + + /** + * Returns the scroll position of the window's currently loaded document. + * + * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs. + * @see nsIDOMWindow::scrollX/Y + */ + void getScrollXYFloat(in boolean aFlushLayout, out float aScrollX, out float aScrollY); + + /** + * Returns the scrollbar width of the window's scroll frame. + * + * @param aFlushLayout flushes layout if true. Otherwise, no flush occurs. + */ + void getScrollbarSize(in boolean aFlushLayout, out long aWidth, out long aHeight); + + /** + * Returns the given element's bounds without flushing pending layout changes. + */ + nsIDOMClientRect getBoundsWithoutFlushing(in nsIDOMElement aElement); + + /** + * Returns the bounds of the window's currently loaded document. This will + * generally be (0, 0, pageWidth, pageHeight) but in some cases (e.g. RTL + * documents) may have a negative left value. + */ + nsIDOMClientRect getRootBounds(); + + /** + * Get IME open state. TRUE means 'Open', otherwise, 'Close'. + * This property works only when IMEEnabled is IME_STATUS_ENABLED. + */ + readonly attribute boolean IMEIsOpen; + + /** + * WARNING: These values must be same as nsIWidget's values. + */ + + /** + * DISABLED means users cannot use IME completely. + * Note that this state is *not* same as |ime-mode: disabled;|. + */ + const unsigned long IME_STATUS_DISABLED = 0; + + /** + * ENABLED means users can use all functions of IME. This state is same as + * |ime-mode: normal;|. + */ + const unsigned long IME_STATUS_ENABLED = 1; + + /** + * PASSWORD means users cannot use most functions of IME. But on GTK2, + * users can use "Simple IM" which only supports dead key inputting. + * The behavior is same as the behavior of the native password field. + * This state is same as |ime-mode: disabled;|. + */ + const unsigned long IME_STATUS_PASSWORD = 2; + + /** + * PLUGIN means a plug-in has focus. At this time we should not touch to + * controlling the IME state. + */ + const unsigned long IME_STATUS_PLUGIN = 3; + + /** + * Get IME status, see above IME_STATUS_* definitions. + */ + readonly attribute unsigned long IMEStatus; + + /** + * Get the number of screen pixels per CSS pixel. + */ + readonly attribute float screenPixelsPerCSSPixel; + + /** + * Get the current zoom factor. + * This is _approximately_ the same as nsIContentViewer.fullZoom, + * but takes into account Gecko's quantization of the zoom factor, which is + * implemented by adjusting the (integer) number of appUnits per devPixel. + */ + readonly attribute float fullZoom; + + /** + * Dispatches aEvent via the nsIPresShell object of the window's document. + * The event is dispatched to aTarget, which should be an object + * which implements nsIContent interface (#element, #text, etc). + * + * Cannot be accessed from unprivileged context (not + * content-accessible) Will throw a DOM security error if called + * without chrome privileges. + * + * @note Event handlers won't get aEvent as parameter, but a similar event. + * Also, aEvent should not be reused. + */ + boolean dispatchDOMEventViaPresShell(in nsIDOMNode aTarget, + in nsIDOMEvent aEvent, + in boolean aTrusted); + + /** + * Sets WidgetEvent::mFlags::mOnlyChromeDispatch to true to ensure that + * the event is propagated only to chrome. + * Event's .target property will be aTarget. + * Returns the same value as what EventTarget.dispatchEvent does. + */ + boolean dispatchEventToChromeOnly(in nsIDOMEventTarget aTarget, + in nsIDOMEvent aEvent); + + /** + * Returns the real classname (possibly of the mostly-transparent security + * wrapper) of aObj. + */ + [implicit_jscontext] string getClassName(in jsval aObject); + + /** + * Generate a content command event. + * + * Cannot be accessed from unprivileged context (not content-accessible) + * Will throw a DOM security error if called without chrome privileges. + * + * @param aType Type of command content event to send. Can be one of "cut", + * "copy", "paste", "delete", "undo", "redo", or "pasteTransferable". + * @param aTransferable an instance of nsITransferable when aType is + * "pasteTransferable" + */ + void sendContentCommandEvent(in AString aType, + [optional] in nsITransferable aTransferable); + + /** + * If sendQueryContentEvent()'s aAdditionalFlags argument is + * QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK, plain text generated from content + * is created with "\n". + * Otherwise, platform dependent. E.g., on Windows, "\r\n" is used. + * aOffset and aLength are offset and length in/of the plain text content. + * This flag also affects the result values such as offset, length and string. + */ + const unsigned long QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; + const unsigned long QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK = 0x0001; + + /** + * sendQueryContentEvent()'s aAdditionalFlags may have one of following + * flags when aType is QUERY_SELECTED_TEXT. If one of them is set, + * the result is the first range of the selection type. See also + * nsISelectionController::SELECTION_*. + */ + const unsigned long QUERY_CONTENT_FLAG_SELECTION_SPELLCHECK = 0x0002; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_RAWINPUT = 0x0004; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDRAWTEXT = 0x0008; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_CONVERTEDTEXT = 0x0010; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDCONVERTEDTEXT = + 0x0020; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_ACCESSIBILITY = 0x0040; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_FIND = 0x0080; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSECONDARY = 0x0100; + const unsigned long QUERY_CONTENT_FLAG_SELECTION_URLSTRIKEOUT = 0x0200; + + /** + * One of sendQueryContentEvent()'s aAdditionalFlags. If this is specified, + * aOffset is relative to start of selection or composition. + * Note that this is supported only when QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK + * is not specified for now. + */ + const unsigned long QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT = + 0x0400; + + /** + * Synthesize a query content event. Note that the result value returned here + * is in LayoutDevice pixels rather than CSS pixels. + * + * @param aType One of the following const values. And see also each comment + * for the other parameters and the result. + * @param aAdditionalFlags See the description of QUERY_CONTENT_FLAG_*. + */ + nsIQueryContentEventResult sendQueryContentEvent( + in unsigned long aType, + in long long aOffset, + in unsigned long aLength, + in long aX, + in long aY, + [optional] in unsigned long aAdditionalFlags); + + /** + * QUERY_SELECTED_TEXT queries the first selection range's information. + * + * @param aOffset Not used. + * @param aLength Not used. + * @param aX Not used. + * @param aY Not used. + * + * @return offset, reversed and text properties of the result are available. + */ + const unsigned long QUERY_SELECTED_TEXT = 3200; + + /** + * QUERY_TEXT_CONTENT queries the text at the specified range. + * + * @param aOffset The first character's offset. 0 is the first character. + * @param aLength The length of getting text. If the aLength is too long, + * the result text is shorter than this value. + * @param aX Not used. + * @param aY Not used. + * + * @return text property of the result is available. + */ + const unsigned long QUERY_TEXT_CONTENT = 3201; + + /** + * QUERY_CARET_RECT queries the (collapsed) caret rect of the offset. + * If the actual caret is there at the specified offset, this returns the + * actual caret rect. Otherwise, this guesses the caret rect from the + * metrics of the text. + * + * @param aOffset The caret offset. 0 is the left side of the first + * caracter in LTR text. + * @param aLength Not used. + * @param aX Not used. + * @param aY Not used. + * + * @return left, top, width and height properties of the result are available. + * The left and the top properties are offset in the client area of + * the DOM window. + */ + const unsigned long QUERY_CARET_RECT = 3203; + + /** + * QUERY_TEXT_RECT queries the specified text's rect. + * + * @param aOffset The first character's offset. 0 is the first character. + * @param aLength The length of getting text. If the aLength is too long, + * the extra length is ignored. + * @param aX Not used. + * @param aY Not used. + * + * @return left, top, width and height properties of the result are available. + * The left and the top properties are offset in the client area of + * the DOM window. + */ + const unsigned long QUERY_TEXT_RECT = 3204; + + /** + * QUERY_TEXT_RECT queries the focused editor's rect. + * + * @param aOffset Not used. + * @param aLength Not used. + * @param aX Not used. + * @param aY Not used. + * + * @return left, top, width and height properties of the result are available. + */ + const unsigned long QUERY_EDITOR_RECT = 3205; + + /** + * QUERY_CHARACTER_AT_POINT queries the character information at the + * specified point. The point is offset in the window. + * NOTE: If there are some panels at the point, this method send the query + * event to the panel's widget automatically. + * + * @param aOffset Not used. + * @param aLength Not used. + * @param aX X offset in the widget. + * @param aY Y offset in the widget. + * + * @return offset, notFound, left, top, width and height properties of the + * result are available. + */ + const unsigned long QUERY_CHARACTER_AT_POINT = 3208; + + /** + * QUERY_TEXT_RECT_ARRAY queries the rects per character + * + * @param aOffset The first character's offset. 0 is the first character. + * @param aLength The length of getting text. If the aLength is too long, + * the extra length is ignored. + * @param aX Not used. + * @param aY Not used. + */ + const unsigned long QUERY_TEXT_RECT_ARRAY = 3209; + + /** + * Called when the remote child frame has changed its fullscreen state, + * when entering fullscreen, and when the origin which is fullscreen changes. + * aFrameElement is the iframe element which contains the child-process + * fullscreen document. + */ + void remoteFrameFullscreenChanged(in nsIDOMElement aFrameElement); + + /** + * Called when the remote frame has popped all fullscreen elements off its + * stack, so that the operation can complete on the parent side. + */ + void remoteFrameFullscreenReverted(); + + /** + * Calls the document to handle any pending fullscreen requests. + * It is called when the parent document has entered fullscreen, and + * we want to put the current document into fullscreen as well. + * The return value indicates whether there is any fullscreen request + * handled by this call. + */ + boolean handleFullscreenRequests(); + + /** + * Called when the child frame has fully exit fullscreen, so that the parent + * process can also fully exit. + */ + void exitFullscreen(); + + /** + * If sendQueryContentEvent()'s aAdditionalFlags argument is + * SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK, aOffset and aLength are offset + * and length in/of plain text generated from content is created with "\n". + * Otherwise, platform dependent. E.g., on Windows, "\r\n" is used. + */ + const unsigned long SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; + const unsigned long SELECTION_SET_FLAG_USE_XP_LINE_BREAK = 0x0001; + + /** + * If SELECTION_SET_FLAG_REVERSE is set, the selection is set from + * |aOffset + aLength| to |aOffset|. Otherwise, it's set from |aOffset| to + * |aOffset + aLength|. + */ + const unsigned long SELECTION_SET_FLAG_REVERSE = 0x0002; + + /** + * Synthesize a selection set event to the window. + * + * This sets the selection as the specified information. + * + * @param aOffset The caret offset of the selection start. + * @param aLength The length of the selection. If this is too long, the + * extra length is ignored. + * @param aAdditionalFlags See the description of SELECTION_SET_FLAG_*. + * @return True, if succeeded. Otherwise, false. + */ + boolean sendSelectionSetEvent(in unsigned long aOffset, + in unsigned long aLength, + [optional] in unsigned long aAdditionalFlags); + + /* Selection behaviors - mirror nsIFrame's nsSelectionAmount constants */ + const unsigned long SELECT_CHARACTER = 0; + const unsigned long SELECT_CLUSTER = 1; + const unsigned long SELECT_WORD = 2; + const unsigned long SELECT_LINE = 3; + const unsigned long SELECT_BEGINLINE = 4; + const unsigned long SELECT_ENDLINE = 5; + const unsigned long SELECT_PARAGRAPH = 6; + const unsigned long SELECT_WORDNOSPACE = 7; + + /** + * Select content at a client point based on a selection behavior if the + * underlying content is selectable. Selection will accumulate with any + * existing selection, callers should clear selection prior if needed. + * May fire selection changed events. Calls nsFrame's SelectByTypeAtPoint. + * + * @param aX, aY The selection point in client coordinates. + * @param aSelectType The selection behavior requested. + * @return True if a selection occured, false otherwise. + * @throw NS_ERROR_DOM_SECURITY_ERR, NS_ERROR_UNEXPECTED for utils + * issues, and NS_ERROR_INVALID_ARG for coordinates that are outside + * this window. + */ + boolean selectAtPoint(in float aX, + in float aY, + in unsigned long aSelectBehavior); + + /** + * Perform the equivalent of: + * window.getComputedStyle(aElement, aPseudoElement). + * getPropertyValue(aPropertyName) + * except that, when the link whose presence in history is allowed to + * influence aElement's style is visited, get the value the property + * would have if allowed all properties to change as a result of + * :visited selectors (except for cases where getComputedStyle uses + * data from the frame). + * + * This is easier to implement than adding our property restrictions + * to this API, and is sufficient for the present testing + * requirements (which are essentially testing 'color'). + */ + AString getVisitedDependentComputedStyle(in nsIDOMElement aElement, + in AString aPseudoElement, + in AString aPropertyName); + + /** + * Get the id of the outer window of this window. This will never throw. + */ + readonly attribute unsigned long long outerWindowID; + + /** + * Get the id of the current inner window of this window. If there + * is no current inner window, throws NS_ERROR_NOT_AVAILABLE. + */ + readonly attribute unsigned long long currentInnerWindowID; + + /** + * Put the window into a state where scripts are frozen and events + * suppressed, for use when the window has launched a modal prompt. + */ + void enterModalState(); + + /** + * Resume normal window state, where scripts can run and events are + * delivered. + */ + void leaveModalState(); + + /** + * Is the window is in a modal state? [See enterModalState()] + */ + [noscript] boolean isInModalState(); + + /** + * Request set internal desktopMode flag change. + */ + void setDesktopModeViewport(in boolean aDesktopModeViewport); + + /** + * Suspend/resume timeouts on this window and its descendant windows. + */ + void suspendTimeouts(); + void resumeTimeouts(); + + /** + * What type of layer manager the widget associated with this window is + * using. "Basic" is unaccelerated; other types are accelerated. Throws an + * error if there is no widget associated with this window. + */ + readonly attribute AString layerManagerType; + + /** + * True if the layer manager for the widget associated with this window is + * forwarding layers to a remote compositor, false otherwise. Throws an + * error if there is no widget associated with this window. + */ + readonly attribute boolean layerManagerRemote; + + /** + * Returns a Promise that will be resolved with a string once the capabilities + * of the h264 decoder have been determined. + * Success does not mean that all h264 video decoding will be done + * in hardware. + */ + readonly attribute jsval supportsHardwareH264Decoding; + + /** + * Returns the current audio backend as a free-form string. + */ + readonly attribute AString currentAudioBackend; + + /** + * Record (and return) frame-intervals for frames which were presented + * between calling StartFrameTimeRecording and StopFrameTimeRecording. + * + * - Uses a cyclic buffer and serves concurrent consumers, so if Stop is called too late + * (elements were overwritten since Start), result is considered invalid and hence empty. + * - Buffer is capable of holding 10 seconds @ 60fps (or more if frames were less frequent). + * Can be changed (up to 1 hour) via pref: toolkit.framesRecording.bufferSize. + * - Note: the first frame-interval may be longer than expected because last frame + * might have been presented some time before calling StartFrameTimeRecording. + */ + + /** + * Returns a handle which represents current recording start position. + */ + void startFrameTimeRecording([retval] out unsigned long startIndex); + + /** + * Returns number of recorded frames since startIndex was issued, + * and allocates+populates 2 arraye with the recorded data. + * - Allocation is infallible. Should be released even if size is 0. + */ + void stopFrameTimeRecording(in unsigned long startIndex, + [optional] out unsigned long frameCount, + [retval, array, size_is(frameCount)] out float frameIntervals); + + /** + * Signals that we're begining to tab switch. This is used by painting code to + * determine total tab switch time. + */ + void beginTabSwitch(); + + /** + * The DPI of the display + */ + readonly attribute float displayDPI; + + /** + * Return the outer window with the given ID, if any. Can return null. + * @deprecated Use nsIWindowMediator.getOuterWindowWithId. See bug 865664. + */ + nsIDOMWindow getOuterWindowWithId(in unsigned long long aOuterWindowID); + + /** + * Return this window's frame element. + * Ignores all chrome/content or mozbrowser boundaries. + */ + readonly attribute nsIDOMElement containerElement; + + [noscript] void RenderDocument(in nsConstRect aRect, + in uint32_t aFlags, + in nscolor aBackgroundColor, + in gfxContext aThebesContext); + + /** + * advanceTimeAndRefresh allows the caller to take over the refresh + * driver timing for a window. A call to advanceTimeAndRefresh does + * three things: + * (1) It marks the refresh driver for this presentation so that it + * no longer refreshes on its own, but is instead driven entirely + * by the caller (except for the refresh that happens when a + * document comes out of the bfcache). + * (2) It advances the refresh driver's current refresh time by the + * argument given. Negative advances are permitted. + * (3) It does a refresh (i.e., notifies refresh observers) at that + * new time. + * + * Note that this affects other connected docshells of the same type + * in the same docshell tree, such as parent frames. + * + * When callers have completed their use of advanceTimeAndRefresh, + * they must call restoreNormalRefresh. + */ + void advanceTimeAndRefresh(in long long aMilliseconds); + + /** + * Undoes the effects of advanceTimeAndRefresh. + */ + void restoreNormalRefresh(); + + /** + * Reports whether the current state is test-controlled refreshes + * (see advanceTimeAndRefresh and restoreNormalRefresh above). + */ + readonly attribute bool isTestControllingRefreshes; + + /** + * Reports whether APZ is enabled on the widget that this window is attached + * to. If there is no widget it will report the default platform value of + * whether or not APZ is enabled. + */ + readonly attribute bool asyncPanZoomEnabled; + + /** + * Set async scroll offset on an element. The next composite will render + * with that offset if async scrolling is enabled, and then the offset + * will be removed. Only call this while test-controlled refreshes is enabled. + */ + void setAsyncScrollOffset(in nsIDOMNode aNode, in float aX, in float aY); + + /** + * Set async zoom value. aRootElement should be the document element of our + * document. The next composite will render with that zoom added to any + * existing zoom if async scrolling is enabled, and then the zoom will be + * removed. Only call this while test-controlled refreshes is enabled. + */ + void setAsyncZoom(in nsIDOMNode aRootElement, in float aValue); + + /** + * Do a round-trip to the compositor to ensure any pending APZ repaint requests + * get flushed to the main thread. If the function returns true, the flush was + * triggered and an "apz-repaints-flushed" notification will be dispatched via + * the observer service once the flush is complete. If the function returns + * false, an error occurred or a flush is not needed, and the notification + * will not fire. This is intended to be used by test code only! + */ + bool flushApzRepaints(); + + /** + * Ask APZ to pan and zoom to the focused input element. + */ + void zoomToFocusedInput(); + + /** + * Method for testing StyleAnimationValue::ComputeDistance. + * + * Returns the distance between the two values as reported by + * StyleAnimationValue::ComputeDistance for the given element and + * property. + */ + double computeAnimationDistance(in nsIDOMElement element, + in AString property, + in AString value1, + in AString value2); + + /** + * Wrap an nsIFile in an DOM File + * Returns a File object. + */ + nsISupports wrapDOMFile(in nsIFile aFile); + + /** + * Get the type of the currently focused html input, if any. + */ + readonly attribute string focusedInputType; + + /** + * Find the view ID for a given element. This is the reverse of + * findElementWithViewId(). + */ + nsViewID getViewId(in nsIDOMElement aElement); + + /** + * Checks the layer tree for this window and returns true + * if all layers have transforms that are translations by integers, + * no leaf layers overlap, and the union of the leaf layers is exactly + * the bounds of the window. Always returns true in non-DEBUG builds. + */ + boolean leafLayersPartitionWindow(); + + /** + * Check if any PaintedLayer painting has been done for this element, + * clears the painted flags if they have. + */ + boolean checkAndClearPaintedState(in nsIDOMElement aElement); + + /** + * Check whether all display items of the primary frame of aElement have been + * assigned to the same single PaintedLayer in the last paint. If that is the + * case, returns whether that PaintedLayer is opaque; if it's not the case, an + * exception is thrown. + */ + boolean isPartOfOpaqueLayer(in nsIDOMElement aElement); + + /** + * Count the number of different PaintedLayers that the supplied elements have + * been assigned to in the last paint. Throws an exception if any of the + * elements doesn't have a primary frame, or if that frame's display items are + * assigned to any other layers than just a single PaintedLayer per element. + */ + unsigned long numberOfAssignedPaintedLayers([array, size_is(count)] in nsIDOMElement aElements, + in uint32_t count); + + /** + * Get internal id of the stored blob, file or file handle. + */ + [implicit_jscontext] long long getFileId(in jsval aFile); + + /** + * Get internal file path of the stored file or file handle. + * + * TODO: File handle objects are actually not supported at the moment. + */ + [implicit_jscontext] AString getFilePath(in jsval aFile); + + /** + * Get file ref count info for given database and file id. + * + */ + [implicit_jscontext] + boolean getFileReferences(in AString aDatabaseName, in long long aId, + [optional] in jsval aOptions, + [optional] out long aRefCnt, + [optional] out long aDBRefCnt, + [optional] out long aSliceRefCnt); + + void flushPendingFileDeletions(); + + /** + * Return whether incremental GC has been disabled due to a binary add-on. + */ + [implicit_jscontext] + boolean isIncrementalGCEnabled(); + + /** + * Begin opcode-level profiling of all JavaScript execution in the window's + * runtime. + */ + [implicit_jscontext] + void startPCCountProfiling(); + + /** + * Stop opcode-level profiling of JavaScript execution in the runtime, and + * collect all counts for use by getPCCount methods. + */ + [implicit_jscontext] + void stopPCCountProfiling(); + + /** + * Purge collected PC counters. + */ + [implicit_jscontext] + void purgePCCounts(); + + /** + * Get the number of scripts with opcode-level profiling information. + */ + [implicit_jscontext] + long getPCCountScriptCount(); + + /** + * Get a JSON string for a short summary of a script and the PC counts + * accumulated for it. + */ + [implicit_jscontext] + AString getPCCountScriptSummary(in long script); + + /** + * Get a JSON string with full information about a profiled script, + * including the decompilation of the script and placement of decompiled + * operations within it, and PC counts for each operation. + */ + [implicit_jscontext] + AString getPCCountScriptContents(in long script); + + /** + * Returns true if painting is suppressed for this window and false + * otherwise. + */ + readonly attribute boolean paintingSuppressed; + + /** + * Returns an array of plugins on the page for opt-in activation. + * + * Cannot be accessed from unprivileged context (not content-accessible). + * Will throw a DOM security error if called without chrome privileges. + * + */ + [implicit_jscontext] + readonly attribute jsval plugins; + + /** + * Set the scrollport size for the purposes of clamping scroll positions for + * the root scroll frame of this document to be (aWidth,aHeight) in CSS pixels. + * + * The caller of this method must have chrome privileges. + */ + void setScrollPositionClampingScrollPortSize(in float aWidth, in float aHeight); + + /** + * These are used to control whether dialogs (alert, prompt, confirm) are + * allowed. + */ + void disableDialogs(); + void enableDialogs(); + bool areDialogsEnabled(); + + const unsigned long AGENT_SHEET = 0; + const unsigned long USER_SHEET = 1; + const unsigned long AUTHOR_SHEET = 2; + /** + * Synchronously loads a style sheet from |sheetURI| and adds it to the list + * of additional style sheets of the document. + * + * These additional style sheets are very much like user/agent sheets loaded + * with loadAndRegisterSheet. The only difference is that they are applied only + * on the document owned by this window. + * + * Sheets added via this API take effect immediately on the document. + */ + void loadSheet(in nsIURI sheetURI, in unsigned long type); + + /** + * Same as the above method but allows passing the URI as a string. + */ + void loadSheetUsingURIString(in ACString sheetURI, in unsigned long type); + + /** + * Adds a style sheet to the list of additional style sheets of the document. + * + * Style sheets can be preloaded with nsIStyleSheetService.preloadSheet. + * + * Sheets added via this API take effect immediately on the document. + */ + void addSheet(in nsIDOMStyleSheet sheet, in unsigned long type); + + /** + * Remove the document style sheet at |sheetURI| from the list of additional + * style sheets of the document. The removal takes effect immediately. + */ + void removeSheet(in nsIURI sheetURI, in unsigned long type); + + /** + * Same as the above method but allows passing the URI as a string. + */ + void removeSheetUsingURIString(in ACString sheetURI, in unsigned long type); + + /** + * Returns true if a user input is being handled. + * + * This calls EventStateManager::IsHandlingUserInput(). + */ + readonly attribute boolean isHandlingUserInput; + + /** + * Returns milliseconds elapsed since last user input was started + * + * This relies on EventStateManager::LatestUserInputStart() + */ + readonly attribute double millisSinceLastUserInput; + + /** + * After calling the method, the window for which this DOMWindowUtils + * was created can be closed using scripts. + */ + void allowScriptsToClose(); + + /** + * Is the parent window's main widget visible? If it isn't, we probably + * don't want to display any dialogs etc it may request. This corresponds + * to the visibility check in nsWindowWatcher::OpenWindowInternal(). + * + * Will throw a DOM security error if called without chrome privileges or + * NS_ERROR_NOT_AVAILABLE in the unlikely event that the parent window's + * main widget can't be reached. + */ + readonly attribute boolean isParentWindowMainWidgetVisible; + + /** + * In certain cases the event handling of nodes, form controls in practice, + * may be disabled. Such cases are for example the existence of disabled + * attribute or -moz-user-input: none/disabled. + */ + boolean isNodeDisabledForEvents(in nsIDOMNode aNode); + + /** + * Setting paintFlashing to true will flash newly painted area. + */ + attribute boolean paintFlashing; + + /* + * Returns the value of a given property animated on the compositor thread. + * If the property is NOT currently being animated on the compositor thread, + * returns an empty string. + */ + AString getOMTAStyle(in nsIDOMElement aElement, in AString aProperty, + [optional] in AString aPseudoElement); + + /** + * Special function that gets a property syncronously from the last composite + * that occured. + * + * Supported properties: + * "overdraw": Report a percentage between 0 and 999 indicate how many times + * each pixels on the destination window have been touched. + * "missed_hwc": Report a bool if hardware composer is supported but was + * not used for the last frame. + */ + float requestCompositorProperty(in AString aProperty); + + /** + * If aHandlingInput is true, this informs the event state manager that + * we're handling user input. Otherwise, this is a no-op (as by default + * we're not handling user input). + * Remember to call destruct() on the return value! + * See also nsIDOMWindowUtils::isHandlingUserInput. + */ + nsIJSRAIIHelper setHandlingUserInput(in boolean aHandlingInput); + + /** + * Get the content- and compositor-side APZ test data instances. + * The return values are of type APZTestData (see APZTestData.webidl). + */ + [implicit_jscontext] jsval getContentAPZTestData(); + [implicit_jscontext] jsval getCompositorAPZTestData(); + + /** + * Posts an eRestyle_Self restyle event for the given element. + */ + void postRestyleSelfEvent(in nsIDOMElement aElement); + + /** + * Used to pause or resume all media in this window. Use-cases are audio + * competing, remote media control and to prevent auto-playing media. + */ + attribute uint32_t mediaSuspend; + + /** + * With this it's possible to mute all the MediaElements in this window. + * We have audioMuted and audioVolume to preserve the volume across + * mute/umute. + */ + attribute boolean audioMuted; + + /** + * range: greater or equal to 0. The real volume level is affected by the + * volume of all ancestor windows. + */ + attribute float audioVolume; + + /** + * This method doesn't do anything useful. It was solely added for the + * purpose of the test for bug 503926. + */ + void xpconnectArgument(in nsIDOMWindowUtils aThis); + + /** + * Helper for JS components that need to send permission requests with + * e10s support properly. + */ + void askPermission(in nsIContentPermissionRequest aRequest); + + /** + * Number of elements restyled for the curent document. + * + * Note that during a restyle operation we may restyle an element more + * than once (e.g., for an inline that contains blocks). This also + * counts restyling of pseudo-elements and anonymous boxes. + * + * May throw NS_ERROR_NOT_AVAILABLE. + */ + readonly attribute unsigned long long elementsRestyled; + + /** + * Number of frames constructed (excluding breaking) for the curent + * document. + * + * May throw NS_ERROR_NOT_AVAILABLE. + */ + readonly attribute unsigned long long framesConstructed; + + /** + * Number of frames reflowed for the curent document. + * + * May throw NS_ERROR_NOT_AVAILABLE. + */ + readonly attribute unsigned long long framesReflowed; + + /** + * Controls the amount of chrome that should be visible on each side of + * the window. Works like the chromemargin xul:window attribute. + * This should only be used with non-XUL windows. + */ + void setChromeMargin(in int32_t aTop, + in int32_t aRight, + in int32_t aBottom, + in int32_t aLeft); + + /** + * Enable some service workers testing features. + */ + attribute boolean serviceWorkersTestingEnabled; + + /** + * Returns a JSObject which contains a list of frame uniformities + * when the pref gfx.vsync.collect-scroll-data is enabled. + * Every result contains a layer address and a frame uniformity for that layer. + * A negative frame uniformity value indicates an invalid frame uniformity and an error has occured. + */ + [implicit_jscontext] jsval getFrameUniformityTestData(); + + /* + * Increase the chaos mode activation level. An equivalent number of + * calls to leaveChaosMode must be made in order to restore the original + * chaos mode state. If the activation level is nonzero all chaos mode + * features are activated. + */ + void enterChaosMode(); + + /** + * Decrease the chaos mode activation level. See enterChaosMode(). + */ + void leaveChaosMode(); + + /** + * Returns whether the document's style set's rule processor for the + * specified level of the cascade is shared by multiple style sets. + * (Used by tests to ensure that certain optimizations do not regress.) + * + * @param aSheetType One of the nsIStyleSheetService.*_SHEET constants. + */ + bool hasRuleProcessorUsedByMultipleStyleSets(in unsigned long aSheetType); + + /* + * Force the use counters for the node's associated document(s) to be + * flushed to telemetry. For example, a document node will flush its own + * counters and an image node with an SVG source will flush the SVG + * document's counters. Normally, use counters are flushed to telemetry + * upon document destruction, but as document destruction is somewhat + * non-deterministic, we have this method here for more determinism when + * running tests. + */ + void forceUseCounterFlush(in nsIDOMNode aNode); + + void setNextPaintSyncId(in long aSyncId); + + /** + * Enable or disable displayport suppression. This is intended to be used by + * testing code, to provide more deterministic behaviour over the displayport + * suppression during tests. Note that this updates a flag, so whatever value + * was last provided is what will be used. + */ + void respectDisplayPortSuppression(in boolean aEnabled); + + /** + * Set a flag that forces the next reflow interrupt check to return true. This + * can be used by tests to force execution of the interrupted reflow codepaths. + */ + void forceReflowInterrupt(); + + /** + * Terminate the GPU process. Used for testing GPU process restarts. + */ + void terminateGPUProcess(); + + /** + * Returns the GPU process pid, or -1 if there is no GPU process. + */ + readonly attribute int32_t gpuProcessPid; + + const long MOUSE_BUTTONS_NO_BUTTON = 0x00; + const long MOUSE_BUTTONS_LEFT_BUTTON = 0x01; + const long MOUSE_BUTTONS_RIGHT_BUTTON = 0x02; + const long MOUSE_BUTTONS_MIDDLE_BUTTON = 0x04; + // Typically, "back" button being left side of 5-button + // mice, see "buttons" attribute document of DOM3 Events. + const long MOUSE_BUTTONS_4TH_BUTTON = 0x08; + // Typically, "forward" button being right side of 5-button + // mice, see "buttons" attribute document of DOM3 Events. + const long MOUSE_BUTTONS_5TH_BUTTON = 0x10; + // Buttons are not specified, will be calculated from |aButton|. + const long MOUSE_BUTTONS_NOT_SPECIFIED = -1; +}; + +[scriptable, uuid(c694e359-7227-4392-a138-33c0cc1f15a6)] +interface nsITranslationNodeList : nsISupports { + readonly attribute unsigned long length; + nsIDOMNode item(in unsigned long index); + + // A translation root is a block element, or an inline element + // which its parent is not a translation node. + boolean isTranslationRootAtIndex(in unsigned long index); +}; + +/** + * JS doesn't do RAII very well. We can use this interface to make remembering + * to destruct an object in a finally clause easier. + */ +[scriptable, uuid(52e5a996-d0a9-4efc-a6fa-24489c532b19)] +interface nsIJSRAIIHelper : nsISupports { + void destruct(); +}; diff --git a/dom/interfaces/base/nsIFocusManager.idl b/dom/interfaces/base/nsIFocusManager.idl new file mode 100644 index 000000000..0deddc2c3 --- /dev/null +++ b/dom/interfaces/base/nsIFocusManager.idl @@ -0,0 +1,276 @@ +/* -*- 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 mozIDOMWindowProxy; +interface nsIDocument; +interface nsIContent; + +[scriptable, uuid(86e1f1e1-365d-493b-b52a-a649f3f311dc)] +/** + * The focus manager deals with all focus related behaviour. Only one element + * in the entire application may have the focus at a time; this element + * receives any keyboard events. While there is only one application-wide + * focused element, each nsIDOMWindow maintains a reference to the element + * that would be focused if the window was active. + * + * If the window's reference is to a frame element (iframe, browser, + * editor), then the child window contains the element that is currently + * focused. If the window's reference is to a root element, then the root is + * focused. If a window's reference is null, then no element is focused, yet + * the window is still focused. + * + * The blur event is fired on an element when it loses the application focus. + * After this blur event, if the focus is moving away from a document, two + * additional blur events are fired on the old document and window containing + * the focus respectively. + * + * When a new document is focused, two focus events are fired on the new + * document and window respectively. Then the focus event is fired on an + * element when it gains the application focus. + * + * A special case is that the root element may be focused, yet does not + * receive the element focus and blur events. Instead a focus outline may be + * drawn around the document. + * + * Blur and focus events do not bubble as per the W3C DOM Events spec. + */ +interface nsIFocusManager : nsISupports +{ + /** + * The most active (frontmost) window, or null if no window that is part of + * the application is active. Setting the activeWindow raises it, and + * focuses the current child window's current element, if any. Setting this + * to null or to a non-top-level window throws an NS_ERROR_INVALID_ARG + * exception. + */ + attribute mozIDOMWindowProxy activeWindow; + + /** + * The child window within the activeWindow that is focused. This will + * always be activeWindow, a child window of activeWindow or null if no + * child window is focused. Setting the focusedWindow changes the focused + * window and raises the toplevel window it is in. If the current focus + * within the new focusedWindow is a frame element, then the focusedWindow + * will actually be set to the child window and the current element within + * that set as the focused element. This process repeats downwards until a + * non-frame element is found. + */ + attribute mozIDOMWindowProxy focusedWindow; + + /** + * The element that is currently focused. This will always be an element + * within the document loaded in focusedWindow or null if no element in that + * document is focused. + */ + readonly attribute nsIDOMElement focusedElement; + + /** + * Returns the method that was used to focus the element in window. This + * will either be 0, FLAG_BYMOUSE or FLAG_BYKEY. If window is null, then + * the current focusedWindow will be used by default. This has the result + * of retrieving the method that was used to focus the currently focused + * element. + */ + uint32_t getLastFocusMethod(in mozIDOMWindowProxy window); + + /** + * Changes the focused element reference within the window containing + * aElement to aElement. + */ + void setFocus(in nsIDOMElement aElement, in unsigned long aFlags); + + /** + * Move the focus to another element. If aStartElement is specified, then + * movement is done relative to aStartElement. If aStartElement is null, + * then movement is done relative to the currently focused element. If no + * element is focused, focus the first focusable element within the + * document (or the last focusable element if aType is MOVEFOCUS_END). This + * method is equivalent to setting the focusedElement to the new element. + * + * Specifying aStartElement and using MOVEFOCUS_LAST is not currently + * implemented. + * + * If no element is found, and aType is either MOVEFOCUS_ROOT or + * MOVEFOCUS_CARET, then the focus is cleared. If aType is any other value, + * the focus is not changed. + * + * Returns the element that was focused. The return value may be null if focus + * was moved into a child process. + */ + nsIDOMElement moveFocus(in mozIDOMWindowProxy aWindow, + in nsIDOMElement aStartElement, + in unsigned long aType, in unsigned long aFlags); + + /** + * Clears the focused element within aWindow. If the current focusedWindow + * is a descendant of aWindow, sets the current focusedWindow to aWindow. + * + * @throws NS_ERROR_INVALID_ARG if aWindow is null + */ + void clearFocus(in mozIDOMWindowProxy aWindow); + + /** + * Returns the currently focused element within aWindow. If aWindow is equal + * to the current value of focusedWindow, then the returned element will be + * the application-wide focused element (the value of focusedElement). The + * return value will be null if no element is focused. + * + * If aDeep is true, then child frames are traversed and the return value + * may be the element within a child descendant window that is focused. If + * aDeep if false, then the return value will be the frame element if the + * focus is in a child frame. + * + * aFocusedWindow will be set to the currently focused descendant window of + * aWindow, or to aWindow if aDeep is false. This will be set even if no + * element is focused. + * + * @throws NS_ERROR_INVALID_ARG if aWindow is null + */ + nsIDOMElement getFocusedElementForWindow(in mozIDOMWindowProxy aWindow, + in boolean aDeep, + out mozIDOMWindowProxy aFocusedWindow); + + /** + * Moves the selection caret within aWindow to the current focus. + */ + void moveCaretToFocus(in mozIDOMWindowProxy aWindow); + + /*** + * Check if given element is focusable. + */ + boolean elementIsFocusable(in nsIDOMElement aElement, in unsigned long aFlags); + + /* + * Raise the window when switching focus + */ + const unsigned long FLAG_RAISE = 1; + + /** + * Do not scroll the element to focus into view + */ + const unsigned long FLAG_NOSCROLL = 2; + + /** + * If attempting to change focus in a window that is not focused, do not + * switch focus to that window. Instead, just update the focus within that + * window and leave the application focus as is. This flag will have no + * effect if a child window is focused and an attempt is made to adjust the + * focus in an ancestor, as the frame must be switched in this case. + */ + const unsigned long FLAG_NOSWITCHFRAME = 4; + + /** + * This flag is only used when passed to moveFocus. If set, focus is never + * moved to the parent frame of the starting element's document, instead + * iterating around to the beginning of that document again. Child frames + * are navigated as normal. + */ + const unsigned long FLAG_NOPARENTFRAME = 8; + + /** + * Focus is changing due to a mouse operation, for instance the mouse was + * clicked on an element. + */ + const unsigned long FLAG_BYMOUSE = 0x1000; + + /** + * Focus is changing due to a key operation, for instance pressing the tab + * key. This flag would normally be passed when MOVEFOCUS_FORWARD or + * MOVEFOCUS_BACKWARD is used. + */ + const unsigned long FLAG_BYKEY = 0x2000; + + /** + * Focus is changing due to a call to MoveFocus. This flag will be implied + * when MoveFocus is called except when one of the other mechanisms (mouse + * or key) is specified, or when the type is MOVEFOCUS_ROOT or + * MOVEFOCUS_CARET. + */ + const unsigned long FLAG_BYMOVEFOCUS = 0x4000; + + /** + * Always show the focus ring or other indicator of focus, regardless of + * other state. + */ + const unsigned long FLAG_SHOWRING = 0x100000; + + /** + * Focus is changing due to a touch operation that generated a mouse event. + * Normally used in conjunction with FLAG_BYMOUSE. + */ + const unsigned long FLAG_BYTOUCH = 0x200000; + + // these constants are used with the aType argument to MoveFocus + + /** move focus forward one element, used when pressing TAB */ + const unsigned long MOVEFOCUS_FORWARD = 1; + /** move focus backward one element, used when pressing Shift+TAB */ + const unsigned long MOVEFOCUS_BACKWARD = 2; + /** move focus forward to the next frame document, used when pressing F6 */ + const unsigned long MOVEFOCUS_FORWARDDOC = 3; + /** move focus forward to the previous frame document, used when pressing Shift+F6 */ + const unsigned long MOVEFOCUS_BACKWARDDOC = 4; + /** move focus to the first focusable element */ + const unsigned long MOVEFOCUS_FIRST = 5; + /** move focus to the last focusable element */ + const unsigned long MOVEFOCUS_LAST = 6; + /** move focus to the root element in the document */ + const unsigned long MOVEFOCUS_ROOT = 7; + /** move focus to a link at the position of the caret. This is a special value used to + * focus links as the caret moves over them in caret browsing mode. + */ + const unsigned long MOVEFOCUS_CARET = 8; + + /** move focus to the first focusable document */ + const unsigned long MOVEFOCUS_FIRSTDOC = 9; + /** move focus to the last focusable document */ + const unsigned long MOVEFOCUS_LASTDOC = 10; + + /** + * Called when a window has been raised. + */ + [noscript] void windowRaised(in mozIDOMWindowProxy aWindow); + + /** + * Called when a window has been lowered. + */ + [noscript] void windowLowered(in mozIDOMWindowProxy aWindow); + + /** + * Called when a new document in a window is shown. + * + * If aNeedsFocus is true, then focus events are expected to be fired on the + * window if this window is in the focused window chain. + */ + [noscript] void windowShown(in mozIDOMWindowProxy aWindow, + in boolean aNeedsFocus); + + /** + * Called when a document in a window has been hidden or otherwise can no + * longer accept focus. + */ + [noscript] void windowHidden(in mozIDOMWindowProxy aWindow); + + /** + * Fire any events that have been delayed due to synchronized actions. + */ + [noscript] void fireDelayedEvents(in nsIDocument aDocument); + + /** + * Indicate that a plugin wishes to take the focus. This is similar to a + * normal focus except that the widget focus is not changed. Updating the + * widget focus state is the responsibility of the caller. + */ + [noscript] void focusPlugin(in nsIContent aPlugin); + + /** + * Used in a child process to indicate that the parent window is now + * active or deactive. + */ + [noscript] void parentActivated(in mozIDOMWindowProxy aWindow, + in bool active); +}; diff --git a/dom/interfaces/base/nsIIdleObserver.idl b/dom/interfaces/base/nsIIdleObserver.idl new file mode 100644 index 000000000..e7a31c319 --- /dev/null +++ b/dom/interfaces/base/nsIIdleObserver.idl @@ -0,0 +1,16 @@ +/* -*- 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" + +[scriptable, uuid(37916e05-e062-4f72-96d5-660cfb55e9b6)] +interface nsIIdleObserver : nsISupports +{ + // Time is in seconds and is read only when idle observers are added + // and removed. + readonly attribute unsigned long time; + void onidle(); + void onactive(); +}; diff --git a/dom/interfaces/base/nsIQueryContentEventResult.idl b/dom/interfaces/base/nsIQueryContentEventResult.idl new file mode 100644 index 000000000..cdf328535 --- /dev/null +++ b/dom/interfaces/base/nsIQueryContentEventResult.idl @@ -0,0 +1,34 @@ +/* -*- 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 result of query content events. succeeded propery can be used always. + * Whether other properties can be used or not depends on the event. + * See nsIDOMWindowUtils.idl, which properites can be used was documented. + */ + +[scriptable, uuid(e2c39e0e-345f-451a-a7b2-e0230d555847)] +interface nsIQueryContentEventResult : nsISupports +{ + readonly attribute unsigned long offset; + readonly attribute unsigned long tentativeCaretOffset; + readonly attribute boolean reversed; + + readonly attribute long left; + readonly attribute long top; + readonly attribute long width; + readonly attribute long height; + readonly attribute AString text; + + void getCharacterRect(in long offset, + out long left, out long top, + out long width, out long height); + + readonly attribute boolean succeeded; + readonly attribute boolean notFound; + readonly attribute boolean tentativeCaretOffsetNotFound; +}; diff --git a/dom/interfaces/base/nsIRemoteBrowser.idl b/dom/interfaces/base/nsIRemoteBrowser.idl new file mode 100644 index 000000000..25ab5d737 --- /dev/null +++ b/dom/interfaces/base/nsIRemoteBrowser.idl @@ -0,0 +1,25 @@ +/* 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" + +[scriptable, uuid(C8379366-F79F-4D25-89A6-22BEC0A93D16)] +interface nsIRemoteBrowser : nsISupports +{ + /* + * Called by the child to inform the parent that a command update has occurred + * and the supplied set of commands are now enabled and disabled. + * + * @param action command updater action + * @param enabledLength length of enabledCommands array + * @param enabledCommands commands to enable + * @param disabledLength length of disabledCommands array + * @param disabledCommand commands to disable + */ + void enableDisableCommands(in AString action, + in unsigned long enabledLength, + [array, size_is(enabledLength)] in string enabledCommands, + in unsigned long disabledLength, + [array, size_is(disabledLength)] in string disabledCommands); +}; diff --git a/dom/interfaces/base/nsIServiceWorkerManager.idl b/dom/interfaces/base/nsIServiceWorkerManager.idl new file mode 100644 index 000000000..794a740d5 --- /dev/null +++ b/dom/interfaces/base/nsIServiceWorkerManager.idl @@ -0,0 +1,227 @@ +/* -*- 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 mozIDOMWindow; +interface nsPIDOMWindowInner; +interface mozIDOMWindowProxy; +interface nsIArray; +interface nsIDocument; +interface nsIInterceptedChannel; +interface nsIPrincipal; +interface nsIRunnable; +interface nsIURI; + +[scriptable, uuid(52ee2c9d-ee87-4caf-9588-23ae77ff8798)] +interface nsIServiceWorkerUnregisterCallback : nsISupports +{ + // aState is true if the unregistration succeded. + // It's false if this ServiceWorkerRegistration doesn't exist. + void unregisterSucceeded(in bool aState); + void unregisterFailed(); +}; + +interface nsIWorkerDebugger; + +[scriptable, builtinclass, uuid(76e357ed-208d-4e4c-9165-1c4059707879)] +interface nsIServiceWorkerInfo : nsISupports +{ + // State values below should match the ServiceWorkerState enumeration. + const unsigned short STATE_INSTALLING = 0; + const unsigned short STATE_INSTALLED = 1; + const unsigned short STATE_ACTIVATING = 2; + const unsigned short STATE_ACTIVATED = 3; + const unsigned short STATE_REDUNDANT = 4; + const unsigned short STATE_UNKNOWN = 5; + + readonly attribute DOMString scriptSpec; + readonly attribute DOMString cacheName; + + readonly attribute unsigned short state; + + readonly attribute nsIWorkerDebugger debugger; + + void attachDebugger(); + + void detachDebugger(); +}; + +[scriptable, uuid(87e63548-d440-4b8a-b158-65ad1de0211E)] +interface nsIServiceWorkerRegistrationInfoListener : nsISupports +{ + void onChange(); +}; + +[scriptable, builtinclass, uuid(ddbc1fd4-2f2e-4fca-a395-6e010bbedfe3)] +interface nsIServiceWorkerRegistrationInfo : nsISupports +{ + readonly attribute nsIPrincipal principal; + + readonly attribute DOMString scope; + readonly attribute DOMString scriptSpec; + + readonly attribute nsIServiceWorkerInfo installingWorker; + readonly attribute nsIServiceWorkerInfo waitingWorker; + readonly attribute nsIServiceWorkerInfo activeWorker; + + // Allows to get the related nsIServiceWorkerInfo for a given + // nsIWorkerDebugger. Over time we shouldn't need this anymore, + // and instead always control then nsIWorkerDebugger from + // nsIServiceWorkerInfo and not the other way around. Returns + // null if the service worker is no longer registered. + nsIServiceWorkerInfo getWorkerByID(in unsigned long long aID); + + void addListener(in nsIServiceWorkerRegistrationInfoListener listener); + + void removeListener(in nsIServiceWorkerRegistrationInfoListener listener); +}; + +[scriptable, uuid(9e523e7c-ad6f-4df0-8077-c74aebbc679d)] +interface nsIServiceWorkerManagerListener : nsISupports +{ + void onRegister(in nsIServiceWorkerRegistrationInfo aInfo); + + void onUnregister(in nsIServiceWorkerRegistrationInfo aInfo); +}; + +[scriptable, builtinclass, uuid(7404c8e8-4d47-4449-8ed1-47d1261d4e33)] +interface nsIServiceWorkerManager : nsISupports +{ + /** + * Registers a ServiceWorker with script loaded from `aScriptURI` to act as + * the ServiceWorker for aScope. Requires a valid entry settings object on + * the stack. This means you must call this from content code 'within' + * a window. + * + * Returns a Promise. + */ + nsISupports register(in mozIDOMWindow aWindow, in nsIURI aScope, in nsIURI aScriptURI); + + /** + * Unregister an existing ServiceWorker registration for `aScope`. + * It keeps aCallback alive until the operation is concluded. + */ + void unregister(in nsIPrincipal aPrincipal, + in nsIServiceWorkerUnregisterCallback aCallback, + in DOMString aScope); + + // Returns a Promise + nsISupports getRegistrations(in mozIDOMWindow aWindow); + + // Returns a Promise + nsISupports getRegistration(in mozIDOMWindow aWindow, in DOMString aScope); + + // Returns a Promise + nsISupports getReadyPromise(in mozIDOMWindow aWindow); + + // Remove ready pending Promise + void removeReadyPromise(in mozIDOMWindow aWindow); + + nsIServiceWorkerRegistrationInfo getRegistrationByPrincipal(in nsIPrincipal aPrincipal, + in DOMString aScope); + + /** + * Call this to request that document `aDoc` be controlled by a ServiceWorker + * if a registration exists for it's scope. + * + * This MUST only be called once per document! + */ + [notxpcom,nostdcall] void MaybeStartControlling(in nsIDocument aDoc, in DOMString aDocumentId); + + /** + * Documents that have called MaybeStartControlling() should call this when + * they are destroyed. This function may be called multiple times, and is + * idempotent. + */ + [notxpcom,nostdcall] void MaybeStopControlling(in nsIDocument aDoc); + + /* + * Returns a ServiceWorker. + * window is the window of the caller. scope is the registration's scope and must be + * a valid entry that window is allowed to load, otherwise this will return nullptr. + * These are only meant to be called from ServiceWorkerRegistration instances. + */ + [noscript] nsISupports GetInstalling(in nsPIDOMWindowInner aWindow, in DOMString aScope); + [noscript] nsISupports GetWaiting(in nsPIDOMWindowInner aWindow, in DOMString aScope); + [noscript] nsISupports GetActive(in nsPIDOMWindowInner aWindow, in DOMString aScope); + + /* + * Returns a ServiceWorker object representing the active worker controlling this + * window. + */ + [noscript] nsISupports GetDocumentController(in nsPIDOMWindowInner aWindow); + + /* + * Clears ServiceWorker registrations from memory and disk for the specified + * host. + * - All ServiceWorker instances change their state to redundant. + * - Existing ServiceWorker instances handling fetches will keep running. + * - All documents will immediately stop being controlled. + * - Unregister jobs will be queued for all registrations. + * This eventually results in the registration being deleted from disk too. + */ + void removeAndPropagate(in AUTF8String aHost); + + // Testing + DOMString getScopeForUrl(in nsIPrincipal aPrincipal, in DOMString aPath); + + // Note: This is meant to be used only by about:serviceworkers. + // It returns an array of nsIServiceWorkerRegistrationInfos. + nsIArray getAllRegistrations(); + + // Note: This is meant to be used only by about:serviceworkers. + // It calls softUpdate() for each child process. + [implicit_jscontext] void propagateSoftUpdate(in jsval aOriginAttributes, + in DOMString aScope); + + // Note: This is meant to be used only by about:serviceworkers. + // It calls unregister() in each child process. The callback is used to + // inform when unregister() is completed on the current process. + void propagateUnregister(in nsIPrincipal aPrincipal, + in nsIServiceWorkerUnregisterCallback aCallback, + in DOMString aScope); + + void sendNotificationClickEvent(in ACString aOriginSuffix, + in ACString scope, + in AString aID, + in AString aTitle, + in AString aDir, + in AString aLang, + in AString aBody, + in AString aTag, + in AString aIcon, + in AString aData, + in AString aBehavior); + + void sendNotificationCloseEvent(in ACString aOriginSuffix, + in ACString scope, + in AString aID, + in AString aTitle, + in AString aDir, + in AString aLang, + in AString aBody, + in AString aTag, + in AString aIcon, + in AString aData, + in AString aBehavior); + + [optional_argc] void sendPushEvent(in ACString aOriginAttributes, + in ACString aScope, + [optional] in uint32_t aDataLength, + [optional, array, size_is(aDataLength)] in uint8_t aDataBytes); + void sendPushSubscriptionChangeEvent(in ACString aOriginAttributes, + in ACString scope); + + void addListener(in nsIServiceWorkerManagerListener aListener); + + void removeListener(in nsIServiceWorkerManagerListener aListener); + + bool shouldReportToWindow(in mozIDOMWindowProxy aWindow, in ACString aScope); +}; + +%{ C++ +#define SERVICEWORKERMANAGER_CONTRACTID "@mozilla.org/serviceworkers/manager;1" +%} diff --git a/dom/interfaces/base/nsIStructuredCloneContainer.idl b/dom/interfaces/base/nsIStructuredCloneContainer.idl new file mode 100644 index 000000000..23f11c714 --- /dev/null +++ b/dom/interfaces/base/nsIStructuredCloneContainer.idl @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * vim: set ts=8 sw=2 et 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 "nsISupports.idl" + +interface nsIVariant; +interface nsIDocument; + +%{C++ +#include "js/TypeDecls.h" +%} + +/** + * This interface acts as a container for an object serialized using the + * structured clone algorithm. + * + * You can copy an object into an nsIStructuredCloneContainer using + * initFromJSVal or initFromBase64. It's an error to initialize an + * nsIStructuredCloneContainer more than once. + * + * Once you've initialized the container, you can get a copy of the object it + * stores by calling deserializeToVariant. You can also get a base-64-encoded + * string containing a copy of the container's serialized data, using + * getDataAsBase64. + */ +[scriptable, uuid(c664aae7-0d67-4155-a2dd-a3861778626f)] +interface nsIStructuredCloneContainer : nsISupports +{ + /** + * Initialize this structured clone container so it contains a clone of the + * given jsval. + */ + [noscript, implicit_jscontext] + void initFromJSVal(in jsval aData); + + /** + * Initialize this structured clone container from a base-64-encoded byte + * stream, stored in aData. aFormatVersion should be the version of the + * structured clone algorithm which was used to generate aData. + */ + void initFromBase64(in AString aData, in unsigned long aFormatVersion); + + /** + * Deserializes this structured clone container returning it as a jsval. + * Can be called on main and worker threads. + */ + [implicit_jscontext] + jsval deserializeToJsval(); + + /** + * Deserialize the object this container holds, returning it wrapped as + * an nsIVariant. + * Main thread only! + */ + [implicit_jscontext] + nsIVariant deserializeToVariant(); + + /** + * Get this structured clone container's data as a base-64-encoded string. + */ + AString getDataAsBase64(); + + /** + * Get the size in bytes of this container's serialized data. + */ + readonly attribute unsigned long long serializedNBytes; + + /** + * Get the version of the structured clone algorithm which was used to + * generate this container's serialized buffer. + */ + readonly attribute unsigned long formatVersion; +}; diff --git a/dom/interfaces/base/nsITabChild.idl b/dom/interfaces/base/nsITabChild.idl new file mode 100644 index 000000000..cf3d0bfd6 --- /dev/null +++ b/dom/interfaces/base/nsITabChild.idl @@ -0,0 +1,38 @@ +/* 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 "nsIDroppedLinkHandler.idl" + +interface nsIContentFrameMessageManager; +interface nsIWebBrowserChrome3; + +native CommandsArray(nsTArray<nsCString>); +[ref] native CommandsArrayRef(nsTArray<nsCString>); + +[scriptable, uuid(1fb79c27-e760-4088-b19c-1ce3673ec24e)] +interface nsITabChild : nsISupports +{ + readonly attribute nsIContentFrameMessageManager messageManager; + + attribute nsIWebBrowserChrome3 webBrowserChrome; + + [notxpcom] void sendRequestFocus(in boolean canFocus); + + [notxpcom] void sendGetTabCount(out uint32_t tabCount); + + [noscript, notxpcom] void enableDisableCommands(in AString action, + in CommandsArrayRef enabledCommands, + in CommandsArrayRef disabledCommands); + + [noscript] void remoteSizeShellTo(in int32_t width, in int32_t height, + in int32_t shellItemWidth, in int32_t shellItemHeight); + + [noscript] void remoteDropLinks(in unsigned long linksCount, + [array, size_is(linksCount)] in nsIDroppedLinkItem links); + + readonly attribute uint64_t tabId; +}; + diff --git a/dom/interfaces/base/nsITabParent.idl b/dom/interfaces/base/nsITabParent.idl new file mode 100644 index 000000000..5b03c9070 --- /dev/null +++ b/dom/interfaces/base/nsITabParent.idl @@ -0,0 +1,59 @@ +/* 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" + +[builtinclass, scriptable, uuid(8e49f7b0-1f98-4939-bf91-e9c39cd56434)] +interface nsITabParent : nsISupports +{ + void getChildProcessOffset(out int32_t aCssX, out int32_t aCssY); + + readonly attribute boolean useAsyncPanZoom; + + /** + * Manages the docshell active state of the remote browser. + */ + attribute boolean docShellIsActive; + + /** + * Whether this tabParent is in prerender mode. + */ + [infallible] readonly attribute boolean isPrerendered; + + /** + * As an optimisation, setting the docshell's active state to + * inactive also triggers a layer invalidation to free up some + * potentially unhelpful memory usage. Calling preserveLayers + * will cause the layers to be preserved even for inactive + * docshells. + */ + void preserveLayers(in boolean aPreserveLayers); + + /** + * During interactions where painting performance + * is more important than scrolling, we may temporarily + * suppress the displayport. Each enable called must be matched + * with a disable call. + */ + void suppressDisplayport(in bool aEnabled); + + readonly attribute uint64_t tabId; + + /** + * The OS level process Id of the related child process. + */ + readonly attribute int32_t osPid; + + /** + * Navigate by key. If aForDocumentNavigation is true, navigate by document. + * If aForDocumentNavigation is false, navigate by element. + * + * If aForward is true, navigate to the first focusable element or document. + * If aForward is false, navigate to the last focusable element or document. + */ + void navigateByKey(in bool aForward, in bool aForDocumentNavigation); + + readonly attribute boolean hasContentOpener; +}; diff --git a/dom/interfaces/base/nsITextInputProcessor.idl b/dom/interfaces/base/nsITextInputProcessor.idl new file mode 100644 index 000000000..2ba6b1ecc --- /dev/null +++ b/dom/interfaces/base/nsITextInputProcessor.idl @@ -0,0 +1,589 @@ +/* -*- 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" + +interface nsIDOMKeyEvent; +interface mozIDOMWindow; +interface nsITextInputProcessorCallback; + +/** + * An nsITextInputProcessor instance is associated with a top level widget which + * handles native IME. It's associated by calling beginInputTransaction() or + * beginInputTransactionForTests(). While an instance has composition, nobody + * can steal the rights to make composition on the top level widget. In other + * words, if another instance is composing on a top level widget, either + * beginInputTransaction() or beginInputTransactionForTests() returns false + * (i.e., not throws an exception). + * + * NOTE: See nsITextInputProcessorCallback.idl for examples of |callback| in + * following examples, + * + * Example #1 JS-IME can start composition like this: + * + * var TIP = Components.classes["@mozilla.org/text-input-processor;1"]. + * createInstance(Components.interfaces.nsITextInputProcessor); + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to make composition + * } + * // Create a keyboard event if the following compositionc change is caused + * // by a key event. + * var keyEvent = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // Set new composition string first + * TIP.setPendingCompositionString("some-words-are-inputted"); + * // Set clause information. + * TIP.appendClauseToPendingComposition(23, TIP.ATTR_RAW_CLAUSE); + * // Set caret position, this is optional. + * TIP.setCaretInPendingComposition(23); + * // Flush the pending composition + * if (!TIP.flushPendingComposition(keyEvent)) { + * // If it returns false, it fails to start composition. + * return; + * } + * + * Example #2 JS-IME can separate composition string to two or more clauses: + * + * // Create a keyboard event if the following compositionc change is caused + * // by a key event. + * var keyEvent = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // First, set composition string again + * TIP.setPendingCompositionString("some-words-are-inputted"); + * // Then, if "are" is selected to convert, there are 3 clauses: + * TIP.appendClauseToPendingComposition(11, TIP.ATTR_CONVERTED_CLAUSE); + * TIP.appendClauseToPendingComposition(3, TIP.ATTR_SELECTED_CLAUSE); + * TIP.appendClauseToPendingComposition(9, TIP.ATTR_CONVERTED_CLAUSE); + * // Show caret at the beginning of the selected clause + * TIP.setCaretInPendingComposition(11); + * // Flush the pending composition. Note that if there is a composition, + * // flushPendingComposition() won't return false. + * TIP.flushPendingComposition(keyEvent); + * + * Example #3 JS-IME can commit composition with specific string with this: + * + * // Create a keyboard event if the following compositionc change is caused + * // by a key event. + * var keyEvent1 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // First, there is a composition. + * TIP.setPendingCompositionString("some-words-directly-inputted"); + * TIP.appendClauseToPendingComposition(28, TIP.ATTR_RAW_CLAUSE); + * TIP.flushPendingComposition(keyEvent1); + * // Create a keyboard event if the following commit composition is caused + * // by a key event. + * var keyEvent2 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // This is useful when user selects a commit string from candidate list UI + * // which is provided by JS-IME. + * TIP.commitCompositionWith("selected-words-from-candidate-list", keyEvent2); + * + * Example #4 JS-IME can commit composition with the last composition string + * without specifying commit string: + * + * // Create a keyboard event if the following compositionc change is caused + * // by a key event. + * var keyEvent1 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // First, there is a composition. + * TIP.setPendingCompositionString("some-words-will-be-commited"); + * TIP.appendClauseToPendingComposition(27, TIP.ATTR_RAW_CLAUSE); + * TIP.flushPendingComposition(keyEvent1); + * // Create a keyboard event if the following commit is caused by a key + * // event. + * var keyEvent2 = + * new KeyboardEvent("", { key: "Enter", code: "Enter", + keyCode: KeyboardEvent.DOM_VK_RETURN }); + * // This is useful when user just type Enter key. + * TIP.commitComposition(keyEvent2); + * + * Example #5 JS-IME can cancel composition with this: + * + * // Create a keyboard event if the following composition change is caused + * // by a key event. + * var keyEvent1 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // First, there is a composition. + * TIP.setPendingCompositionString("some-words-will-be-canceled"); + * TIP.appendClauseToPendingComposition(27, TIP.ATTR_RAW_CLAUSE); + * TIP.flushPendingComposition(keyEvent1); + * // Create a keyboard event if the following canceling composition is + * // caused by a key event. + * var keyEvent2 = + * new KeyboardEvent("", { key: "Escape", code: "Escape", + keyCode: KeyboardEvent.DOM_VK_ESCAPE }); + * // This is useful when user doesn't want to commit the composition. + * // FYI: This is same as TIP.commitCompositionWith("") for now. + * TIP.cancelComposition(keyEvent2); + * + * Example #6 JS-IME can insert text only with commitCompositionWith(): + * + * // Create a keyboard event if the following inserting text is caused by a + * // key event. + * var keyEvent1 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to make composition + * } + * TIP.commitCompositionWith("Some words", keyEvent1); + * + * Example #7 JS-IME can start composition explicitly: + * + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to make composition + * } + * // Create a keyboard event if the following starting composition is caused + * // by a key event. + * var keyEvent1 = + * new KeyboardEvent("", { key: "foo", code: "bar", keyCode: buzz }); + * // If JS-IME don't want to show composing string in the focused editor, + * // JS-IME can dispatch only compositionstart event with this. + * if (!TIP.startComposition(keyEvent1)) { + * // Failed to start composition. + * return; + * } + * // And when user selects a result from UI of JS-IME, commit with it. + * // Then, the key event should be null. + * TIP.commitCompositionWith("selected-words"); + * + * Example #8 JS-IME or JS-Keyboard should dispatch key events even during + * composition (non-printable key case): + * + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to dispatch key events + * } + * + * // You don't need to specify .keyCode value if it's non-printable key + * // because it can be computed from .key value. + * // If you specify non-zero value to .keyCode, it'll be used. + * var keyEvent = new KeyboardEvent("", { code: "Enter", key: "Enter" }); + * if (TIP.keydown(keyEvent)) { + * // Handle its default action + * } + * + * // Even if keydown event was consumed, keyup event should be dispatched. + * if (TIP.keyup(keyEvent)) { + * // Handle its default action + * } + * + * Example #9 JS-IME or JS-Keyboard should dispatch key events even during + * composition (printable key case): + * + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to dispatch key events + * } + * + * // You need to specify .keyCode value if it's printable key. + * // The rules of .keyCode value is documented in MDN: + * // https://developer.mozilla.org/docs/Web/API/KeyboardEvent.keyCode + * // + * // #1 If the key location is DOM_KEY_LOCATION_NUMPAD and NumLock is + * // active, you should specify DOM_VK_NUMPAD[0-9], DOM_VK_MULTIPLY, + * // DOM_VK_ADD, DOM_VK_SEPARATOR, DOM_VK_SUBTRACT, DOM_VK_DECIMAL or + * // DOM_VK_DIVIDE. + * // #2 If the key is Spacebar, use DOM_VK_SPACE. + * // + * // Following rules are printable keys in DOM_KEY_LOCATION_STANDARD. + * // .keyCode value for a key shouldn't be changed by modifier states: + * // #1 If the key can input [0-9] with any modifier state (except + * // NumLock state), the value should be DOM_VK_[0-9]. + * // #2 Otherwise, and if the key inputs an ASCII alphabet with no + * // active modifiers, use DOM_VK_[A-Z]. + * // #3 Otherwise, and if the key inputs an ASCII alphabet with no + * // active modifiers except Shift key state, use DOM_VK_[A-Z] for + * // the shifted character. E.g., if a key causes non-alphabet + * // character such as "@" or a Unicode character without Shift key + * // but "a" is inputted when Shift key is pressed, the proper + * // keyCode is DOM_VK_A. + * // #4 Otherwise, and if the key inputs another ASCII character with + * // no modifier states, use a proper value for the character. E.g., + * // if the key inputs "*" without Shift key state, it should be + * // DOM_VK_ASTERISK. + * // #5 Otherwise, and if the key inputs another ASCII character with + * // Shift key state, use a proper value for the character. E.g., + * // if a key causes a Unicode character without Shift key but "&" + * // is inputted when Shift key is pressed, the proper keyCode is + * // DOM_VK_AMPERSAND. + * // See above document for the other cases. + * // + * // NOTE: If the software keyboard is 10-key like simple phone, + * // We don't have common rules to decide its .keyCode value. + * // Above rules should be used when the JS-Keyboard emulates PC + * // keyboard. + * // .key value should be inputting character by the key with current + * // modifier state. + * // .code value should be empty string if the JS-Keyboard isn't emulating + * // physical keyboard. Otherwise, use same value with physical keyboard's + * // same key. + * var keyEvent = new KeyboardEvent("", { code: "KeyA", key: "a", + * keyCode: KeyboardEvent.DOM_VK_A }); + * if (TIP.keydown(keyEvent)) { + * // Handle its default action + * } + * + * // Even if keydown event was consumed, keyup event should be dispatched. + * if (TIP.keyup(keyEvent)) { + * // Handle its default action + * } + * + * Example #10 JS-Keyboard doesn't need to initialize modifier states at + * calling either keydown() or keyup(). + * + * // Neither beginInputTransaction() nor beginInputTransactionForTests() + * // resets modifier state. + * if (!TIP.beginInputTransaction(window, callback)) { + * return; // You failed to get the rights to dispatch key events + * } + * + * var leftShift = new KeyboardEvent("", { code: "ShiftLeft", key: "Shift" }); + * + * // This causes following key events will be shifted automatically. + * TIP.keydown(leftShift); + * + * var rightShift = + * new KeyboardEvent("", { code: "ShiftRight", key: "Shift" }); + * + * TIP.keydown(rightShift); + * + * // keyup of one of shift key doesn't cause inactivating "Shift" state. + * TIP.keyup(rightShift); + * + * // This causes inactivating "Shift" state completely. + * TIP.keyup(leftShift); + */ + +[scriptable, builtinclass, uuid(47ae2181-2e98-4d58-84a2-b8db6764ce9a)] +interface nsITextInputProcessor : nsISupports +{ + /** + * Returns true if this instance was dispatched compositionstart but hasn't + * dispatched compositionend yet. + */ + readonly attribute boolean hasComposition; + + /** + * When you create an instance, you must call beginInputTransaction() first + * except when you created the instance for automated tests. + * + * @param aWindow A DOM window. The instance will look for a top + * level widget from this. + * @param aCallback Callback interface which handles requests to + * IME and notifications to IME. This must not be + * null. + * @return If somebody uses internal text input service for a + * composition, this returns false. Otherwise, returns + * true. I.e., only your TIP can create composition + * when this returns true. If this returns false, + * your TIP should wait next chance. + */ + boolean beginInputTransaction(in mozIDOMWindow aWindow, + in nsITextInputProcessorCallback aCallback); + + /** + * When you create an instance for automated test, you must call + * beginInputTransaction(), first. See beginInputTransaction() for more + * detail of this. + * Note that aCallback can be null. If it's null, nsITextInputProcessor + * implementation will handle them automatically. + */ + [optional_argc] boolean + beginInputTransactionForTests( + in mozIDOMWindow aWindow, + [optional] in nsITextInputProcessorCallback aCallback); + + /** + * startComposition() dispatches compositionstart event explicitly. + * IME does NOT need to call this typically since compositionstart event + * is automatically dispatched by sendPendingComposition() if + * compositionstart event hasn't been dispatched yet. If this is called + * when compositionstart has already been dispatched, this throws an + * exception. + * + * @param aKeyboardEvent Key event which causes starting composition. + * If its type value is "keydown", this method + * dispatches only keydown event first. Otherwise, + * dispatches keydown first and keyup at last. + * @param aKeyFlags See KEY_* constants. + * @return Returns true if composition starts normally. + * Otherwise, returns false because it might be + * canceled by the web application. + */ + [optional_argc] + boolean startComposition([optional] in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * Set new composition string. Pending composition will be flushed by + * a call of flushPendingComposition(). However, if the new composition + * string isn't empty, you need to call appendClauseToPendingComposition() to + * fill all characters of aString with one or more clauses before flushing. + * Note that if you need to commit or cancel composition, use + * commitComposition(), commitCompositionWith() or cancelComposition(). + */ + void setPendingCompositionString(in DOMString aString); + + // ATTR_RAW_CLAUSE means that the clause hasn't been selected nor converted + // yet. + const unsigned long ATTR_RAW_CLAUSE = 0x02; + // ATTR_SELECTED_RAW_CLAUSE means that the clause hasn't been converted yet + // but is selected for converting to the other string. + const unsigned long ATTR_SELECTED_RAW_CLAUSE = 0x03; + // ATTR_CONVERTED_CLAUSE means that the clause has already been converted but + // is not selected. This does NOT mean that this clause isn't modifiable. + const unsigned long ATTR_CONVERTED_CLAUSE = 0x04; + // ATTR_SELECTED_CLAUSE means that the clause has already been converted and + // is selected. In other words, the clause is being converted. + const unsigned long ATTR_SELECTED_CLAUSE = 0x05; + + /** + * Append a clause to the pending composition. + * + * If you need to fill the pending composition string with a clause, you + * should call this once. For example: + * appendClauseToPendingComposition(compositionString.length, + * ATTR_RAW_CLAUSE); + * is enough. If you need to separate the pending composition string to + * multiple clauses, you need to call this multiple times. For example, + * if your pending composition string has three clauses and the second clause + * is being converted: + * appendClauseToPendingComposition(firstClauseLength, + * ATTR_CONVERTED_CLAUSE); + * appendClauseToPendingComposition(secondClauseLength, + * ATTR_SELECTED_CLAUSE); + * appendClauseToPendingComposition(thirdClauseLength, + * ATTR_CONVERTED_CLAUSE); + * Note that if sum of aLength mismatches length of the pending composition + * string, flushPendingComposition() will throw an exception. I.e., + * |firstClauseLength + secondClauseLength + thirdClauseLength| must be + * same as the length of pending composition string. + * + * TODO: Should be able to specify custom clause style. + * + * @param aLength Length of the clause. + * @param aAttribute One of ATTR_* constants. + */ + void appendClauseToPendingComposition(in unsigned long aLength, + in unsigned long aAttribute); + + /** + * Set caret offset in the pending composition string. If you don't need to + * show a caret, you don't need to call this. + * + * @param aOffset Caret offset in the pending composition string. + * This must be between 0 and length of the pending + * composition string. + */ + void setCaretInPendingComposition(in unsigned long aOffset); + + /** + * flushPendingComposition() must be called after + * setPendingCompositionString() and appendClauseToPendingComposition() + * (setCaretInPendingComposition() is optional) are called. + * + * Note that compositionstart will be automatically dispatched if this is + * called when there is no composition. + * + * Note that if sum of lengths of appended clauses are not same as composition + * string or caret offset is larger than the composition string length, this + * throws an exception. + * + * @param aKeyboardEvent Key event which causes the composition string. + * If its type value is "keydown", this method + * dispatches only keydown event first. Otherwise, + * dispatches keydown first and keyup at last. + * @param aKeyFlags See KEY_* constants. + * @return Returns true if there is a composition already or + * starting composition automatically. + * Otherwise, i.e., if it cannot start composition + * automatically, e.g., canceled by web apps, returns + * false. + */ + [optional_argc] + boolean flushPendingComposition( + [optional] in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * commitComposition() will commit composition with the last composition + * string. If there is no composition, this will throw an exception. + * + * @param aKeyboardEvent Key event which causes the commit composition. + * If its type value is "keydown", this method + * dispatches only keydown event first. Otherwise, + * dispatches keydown first and keyup at last. + * @param aKeyFlags See KEY_* constants. + */ + [optional_argc] + void commitComposition([optional] in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * commitCompositionWith() will commit composition with the specific string. + * If there is no composition, this will start composition and commit it + * with the specified string. + * + * @param aCommitString The string to be committed. + * @param aKeyboardEvent Key event which causes the commit composition. + * If its type value is "keydown", this method + * dispatches only keydown event first. Otherwise, + * dispatches keydown first and keyup at last. + * @param aKeyFlags See KEY_* constants. + * @return Returns true if there is a composition already or + * starting composition automatically. + * Otherwise, i.e., if it cannot start composition + * automatically, e.g., canceled by web apps, returns + * false. + */ + [optional_argc] + boolean commitCompositionWith(in DOMString aCommitString, + [optional] in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * cancelComposition() will cancel composition. This is for now the same as + * calling commitComposition(""). However, in the future, this might work + * better. If your IME needs to cancel composition, use this instead of + * commitComposition(). + * + * Note that if you tries to cancel composition when there is no composition, + * this throws an exception. + * + * @param aKeyboardEvent Key event which causes the canceling composition. + * If its type value is "keydown", this method + * dispatches only keydown event first. Otherwise, + * dispatches keydown first and keyup at last. + * @param aKeyFlags See KEY_* constants. + */ + [optional_argc] + void cancelComposition([optional] in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + // Specifying KEY_DEFAULT_PREVENTED can dispatch key events whose + // defaultPrevented are true. Note that if this is specified, keypress event + // won't be fired. + const unsigned long KEY_DEFAULT_PREVENTED = 0x00000001; + // If KEY_NON_PRINTABLE_KEY is specified and the .key value isn't valid + // key name, the methods will throws an exception. In other words, this + // flag prevents to dispatch key events with wrong key values and to cause + // such key events input the key values as text. + const unsigned long KEY_NON_PRINTABLE_KEY = 0x00000002; + // If KEY_FORCE_PRINTABLE_KEY is specified and even if the .key value is a + // registered key name, it's treated as inputting text value. + const unsigned long KEY_FORCE_PRINTABLE_KEY = 0x00000004; + // If KEY_KEEP_KEY_LOCATION_STANDARD is specified when its .location is not + // initialized or initialized with 0, the value isn't computed with .code + // value. Note that if .location is initialized with non-zero value, + // this flag causes throwing an exception. + // NOTE: This is not recommended to use except for tests. + const unsigned long KEY_KEEP_KEY_LOCATION_STANDARD = 0x00000008; + // If KEY_KEEP_KEYCODE_ZERO is specified when its .keyCode is not initialized + // or initialized with 0, the value isn't computed with .key value when it + // represents non-printable key. Note that if .keyCode is initialized with + // non-zero value, this flag causes throwing an exception. + const unsigned long KEY_KEEP_KEYCODE_ZERO = 0x00000010; + // If KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT is specified when the key event is + // a modifier key's, keydown() and keyup() only modifies its modifier state + // without dispatching key events. This is useful for testing odd behavior + // or emulating legacy API behavior. + const unsigned long KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT = 0x00000020; + + // These values can be used to do bitwise operation with the return value of + // the keydown() method. + const unsigned long KEYEVENT_NOT_CONSUMED = 0x00000000; + const unsigned long KEYDOWN_IS_CONSUMED = 0x00000001; + const unsigned long KEYPRESS_IS_CONSUMED = 0x00000002; + + /** + * keydown() may dispatch a keydown event and some keypress events if + * preceding keydown event isn't consumed and they are necessary. + * Note that even if this is called during composition, key events may not + * be dispatched. In this case, this returns false. + * + * You should initialize at least .key value and .code value of the event. + * Additionally, if you try to emulate a printable key, .keyCode value should + * be specified if there is proper key value. See the comment of above + * example how to decide .keyCode value of a printable key. On the other + * hand, .keyCode value is automatically computed when you try to emulate + * non-printable key. However, if you try to emulate physical keyboard of + * desktop platform, you need to specify proper value explicitly because + * the mapping table of this API isn't enough to emulate the behavior of + * Gecko for desktop platforms. + * + * NOTE: Even if this has composition, JS-Keyboard should call keydown() and + * keyup(). Although, with the default preferences and normal + * conditions, DOM key events won't be fired during composition. + * However, they MAY be dispatched for some reasons, e.g., the web + * content listens only key events, or if the standard DOM event spec + * will be changed in the future. + * + * @param aKeyboardEvent Must be a keyboard event which should be dispatched + * as a keydown event and keypress events. + * #1 Note that you don't need to set charCode value + * because it's computed from its key value. + * #2 If code value is set properly and location value + * isn't specified (i.e., 0), the location value will + * be guessed from the code value. + * #3 Non-defined code names are not allowed. If your + * key isn't registered, file a bug. If your key isn't + * defined by any standards, use "" (empty string). + * #4 .keyCode is guessed from .key value if the key + * name is registered and .keyCode isn't initialized. + * #5 modifier key states, e.g., .shiftKey, are + * ignored. Instead, modifier states are managed by + * each instance and set automatically. + * @param aKeyFlags Special flags. The values can be some of KEY_* + * constants. + * @return KEYEVENT_NOT_CONSUMED, if the keydown event nor + * the following keypress event(s) are consumed. + * KEYDOWN_IS_CONSUMED, if the keydown event is + * consumed. No keypress event will be dispatched in + * this case. + * KEYPRESS_IS_CONSUMED, if the keypress event(s) is + * consumed when dispatched. + * Note that keypress event is always consumed by + * native code for the printable keys (indicating the + * default action has been taken). + */ + [optional_argc] + unsigned long keydown(in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * Similar to keydown(), but this dispatches only a keyup event. + */ + [optional_argc] + boolean keyup(in nsIDOMKeyEvent aKeyboardEvent, + [optional] in unsigned long aKeyFlags); + + /** + * getModifierState() returns modifier state managed by this instance. + * + * @param aModifier One of modifier key names. This doesn't support + * virtual modifiers like "Accel". + * @return true if the modifier key is active. Otherwise, + * false. + */ + boolean getModifierState(in DOMString aModifierKey); + + /** + * shareModifierStateOf() makes the instance shares modifier state of + * another instance. When this is called, the instance refers the modifier + * state of another instance. After that, changes to either this and the + * other instance's modifier state is synchronized. + * + * @param aOther Another instance which will be referred by the + * instance. If this is null, the instance restarts + * to manage modifier state independently. + */ + void shareModifierStateOf(in nsITextInputProcessor aOther); +}; + +%{C++ +#define TEXT_INPUT_PROCESSOR_CID \ + { 0xcaaab47f, 0x1e31, 0x478e, \ + { 0x89, 0x19, 0x97, 0x09, 0x04, 0xe9, 0xcb, 0x72 } } +#define TEXT_INPUT_PROCESSOR_CONTRACTID \ + "@mozilla.org/text-input-processor;1" +%} diff --git a/dom/interfaces/base/nsITextInputProcessorCallback.idl b/dom/interfaces/base/nsITextInputProcessorCallback.idl new file mode 100644 index 000000000..61b6d50ed --- /dev/null +++ b/dom/interfaces/base/nsITextInputProcessorCallback.idl @@ -0,0 +1,104 @@ +/* -*- 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" + +interface nsITextInputProcessor; + +/** + * nsITextInputProcessorNotification stores the type of notification to IME and + * its detail. See each explanation of attribute for the detail. + */ + +[scriptable, builtinclass, uuid(c0ce1add-82bb-45ab-b99a-42cfba7fd5d7)] +interface nsITextInputProcessorNotification : nsISupports +{ + /** + * type attribute represents what's notified or requested. Value must be + * one of following values: + * + * "request-to-commit" (required to be handled) + * This is requested when Gecko believes that active composition should be + * committed. nsITextInputProcessorCallback::onNotify() has to handle this + * notification. + * + * "request-to-cancel" (required to be handled) + * This is requested when Gecko believes that active composition should be + * canceled. I.e., composition should be committed with empty string. + * nsITextInputProcessorCallback::onNotify() has to handle this + * notification. + * + * "notify-end-input-transaction" (optional) + * This is notified when the callback is detached from + * nsITextInputProcessor. I.e., the TextInputProcessor lost the rights + * to input text and needs to call .beginInputTransaction() before next + * input. + * + * "notify-focus" (optional) + * This is notified when an editable editor gets focus and Gecko starts + * to observe changes in the content. E.g., selection changes. + * IME shouldn't change DOM tree, focus nor something when this is notified. + * + * "notify-blur" (optional) + * This is notified when an editable editor loses focus and Gecko stops + * observing the changes in the content. + */ + readonly attribute ACString type; +}; + +/** + * nsITextInputProcessorCallback is a callback interface for JS to implement + * IME. IME implemented by JS can implement onNotify() function and must send + * it to nsITextInputProcessor at initializing. Then, onNotify() will be + * called with nsITextInputProcessorNotification instance. + * The reason why onNotify() uses string simply is that if we will support + * other notifications such as text changes and selection changes, we need to + * notify IME of some other information. Then, only changing + * nsITextInputProcessorNotification interface is better for compatibility. + */ + +[scriptable, function, uuid(23d5f242-adb5-46f1-8766-90d1bf0383df)] +interface nsITextInputProcessorCallback : nsISupports +{ + /** + * When Gecko notifies IME of something or requests something to IME, + * this is called. + * + * @param aTextInputProcessor Reference to the nsITextInputProcessor service + * which is the original receiver of the request + * or notification. + * @param aNotification Stores type of notifications and additional + * information. + * @return Return true if it succeeded or does nothing. + * Otherwise, return false. + * + * Example #1 The simplest implementation of nsITextInputProcessorCallback is: + * + * function simpleCallback(aTIP, aNotification) + * { + * try { + * switch (aNotification.type) { + * case "request-to-commit": + * aTIP.commitComposition(); + * break; + * case "request-to-cancel": + * aTIP.cancelComposition(); + * break; + * } + * } catch (e) { + * return false; + * } + * return true; + * } + * + * var TIP = Components.classes["@mozilla.org/text-input-processor;1"]. + * createInstance(Components.interfaces.nsITextInputProcessor); + * if (!TIP.init(window, simpleCallback)) { + * return; + * } + */ + boolean onNotify(in nsITextInputProcessor aTextInputProcessor, + in nsITextInputProcessorNotification aNotification); +}; |