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"
|
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
|
|
|
#include "nsIDOMScriptObjectFactory.h"
|
2002-08-09 12:45:30 +04:00
|
|
|
#include "nsIJSContextStack.h"
|
|
|
|
#include "nsIScriptContext.h"
|
2002-12-04 08:18:39 +03:00
|
|
|
#include "nsCOMArray.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"
|
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
|
|
|
class nsIXPConnect;
|
|
|
|
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;
|
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;
|
2004-10-08 00:59:53 +04:00
|
|
|
#ifdef MOZ_XTF
|
|
|
|
class nsIXTFService;
|
|
|
|
#endif
|
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();
|
|
|
|
|
|
|
|
static nsresult ReparentContentWrapper(nsIContent *aContent,
|
|
|
|
nsIContent *aNewParent,
|
|
|
|
nsIDocument *aNewDocument,
|
|
|
|
nsIDocument *aOldDocument);
|
2001-02-17 12:53:29 +03:00
|
|
|
|
2002-06-26 00:03:06 +04:00
|
|
|
static PRBool IsCallerChrome();
|
|
|
|
|
|
|
|
/*
|
2002-06-27 01:05:00 +04:00
|
|
|
* Returns true if the nodes are both in the same document or
|
|
|
|
* if neither is in a document.
|
|
|
|
* Returns false if the nodes are not in the same document.
|
2002-06-26 00:03:06 +04:00
|
|
|
*/
|
|
|
|
static PRBool InSameDoc(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aOther);
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
static PRBool ContentIsDescendantOf(nsIContent* aPossibleDescendant,
|
|
|
|
nsIContent* aPossibleAncestor);
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* The elements of |aAncestorNodes| were |nsIContent*|s before casting to
|
|
|
|
* |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.
|
|
|
|
*/
|
|
|
|
static nsresult GetCommonAncestor(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aOther,
|
|
|
|
nsIDOMNode** aCommonAncestor);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* |aDifferentNodes| will contain up to 3 elements.
|
|
|
|
* The first, if present, is the common ancestor of |aNode| and |aOther|.
|
|
|
|
* The second, if present, is the ancestor node of |aNode| which is
|
|
|
|
* closest to the common ancestor, but not an ancestor of |aOther|.
|
|
|
|
* The third, if present, is the ancestor node of |aOther| which is
|
|
|
|
* closest to the common ancestor, but not an ancestor of |aNode|.
|
2004-04-15 00:12:54 +04:00
|
|
|
*
|
|
|
|
* @throws NS_ERROR_FAILURE if aNode and aOther are disconnected.
|
2002-06-26 00:03:06 +04:00
|
|
|
*/
|
|
|
|
static nsresult GetFirstDifferentAncestors(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aOther,
|
2002-12-04 08:18:39 +03:00
|
|
|
nsCOMArray<nsIDOMNode>& aDifferentNodes);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares the document position of nodes which may have parents.
|
|
|
|
* DO NOT pass in nodes that cannot have a parentNode. In other words:
|
|
|
|
* DO NOT pass in Attr, Document, DocumentFragment, Entity, or Notation!
|
|
|
|
* The results will be completely wrong!
|
|
|
|
*
|
|
|
|
* @param aNode The node to which you are comparing.
|
|
|
|
* @param aOther The reference node to which aNode is compared.
|
|
|
|
*
|
|
|
|
* @return The document position flags of the nodes.
|
|
|
|
*
|
|
|
|
* @see nsIDOMNode
|
|
|
|
* @see nsIDOM3Node
|
|
|
|
*/
|
|
|
|
static PRUint16 ComparePositionWithAncestors(nsIDOMNode *aNode,
|
|
|
|
nsIDOMNode *aOther);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
2002-03-24 02:54:46 +03:00
|
|
|
static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
|
2001-02-17 12:53:29 +03:00
|
|
|
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();
|
2002-07-15 23:25:27 +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
|
|
|
|
2002-09-20 17:40:53 +04:00
|
|
|
/**
|
|
|
|
* Get the document through the JS context that's currently on the stack.
|
|
|
|
* If there's no JS context currently on the stack aDocument will be null.
|
|
|
|
*
|
|
|
|
* @param aDocument The document or null if no JS context
|
|
|
|
*/
|
2004-02-10 01:48:53 +03:00
|
|
|
static nsIDOMDocument *GetDocumentFromCaller();
|
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.
|
|
|
|
static PRBool InProlog(nsIDOMNode *aNode);
|
|
|
|
|
2002-11-19 16:39:20 +03:00
|
|
|
static nsIParserService* GetParserServiceWeakRef();
|
|
|
|
|
2002-11-30 02:44:07 +03:00
|
|
|
static nsINameSpaceManager* GetNSManagerWeakRef()
|
|
|
|
{
|
2003-07-08 09:35:04 +04:00
|
|
|
return sNameSpaceManager;
|
2002-11-30 02:44:07 +03:00
|
|
|
};
|
|
|
|
|
2003-07-08 09:35:04 +04:00
|
|
|
static nsIIOService* GetIOServiceWeakRef()
|
|
|
|
{
|
|
|
|
return sIOService;
|
|
|
|
};
|
2003-10-22 02:11:49 +04:00
|
|
|
|
2004-10-08 00:59:53 +04:00
|
|
|
#ifdef MOZ_XTF
|
|
|
|
static nsIXTFService* GetXTFServiceWeakRef();
|
|
|
|
#endif
|
|
|
|
|
2003-10-22 02:11:49 +04:00
|
|
|
static nsIScriptSecurityManager* GetSecurityManager()
|
|
|
|
{
|
|
|
|
return sSecurityManager;
|
|
|
|
}
|
2003-07-08 09:35:04 +04:00
|
|
|
|
2003-05-30 04:21:01 +04:00
|
|
|
static nsresult GenerateStateKey(nsIContent* aContent,
|
|
|
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2004-02-10 13:58:13 +03:00
|
|
|
static nsresult CheckQName(const nsAString& aQualifiedName,
|
|
|
|
PRBool aNamespaceAware = PR_TRUE);
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2003-01-22 06:25:51 +03:00
|
|
|
static nsresult GetDocumentAndPrincipal(nsIDOMNode* aNode,
|
|
|
|
nsIDocument** aDocument,
|
|
|
|
nsIPrincipal** aPrincipal);
|
|
|
|
|
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
|
2004-05-13 22:34:18 +04:00
|
|
|
* @return PR_TRUE if the load can proceed, or PR_FALSE if it is blocked
|
2004-03-09 06:57:51 +03:00
|
|
|
*/
|
2004-05-13 22:34:18 +04:00
|
|
|
static PRBool CanLoadImage(nsIURI* aURI,
|
|
|
|
nsISupports* aContext,
|
|
|
|
nsIDocument* aLoadingDocument);
|
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.
|
|
|
|
* @return the nsIImage corresponding to the first frame of the image
|
|
|
|
*/
|
|
|
|
static already_AddRefed<nsIImage> GetImageFromContent(nsIImageLoadingContent* aContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method that gets the URI of the link content. If the content
|
|
|
|
* isn't a link, return null.
|
|
|
|
*
|
|
|
|
* @param aContent The link content
|
|
|
|
* @return the URI the link points to
|
|
|
|
*/
|
|
|
|
static already_AddRefed<nsIURI> GetLinkURI(nsIContent* aContent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method that gets the XLink uri for a content node, if it's an XLink
|
|
|
|
*
|
|
|
|
* @param aContent The content node, possibly an XLink
|
|
|
|
* @return Null if aContent is not an XLink, the URI it points to otherwise
|
|
|
|
*/
|
|
|
|
static already_AddRefed<nsIURI> GetXLinkURI(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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve a pointer to the document that owns aNodeInfo.
|
|
|
|
*/
|
|
|
|
static nsIDocument *GetDocument(nsINodeInfo *aNodeInfo)
|
|
|
|
{
|
|
|
|
return aNodeInfo->NodeInfoManager()->GetDocument();
|
|
|
|
}
|
2004-07-22 20:38:05 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the appropriate event argument name for the specified
|
|
|
|
* namespace. Added because we need to switch between SVG's "evt"
|
|
|
|
* and the rest of the world's "event".
|
|
|
|
*/
|
|
|
|
static const char *GetEventArgName(PRInt32 aNameSpaceID);
|
|
|
|
|
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,
|
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,
|
|
|
|
nsString& aResult);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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,
|
|
|
|
nsString& aResult);
|
|
|
|
|
|
|
|
|
2004-03-06 05:58:08 +03:00
|
|
|
private:
|
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,
|
|
|
|
nsIDocument *aNewDocument,
|
|
|
|
nsIDocument *aOldDocument,
|
|
|
|
JSContext *cx,
|
|
|
|
JSObject *parent_obj);
|
|
|
|
|
2004-12-17 23:40:48 +03:00
|
|
|
static nsresult EnsureStringBundle(PropertiesFile aFile);
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
static nsIStringBundleService* sStringBundleService;
|
|
|
|
static nsIStringBundle* sStringBundles[PropertiesFile_COUNT];
|
|
|
|
|
2003-10-30 05:53:08 +03:00
|
|
|
static PRBool sInitialized;
|
2002-08-09 12:45:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class nsCxPusher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsCxPusher(nsISupports *aCurrentTarget)
|
|
|
|
: mScriptIsRunning(PR_FALSE)
|
|
|
|
{
|
|
|
|
if (aCurrentTarget) {
|
|
|
|
Push(aCurrentTarget);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsCxPusher()
|
|
|
|
{
|
|
|
|
Pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Push(nsISupports *aCurrentTarget);
|
|
|
|
void Pop();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIJSContextStack> mStack;
|
|
|
|
nsCOMPtr<nsIScriptContext> mScx;
|
|
|
|
PRBool mScriptIsRunning;
|
2001-02-17 12:53:29 +03:00
|
|
|
};
|
|
|
|
|
2002-08-09 12:45:30 +04: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
|
|
|
#define NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(_class) \
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsIClassInfo))) { \
|
|
|
|
foundInterface = \
|
2001-07-11 13:09:30 +04:00
|
|
|
nsContentUtils::GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
|
2004-01-06 03:36:01 +03:00
|
|
|
if (!foundInterface) { \
|
|
|
|
*aInstancePtr = nsnull; \
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY; \
|
|
|
|
} \
|
|
|
|
} else
|
|
|
|
|
|
|
|
#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___ */
|