Mozilla/mozilla/layout/base/src/nsNodeInfo.h
jst%netscape.com bcd798824b Checking in new files for (the not yet checked in) shared node info code. Not part of the build yet. r=buster@netscape.com
git-svn-id: svn://10.0.0.236/trunk@68672 18797224-902f-48f8-a5cc-f745e15eee43
2000-05-08 14:29:44 +00:00

109 lines
3.6 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsNodeInfo_h___
#define nsNodeInfo_h___
#include "nsINodeInfo.h"
#include "nsINameSpaceManager.h"
#include "plhash.h"
/*
* nsNodeInfoInner is used for two things:
*
* 1. as a member in nsNodeInfo for holding the name, prefix and
* namespace ID
* 2. as the hash key in the hash table in nsNodeInfoManager
*
* nsNodeInfoInner does not do any kind of reference counting, that's up
* to the user of this class, since nsNodeInfoInner is a member of
* nsNodeInfo the hash table doesn't need to delete the keys, when the
* value (nsNodeInfo) the key is automatically deleted.
*/
struct nsNodeInfoInner
{
nsNodeInfoInner(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID)
: mName(aName), mPrefix(aPrefix), mNamespaceID(aNamespaceID) {}
nsNodeInfoInner()
: mName(nsnull), mPrefix(nsnull), mNamespaceID(kNameSpaceID_None) {}
static PR_CALLBACK PRIntn KeyCompare(const void *key1, const void *key2);
static PR_CALLBACK PLHashNumber GetHashValue(const void *key);
nsIAtom* mName;
nsIAtom* mPrefix;
PRInt32 mNamespaceID;
};
class nsNodeInfoManager;
class nsNodeInfo : public nsINodeInfo
{
public:
NS_DECL_ISUPPORTS
// nsINodeInfo
NS_IMETHOD GetName(nsString& aName);
NS_IMETHOD GetNameAtom(nsIAtom*& aAtom);
NS_IMETHOD GetQualifiedName(nsString& aQualifiedName);
NS_IMETHOD GetLocalName(nsString& aLocalName);
NS_IMETHOD GetPrefix(nsString& aPrefix);
NS_IMETHOD GetPrefixAtom(nsIAtom*& aAtom);
NS_IMETHOD GetNamespaceURI(nsString& aNameSpaceURI);
NS_IMETHOD GetNamespaceID(PRInt32& aResult);
NS_IMETHOD GetNodeInfoManager(nsINodeInfoManager*& aNodeInfoManager);
NS_IMETHOD_(PRBool) Equals(nsIAtom *aNameAtom);
NS_IMETHOD_(PRBool) Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom);
NS_IMETHOD_(PRBool) Equals(nsIAtom *aNameAtom, PRInt32 aNamespaceID);
NS_IMETHOD_(PRBool) Equals(nsIAtom *aNameAtom, nsIAtom *aPrefixAtom,
PRInt32 aNamespaceID);
NS_IMETHOD_(PRBool) NamespaceEquals(PRInt32 aNamespaceID);
NS_IMETHOD NameChanged(nsIAtom *aName, nsINodeInfo*& aResult);
NS_IMETHOD PrefixChanged(nsIAtom *aPrefix, nsINodeInfo*& aResult);
// nsNodeInfo
nsNodeInfo();
virtual ~nsNodeInfo();
/*
* Note! Init() must be called exactly once on every nsNodeInfo before
* the object is used, if Init() returns an error code the nsNodeInfo
* should not be used.
*
* aName and aOwnerManager may not be null.
*/
nsresult Init(nsIAtom *aName, nsIAtom *aPrefix, PRInt32 aNamespaceID,
nsNodeInfoManager *aOwnerManager);
protected:
friend class nsNodeInfoManager; // The NodeInfoManager needs to pass this
// to the hash table.
nsNodeInfoInner mInner;
nsNodeInfoManager* mOwnerManager; // Strong reference!
};
#endif /* nsNodeInfo_h___ */