1998-12-21 19:51:10 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* 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/.
|
2000-04-05 06:37:25 +04:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* This Original Code has been modified by IBM Corporation.
|
|
|
|
* Modifications made by IBM described herein are
|
|
|
|
* Copyright (c) International Business Machines
|
|
|
|
* Corporation, 2000
|
|
|
|
*
|
|
|
|
* Modifications to Mozilla code or documentation
|
|
|
|
* identified per MPL Section 3.3
|
|
|
|
*
|
|
|
|
* Date Modified by Description of modification
|
|
|
|
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
|
|
|
|
* use in OS2
|
1998-12-21 19:51:10 +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 21:42:36 +04:00
|
|
|
#ifndef nsScriptNameSpaceManager_h__
|
|
|
|
#define nsScriptNameSpaceManager_h__
|
1998-12-21 19:51:10 +03:00
|
|
|
|
|
|
|
#include "nsIScriptNameSpaceManager.h"
|
2002-01-17 07:08:14 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
#include "pldhash.h"
|
2002-03-04 05:25:08 +03:00
|
|
|
#include "nsDOMClassInfo.h"
|
2010-11-17 01:09:50 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
2002-08-30 12:48:58 +04:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
struct nsGlobalNameStruct
|
|
|
|
{
|
2002-08-30 12:48:58 +04:00
|
|
|
struct ConstructorAlias
|
|
|
|
{
|
|
|
|
nsCID mCID;
|
|
|
|
nsString mProtoName;
|
|
|
|
nsGlobalNameStruct* mProto;
|
|
|
|
};
|
|
|
|
|
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 21:42:36 +04:00
|
|
|
enum nametype {
|
2002-01-17 07:08:14 +03:00
|
|
|
eTypeNotInitialized,
|
2012-06-14 18:56:38 +04:00
|
|
|
eTypeNewDOMBinding,
|
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 21:42:36 +04:00
|
|
|
eTypeInterface,
|
|
|
|
eTypeProperty,
|
2011-09-06 23:01:01 +04:00
|
|
|
eTypeNavigatorProperty,
|
2001-07-11 13:09:30 +04:00
|
|
|
eTypeExternalConstructor,
|
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 21:42:36 +04:00
|
|
|
eTypeStaticNameSet,
|
2001-07-11 13:09:30 +04:00
|
|
|
eTypeDynamicNameSet,
|
|
|
|
eTypeClassConstructor,
|
2002-03-04 05:25:08 +03:00
|
|
|
eTypeClassProto,
|
|
|
|
eTypeExternalClassInfoCreator,
|
2002-08-30 12:48:58 +04:00
|
|
|
eTypeExternalClassInfo,
|
|
|
|
eTypeExternalConstructorAlias
|
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 21:42:36 +04:00
|
|
|
} mType;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mChromeOnly;
|
|
|
|
bool mDisabled;
|
2007-06-26 18:44:20 +04:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
union {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t mDOMClassInfoID; // eTypeClassConstructor
|
2003-01-22 06:22:35 +03:00
|
|
|
nsIID mIID; // eTypeInterface, eTypeClassProto
|
2002-03-04 05:25:08 +03:00
|
|
|
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
|
2002-08-30 12:48:58 +04:00
|
|
|
ConstructorAlias* mAlias; // eTypeExternalConstructorAlias
|
2012-06-14 18:56:38 +04:00
|
|
|
nsCID mCID; // All other types except eTypeNewDOMBinding
|
2001-07-11 13:09:30 +04:00
|
|
|
};
|
|
|
|
|
2012-03-31 08:42:20 +04:00
|
|
|
// For new style DOM bindings.
|
2012-05-22 17:46:20 +04:00
|
|
|
mozilla::dom::DefineInterface mDefineDOMInterface;
|
2012-09-05 21:37:28 +04:00
|
|
|
mozilla::dom::PrefEnabled mPrefEnabled; // May be null if not pref controlled
|
2012-03-31 08:42:20 +04:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
private:
|
|
|
|
|
|
|
|
// copy constructor
|
|
|
|
};
|
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 21:42:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
class nsIScriptContext;
|
|
|
|
class nsICategoryManager;
|
2009-06-03 19:30:18 +04:00
|
|
|
class GlobalNameMapEntry;
|
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 21:42:36 +04:00
|
|
|
|
|
|
|
|
2010-11-23 18:00:32 +03:00
|
|
|
class nsScriptNameSpaceManager : public nsIObserver,
|
|
|
|
public nsSupportsWeakReference
|
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 21:42:36 +04:00
|
|
|
{
|
|
|
|
public:
|
2010-11-17 01:09:50 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
1998-12-21 19:51:10 +03:00
|
|
|
nsScriptNameSpaceManager();
|
|
|
|
virtual ~nsScriptNameSpaceManager();
|
|
|
|
|
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 21:42:36 +04:00
|
|
|
nsresult Init();
|
|
|
|
nsresult InitForContext(nsIScriptContext *aContext);
|
|
|
|
|
2002-01-17 07:08:14 +03:00
|
|
|
// Returns a nsGlobalNameStruct for aName, or null if one is not
|
|
|
|
// found. The returned nsGlobalNameStruct is only guaranteed to be
|
|
|
|
// valid until the next call to any of the methods in this class.
|
2003-01-31 15:10:13 +03:00
|
|
|
// It also returns a pointer to the string buffer of the classname
|
|
|
|
// in the nsGlobalNameStruct.
|
2012-03-29 22:43:13 +04:00
|
|
|
const nsGlobalNameStruct* LookupName(const nsAString& aName,
|
2012-07-30 18:20:58 +04:00
|
|
|
const PRUnichar **aClassName = nullptr)
|
2012-03-29 22:43:13 +04:00
|
|
|
{
|
|
|
|
return LookupNameInternal(aName, aClassName);
|
|
|
|
}
|
|
|
|
|
2011-09-06 23:01:01 +04:00
|
|
|
// Returns a nsGlobalNameStruct for the navigator property aName, or
|
|
|
|
// null if one is not found. The returned nsGlobalNameStruct is only
|
|
|
|
// guaranteed to be valid until the next call to any of the methods
|
|
|
|
// in this class.
|
2012-12-02 12:59:51 +04:00
|
|
|
const nsGlobalNameStruct* LookupNavigatorName(const nsAString& aName);
|
1998-12-21 19:51:10 +03:00
|
|
|
|
2001-07-11 13:09:30 +04:00
|
|
|
nsresult RegisterClassName(const char *aClassName,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aDOMClassInfoID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aPrivileged,
|
|
|
|
bool aDisabled,
|
2009-06-03 19:30:18 +04:00
|
|
|
const PRUnichar **aResult);
|
2001-07-11 13:09:30 +04:00
|
|
|
|
|
|
|
nsresult RegisterClassProto(const char *aClassName,
|
|
|
|
const nsIID *aConstructorProtoIID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *aFoundOld);
|
2001-07-11 13:09:30 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult RegisterExternalInterfaces(bool aAsProto);
|
2002-03-04 05:25:08 +03:00
|
|
|
|
|
|
|
nsresult RegisterExternalClassName(const char *aClassName,
|
|
|
|
nsCID& aCID);
|
|
|
|
|
|
|
|
// Register the info for an external class. aName must be static
|
|
|
|
// data, it will not be deleted by the DOM code.
|
|
|
|
nsresult RegisterDOMCIData(const char *aName,
|
|
|
|
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
|
|
|
const nsIID *aProtoChainInterface,
|
|
|
|
const nsIID **aInterfaces,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aScriptableFlags,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aHasClassInterface,
|
2002-03-04 05:25:08 +03:00
|
|
|
const nsCID *aConstructorCID);
|
|
|
|
|
2002-08-30 12:48:58 +04:00
|
|
|
nsGlobalNameStruct* GetConstructorProto(const nsGlobalNameStruct* aStruct);
|
|
|
|
|
2012-06-14 18:56:38 +04:00
|
|
|
void RegisterDefineDOMInterface(const nsAFlatString& aName,
|
2012-09-05 21:37:28 +04:00
|
|
|
mozilla::dom::DefineInterface aDefineDOMInterface,
|
|
|
|
mozilla::dom::PrefEnabled aPrefEnabled);
|
2012-03-31 08:42:20 +04:00
|
|
|
|
2012-11-01 21:51:57 +04:00
|
|
|
typedef PLDHashOperator
|
|
|
|
(* GlobalNameEnumerator)(const nsAString& aGlobalName, void* aClosure);
|
|
|
|
|
|
|
|
void EnumerateGlobalNames(GlobalNameEnumerator aEnumerator,
|
|
|
|
void* aClosure);
|
|
|
|
|
2012-11-05 02:18:44 +04:00
|
|
|
size_t SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf);
|
|
|
|
|
2012-03-31 08:42:20 +04:00
|
|
|
private:
|
2002-01-17 07:08:14 +03:00
|
|
|
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
|
|
|
// that aKey will be mapped to. If mType in the returned
|
|
|
|
// nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
|
|
|
|
// already existed.
|
2012-06-14 18:56:38 +04:00
|
|
|
nsGlobalNameStruct *AddToHash(PLDHashTable *aTable, const nsAString *aKey,
|
2012-07-30 18:20:58 +04:00
|
|
|
const PRUnichar **aClassName = nullptr);
|
2012-06-14 18:56:38 +04:00
|
|
|
nsGlobalNameStruct *AddToHash(PLDHashTable *aTable, const char *aKey,
|
2012-07-30 18:20:58 +04:00
|
|
|
const PRUnichar **aClassName = nullptr)
|
2012-06-14 18:56:38 +04:00
|
|
|
{
|
|
|
|
NS_ConvertASCIItoUTF16 key(aKey);
|
|
|
|
return AddToHash(aTable, &key, aClassName);
|
|
|
|
}
|
2002-01-17 07:08:14 +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 21:42:36 +04:00
|
|
|
nsresult FillHash(nsICategoryManager *aCategoryManager,
|
2010-11-17 01:09:50 +03:00
|
|
|
const char *aCategory);
|
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 21:42:36 +04:00
|
|
|
nsresult FillHashWithDOMInterfaces();
|
2003-01-22 06:22:35 +03:00
|
|
|
nsresult RegisterInterface(const char* aIfName,
|
|
|
|
const nsIID *aIfIID,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aFoundOld);
|
1998-12-21 19:51:10 +03:00
|
|
|
|
2010-11-17 01:09:50 +03:00
|
|
|
/**
|
|
|
|
* Add a new category entry into the hash table.
|
2011-02-03 02:46:12 +03:00
|
|
|
* Only some categories can be added (see the beginning of the definition).
|
|
|
|
* The other ones will be ignored.
|
2010-11-17 01:09:50 +03:00
|
|
|
*
|
|
|
|
* @aCategoryManager Instance of the category manager service.
|
|
|
|
* @aCategory Category where the entry comes from.
|
|
|
|
* @aEntry The entry that should be added.
|
|
|
|
*/
|
|
|
|
nsresult AddCategoryEntryToHash(nsICategoryManager* aCategoryManager,
|
|
|
|
const char* aCategory,
|
|
|
|
nsISupports* aEntry);
|
|
|
|
|
2012-03-29 22:43:13 +04:00
|
|
|
nsGlobalNameStruct* LookupNameInternal(const nsAString& aName,
|
2012-07-30 18:20:58 +04:00
|
|
|
const PRUnichar **aClassName = nullptr);
|
2012-03-29 22:43:13 +04:00
|
|
|
|
2002-01-17 07:08:14 +03:00
|
|
|
PLDHashTable mGlobalNames;
|
2011-09-06 23:01:01 +04:00
|
|
|
PLDHashTable mNavigatorNames;
|
2002-01-17 07:08:14 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mIsInitialized;
|
1998-12-21 19:51:10 +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 21:42:36 +04:00
|
|
|
#endif /* nsScriptNameSpaceManager_h__ */
|