2001-02-17 12:53:29 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-02-17 12:53:29 +03:00
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2001-02-17 12:53:29 +03:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code, released
|
|
|
|
* March 31, 1998.
|
|
|
|
*
|
2004-04-18 01:52:36 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2001-02-17 12:53:29 +03:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
/* A namespace class for static content utilities. */
|
2001-02-17 12:53:29 +03:00
|
|
|
|
|
|
|
#ifndef nsContentUtils_h___
|
|
|
|
#define nsContentUtils_h___
|
|
|
|
|
|
|
|
#include "jspubtd.h"
|
2002-03-24 02:54:46 +03:00
|
|
|
#include "nsAString.h"
|
2003-05-30 04:21:01 +04:00
|
|
|
#include "nsIStatefulFrame.h"
|
2004-04-30 03:34:19 +04:00
|
|
|
#include "nsIPref.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
2005-05-10 06:06:29 +04:00
|
|
|
#include "nsContentList.h"
|
2006-03-22 21:36:36 +03:00
|
|
|
#include "nsDOMClassInfoID.h"
|
|
|
|
#include "nsIClassInfo.h"
|
2006-05-16 18:51:52 +04:00
|
|
|
#include "nsIDOM3Node.h"
|
2007-04-02 21:17:36 +04:00
|
|
|
#include "nsDataHashtable.h"
|
2007-03-02 16:34:14 +03:00
|
|
|
#include "nsIScriptRuntime.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
2001-02-17 12:53:29 +03:00
|
|
|
|
2006-03-22 21:36:36 +03:00
|
|
|
class nsIDOMScriptObjectFactory;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
class nsIXPConnect;
|
2006-05-15 11:03:15 +04:00
|
|
|
class nsINode;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
class nsIContent;
|
2004-08-04 23:48:55 +04:00
|
|
|
class nsIDOMNode;
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
class nsIDocument;
|
2002-08-09 12:45:30 +04:00
|
|
|
class nsIDocShell;
|
2002-11-30 02:44:07 +03:00
|
|
|
class nsINameSpaceManager;
|
2002-07-18 09:53:28 +04:00
|
|
|
class nsIScriptSecurityManager;
|
2006-03-22 21:36:36 +03:00
|
|
|
class nsIJSContextStack;
|
2002-08-09 12:45:30 +04:00
|
|
|
class nsIThreadJSContextStack;
|
2002-11-19 16:39:20 +03:00
|
|
|
class nsIParserService;
|
2003-07-08 09:35:04 +04:00
|
|
|
class nsIIOService;
|
|
|
|
class nsIURI;
|
2004-03-09 06:57:51 +03:00
|
|
|
class imgIDecoderObserver;
|
|
|
|
class imgIRequest;
|
|
|
|
class imgILoader;
|
2004-04-30 03:34:19 +04:00
|
|
|
class nsIPrefBranch;
|
2004-07-30 10:04:57 +04:00
|
|
|
class nsIImage;
|
|
|
|
class nsIImageLoadingContent;
|
2004-08-04 23:48:55 +04:00
|
|
|
class nsIDOMHTMLFormElement;
|
|
|
|
class nsIDOMDocument;
|
2004-09-14 21:26:35 +04:00
|
|
|
class nsIConsoleService;
|
|
|
|
class nsIStringBundleService;
|
|
|
|
class nsIStringBundle;
|
2005-08-19 19:00:01 +04:00
|
|
|
class nsIContentPolicy;
|
2005-08-22 07:00:06 +04:00
|
|
|
class nsILineBreaker;
|
|
|
|
class nsIWordBreaker;
|
2005-09-24 06:33:33 +04:00
|
|
|
class nsIJSRuntimeService;
|
2006-02-07 17:34:10 +03:00
|
|
|
class nsIEventListenerManager;
|
2006-03-22 21:36:36 +03:00
|
|
|
class nsIScriptContext;
|
|
|
|
template<class E> class nsCOMArray;
|
|
|
|
class nsIPref;
|
|
|
|
class nsVoidArray;
|
2005-09-24 06:33:33 +04:00
|
|
|
struct JSRuntime;
|
2004-10-08 00:59:53 +04:00
|
|
|
#ifdef MOZ_XTF
|
|
|
|
class nsIXTFService;
|
|
|
|
#endif
|
2006-08-08 09:14:52 +04:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
class nsIBidiKeyboard;
|
|
|
|
#endif
|
2001-02-17 12:53:29 +03:00
|
|
|
|
2006-06-16 00:30:44 +04:00
|
|
|
extern const char kLoadAsData[];
|
|
|
|
|
2007-04-02 21:17:36 +04:00
|
|
|
enum EventNameType {
|
|
|
|
EventNameType_None = 0x0000,
|
|
|
|
EventNameType_HTML = 0x0001,
|
|
|
|
EventNameType_XUL = 0x0002,
|
|
|
|
EventNameType_SVGGraphic = 0x0004, // svg graphic elements
|
|
|
|
EventNameType_SVGSVG = 0x0008, // the svg element
|
|
|
|
|
|
|
|
EventNameType_HTMLXUL = 0x0003,
|
|
|
|
EventNameType_All = 0xFFFF
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EventNameMapping {
|
|
|
|
PRUint32 mId;
|
|
|
|
PRInt32 mType;
|
|
|
|
};
|
|
|
|
|
2001-02-17 12:53:29 +03:00
|
|
|
class nsContentUtils
|
|
|
|
{
|
|
|
|
public:
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static nsresult Init();
|
|
|
|
|
2005-10-01 00:06:33 +04:00
|
|
|
// You MUST pass the old ownerDocument of aContent in as aOldDocument and the
|
|
|
|
// new one as aNewDocument. aNewParent is allowed to be null; in that case
|
|
|
|
// aNewDocument will be assumed to be the parent. Note that at this point
|
|
|
|
// the actual ownerDocument of aContent may not yet be aNewDocument.
|
|
|
|
// XXXbz but then if it gets wrapped after we do this call but before its
|
|
|
|
// ownerDocument actually changes, things will break...
|
2006-04-11 07:49:44 +04:00
|
|
|
static nsresult ReparentContentWrapper(nsIContent *aNode,
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
nsIContent *aNewParent,
|
|
|
|
nsIDocument *aNewDocument,
|
|
|
|
nsIDocument *aOldDocument);
|
2001-02-17 12:53:29 +03:00
|
|
|
|
2006-07-29 20:02:11 +04:00
|
|
|
/**
|
|
|
|
* Get a scope from aOldDocument and one from aNewDocument. Also get a
|
|
|
|
* context through one of the scopes, from the stack or the safe context.
|
|
|
|
*
|
|
|
|
* @param aOldDocument The document to get aOldScope from.
|
|
|
|
* @param aNewDocument The document to get aNewScope from.
|
|
|
|
* @param aCx [out] Context gotten through one of the scopes, from the stack
|
|
|
|
* or the safe context.
|
|
|
|
* @param aOldScope [out] Scope gotten from aOldDocument.
|
|
|
|
* @param aNewScope [out] Scope gotten from aNewDocument.
|
|
|
|
*/
|
|
|
|
static nsresult GetContextAndScopes(nsIDocument *aOldDocument,
|
|
|
|
nsIDocument *aNewDocument,
|
|
|
|
JSContext **aCx, JSObject **aOldScope,
|
|
|
|
JSObject **aNewScope);
|
|
|
|
|
2006-04-26 23:53:27 +04:00
|
|
|
/**
|
|
|
|
* When a document's scope changes (e.g., from document.open(), call this
|
|
|
|
* function to move all content wrappers from the old scope to the new one.
|
|
|
|
*/
|
|
|
|
static nsresult ReparentContentWrappersInScope(nsIScriptGlobalObject *aOldScope,
|
|
|
|
nsIScriptGlobalObject *aNewScope);
|
|
|
|
|
2002-06-26 00:03:06 +04:00
|
|
|
static PRBool IsCallerChrome();
|
|
|
|
|
2006-03-27 00:57:53 +04:00
|
|
|
static PRBool IsCallerTrustedForRead();
|
|
|
|
|
|
|
|
static PRBool IsCallerTrustedForWrite();
|
|
|
|
|
2002-06-28 05:30:09 +04:00
|
|
|
/**
|
|
|
|
* Do not ever pass null pointers to this method. If one of your
|
|
|
|
* nsIContents is null, you have to decide for yourself what
|
|
|
|
* "IsDescendantOf" really means.
|
|
|
|
*
|
|
|
|
* @param aPossibleDescendant node to test for being a descendant of
|
|
|
|
* aPossibleAncestor
|
|
|
|
* @param aPossibleAncestor node to test for being an ancestor of
|
|
|
|
* aPossibleDescendant
|
|
|
|
* @return PR_TRUE if aPossibleDescendant is a descendant of
|
|
|
|
* aPossibleAncestor (or is aPossibleAncestor). PR_FALSE
|
|
|
|
* otherwise.
|
2005-06-03 03:36:08 +04:00
|
|
|
*/
|
2006-05-19 14:01:22 +04:00
|
|
|
static PRBool ContentIsDescendantOf(nsINode* aPossibleDescendant,
|
|
|
|
nsINode* aPossibleAncestor);
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2002-06-26 00:03:06 +04:00
|
|
|
/*
|
|
|
|
* This method fills the |aArray| with all ancestor nodes of |aNode|
|
|
|
|
* including |aNode| at the zero index.
|
|
|
|
*
|
|
|
|
* These elements were |nsIDOMNode*|s before casting to |void*| and must
|
|
|
|
* be cast back to |nsIDOMNode*| on usage, or bad things will happen.
|
|
|
|
*/
|
|
|
|
static nsresult GetAncestors(nsIDOMNode* aNode,
|
|
|
|
nsVoidArray* aArray);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This method fills |aAncestorNodes| with all ancestor nodes of |aNode|
|
|
|
|
* including |aNode| (QI'd to nsIContent) at the zero index.
|
|
|
|
* For each ancestor, there is a corresponding element in |aAncestorOffsets|
|
|
|
|
* which is the IndexOf the child in relation to its parent.
|
|
|
|
*
|
2005-06-03 03:36:08 +04:00
|
|
|
* The elements of |aAncestorNodes| were |nsIContent*|s before casting to
|
2002-06-26 00:03:06 +04:00
|
|
|
* |void*| and must be cast back to |nsIContent*| on usage, or bad things
|
|
|
|
* will happen.
|
|
|
|
*
|
|
|
|
* This method just sucks.
|
|
|
|
*/
|
|
|
|
static nsresult GetAncestorsAndOffsets(nsIDOMNode* aNode,
|
|
|
|
PRInt32 aOffset,
|
|
|
|
nsVoidArray* aAncestorNodes,
|
|
|
|
nsVoidArray* aAncestorOffsets);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The out parameter, |aCommonAncestor| will be the closest node, if any,
|
|
|
|
* to both |aNode| and |aOther| which is also an ancestor of each.
|
2006-05-16 18:51:52 +04:00
|
|
|
* Returns an error if the two nodes are disconnected and don't have
|
|
|
|
* a common ancestor.
|
2002-06-26 00:03:06 +04:00
|
|
|
*/
|
|
|
|
static nsresult GetCommonAncestor(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aOther,
|
|
|
|
nsIDOMNode** aCommonAncestor);
|
|
|
|
|
2006-05-16 18:51:52 +04:00
|
|
|
/**
|
|
|
|
* Returns the common ancestor, if any, for two nodes. Returns null if the
|
|
|
|
* nodes are disconnected.
|
2002-06-26 00:03:06 +04:00
|
|
|
*/
|
2006-05-16 18:51:52 +04:00
|
|
|
static nsINode* GetCommonAncestor(nsINode* aNode1,
|
|
|
|
nsINode* aNode2);
|
2002-12-04 08:18:39 +03:00
|
|
|
|
|
|
|
/**
|
2006-05-16 18:51:52 +04:00
|
|
|
* Compares the document position of nodes.
|
2002-12-04 08:18:39 +03:00
|
|
|
*
|
2006-05-16 18:51:52 +04:00
|
|
|
* @param aNode1 The node whose position is being compared to the reference
|
|
|
|
* node
|
|
|
|
* @param aNode2 The reference node
|
2002-12-04 08:18:39 +03:00
|
|
|
*
|
2006-05-16 18:51:52 +04:00
|
|
|
* @return The document position flags of the nodes. aNode1 is compared to
|
|
|
|
* aNode2, i.e. if aNode1 is before aNode2 then
|
|
|
|
* DOCUMENT_POSITION_PRECEDING will be set.
|
2002-12-04 08:18:39 +03:00
|
|
|
*
|
|
|
|
* @see nsIDOMNode
|
|
|
|
* @see nsIDOM3Node
|
|
|
|
*/
|
2006-05-16 18:51:52 +04:00
|
|
|
static PRUint16 ComparePosition(nsINode* aNode1,
|
|
|
|
nsINode* aNode2);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if aNode1 is before aNode2 in the same connected
|
|
|
|
* tree.
|
|
|
|
*/
|
|
|
|
static PRBool PositionIsBefore(nsINode* aNode1,
|
|
|
|
nsINode* aNode2)
|
|
|
|
{
|
2006-05-17 09:27:21 +04:00
|
|
|
return (ComparePosition(aNode1, aNode2) &
|
2006-05-16 18:51:52 +04:00
|
|
|
(nsIDOM3Node::DOCUMENT_POSITION_PRECEDING |
|
2006-05-17 09:27:21 +04:00
|
|
|
nsIDOM3Node::DOCUMENT_POSITION_DISCONNECTED)) ==
|
2006-05-16 18:51:52 +04:00
|
|
|
nsIDOM3Node::DOCUMENT_POSITION_PRECEDING;
|
|
|
|
}
|
2002-12-04 08:18:39 +03:00
|
|
|
|
2006-10-21 05:30:54 +04:00
|
|
|
/**
|
|
|
|
* Utility routine to compare two "points", where a point is a
|
|
|
|
* node/offset pair
|
|
|
|
* Returns -1 if point1 < point2, 1, if point1 > point2,
|
|
|
|
* 0 if error or if point1 == point2.
|
|
|
|
* NOTE! The two nodes MUST be in the same connected subtree!
|
|
|
|
* if they are not the result is undefined.
|
|
|
|
*/
|
|
|
|
static PRInt32 ComparePoints(nsINode* aParent1, PRInt32 aOffset1,
|
|
|
|
nsINode* aParent2, PRInt32 aOffset2);
|
|
|
|
|
2006-08-15 19:55:45 +04:00
|
|
|
/**
|
|
|
|
* Find the first child of aParent with a resolved tag matching
|
|
|
|
* aNamespace and aTag. Both the explicit and anonymous children of
|
|
|
|
* aParent are examined. The return value is not addrefed.
|
|
|
|
*
|
|
|
|
* XXXndeakin this should return the first child whether in anonymous or
|
|
|
|
* explicit children, but currently XBL doesn't tell us the relative
|
|
|
|
* ordering of anonymous vs explicit children, so instead it searches
|
|
|
|
* the explicit children first then the anonymous children.
|
|
|
|
*/
|
|
|
|
static nsIContent* FindFirstChildWithResolvedTag(nsIContent* aParent,
|
|
|
|
PRInt32 aNamespace,
|
|
|
|
nsIAtom* aTag);
|
|
|
|
|
2005-10-19 00:33:35 +04:00
|
|
|
/**
|
|
|
|
* Brute-force search of the element subtree rooted at aContent for
|
2005-10-21 19:17:15 +04:00
|
|
|
* an element with the given id. aId must be nonempty, otherwise
|
|
|
|
* this method may return nodes even if they have no id!
|
2005-10-19 00:33:35 +04:00
|
|
|
*/
|
|
|
|
static nsIContent* MatchElementId(nsIContent *aContent,
|
|
|
|
const nsAString& aId);
|
|
|
|
|
2005-11-16 05:55:29 +03:00
|
|
|
/**
|
|
|
|
* Similar to above, but to be used if one already has an atom for the ID
|
|
|
|
*/
|
|
|
|
static nsIContent* MatchElementId(nsIContent *aContent,
|
|
|
|
nsIAtom* aId);
|
|
|
|
|
2005-10-19 00:33:35 +04:00
|
|
|
/**
|
|
|
|
* Given a URI containing an element reference (#whatever),
|
|
|
|
* resolve it to the target content element with the given ID.
|
|
|
|
*
|
|
|
|
* If aFromContent is anonymous XBL content then the URI
|
|
|
|
* must refer to its binding document and we will return
|
|
|
|
* a node in the same anonymous content subtree as aFromContent,
|
|
|
|
* if one exists with the correct ID.
|
|
|
|
*
|
|
|
|
* @param aFromContent the context of the reference;
|
|
|
|
* currently we only support references to elements in the
|
|
|
|
* same document as the context, so this must be non-null
|
|
|
|
*
|
|
|
|
* @return the element, or nsnull on failure
|
|
|
|
*/
|
|
|
|
static nsIContent* GetReferencedElement(nsIURI* aURI,
|
|
|
|
nsIContent *aFromContent);
|
|
|
|
|
2002-12-04 08:18:39 +03:00
|
|
|
/**
|
|
|
|
* Reverses the document position flags passed in.
|
|
|
|
*
|
|
|
|
* @param aDocumentPosition The document position flags to be reversed.
|
|
|
|
*
|
|
|
|
* @return The reversed document position flags.
|
|
|
|
*
|
|
|
|
* @see nsIDOMNode
|
|
|
|
* @see nsIDOM3Node
|
|
|
|
*/
|
|
|
|
static PRUint16 ReverseDocumentPosition(PRUint16 aDocumentPosition);
|
2002-04-12 14:11:00 +04:00
|
|
|
|
2005-06-03 03:36:08 +04:00
|
|
|
static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
|
|
|
|
PRUint32 aSrcOffset,
|
|
|
|
PRUnichar* aDest,
|
2001-07-06 02:20:34 +04:00
|
|
|
PRUint32 aLength,
|
|
|
|
PRBool& aLastCharCR);
|
2001-02-17 12:53:29 +03:00
|
|
|
|
2002-03-24 02:54:46 +03:00
|
|
|
static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
|
|
|
static nsISupports *
|
2001-07-11 13:09:30 +04:00
|
|
|
GetClassInfoInstance(nsDOMClassInfoID aID);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2002-06-12 03:23:12 +04:00
|
|
|
static const nsDependentSubstring TrimCharsInSet(const char* aSet,
|
|
|
|
const nsAString& aValue);
|
|
|
|
|
2003-02-27 03:49:36 +03:00
|
|
|
static const nsDependentSubstring TrimWhitespace(const nsAString& aStr,
|
|
|
|
PRBool aTrimTrailing = PR_TRUE);
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static void Shutdown();
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2002-07-18 09:53:28 +04:00
|
|
|
/**
|
|
|
|
* Checks whether two nodes come from the same origin. aTrustedNode is
|
|
|
|
* considered 'safe' in that a user can operate on it and that it isn't
|
|
|
|
* a js-object that implements nsIDOMNode.
|
|
|
|
* Never call this function with the first node provided by script, it
|
|
|
|
* must always be known to be a 'real' node!
|
|
|
|
*/
|
|
|
|
static nsresult CheckSameOrigin(nsIDOMNode* aTrustedNode,
|
|
|
|
nsIDOMNode* aUnTrustedNode);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2002-07-16 17:09:15 +04:00
|
|
|
// Check if the (JS) caller can access aNode.
|
|
|
|
static PRBool CanCallerAccess(nsIDOMNode *aNode);
|
|
|
|
|
2002-09-20 17:40:53 +04:00
|
|
|
/**
|
|
|
|
* Get the docshell through the JS context that's currently on the stack.
|
|
|
|
* If there's no JS context currently on the stack aDocShell will be null.
|
|
|
|
*
|
|
|
|
* @param aDocShell The docshell or null if no JS context
|
|
|
|
*/
|
2004-02-10 01:48:53 +03:00
|
|
|
static nsIDocShell *GetDocShellFromCaller();
|
2002-08-09 12:45:30 +04:00
|
|
|
|
2005-11-04 01:47:06 +03:00
|
|
|
/**
|
|
|
|
* The two GetDocumentFrom* functions below allow a caller to get at a
|
|
|
|
* document that is relevant to the currently executing script.
|
|
|
|
*
|
|
|
|
* GetDocumentFromCaller gets its document by looking at the last called
|
|
|
|
* function and finding the document that the function itself relates to.
|
|
|
|
* For example, consider two windows A and B in the same origin. B has a
|
|
|
|
* function which does something that ends up needing the current document.
|
|
|
|
* If a script in window A were to call B's function, GetDocumentFromCaller
|
|
|
|
* would find that function (in B) and return B's document.
|
|
|
|
*
|
|
|
|
* GetDocumentFromContext gets its document by looking at the currently
|
|
|
|
* executing context's global object and returning its document. Thus,
|
|
|
|
* given the example above, GetDocumentFromCaller would see that the
|
|
|
|
* currently executing script was in window A, and return A's document.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Get the document from the currently executing function. This will return
|
|
|
|
* the document that the currently executing function is in/from.
|
|
|
|
*
|
|
|
|
* @return The document or null if no JS Context.
|
|
|
|
*/
|
|
|
|
static nsIDOMDocument *GetDocumentFromCaller();
|
|
|
|
|
2002-09-20 17:40:53 +04:00
|
|
|
/**
|
|
|
|
* Get the document through the JS context that's currently on the stack.
|
2005-09-02 22:02:51 +04:00
|
|
|
* If there's no JS context currently on the stack it will return null.
|
2005-11-04 01:47:06 +03:00
|
|
|
* This will return the document of the calling script.
|
2002-09-20 17:40:53 +04:00
|
|
|
*
|
2005-09-02 22:02:51 +04:00
|
|
|
* @return The document or null if no JS context
|
2002-09-20 17:40:53 +04:00
|
|
|
*/
|
2005-11-04 01:47:06 +03:00
|
|
|
static nsIDOMDocument *GetDocumentFromContext();
|
2002-09-20 17:40:53 +04:00
|
|
|
|
2002-09-04 10:57:25 +04:00
|
|
|
// Check if a node is in the document prolog, i.e. before the document
|
|
|
|
// element.
|
2006-05-19 14:01:22 +04:00
|
|
|
static PRBool InProlog(nsINode *aNode);
|
2002-09-04 10:57:25 +04:00
|
|
|
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsIParserService* GetParserService();
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsINameSpaceManager* NameSpaceManager()
|
2002-11-30 02:44:07 +03:00
|
|
|
{
|
2003-07-08 09:35:04 +04:00
|
|
|
return sNameSpaceManager;
|
2005-02-03 20:23:35 +03:00
|
|
|
}
|
2002-11-30 02:44:07 +03:00
|
|
|
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsIIOService* GetIOService()
|
2003-07-08 09:35:04 +04:00
|
|
|
{
|
|
|
|
return sIOService;
|
2005-02-03 20:23:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static imgILoader* GetImgLoader()
|
|
|
|
{
|
|
|
|
return sImgLoader;
|
|
|
|
}
|
2003-10-22 02:11:49 +04:00
|
|
|
|
2004-10-08 00:59:53 +04:00
|
|
|
#ifdef MOZ_XTF
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsIXTFService* GetXTFService();
|
2004-10-08 00:59:53 +04:00
|
|
|
#endif
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2006-08-08 09:14:52 +04:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
static nsIBidiKeyboard* GetBidiKeyboard();
|
|
|
|
#endif
|
|
|
|
|
2005-10-14 13:07:29 +04:00
|
|
|
/**
|
|
|
|
* Get the cache security manager service. Can return null if the layout
|
|
|
|
* module has been shut down.
|
|
|
|
*/
|
|
|
|
static nsIScriptSecurityManager* GetSecurityManager()
|
2003-10-22 02:11:49 +04:00
|
|
|
{
|
|
|
|
return sSecurityManager;
|
|
|
|
}
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2003-05-30 04:21:01 +04:00
|
|
|
static nsresult GenerateStateKey(nsIContent* aContent,
|
2005-01-15 20:47:23 +03:00
|
|
|
nsIDocument* aDocument,
|
2003-05-30 04:21:01 +04:00
|
|
|
nsIStatefulFrame::SpecialStateID aID,
|
|
|
|
nsACString& aKey);
|
|
|
|
|
2003-07-08 09:35:04 +04:00
|
|
|
/**
|
2003-07-08 13:23:32 +04:00
|
|
|
* Create a new nsIURI from aSpec, using aBaseURI as the base. The
|
|
|
|
* origin charset of the new nsIURI will be the document charset of
|
|
|
|
* aDocument.
|
2003-07-08 09:35:04 +04:00
|
|
|
*/
|
|
|
|
static nsresult NewURIWithDocumentCharset(nsIURI** aResult,
|
|
|
|
const nsAString& aSpec,
|
|
|
|
nsIDocument* aDocument,
|
|
|
|
nsIURI* aBaseURI);
|
2003-07-15 06:07:55 +04:00
|
|
|
|
2005-10-19 00:33:35 +04:00
|
|
|
/**
|
|
|
|
* Convert aInput (in charset aCharset) to UTF16 in aOutput.
|
|
|
|
*
|
|
|
|
* @param aCharset the name of the charset; if empty, we assume UTF8
|
|
|
|
*/
|
|
|
|
static nsresult ConvertStringFromCharset(const nsACString& aCharset,
|
|
|
|
const nsACString& aInput,
|
|
|
|
nsAString& aOutput);
|
|
|
|
|
2003-07-15 06:07:55 +04:00
|
|
|
/**
|
|
|
|
* Determine whether aContent is in some way associated with aForm. If the
|
|
|
|
* form is a container the only elements that are considered to be associated
|
|
|
|
* with a form are the elements that are contained within the form. If the
|
|
|
|
* form is a leaf element then all elements will be accepted into this list,
|
|
|
|
* since this can happen due to content fixup when a form spans table rows or
|
|
|
|
* table cells.
|
|
|
|
*/
|
|
|
|
static PRBool BelongsInForm(nsIDOMHTMLFormElement *aForm,
|
|
|
|
nsIContent *aContent);
|
2005-06-03 03:36:08 +04:00
|
|
|
|
2004-02-10 13:58:13 +03:00
|
|
|
static nsresult CheckQName(const nsAString& aQualifiedName,
|
|
|
|
PRBool aNamespaceAware = PR_TRUE);
|
|
|
|
|
2005-01-01 21:02:03 +03:00
|
|
|
static nsresult SplitQName(nsIContent* aNamespaceResolver,
|
|
|
|
const nsAFlatString& aQName,
|
|
|
|
PRInt32 *aNamespace, nsIAtom **aLocalName);
|
|
|
|
|
|
|
|
static nsresult LookupNamespaceURI(nsIContent* aNamespaceResolver,
|
|
|
|
const nsAString& aNamespacePrefix,
|
|
|
|
nsAString& aNamespaceURI);
|
|
|
|
|
2004-02-10 13:58:13 +03:00
|
|
|
static nsresult GetNodeInfoFromQName(const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
2004-06-25 16:26:02 +04:00
|
|
|
nsNodeInfoManager* aNodeInfoManager,
|
2004-02-10 13:58:13 +03:00
|
|
|
nsINodeInfo** aNodeInfo);
|
|
|
|
|
2004-12-15 18:37:23 +03:00
|
|
|
static void SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
|
|
|
nsIAtom **aTagName, PRInt32 *aNameSpaceID);
|
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
static nsAdoptingCString GetCharPref(const char *aPref);
|
|
|
|
static PRPackedBool GetBoolPref(const char *aPref,
|
|
|
|
PRBool aDefault = PR_FALSE);
|
|
|
|
static PRInt32 GetIntPref(const char *aPref, PRInt32 aDefault = 0);
|
|
|
|
static nsAdoptingString GetLocalizedStringPref(const char *aPref);
|
|
|
|
static nsAdoptingString GetStringPref(const char *aPref);
|
|
|
|
static void RegisterPrefCallback(const char *aPref,
|
|
|
|
PrefChangedFunc aCallback,
|
|
|
|
void * aClosure);
|
|
|
|
static void UnregisterPrefCallback(const char *aPref,
|
|
|
|
PrefChangedFunc aCallback,
|
|
|
|
void * aClosure);
|
|
|
|
static nsIPrefBranch *GetPrefBranch()
|
|
|
|
{
|
|
|
|
return sPrefBranch;
|
|
|
|
}
|
|
|
|
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsILineBreaker* LineBreaker()
|
2005-08-22 07:00:06 +04:00
|
|
|
{
|
|
|
|
return sLineBreaker;
|
|
|
|
}
|
|
|
|
|
2005-09-11 14:08:43 +04:00
|
|
|
static nsIWordBreaker* WordBreaker()
|
2005-08-22 07:00:06 +04:00
|
|
|
{
|
|
|
|
return sWordBreaker;
|
|
|
|
}
|
|
|
|
|
2006-01-18 07:09:33 +03:00
|
|
|
/**
|
|
|
|
* @return PR_TRUE if aContent has an attribute aName in namespace aNameSpaceID,
|
|
|
|
* and the attribute value is non-empty.
|
|
|
|
*/
|
|
|
|
static PRBool HasNonEmptyAttr(nsIContent* aContent, PRInt32 aNameSpaceID,
|
|
|
|
nsIAtom* aName);
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
/**
|
|
|
|
* Method to do security and content policy checks on the image URI
|
|
|
|
*
|
|
|
|
* @param aURI uri of the image to be loaded
|
|
|
|
* @param aContext the context the image is loaded in (eg an element)
|
|
|
|
* @param aLoadingDocument the document we belong to
|
2005-03-02 07:05:12 +03:00
|
|
|
* @param aImageBlockingStatus the nsIContentPolicy blocking status for this
|
|
|
|
* image. This will be set even if a security check fails for the
|
|
|
|
* image, to some reasonable REJECT_* value. This out param will only
|
|
|
|
* be set if it's non-null.
|
|
|
|
* @return PR_TRUE if the load can proceed, or PR_FALSE if it is blocked.
|
|
|
|
* Note that aImageBlockingStatus, if set will always be an ACCEPT
|
|
|
|
* status if PR_TRUE is returned and always be a REJECT_* status if
|
|
|
|
* PR_FALSE is returned.
|
2004-03-09 06:57:51 +03:00
|
|
|
*/
|
2004-05-13 22:34:18 +04:00
|
|
|
static PRBool CanLoadImage(nsIURI* aURI,
|
|
|
|
nsISupports* aContext,
|
2005-03-02 07:05:12 +03:00
|
|
|
nsIDocument* aLoadingDocument,
|
|
|
|
PRInt16* aImageBlockingStatus = nsnull);
|
2004-03-09 06:57:51 +03:00
|
|
|
/**
|
|
|
|
* Method to start an image load. This does not do any security checks.
|
|
|
|
*
|
|
|
|
* @param aURI uri of the image to be loaded
|
|
|
|
* @param aLoadingDocument the document we belong to
|
|
|
|
* @param aObserver the observer for the image load
|
|
|
|
* @param aLoadFlags the load flags to use. See nsIRequest
|
|
|
|
* @return the imgIRequest for the image load
|
|
|
|
*/
|
|
|
|
static nsresult LoadImage(nsIURI* aURI,
|
|
|
|
nsIDocument* aLoadingDocument,
|
2004-07-15 01:56:23 +04:00
|
|
|
nsIURI* aReferrer,
|
2004-03-09 06:57:51 +03:00
|
|
|
imgIDecoderObserver* aObserver,
|
|
|
|
PRInt32 aLoadFlags,
|
|
|
|
imgIRequest** aRequest);
|
2004-06-25 16:26:02 +04:00
|
|
|
|
2004-07-30 10:04:57 +04:00
|
|
|
/**
|
|
|
|
* Method to get an nsIImage from an image loading content
|
|
|
|
*
|
|
|
|
* @param aContent The image loading content. Must not be null.
|
2005-02-08 01:20:14 +03:00
|
|
|
* @param aRequest The image request [out]
|
2004-07-30 10:04:57 +04:00
|
|
|
* @return the nsIImage corresponding to the first frame of the image
|
|
|
|
*/
|
2005-02-08 01:20:14 +03:00
|
|
|
static already_AddRefed<nsIImage> GetImageFromContent(nsIImageLoadingContent* aContent, imgIRequest **aRequest = nsnull);
|
2004-07-30 10:04:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Method that decides whether a content node is draggable
|
|
|
|
*
|
|
|
|
* @param aContent The content node to test.
|
|
|
|
* @return whether it's draggable
|
|
|
|
*/
|
|
|
|
static PRBool ContentIsDraggable(nsIContent* aContent) {
|
|
|
|
return IsDraggableImage(aContent) || IsDraggableLink(aContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method that decides whether a content node is a draggable image
|
|
|
|
*
|
|
|
|
* @param aContent The content node to test.
|
|
|
|
* @return whether it's a draggable image
|
|
|
|
*/
|
|
|
|
static PRBool IsDraggableImage(nsIContent* aContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method that decides whether a content node is a draggable link
|
|
|
|
*
|
|
|
|
* @param aContent The content node to test.
|
|
|
|
* @return whether it's a draggable link
|
|
|
|
*/
|
|
|
|
static PRBool IsDraggableLink(nsIContent* aContent);
|
|
|
|
|
2004-06-25 16:26:02 +04:00
|
|
|
/**
|
|
|
|
* Convenience method to create a new nodeinfo that differs only by name
|
|
|
|
* from aNodeInfo.
|
|
|
|
*/
|
|
|
|
static nsresult NameChanged(nsINodeInfo *aNodeInfo, nsIAtom *aName,
|
|
|
|
nsINodeInfo** aResult)
|
|
|
|
{
|
|
|
|
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
|
|
|
|
|
|
|
return niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
|
|
|
|
aNodeInfo->NamespaceID(), aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to create a new nodeinfo that differs only by prefix
|
|
|
|
* from aNodeInfo.
|
|
|
|
*/
|
|
|
|
static nsresult PrefixChanged(nsINodeInfo *aNodeInfo, nsIAtom *aPrefix,
|
|
|
|
nsINodeInfo** aResult)
|
|
|
|
{
|
|
|
|
nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
|
|
|
|
|
|
|
|
return niMgr->GetNodeInfo(aNodeInfo->NameAtom(), aPrefix,
|
|
|
|
aNodeInfo->NamespaceID(), aResult);
|
|
|
|
}
|
|
|
|
|
2004-07-22 20:38:05 +04:00
|
|
|
/**
|
2006-06-13 07:07:47 +04:00
|
|
|
* Returns the appropriate event argument names for the specified
|
|
|
|
* namespace and event name. Added because we need to switch between
|
|
|
|
* SVG's "evt" and the rest of the world's "event", and because onerror
|
|
|
|
* takes 3 args.
|
2004-07-22 20:38:05 +04:00
|
|
|
*/
|
2006-06-13 07:07:47 +04:00
|
|
|
static void GetEventArgNames(PRInt32 aNameSpaceID, nsIAtom *aEventName,
|
|
|
|
PRUint32 *aArgCount, const char*** aArgNames);
|
2004-07-22 20:38:05 +04:00
|
|
|
|
2007-01-30 08:48:22 +03:00
|
|
|
/**
|
|
|
|
* If aNode is not an element, return true exactly when aContent's binding
|
|
|
|
* parent is null.
|
|
|
|
*
|
|
|
|
* If aNode is an element, return true exactly when aContent's binding parent
|
|
|
|
* is the same as aNode's.
|
|
|
|
*
|
|
|
|
* This method is particularly useful for callers who are trying to ensure
|
|
|
|
* that they are working with a non-anonymous descendant of a given node. If
|
|
|
|
* aContent is a descendant of aNode, a return value of PR_FALSE from this
|
|
|
|
* method means that it's an anonymous descendant from aNode's point of view.
|
|
|
|
*
|
|
|
|
* Both arguments to this method must be non-null.
|
|
|
|
*/
|
|
|
|
static PRBool IsInSameAnonymousTree(nsINode* aNode, nsIContent* aContent);
|
|
|
|
|
2004-09-01 20:50:12 +04:00
|
|
|
/**
|
|
|
|
* Return the nsIXPConnect service.
|
|
|
|
*/
|
|
|
|
static nsIXPConnect *XPConnect()
|
|
|
|
{
|
|
|
|
return sXPConnect;
|
|
|
|
}
|
|
|
|
|
2004-09-14 21:26:35 +04:00
|
|
|
/**
|
|
|
|
* Report a localized error message to the error console.
|
|
|
|
* @param aFile Properties file containing localized message.
|
|
|
|
* @param aMessageName Name of localized message.
|
|
|
|
* @param aParams Parameters to be substituted into localized message.
|
|
|
|
* @param aParamsLength Length of aParams.
|
|
|
|
* @param aURI URI of resource containing error (may be null).
|
2004-11-23 20:45:37 +03:00
|
|
|
* @param aSourceLine The text of the line that contains the error (may be
|
|
|
|
empty).
|
2004-09-14 21:26:35 +04:00
|
|
|
* @param aLineNumber Line number within resource containing error.
|
|
|
|
* @param aColumnNumber Column number within resource containing error.
|
|
|
|
* @param aErrorFlags See nsIScriptError.
|
|
|
|
* @param aCategory Name of module reporting error.
|
|
|
|
*/
|
|
|
|
enum PropertiesFile {
|
|
|
|
eCSS_PROPERTIES,
|
|
|
|
eXBL_PROPERTIES,
|
|
|
|
eXUL_PROPERTIES,
|
2004-11-23 20:45:37 +03:00
|
|
|
eLAYOUT_PROPERTIES,
|
2004-12-17 23:40:48 +03:00
|
|
|
eFORMS_PROPERTIES,
|
|
|
|
ePRINTING_PROPERTIES,
|
|
|
|
eDOM_PROPERTIES,
|
2006-07-27 15:58:05 +04:00
|
|
|
#ifdef MOZ_SVG
|
|
|
|
eSVG_PROPERTIES,
|
|
|
|
#endif
|
2005-04-03 21:16:28 +04:00
|
|
|
eBRAND_PROPERTIES,
|
2006-02-14 05:06:48 +03:00
|
|
|
eCOMMON_DIALOG_PROPERTIES,
|
2004-09-14 21:26:35 +04:00
|
|
|
PropertiesFile_COUNT
|
|
|
|
};
|
|
|
|
static nsresult ReportToConsole(PropertiesFile aFile,
|
|
|
|
const char *aMessageName,
|
|
|
|
const PRUnichar **aParams,
|
|
|
|
PRUint32 aParamsLength,
|
|
|
|
nsIURI* aURI,
|
2004-11-23 20:45:37 +03:00
|
|
|
const nsAFlatString& aSourceLine,
|
2004-09-14 21:26:35 +04:00
|
|
|
PRUint32 aLineNumber,
|
|
|
|
PRUint32 aColumnNumber,
|
|
|
|
PRUint32 aErrorFlags,
|
|
|
|
const char *aCategory);
|
|
|
|
|
2004-12-17 23:40:48 +03:00
|
|
|
/**
|
|
|
|
* Get the localized string named |aKey| in properties file |aFile|.
|
|
|
|
*/
|
|
|
|
static nsresult GetLocalizedString(PropertiesFile aFile,
|
|
|
|
const char* aKey,
|
2005-01-19 02:46:59 +03:00
|
|
|
nsXPIDLString& aResult);
|
2004-12-17 23:40:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fill (with the parameters given) the localized string named |aKey| in
|
|
|
|
* properties file |aFile|.
|
|
|
|
*/
|
|
|
|
static nsresult FormatLocalizedString(PropertiesFile aFile,
|
|
|
|
const char* aKey,
|
|
|
|
const PRUnichar **aParams,
|
|
|
|
PRUint32 aParamsLength,
|
2005-01-19 02:46:59 +03:00
|
|
|
nsXPIDLString& aResult);
|
2004-12-17 23:40:48 +03:00
|
|
|
|
2005-06-03 03:36:08 +04:00
|
|
|
/**
|
|
|
|
* Returns true if aDocument is a chrome document
|
|
|
|
*/
|
|
|
|
static PRBool IsChromeDoc(nsIDocument *aDocument);
|
2004-12-17 23:40:48 +03:00
|
|
|
|
2005-07-06 19:46:12 +04:00
|
|
|
/**
|
|
|
|
* Notify XPConnect if an exception is pending on aCx.
|
|
|
|
*/
|
|
|
|
static void NotifyXPCIfExceptionPending(JSContext *aCx);
|
|
|
|
|
2005-08-15 06:42:59 +04:00
|
|
|
/**
|
|
|
|
* Release *aSupportsPtr when the shutdown notification is received
|
|
|
|
*/
|
|
|
|
static nsresult ReleasePtrOnShutdown(nsISupports** aSupportsPtr) {
|
|
|
|
NS_ASSERTION(aSupportsPtr, "Expect to crash!");
|
|
|
|
NS_ASSERTION(*aSupportsPtr, "Expect to crash!");
|
|
|
|
return sPtrsToPtrsToRelease->AppendElement(aSupportsPtr) ? NS_OK :
|
|
|
|
NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
2005-08-19 19:00:01 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the content policy service
|
|
|
|
*/
|
2005-08-24 01:00:00 +04:00
|
|
|
static nsIContentPolicy *GetContentPolicy();
|
2005-08-25 01:01:51 +04:00
|
|
|
|
2005-09-24 06:33:33 +04:00
|
|
|
/**
|
|
|
|
* Make sure that whatever value *aPtr contains at any given moment is
|
|
|
|
* protected from JS GC until we remove the GC root. A call to this that
|
|
|
|
* succeeds MUST be matched by a call to RemoveJSGCRoot to avoid leaking.
|
|
|
|
*/
|
|
|
|
static nsresult AddJSGCRoot(jsval* aPtr, const char* aName) {
|
|
|
|
return AddJSGCRoot((void*)aPtr, aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure that whatever object *aPtr is pointing to at any given moment is
|
|
|
|
* protected from JS GC until we remove the GC root. A call to this that
|
|
|
|
* succeeds MUST be matched by a call to RemoveJSGCRoot to avoid leaking.
|
|
|
|
*/
|
|
|
|
static nsresult AddJSGCRoot(JSObject** aPtr, const char* aName) {
|
|
|
|
return AddJSGCRoot((void*)aPtr, aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure that whatever object *aPtr is pointing to at any given moment is
|
|
|
|
* protected from JS GC until we remove the GC root. A call to this that
|
|
|
|
* succeeds MUST be matched by a call to RemoveJSGCRoot to avoid leaking.
|
|
|
|
*/
|
|
|
|
static nsresult AddJSGCRoot(void* aPtr, const char* aName);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove aPtr as a JS GC root
|
|
|
|
*/
|
|
|
|
static nsresult RemoveJSGCRoot(jsval* aPtr) {
|
|
|
|
return RemoveJSGCRoot((void*)aPtr);
|
|
|
|
}
|
|
|
|
static nsresult RemoveJSGCRoot(JSObject** aPtr) {
|
|
|
|
return RemoveJSGCRoot((void*)aPtr);
|
|
|
|
}
|
|
|
|
static nsresult RemoveJSGCRoot(void* aPtr);
|
2005-10-10 22:38:57 +04:00
|
|
|
|
2006-04-24 23:52:21 +04:00
|
|
|
/**
|
|
|
|
* Quick helper to determine whether there are any mutation listeners
|
|
|
|
* of a given type that apply to this content or any of its ancestors.
|
|
|
|
*
|
2006-06-02 04:58:04 +04:00
|
|
|
* @param aNode The node to search for listeners
|
|
|
|
* @param aType The type of listener (NS_EVENT_BITS_MUTATION_*)
|
2006-04-24 23:52:21 +04:00
|
|
|
*
|
|
|
|
* @return true if there are mutation listeners of the specified type
|
|
|
|
*/
|
2006-06-02 04:58:04 +04:00
|
|
|
static PRBool HasMutationListeners(nsINode* aNode,
|
2006-04-24 23:52:21 +04:00
|
|
|
PRUint32 aType);
|
|
|
|
|
2005-10-10 22:38:57 +04:00
|
|
|
/**
|
|
|
|
* This method creates and dispatches a trusted event.
|
|
|
|
* Works only with events which can be created by calling
|
|
|
|
* nsIDOMDocumentEvent::CreateEvent() with parameter "Events".
|
|
|
|
* @param aDoc The document which will be used to create the event.
|
|
|
|
* @param aTarget The target of the event, should be QIable to
|
|
|
|
* nsIDOMEventTarget.
|
|
|
|
* @param aEventName The name of the event.
|
|
|
|
* @param aCanBubble Whether the event can bubble.
|
|
|
|
* @param aCancelable Is the event cancelable.
|
|
|
|
* @param aDefaultAction Set to true if default action should be taken,
|
|
|
|
* see nsIDOMEventTarget::DispatchEvent.
|
|
|
|
*/
|
|
|
|
static nsresult DispatchTrustedEvent(nsIDocument* aDoc,
|
|
|
|
nsISupports* aTarget,
|
|
|
|
const nsAString& aEventName,
|
|
|
|
PRBool aCanBubble,
|
|
|
|
PRBool aCancelable,
|
|
|
|
PRBool *aDefaultAction = nsnull);
|
|
|
|
|
2007-04-02 21:17:36 +04:00
|
|
|
/**
|
|
|
|
* Determines if an event attribute name (such as onclick) is valid for
|
|
|
|
* a given element type. Types are from the EventNameType enumeration
|
|
|
|
* defined above.
|
|
|
|
*
|
|
|
|
* @param aName the event name to look up
|
|
|
|
* @param aType the type of content
|
|
|
|
*/
|
|
|
|
static PRBool IsEventAttributeName(nsIAtom* aName, PRInt32 aType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the event id for the event with the given name. The name is the
|
|
|
|
* event name with the 'on' prefix. Returns NS_USER_DEFINED_EVENT if the
|
|
|
|
* event doesn't match a known event name.
|
|
|
|
*
|
|
|
|
* @param aName the event name to look up
|
|
|
|
*/
|
|
|
|
static PRUint32 GetEventId(nsIAtom* aName);
|
|
|
|
|
2007-01-05 01:31:26 +03:00
|
|
|
/**
|
|
|
|
* Used only during traversal of the XPCOM graph by the cycle
|
|
|
|
* collector: push a pointer to the listener manager onto the
|
|
|
|
* children deque, if it exists. Do nothing if there is no listener
|
|
|
|
* manager.
|
|
|
|
*
|
|
|
|
* Crucially: does not perform any refcounting operations.
|
|
|
|
*
|
|
|
|
* @param aNode The node to traverse.
|
|
|
|
* @param children The buffer to push a listener manager pointer into.
|
|
|
|
*/
|
|
|
|
static void TraverseListenerManager(nsINode *aNode,
|
|
|
|
nsCycleCollectionTraversalCallback &cb);
|
|
|
|
|
2006-02-07 17:34:10 +03:00
|
|
|
/**
|
2006-05-15 11:03:15 +04:00
|
|
|
* Get the eventlistener manager for aNode. If a new eventlistener manager
|
2006-03-07 20:08:51 +03:00
|
|
|
* was created, aCreated is set to PR_TRUE.
|
2006-02-07 17:34:10 +03:00
|
|
|
*
|
2006-05-15 11:03:15 +04:00
|
|
|
* @param aNode The node for which to get the eventlistener manager.
|
2006-03-07 20:08:51 +03:00
|
|
|
* @param aCreateIfNotFound If PR_FALSE, returns a listener manager only if
|
|
|
|
* one already exists.
|
2006-05-15 11:03:15 +04:00
|
|
|
* @param aResult [out] Set to the eventlistener manager for aNode.
|
2006-02-07 17:34:10 +03:00
|
|
|
*/
|
2006-05-15 11:03:15 +04:00
|
|
|
static nsresult GetListenerManager(nsINode *aNode,
|
2006-03-07 20:08:51 +03:00
|
|
|
PRBool aCreateIfNotFound,
|
2007-02-16 02:04:33 +03:00
|
|
|
nsIEventListenerManager **aResult);
|
2006-02-07 17:34:10 +03:00
|
|
|
|
|
|
|
/**
|
2006-05-15 11:03:15 +04:00
|
|
|
* Remove the eventlistener manager for aNode.
|
2006-02-07 17:34:10 +03:00
|
|
|
*
|
2006-05-15 11:03:15 +04:00
|
|
|
* @param aNode The node for which to remove the eventlistener manager.
|
2006-02-07 17:34:10 +03:00
|
|
|
*/
|
2006-05-15 11:03:15 +04:00
|
|
|
static void RemoveListenerManager(nsINode *aNode);
|
2006-02-07 17:34:10 +03:00
|
|
|
|
|
|
|
static PRBool IsInitialized()
|
|
|
|
{
|
|
|
|
return sInitialized;
|
|
|
|
}
|
|
|
|
|
2006-04-17 21:13:11 +04:00
|
|
|
/**
|
|
|
|
* Checks if the localname/prefix/namespace triple is valid wrt prefix
|
|
|
|
* and namespace according to the Namespaces in XML and DOM Code
|
|
|
|
* specfications.
|
|
|
|
*
|
|
|
|
* @param aLocalname localname of the node
|
|
|
|
* @param aPrefix prefix of the node
|
|
|
|
* @param aNamespaceID namespace of the node
|
|
|
|
*/
|
|
|
|
static PRBool IsValidNodeName(nsIAtom *aLocalName, nsIAtom *aPrefix,
|
|
|
|
PRInt32 aNamespaceID);
|
|
|
|
|
2006-06-02 17:28:14 +04:00
|
|
|
/**
|
|
|
|
* Associate an object aData to aKey on node aNode. If aData is null any
|
|
|
|
* previously registered object and UserDataHandler associated to aKey on
|
|
|
|
* aNode will be removed.
|
|
|
|
* Should only be used to implement the DOM Level 3 UserData API.
|
|
|
|
*
|
|
|
|
* @param aNode canonical nsINode pointer of the node to add aData to
|
|
|
|
* @param aKey the key to associate the object to
|
|
|
|
* @param aData the object to associate to aKey on aNode (may be nulll)
|
|
|
|
* @param aHandler the UserDataHandler to call when the node is
|
|
|
|
* cloned/deleted/imported/renamed (may be nulll)
|
|
|
|
* @param aResult [out] the previously registered object for aKey on aNode, if
|
|
|
|
* any
|
|
|
|
* @return whether adding the object and UserDataHandler succeeded
|
|
|
|
*/
|
|
|
|
static nsresult SetUserData(nsINode *aNode, nsIAtom *aKey, nsIVariant *aData,
|
|
|
|
nsIDOMUserDataHandler *aHandler,
|
|
|
|
nsIVariant **aResult);
|
|
|
|
|
2006-06-06 00:32:48 +04:00
|
|
|
/**
|
|
|
|
* Creates a DocumentFragment from text using a context node to resolve
|
|
|
|
* namespaces.
|
|
|
|
*
|
|
|
|
* @param aContextNode the node which is used to resolve namespaces
|
|
|
|
* @param aFragment the string which is parsed to a DocumentFragment
|
|
|
|
* @param aReturn [out] the created DocumentFragment
|
|
|
|
*/
|
|
|
|
static nsresult CreateContextualFragment(nsIDOMNode* aContextNode,
|
|
|
|
const nsAString& aFragment,
|
|
|
|
nsIDOMDocumentFragment** aReturn);
|
|
|
|
|
2006-06-16 00:30:44 +04:00
|
|
|
/**
|
|
|
|
* Creates a new XML document, setting the document's container to be the
|
|
|
|
* docshell of whatever script is on the JSContext stack.
|
|
|
|
*
|
|
|
|
* @param aNamespaceURI Namespace for the root element to create and insert in
|
|
|
|
* the document. Only used if aQualifiedName is not
|
|
|
|
* empty.
|
|
|
|
* @param aQualifiedName Qualified name for the root element to create and
|
|
|
|
* insert in the document. If empty no root element will
|
|
|
|
* be created.
|
|
|
|
* @param aDoctype Doctype node to insert in the document.
|
|
|
|
* @param aDocumentURI URI of the document. Must not be null.
|
|
|
|
* @param aBaseURI Base URI of the document. Must not be null.
|
|
|
|
* @param aPrincipal Prinicpal of the document. Must not be null.
|
|
|
|
* @param aResult [out] The document that was created.
|
|
|
|
*/
|
|
|
|
static nsresult CreateDocument(const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aQualifiedName,
|
|
|
|
nsIDOMDocumentType* aDoctype,
|
|
|
|
nsIURI* aDocumentURI,
|
|
|
|
nsIURI* aBaseURI,
|
|
|
|
nsIPrincipal* aPrincipal,
|
|
|
|
nsIDOMDocument** aResult);
|
|
|
|
|
2006-09-15 23:54:45 +04:00
|
|
|
/**
|
|
|
|
* Sets the text contents of a node by replacing all existing children
|
|
|
|
* with a single text child.
|
|
|
|
*
|
|
|
|
* The function always notifies.
|
|
|
|
*
|
|
|
|
* Will reuse the first text child if one is available. Will not reuse
|
|
|
|
* existing cdata children.
|
|
|
|
*
|
|
|
|
* @param aContent Node to set contents of.
|
|
|
|
* @param aValue Value to set contents to.
|
|
|
|
* @param aTryReuse When true, the function will try to reuse an existing
|
|
|
|
* textnodes rather than always creating a new one.
|
|
|
|
*/
|
|
|
|
static nsresult SetNodeTextContent(nsIContent* aContent,
|
|
|
|
const nsAString& aValue,
|
|
|
|
PRBool aTryReuse);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the textual contents of a node. This is a concatination of all
|
|
|
|
* textnodes that are direct or (depending on aDeep) indirect children
|
|
|
|
* of the node.
|
|
|
|
*
|
|
|
|
* NOTE! No serialization takes place and <br> elements
|
|
|
|
* are not converted into newlines. Only textnodes and cdata nodes are
|
|
|
|
* added to the result.
|
|
|
|
*
|
|
|
|
* @param aNode Node to get textual contents of.
|
|
|
|
* @param aDeep If true child elements of aNode are recursivly descended
|
|
|
|
* into to find text children.
|
|
|
|
* @param aResult the result. Out param.
|
|
|
|
*/
|
|
|
|
static void GetNodeTextContent(nsINode* aNode, PRBool aDeep,
|
|
|
|
nsAString& aResult)
|
|
|
|
{
|
|
|
|
aResult.Truncate();
|
|
|
|
AppendNodeTextContent(aNode, aDeep, aResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as GetNodeTextContents but appends the result rather than sets it.
|
|
|
|
*/
|
|
|
|
static void AppendNodeTextContent(nsINode* aNode, PRBool aDeep,
|
|
|
|
nsAString& aResult);
|
|
|
|
|
2006-11-09 03:02:21 +03:00
|
|
|
/**
|
|
|
|
* Utility method that checks if a given node has any non-empty
|
|
|
|
* children.
|
|
|
|
* NOTE! This method does not descend recursivly into elements.
|
|
|
|
* Though it would be easy to make it so if needed
|
|
|
|
*/
|
|
|
|
static PRBool HasNonEmptyTextContent(nsINode* aNode);
|
|
|
|
|
2007-02-01 18:14:00 +03:00
|
|
|
/**
|
|
|
|
* Delete strings allocated for nsContentList matches
|
|
|
|
*/
|
|
|
|
static void DestroyMatchString(void* aData)
|
|
|
|
{
|
|
|
|
if (aData) {
|
|
|
|
nsString* matchString = NS_STATIC_CAST(nsString*, aData);
|
|
|
|
delete matchString;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
/**
|
|
|
|
* Unbinds the content from the tree and nulls it out if it's not null.
|
|
|
|
*/
|
|
|
|
static void DestroyAnonymousContent(nsCOMPtr<nsIContent>* aContent);
|
|
|
|
|
2007-03-02 16:34:14 +03:00
|
|
|
static nsresult HoldScriptObject(PRUint32 aLangID, void *aObject);
|
|
|
|
static nsresult DropScriptObject(PRUint32 aLangID, void *aObject);
|
|
|
|
|
|
|
|
class ScriptObjectHolder
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ScriptObjectHolder(PRUint32 aLangID) : mLangID(aLangID),
|
|
|
|
mObject(nsnull)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
~ScriptObjectHolder()
|
|
|
|
{
|
2007-03-11 13:46:06 +03:00
|
|
|
if (mObject)
|
|
|
|
DropScriptObject(mLangID, mObject);
|
2007-03-02 16:34:14 +03:00
|
|
|
}
|
|
|
|
nsresult set(void *aObject)
|
|
|
|
{
|
|
|
|
nsresult rv = HoldScriptObject(mLangID, aObject);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mObject = aObject;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
PRUint32 mLangID;
|
|
|
|
void *mObject;
|
|
|
|
};
|
|
|
|
|
2004-03-06 05:58:08 +03:00
|
|
|
private:
|
2007-04-02 21:17:36 +04:00
|
|
|
|
|
|
|
static PRBool InitializeEventTable();
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static nsresult doReparentContentWrapper(nsIContent *aChild,
|
|
|
|
JSContext *cx,
|
2005-12-03 09:27:45 +03:00
|
|
|
JSObject *aOldGlobal,
|
2007-01-05 01:31:26 +03:00
|
|
|
JSObject *aNewGlobal,
|
|
|
|
nsIDocument *aOldDocument,
|
|
|
|
nsIDocument *aNewDocument);
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2004-12-17 23:40:48 +03:00
|
|
|
static nsresult EnsureStringBundle(PropertiesFile aFile);
|
|
|
|
|
2007-03-02 16:34:14 +03:00
|
|
|
static nsIDOMScriptObjectFactory *GetDOMScriptObjectFactory();
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
static nsIDOMScriptObjectFactory *sDOMScriptObjectFactory;
|
|
|
|
|
|
|
|
static nsIXPConnect *sXPConnect;
|
2002-07-18 09:53:28 +04:00
|
|
|
|
|
|
|
static nsIScriptSecurityManager *sSecurityManager;
|
2002-08-09 12:45:30 +04:00
|
|
|
|
|
|
|
static nsIThreadJSContextStack *sThreadJSContextStack;
|
2002-11-19 16:39:20 +03:00
|
|
|
|
|
|
|
static nsIParserService *sParserService;
|
|
|
|
|
2002-11-30 02:44:07 +03:00
|
|
|
static nsINameSpaceManager *sNameSpaceManager;
|
2003-07-08 09:35:04 +04:00
|
|
|
|
|
|
|
static nsIIOService *sIOService;
|
2003-10-30 05:53:08 +03:00
|
|
|
|
2004-10-08 00:59:53 +04:00
|
|
|
#ifdef MOZ_XTF
|
|
|
|
static nsIXTFService *sXTFService;
|
|
|
|
#endif
|
|
|
|
|
2004-04-30 03:34:19 +04:00
|
|
|
static nsIPrefBranch *sPrefBranch;
|
|
|
|
|
|
|
|
static nsIPref *sPref;
|
|
|
|
|
2004-03-09 06:57:51 +03:00
|
|
|
static imgILoader* sImgLoader;
|
2004-04-30 03:34:19 +04:00
|
|
|
|
2004-09-14 21:26:35 +04:00
|
|
|
static nsIConsoleService* sConsoleService;
|
|
|
|
|
2007-04-02 21:17:36 +04:00
|
|
|
static nsDataHashtable<nsISupportsHashKey, EventNameMapping>* sEventTable;
|
|
|
|
|
2004-09-14 21:26:35 +04:00
|
|
|
static nsIStringBundleService* sStringBundleService;
|
|
|
|
static nsIStringBundle* sStringBundles[PropertiesFile_COUNT];
|
|
|
|
|
2005-08-19 19:00:01 +04:00
|
|
|
static nsIContentPolicy* sContentPolicyService;
|
2005-08-24 01:00:00 +04:00
|
|
|
static PRBool sTriedToGetContentPolicy;
|
2005-08-19 19:00:01 +04:00
|
|
|
|
2005-08-22 07:00:06 +04:00
|
|
|
static nsILineBreaker* sLineBreaker;
|
|
|
|
static nsIWordBreaker* sWordBreaker;
|
|
|
|
|
2005-08-15 06:42:59 +04:00
|
|
|
// Holds pointers to nsISupports* that should be released at shutdown
|
|
|
|
static nsVoidArray* sPtrsToPtrsToRelease;
|
2005-09-24 06:33:33 +04:00
|
|
|
|
|
|
|
// For now, we don't want to automatically clean this up in Shutdown(), since
|
|
|
|
// consumers might unfortunately end up wanting to use it after that
|
|
|
|
static nsIJSRuntimeService* sJSRuntimeService;
|
2007-03-02 16:34:14 +03:00
|
|
|
static JSRuntime* sJSScriptRuntime;
|
|
|
|
static PRInt32 sJSScriptRootCount;
|
|
|
|
|
|
|
|
static nsIScriptRuntime* sScriptRuntimes[NS_STID_ARRAY_UBOUND];
|
|
|
|
static PRInt32 sScriptRootCount[NS_STID_ARRAY_UBOUND];
|
2006-08-08 09:14:52 +04:00
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
static nsIBidiKeyboard* sBidiKeyboard;
|
|
|
|
#endif
|
|
|
|
|
2003-10-30 05:53:08 +03:00
|
|
|
static PRBool sInitialized;
|
2002-08-09 12:45:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class nsCxPusher
|
|
|
|
{
|
|
|
|
public:
|
2006-03-22 21:36:36 +03:00
|
|
|
nsCxPusher(nsISupports *aCurrentTarget);
|
|
|
|
~nsCxPusher();
|
2002-08-09 12:45:30 +04:00
|
|
|
|
|
|
|
void Push(nsISupports *aCurrentTarget);
|
|
|
|
void Pop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIJSContextStack> mStack;
|
|
|
|
nsCOMPtr<nsIScriptContext> mScx;
|
|
|
|
PRBool mScriptIsRunning;
|
2001-02-17 12:53:29 +03:00
|
|
|
};
|
|
|
|
|
2005-09-24 06:33:33 +04:00
|
|
|
class nsAutoGCRoot {
|
|
|
|
public:
|
|
|
|
// aPtr should be the pointer to the jsval we want to protect
|
|
|
|
nsAutoGCRoot(jsval* aPtr, nsresult* aResult) :
|
|
|
|
mPtr(aPtr)
|
|
|
|
{
|
|
|
|
mResult = *aResult =
|
|
|
|
nsContentUtils::AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
|
|
|
}
|
|
|
|
|
|
|
|
// aPtr should be the pointer to the JSObject* we want to protect
|
|
|
|
nsAutoGCRoot(JSObject** aPtr, nsresult* aResult) :
|
|
|
|
mPtr(aPtr)
|
|
|
|
{
|
|
|
|
mResult = *aResult =
|
|
|
|
nsContentUtils::AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
|
|
|
}
|
|
|
|
|
|
|
|
// aPtr should be the pointer to the thing we want to protect
|
|
|
|
nsAutoGCRoot(void* aPtr, nsresult* aResult) :
|
|
|
|
mPtr(aPtr)
|
|
|
|
{
|
|
|
|
mResult = *aResult =
|
|
|
|
nsContentUtils::AddJSGCRoot(aPtr, "nsAutoGCRoot");
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsAutoGCRoot() {
|
|
|
|
if (NS_SUCCEEDED(mResult)) {
|
|
|
|
nsContentUtils::RemoveJSGCRoot(mPtr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void* mPtr;
|
|
|
|
nsresult mResult;
|
|
|
|
};
|
2002-08-09 12:45:30 +04:00
|
|
|
|
2006-04-08 00:14:51 +04:00
|
|
|
#define NS_AUTO_GCROOT_PASTE2(tok,line) tok##line
|
|
|
|
#define NS_AUTO_GCROOT_PASTE(tok,line) \
|
|
|
|
NS_AUTO_GCROOT_PASTE2(tok,line)
|
|
|
|
#define NS_AUTO_GCROOT(ptr, result) \ \
|
|
|
|
nsAutoGCRoot NS_AUTO_GCROOT_PASTE(_autoGCRoot_, __LINE__) \
|
|
|
|
(ptr, result)
|
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
#define NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(_class) \
|
2007-03-19 12:19:16 +03:00
|
|
|
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class)
|
2004-01-06 03:36:01 +03:00
|
|
|
|
|
|
|
#define NS_INTERFACE_MAP_ENTRY_TEAROFF(_interface, _allocator) \
|
|
|
|
if (aIID.Equals(NS_GET_IID(_interface))) { \
|
|
|
|
foundInterface = NS_STATIC_CAST(_interface *, _allocator); \
|
|
|
|
if (!foundInterface) { \
|
|
|
|
*aInstancePtr = nsnull; \
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
} \
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
} else
|
|
|
|
|
2001-02-17 12:53:29 +03:00
|
|
|
#endif /* nsContentUtils_h___ */
|