Compare commits
10 Commits
Bugzilla_P
...
RDF_HISTOR
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e824341108 | ||
|
|
7bef6ef162 | ||
|
|
a654f68a59 | ||
|
|
00d3937c85 | ||
|
|
3a134ca53e | ||
|
|
55343db4f0 | ||
|
|
f3c2d4306b | ||
|
|
ebc4a76159 | ||
|
|
5d7e007b49 | ||
|
|
3dd7d3424e |
305
mozilla/content/xul/content/src/nsRDFDOMNodeList.cpp
Normal file
305
mozilla/content/xul/content/src/nsRDFDOMNodeList.cpp
Normal file
@@ -0,0 +1,305 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Helper class to implement the nsIDOMNodeList interface.
|
||||
|
||||
XXX It's probably wrong in some sense, as it uses the "naked"
|
||||
content interface to look for kids. (I assume in general this is
|
||||
bad because there may be pseudo-elements created for presentation
|
||||
that aren't visible to the DOM.)
|
||||
|
||||
*/
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFDOMNodeList.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GUID definitions
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class RDFHTMLCollectionImpl : public nsIDOMHTMLCollection
|
||||
{
|
||||
private:
|
||||
nsRDFDOMNodeList* mOuter;
|
||||
|
||||
public:
|
||||
RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter);
|
||||
virtual ~RDFHTMLCollectionImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_IDOMHTMLCOLLECTION
|
||||
};
|
||||
|
||||
|
||||
RDFHTMLCollectionImpl::RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter)
|
||||
: mOuter(aOuter)
|
||||
{
|
||||
}
|
||||
|
||||
RDFHTMLCollectionImpl::~RDFHTMLCollectionImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::AddRef(void)
|
||||
{
|
||||
return mOuter->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::Release(void)
|
||||
{
|
||||
return mOuter->Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMHTMLCollection*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return mOuter->QueryInterface(aIID, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::GetLength(PRUint32* aLength)
|
||||
{
|
||||
return mOuter->GetLength(aLength);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
return mOuter->Item(aIndex, aReturn);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ctors & dtors
|
||||
|
||||
nsRDFDOMNodeList::nsRDFDOMNodeList(void)
|
||||
: mInner(nsnull),
|
||||
mElements(nsnull),
|
||||
mScriptObject(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsRDFDOMNodeList::~nsRDFDOMNodeList(void)
|
||||
{
|
||||
NS_IF_RELEASE(mElements);
|
||||
delete mInner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Create(nsRDFDOMNodeList** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRDFDOMNodeList* list = new nsRDFDOMNodeList();
|
||||
if (! list)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = list->Init())) {
|
||||
delete list;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(list);
|
||||
*aResult = list;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsRDFDOMNodeList);
|
||||
NS_IMPL_RELEASE(nsRDFDOMNodeList);
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNodeList::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeList*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
// Aggregate this interface
|
||||
if (! mInner) {
|
||||
if (! (mInner = new RDFHTMLCollectionImpl(this)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return mInner->QueryInterface(aIID, aResult);
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeList interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
NS_ASSERTION(aLength != nsnull, "null ptr");
|
||||
if (! aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLength = mElements->Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aIndex < (PRUint32) mElements->Count(), "invalid arg");
|
||||
if (aIndex >= (PRUint32) mElements->Count())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Cast is okay because we're in a closed system.
|
||||
*aReturn = (nsIDOMNode*) mElements->ElementAt(aIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptObjectOwner interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIScriptGlobalObject* global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
kIDOMScriptObjectFactoryIID,
|
||||
(nsISupports **)&factory))) {
|
||||
rv = factory->NewScriptHTMLCollection(aContext,
|
||||
(nsISupports*)(nsIDOMNodeList*)this,
|
||||
global,
|
||||
(void**)&mScriptObject);
|
||||
|
||||
nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory);
|
||||
}
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = NS_NewISupportsArray(&mElements))) {
|
||||
NS_ERROR("unable to create elements array");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
if (! aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return mElements->AppendElement(aNode);
|
||||
}
|
||||
58
mozilla/content/xul/content/src/nsRDFDOMNodeList.h
Normal file
58
mozilla/content/xul/content/src/nsRDFDOMNodeList.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#ifndef nsRDFDOMNodeList_h__
|
||||
#define nsRDFDOMNodeList_h__
|
||||
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
class nsIDOMNode;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsRDFDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
nsISupports* mInner;
|
||||
nsISupportsArray* mElements;
|
||||
void* mScriptObject;
|
||||
|
||||
nsRDFDOMNodeList(void);
|
||||
nsresult Init(void);
|
||||
|
||||
public:
|
||||
static nsresult Create(nsRDFDOMNodeList** aResult);
|
||||
virtual ~nsRDFDOMNodeList(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AppendNode(nsIDOMNode* aNode);
|
||||
};
|
||||
|
||||
#endif // nsRDFDOMNodeList_h__
|
||||
|
||||
144
mozilla/content/xul/content/src/nsXULAttributes.cpp
Normal file
144
mozilla/content/xul/content/src/nsXULAttributes.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A helper class used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsXULAttributes.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
const PRUnichar kNullCh = PRUnichar('\0');
|
||||
|
||||
static void ParseClasses(const nsString& aClassString, nsClassList** aClassList)
|
||||
{
|
||||
NS_ASSERTION(nsnull == *aClassList, "non null start list");
|
||||
|
||||
nsAutoString classStr(aClassString); // copy to work buffer
|
||||
classStr.Append(kNullCh); // put an extra null at the end
|
||||
|
||||
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr;
|
||||
PRUnichar* end = start;
|
||||
|
||||
while (kNullCh != *start) {
|
||||
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
|
||||
start++;
|
||||
}
|
||||
end = start;
|
||||
|
||||
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
|
||||
end++;
|
||||
}
|
||||
*end = kNullCh; // end string here
|
||||
|
||||
if (start < end) {
|
||||
*aClassList = new nsClassList(NS_NewAtom(start));
|
||||
aClassList = &((*aClassList)->mNext);
|
||||
}
|
||||
|
||||
start = ++end;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::GetClasses(nsVoidArray& aArray) const
|
||||
{
|
||||
aArray.Clear();
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::HasClass(nsIAtom* aClass) const
|
||||
{
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
if (classList->mAtom == aClass) {
|
||||
return NS_OK;
|
||||
}
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateClassList(const nsString& aValue)
|
||||
{
|
||||
if (mClassList != nsnull)
|
||||
{
|
||||
delete mClassList;
|
||||
mClassList = nsnull;
|
||||
}
|
||||
|
||||
if (aValue != "")
|
||||
ParseClasses(aValue, &mClassList);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue)
|
||||
{
|
||||
if (aValue == "")
|
||||
{
|
||||
// XXX: Removing the rule. Is this sufficient?
|
||||
NS_IF_RELEASE(mStyleRule);
|
||||
mStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIStyleRule* rule;
|
||||
result = css->ParseDeclarations(aValue, aDocURL, rule);
|
||||
//NS_IF_RELEASE(docURL);
|
||||
|
||||
if ((NS_OK == result) && (nsnull != rule)) {
|
||||
mStyleRule = rule; //Addrefed already during parse, so don't need to addref again.
|
||||
//result = SetHTMLAttribute(aAttribute, nsHTMLValue(rule), aNotify);
|
||||
}
|
||||
//else {
|
||||
// result = SetHTMLAttribute(aAttribute, nsHTMLValue(aValue), aNotify);
|
||||
//}
|
||||
NS_RELEASE(css);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
|
||||
{
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
if (mStyleRule != nsnull)
|
||||
{
|
||||
aRule = mStyleRule;
|
||||
NS_ADDREF(aRule);
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
128
mozilla/content/xul/content/src/nsXULAttributes.h
Normal file
128
mozilla/content/xul/content/src/nsXULAttributes.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A helper class used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXULAttributes_h__
|
||||
#define nsXULAttributes_h__
|
||||
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIURL;
|
||||
|
||||
struct nsClassList {
|
||||
nsClassList(nsIAtom* aAtom)
|
||||
: mAtom(aAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
}
|
||||
nsClassList(const nsClassList& aCopy)
|
||||
: mAtom(aCopy.mAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
NS_ADDREF(mAtom);
|
||||
if (nsnull != aCopy.mNext) {
|
||||
mNext = new nsClassList(*(aCopy.mNext));
|
||||
}
|
||||
}
|
||||
~nsClassList(void)
|
||||
{
|
||||
NS_RELEASE(mAtom);
|
||||
if (nsnull != mNext) {
|
||||
delete mNext;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mAtom;
|
||||
nsClassList* mNext;
|
||||
};
|
||||
|
||||
struct nsXULAttribute
|
||||
{
|
||||
nsXULAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue)
|
||||
{
|
||||
mNameSpaceID = aNameSpaceID;
|
||||
NS_IF_ADDREF(aName);
|
||||
mName = aName;
|
||||
mValue = aValue;
|
||||
}
|
||||
|
||||
~nsXULAttribute()
|
||||
{
|
||||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
};
|
||||
|
||||
class nsXULAttributes
|
||||
{
|
||||
public:
|
||||
nsXULAttributes()
|
||||
: mClassList(nsnull), mStyleRule(nsnull)
|
||||
{
|
||||
mAttributes = new nsVoidArray();
|
||||
}
|
||||
|
||||
~nsXULAttributes(void)
|
||||
{
|
||||
if (nsnull != mAttributes) {
|
||||
PRInt32 count = mAttributes->Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsXULAttribute* attr = (nsXULAttribute*)mAttributes->ElementAt(index);
|
||||
delete attr;
|
||||
}
|
||||
}
|
||||
delete mAttributes;
|
||||
}
|
||||
|
||||
// VoidArray Helpers
|
||||
PRInt32 Count() { return mAttributes->Count(); };
|
||||
nsXULAttribute* ElementAt(PRInt32 i) { return (nsXULAttribute*)mAttributes->ElementAt(i); };
|
||||
void AppendElement(nsXULAttribute* aElement) { mAttributes->AppendElement((void*)aElement); };
|
||||
void RemoveElementAt(PRInt32 index) { mAttributes->RemoveElementAt(index); };
|
||||
|
||||
// Style Helpers
|
||||
nsresult GetClasses(nsVoidArray& aArray) const;
|
||||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
|
||||
nsresult UpdateClassList(const nsString& aValue);
|
||||
nsresult UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aRule);
|
||||
|
||||
public:
|
||||
nsClassList* mClassList;
|
||||
nsIStyleRule* mStyleRule;
|
||||
nsVoidArray* mAttributes;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXULAttributes_h__
|
||||
|
||||
2590
mozilla/content/xul/content/src/nsXULElement.cpp
Normal file
2590
mozilla/content/xul/content/src/nsXULElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
3077
mozilla/content/xul/document/src/nsXULDocument.cpp
Normal file
3077
mozilla/content/xul/document/src/nsXULDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
966
mozilla/content/xul/templates/src/nsXULSortService.cpp
Normal file
966
mozilla/content/xul/templates/src/nsXULSortService.cpp
Normal file
@@ -0,0 +1,966 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file provides the implementation for the sort service manager.
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "rdf_qsort.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIXULSortService.h"
|
||||
#include "nsString.h"
|
||||
#include "plhash.h"
|
||||
#include "plstr.h"
|
||||
#include "prlog.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsTextFragment.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "rdf_qsort.h"
|
||||
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIXULSortServiceIID, NS_IXULSORTSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID);
|
||||
|
||||
static NS_DEFINE_IID(kIDomNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDomElementIID, NS_IDOMELEMENT_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
|
||||
// XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cpp
|
||||
static const char kXULNameSpaceURI[]
|
||||
= "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, child);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ServiceImpl
|
||||
//
|
||||
// This is the sort service.
|
||||
//
|
||||
class XULSortServiceImpl : public nsIXULSortService
|
||||
{
|
||||
protected:
|
||||
XULSortServiceImpl(void);
|
||||
virtual ~XULSortServiceImpl(void);
|
||||
|
||||
static nsIXULSortService* gXULSortService; // The one-and-only sort service
|
||||
|
||||
private:
|
||||
static nsrefcnt gRefCnt;
|
||||
static nsIAtom *kTreeAtom;
|
||||
static nsIAtom *kTreeBodyAtom;
|
||||
static nsIAtom *kTreeCellAtom;
|
||||
static nsIAtom *kTreeChildrenAtom;
|
||||
static nsIAtom *kTreeColAtom;
|
||||
static nsIAtom *kTreeItemAtom;
|
||||
static nsIAtom *kResourceAtom;
|
||||
static nsIAtom *kTreeContentsGeneratedAtom;
|
||||
static nsIAtom *kNameAtom;
|
||||
static nsIAtom *kSortAtom;
|
||||
static nsIAtom *kSortDirectionAtom;
|
||||
static nsIAtom *kIdAtom;
|
||||
static nsIAtom *kNaturalOrderPosAtom;
|
||||
|
||||
static PRInt32 kNameSpaceID_XUL;
|
||||
static PRInt32 kNameSpaceID_RDF;
|
||||
|
||||
static nsIRDFService *gRDFService;
|
||||
|
||||
nsresult FindTreeElement(nsIContent* aElement,nsIContent** aTreeElement);
|
||||
nsresult FindTreeBodyElement(nsIContent *tree, nsIContent **treeBody);
|
||||
nsresult GetSortColumnIndex(nsIContent *tree, nsString sortResource, nsString sortDirection, PRInt32 *colIndex);
|
||||
nsresult GetSortColumnInfo(nsIContent *tree, nsString &sortResource, nsString &sortDirection);
|
||||
nsresult GetTreeCell(nsIContent *node, PRInt32 colIndex, nsIContent **cell);
|
||||
nsresult GetTreeCellValue(nsIContent *node, nsString & value);
|
||||
nsresult RemoveAllChildren(nsIContent *node);
|
||||
nsresult SortTreeChildren(nsIContent *container, PRInt32 colIndex, nsString sortDirection, PRInt32 indentLevel);
|
||||
nsresult PrintTreeChildren(nsIContent *container, PRInt32 colIndex, PRInt32 indentLevel);
|
||||
|
||||
public:
|
||||
|
||||
static nsresult GetSortService(nsIXULSortService** result);
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsISortService
|
||||
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection);
|
||||
NS_IMETHOD OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container, nsIRDFResource **flatArray,
|
||||
PRInt32 numElements, PRInt32 elementSize);
|
||||
};
|
||||
|
||||
nsIXULSortService* XULSortServiceImpl::gXULSortService = nsnull;
|
||||
nsrefcnt XULSortServiceImpl::gRefCnt = 0;
|
||||
|
||||
nsIRDFService *XULSortServiceImpl::gRDFService = nsnull;
|
||||
|
||||
nsIAtom* XULSortServiceImpl::kTreeAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeBodyAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeCellAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeChildrenAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeColAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeItemAtom;
|
||||
nsIAtom* XULSortServiceImpl::kResourceAtom;
|
||||
nsIAtom* XULSortServiceImpl::kTreeContentsGeneratedAtom;
|
||||
nsIAtom* XULSortServiceImpl::kNameAtom;
|
||||
nsIAtom* XULSortServiceImpl::kSortAtom;
|
||||
nsIAtom* XULSortServiceImpl::kSortDirectionAtom;
|
||||
nsIAtom* XULSortServiceImpl::kIdAtom;
|
||||
nsIAtom* XULSortServiceImpl::kNaturalOrderPosAtom;
|
||||
|
||||
PRInt32 XULSortServiceImpl::kNameSpaceID_XUL;
|
||||
PRInt32 XULSortServiceImpl::kNameSpaceID_RDF;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
XULSortServiceImpl::XULSortServiceImpl(void)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
if (gRefCnt == 0)
|
||||
{
|
||||
kTreeAtom = NS_NewAtom("tree");
|
||||
kTreeBodyAtom = NS_NewAtom("treebody");
|
||||
kTreeCellAtom = NS_NewAtom("treecell");
|
||||
kTreeChildrenAtom = NS_NewAtom("treechildren");
|
||||
kTreeColAtom = NS_NewAtom("treecol");
|
||||
kTreeItemAtom = NS_NewAtom("treeitem");
|
||||
kResourceAtom = NS_NewAtom("resource");
|
||||
kTreeContentsGeneratedAtom = NS_NewAtom("treecontentsgenerated");
|
||||
kNameAtom = NS_NewAtom("Name");
|
||||
kSortAtom = NS_NewAtom("sortActive");
|
||||
kSortDirectionAtom = NS_NewAtom("sortDirection");
|
||||
kIdAtom = NS_NewAtom("id");
|
||||
kNaturalOrderPosAtom = NS_NewAtom("pos");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID, (nsISupports**) &gRDFService)))
|
||||
{
|
||||
NS_ERROR("couldn't create rdf service");
|
||||
}
|
||||
// Register the XUL and RDF namespaces: these'll just retrieve
|
||||
// the IDs if they've already been registered by someone else.
|
||||
nsINameSpaceManager* mgr;
|
||||
if (NS_SUCCEEDED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID,
|
||||
nsnull,
|
||||
kINameSpaceManagerIID,
|
||||
(void**) &mgr)))
|
||||
{
|
||||
|
||||
// XXX This is sure to change. Copied from mozilla/layout/xul/content/src/nsXULAtoms.cpp
|
||||
static const char kXULNameSpaceURI[]
|
||||
= "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
static const char kRDFNameSpaceURI[]
|
||||
= RDF_NAMESPACE_URI;
|
||||
|
||||
rv = mgr->RegisterNameSpace(kXULNameSpaceURI, kNameSpaceID_XUL);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register XUL namespace");
|
||||
|
||||
rv = mgr->RegisterNameSpace(kRDFNameSpaceURI, kNameSpaceID_RDF);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to register RDF namespace");
|
||||
|
||||
NS_RELEASE(mgr);
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_ERROR("couldn't create namepsace manager");
|
||||
}
|
||||
}
|
||||
++gRefCnt;
|
||||
}
|
||||
|
||||
|
||||
XULSortServiceImpl::~XULSortServiceImpl(void)
|
||||
{
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0)
|
||||
{
|
||||
NS_RELEASE(kTreeAtom);
|
||||
NS_RELEASE(kTreeBodyAtom);
|
||||
NS_RELEASE(kTreeCellAtom);
|
||||
NS_RELEASE(kTreeChildrenAtom);
|
||||
NS_RELEASE(kTreeColAtom);
|
||||
NS_RELEASE(kTreeItemAtom);
|
||||
NS_RELEASE(kResourceAtom);
|
||||
NS_RELEASE(kTreeContentsGeneratedAtom);
|
||||
NS_RELEASE(kNameAtom);
|
||||
NS_RELEASE(kSortAtom);
|
||||
NS_RELEASE(kSortDirectionAtom);
|
||||
NS_RELEASE(kIdAtom);
|
||||
NS_RELEASE(kNaturalOrderPosAtom);
|
||||
|
||||
nsServiceManager::ReleaseService(kRDFServiceCID, gRDFService);
|
||||
gRDFService = nsnull;
|
||||
nsServiceManager::ReleaseService(kXULSortServiceCID, gXULSortService);
|
||||
gXULSortService = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetSortService(nsIXULSortService** mgr)
|
||||
{
|
||||
if (! gXULSortService) {
|
||||
gXULSortService = new XULSortServiceImpl();
|
||||
if (! gXULSortService)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_ADDREF(gXULSortService);
|
||||
*mgr = gXULSortService;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
XULSortServiceImpl::AddRef(void)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
XULSortServiceImpl::Release(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(XULSortServiceImpl, kIXULSortServiceIID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::FindTreeElement(nsIContent *aElement, nsIContent **aTreeElement)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> element(do_QueryInterface(aElement));
|
||||
|
||||
while (element)
|
||||
{
|
||||
PRInt32 nameSpaceID;
|
||||
if (NS_FAILED(rv = element->GetNameSpaceID(nameSpaceID))) return rv;
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = element->GetTag(*getter_AddRefs(tag)))) return rv;
|
||||
if (tag.get() == kTreeAtom)
|
||||
{
|
||||
*aTreeElement = element;
|
||||
NS_ADDREF(*aTreeElement);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsIContent> parent;
|
||||
element->GetParent(*getter_AddRefs(parent));
|
||||
element = parent;
|
||||
}
|
||||
return(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::FindTreeBodyElement(nsIContent *tree, nsIContent **treeBody)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 childIndex = 0, numChildren = 0, nameSpaceID;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = tree->ChildCount(numChildren))) return(rv);
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = tree->ChildAt(childIndex, *getter_AddRefs(child)))) return(rv);
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) return rv;
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag)))) return rv;
|
||||
if (tag.get() == kTreeBodyAtom)
|
||||
{
|
||||
*treeBody = child;
|
||||
NS_ADDREF(*treeBody);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
return(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetSortColumnIndex(nsIContent *tree, nsString sortResource, nsString sortDirection, PRInt32 *sortColIndex)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
PRInt32 childIndex, colIndex = 0, numChildren, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsresult rv;
|
||||
|
||||
*sortColIndex = 0;
|
||||
if (NS_FAILED(rv = tree->ChildCount(numChildren))) return(rv);
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = tree->ChildAt(childIndex, *getter_AddRefs(child)))) return(rv);
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) return(rv);
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag))))
|
||||
return rv;
|
||||
if (tag.get() == kTreeColAtom)
|
||||
{
|
||||
nsString colResource;
|
||||
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_RDF, kResourceAtom, colResource))
|
||||
{
|
||||
if (colResource == sortResource)
|
||||
{
|
||||
nsString trueStr("true");
|
||||
child->SetAttribute(kNameSpaceID_None, kSortAtom, trueStr, PR_TRUE);
|
||||
child->SetAttribute(kNameSpaceID_None, kSortDirectionAtom, sortDirection, PR_TRUE);
|
||||
*sortColIndex = colIndex;
|
||||
found = PR_TRUE;
|
||||
// Note: don't break, want to set/unset attribs on ALL sort columns
|
||||
// break;
|
||||
}
|
||||
else
|
||||
{
|
||||
nsString falseStr("false");
|
||||
child->SetAttribute(kNameSpaceID_None, kSortAtom, falseStr, PR_TRUE);
|
||||
child->SetAttribute(kNameSpaceID_None, kSortDirectionAtom, sortDirection, PR_TRUE);
|
||||
}
|
||||
}
|
||||
++colIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return((found == PR_TRUE) ? NS_OK : NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetSortColumnInfo(nsIContent *tree, nsString &sortResource, nsString &sortDirection)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRBool found = PR_FALSE;
|
||||
PRInt32 childIndex, numChildren, nameSpaceID;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = tree->ChildCount(numChildren))) return(rv);
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = tree->ChildAt(childIndex, *getter_AddRefs(child)))) return(rv);
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) return(rv);
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag))))
|
||||
return rv;
|
||||
if (tag.get() == kTreeColAtom)
|
||||
{
|
||||
nsString value;
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_None, kSortAtom, value))
|
||||
{
|
||||
if (value.Equals("true"))
|
||||
{
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_RDF, kResourceAtom, sortResource))
|
||||
{
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_None, kSortDirectionAtom, sortDirection))
|
||||
{
|
||||
found = PR_TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return((found == PR_TRUE) ? NS_OK : NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetTreeCell(nsIContent *node, PRInt32 cellIndex, nsIContent **cell)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
PRInt32 childIndex = 0, numChildren = 0, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = node->ChildCount(numChildren))) return(rv);
|
||||
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = node->ChildAt(childIndex, *getter_AddRefs(child)))) break;;
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) break;
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag)))) return rv;
|
||||
if (tag.get() == kTreeCellAtom)
|
||||
{
|
||||
if (cellIndex == 0)
|
||||
{
|
||||
found = PR_TRUE;
|
||||
*cell = child;
|
||||
NS_ADDREF(*cell);
|
||||
break;
|
||||
}
|
||||
--cellIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
return((found == PR_TRUE) ? NS_OK : NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::GetTreeCellValue(nsIContent *node, nsString & val)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
PRInt32 childIndex = 0, numChildren = 0, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = node->ChildCount(numChildren))) return(rv);
|
||||
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = node->ChildAt(childIndex, *getter_AddRefs(child)))) break;;
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) break;
|
||||
// XXX is this the correct way to get text? Probably not...
|
||||
if (nameSpaceID != kNameSpaceID_XUL)
|
||||
{
|
||||
nsITextContent *text = nsnull;
|
||||
if (NS_SUCCEEDED(rv = child->QueryInterface(kITextContentIID, (void **)&text)))
|
||||
{
|
||||
const nsTextFragment *textFrags;
|
||||
PRInt32 numTextFrags;
|
||||
if (NS_SUCCEEDED(rv = text->GetText(textFrags, numTextFrags)))
|
||||
{
|
||||
const char *value = textFrags->Get1b();
|
||||
PRInt32 len = textFrags->GetLength();
|
||||
val.SetString(value, len);
|
||||
found = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return((found == PR_TRUE) ? NS_OK : NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::RemoveAllChildren(nsIContent *container)
|
||||
{
|
||||
nsCOMPtr<nsIContent> child;
|
||||
PRInt32 childIndex, numChildren;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = container->ChildCount(numChildren))) return(rv);
|
||||
if (numChildren == 0) return(NS_OK);
|
||||
|
||||
for (childIndex=numChildren-1; childIndex >= 0; childIndex--)
|
||||
{
|
||||
if (NS_FAILED(rv = container->ChildAt(childIndex, *getter_AddRefs(child)))) break;
|
||||
container->RemoveChildAt(childIndex, PR_TRUE);
|
||||
}
|
||||
return(rv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef struct _sortStruct {
|
||||
nsIRDFCompositeDataSource *db;
|
||||
nsIRDFResource *sortProperty;
|
||||
PRBool descendingSort;
|
||||
PRBool naturalOrderSort;
|
||||
} sortStruct, *sortPtr;
|
||||
|
||||
|
||||
|
||||
int openSortCallback(const void *data1, const void *data2, void *sortData);
|
||||
int inplaceSortCallback(const void *data1, const void *data2, void *sortData);
|
||||
|
||||
|
||||
|
||||
int
|
||||
openSortCallback(const void *data1, const void *data2, void *sortData)
|
||||
{
|
||||
int sortOrder = 0;
|
||||
nsresult rv;
|
||||
|
||||
nsIRDFNode *node1, *node2;
|
||||
node1 = *(nsIRDFNode **)data1;
|
||||
node2 = *(nsIRDFNode **)data2;
|
||||
_sortStruct *sortPtr = (_sortStruct *)sortData;
|
||||
|
||||
nsIRDFResource *res1;
|
||||
nsIRDFResource *res2;
|
||||
const PRUnichar *uniStr1 = nsnull;
|
||||
const PRUnichar *uniStr2 = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(node1->QueryInterface(kIRDFResourceIID, (void **) &res1)))
|
||||
{
|
||||
nsIRDFNode *nodeVal1;
|
||||
if (NS_SUCCEEDED(rv = sortPtr->db->GetTarget(res1, sortPtr->sortProperty, PR_TRUE, &nodeVal1)))
|
||||
{
|
||||
nsIRDFLiteral *literal1;
|
||||
if (NS_SUCCEEDED(nodeVal1->QueryInterface(kIRDFLiteralIID, (void **) &literal1)))
|
||||
{
|
||||
literal1->GetValue(&uniStr1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (NS_SUCCEEDED(node2->QueryInterface(kIRDFResourceIID, (void **) &res2)))
|
||||
{
|
||||
nsIRDFNode *nodeVal2;
|
||||
if (NS_SUCCEEDED(rv = sortPtr->db->GetTarget(res2, sortPtr->sortProperty, PR_TRUE, &nodeVal2)))
|
||||
{
|
||||
nsIRDFLiteral *literal2;
|
||||
if (NS_SUCCEEDED(nodeVal2->QueryInterface(kIRDFLiteralIID, (void **) &literal2)))
|
||||
{
|
||||
literal2->GetValue(&uniStr2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((uniStr1 != nsnull) && (uniStr2 != nsnull))
|
||||
{
|
||||
nsAutoString str1(uniStr1), str2(uniStr2);
|
||||
sortOrder = (int)str1.Compare(str2, PR_TRUE);
|
||||
if (sortPtr->descendingSort == PR_TRUE)
|
||||
{
|
||||
sortOrder = -sortOrder;
|
||||
}
|
||||
}
|
||||
else if ((uniStr1 != nsnull) && (uniStr2 == nsnull))
|
||||
{
|
||||
sortOrder = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sortOrder = 1;
|
||||
}
|
||||
return(sortOrder);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
inplaceSortCallback(const void *data1, const void *data2, void *sortData)
|
||||
{
|
||||
char *name1, *name2;
|
||||
name1 = *(char **)data1;
|
||||
name2 = *(char **)data2;
|
||||
_sortStruct *sortPtr = (_sortStruct *)sortData;
|
||||
|
||||
PRInt32 sortOrder=0;
|
||||
nsAutoString str1(name1), str2(name2);
|
||||
|
||||
sortOrder = str1.Compare(name2, PR_TRUE);
|
||||
if (sortPtr->descendingSort == PR_TRUE)
|
||||
{
|
||||
sortOrder = -sortOrder;
|
||||
}
|
||||
return(sortOrder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::SortTreeChildren(nsIContent *container, PRInt32 colIndex, nsString sortDirection, PRInt32 indentLevel)
|
||||
{
|
||||
PRInt32 childIndex = 0, numChildren = 0, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsresult rv;
|
||||
nsVoidArray *childArray;
|
||||
|
||||
_sortStruct sortInfo;
|
||||
|
||||
if (sortDirection.Equals("natural"))
|
||||
{
|
||||
sortInfo.naturalOrderSort = PR_TRUE;
|
||||
sortInfo.descendingSort = PR_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
sortInfo.naturalOrderSort = PR_FALSE;;
|
||||
if (sortDirection.Equals("ascending")) sortInfo.descendingSort = PR_FALSE;
|
||||
else if (sortDirection.Equals("descending")) sortInfo.descendingSort = PR_TRUE;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = container->ChildCount(numChildren))) return(rv);
|
||||
|
||||
if ((childArray = new nsVoidArray()) == nsnull) return (NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = container->ChildAt(childIndex, *getter_AddRefs(child)))) break;
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) break;
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag)))) return rv;
|
||||
if (tag.get() == kTreeItemAtom)
|
||||
{
|
||||
PRBool found = PR_FALSE;
|
||||
nsIContent *cell;
|
||||
if ((indentLevel == 0) && (NS_SUCCEEDED(rv = GetTreeCell(child, colIndex, &cell))))
|
||||
{
|
||||
if (cell)
|
||||
{
|
||||
nsString val;
|
||||
if (NS_SUCCEEDED(rv = GetTreeCellValue(cell, val)))
|
||||
{
|
||||
// hack: always append cell value 1st as
|
||||
// that's what sort callback expects
|
||||
|
||||
if (sortInfo.naturalOrderSort == PR_TRUE)
|
||||
{
|
||||
// ???????????????????
|
||||
|
||||
// XXX: note memory leak!
|
||||
childArray->AppendElement(val.ToNewCString());
|
||||
childArray->AppendElement(child);
|
||||
}
|
||||
else
|
||||
{
|
||||
// XXX: note memory leak!
|
||||
childArray->AppendElement(val.ToNewCString());
|
||||
childArray->AppendElement(child);
|
||||
}
|
||||
found = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found == PR_FALSE)
|
||||
{
|
||||
// hack: always append cell value 1st as
|
||||
// that's what sort callback expects
|
||||
|
||||
PRBool foundValue = PR_FALSE;
|
||||
if (sortInfo.naturalOrderSort == PR_TRUE)
|
||||
{
|
||||
nsString pos;
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos))
|
||||
{
|
||||
// XXX: note memory leak!
|
||||
childArray->AppendElement(pos.ToNewCString());
|
||||
childArray->AppendElement(child);
|
||||
foundValue = PR_TRUE;
|
||||
}
|
||||
}
|
||||
if (foundValue == PR_FALSE)
|
||||
{
|
||||
nsString name;
|
||||
if (NS_OK == child->GetAttribute(kNameSpaceID_None, kNameAtom, name))
|
||||
{
|
||||
// XXX: note memory leak!
|
||||
childArray->AppendElement(name.ToNewCString());
|
||||
childArray->AppendElement(child);
|
||||
foundValue = PR_TRUE;
|
||||
}
|
||||
}
|
||||
found = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned long numElements = childArray->Count();
|
||||
if (numElements > 1)
|
||||
{
|
||||
nsIContent ** flatArray = new nsIContent*[numElements];
|
||||
if (flatArray)
|
||||
{
|
||||
// flatten array of resources, sort them, then add as tree elements
|
||||
unsigned long loop;
|
||||
for (loop=0; loop<numElements; loop++)
|
||||
flatArray[loop] = (nsIContent *)childArray->ElementAt(loop);
|
||||
rdf_qsort((void *)flatArray, numElements/2, 2 * sizeof(void *),
|
||||
inplaceSortCallback, (void *)&sortInfo);
|
||||
|
||||
RemoveAllChildren(container);
|
||||
if (NS_FAILED(rv = container->UnsetAttribute(kNameSpaceID_None,
|
||||
kTreeContentsGeneratedAtom,
|
||||
PR_FALSE)))
|
||||
{
|
||||
printf("unable to clear contents-generated attribute\n");
|
||||
}
|
||||
|
||||
// insert sorted children
|
||||
numChildren = 0;
|
||||
for (loop=0; loop<numElements; loop+=2)
|
||||
{
|
||||
container->InsertChildAt((nsIContent *)flatArray[loop+1], numChildren++, PR_TRUE);
|
||||
}
|
||||
|
||||
// recurse on grandchildren
|
||||
|
||||
for (loop=0; loop<numElements; loop+=2)
|
||||
{
|
||||
container = (nsIContent *)flatArray[loop+1];
|
||||
|
||||
PRBool canHaveKids = PR_FALSE;
|
||||
if (NS_FAILED(rv = container->CanContainChildren(canHaveKids))) continue;
|
||||
if (canHaveKids == PR_FALSE) continue;
|
||||
|
||||
if (NS_FAILED(rv = container->ChildCount(numChildren))) continue;
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = container->ChildAt(childIndex, *getter_AddRefs(child))))
|
||||
continue;
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) continue;
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag))))
|
||||
continue;
|
||||
if (tag.get() == kTreeChildrenAtom)
|
||||
{
|
||||
SortTreeChildren(child, colIndex, sortDirection, indentLevel+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete [] flatArray;
|
||||
flatArray = nsnull;
|
||||
}
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container,
|
||||
nsIRDFResource **flatArray, PRInt32 numElements, PRInt32 elementSize)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIContent *treeNode;
|
||||
nsString sortResource, sortDirection;
|
||||
_sortStruct sortInfo;
|
||||
|
||||
// get sorting info (property to sort on, direction to sort, etc)
|
||||
|
||||
if (NS_FAILED(rv = FindTreeElement(container, &treeNode))) return(rv);
|
||||
|
||||
sortInfo.db = db;
|
||||
if (NS_FAILED(rv = GetSortColumnInfo(treeNode, sortResource, sortDirection))) return(rv);
|
||||
char *uri = sortResource.ToNewCString();
|
||||
if (NS_FAILED(rv = gRDFService->GetResource(uri, &sortInfo.sortProperty))) return(rv);
|
||||
delete [] uri;
|
||||
if (sortDirection.Equals("natural"))
|
||||
{
|
||||
sortInfo.naturalOrderSort = PR_TRUE;
|
||||
sortInfo.descendingSort = PR_FALSE;
|
||||
// no need to sort for natural order
|
||||
}
|
||||
else
|
||||
{
|
||||
sortInfo.naturalOrderSort = PR_FALSE;
|
||||
if (sortDirection.Equals("descending"))
|
||||
sortInfo.descendingSort = PR_TRUE;
|
||||
else
|
||||
sortInfo.descendingSort = PR_FALSE;
|
||||
rdf_qsort((void *)flatArray, numElements, elementSize, openSortCallback, (void *)&sortInfo);
|
||||
}
|
||||
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
XULSortServiceImpl::PrintTreeChildren(nsIContent *container, PRInt32 colIndex, PRInt32 indentLevel)
|
||||
{
|
||||
PRInt32 childIndex = 0, numChildren = 0, nameSpaceID;
|
||||
nsCOMPtr<nsIContent> child;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = container->ChildCount(numChildren))) return(rv);
|
||||
for (childIndex=0; childIndex<numChildren; childIndex++)
|
||||
{
|
||||
if (NS_FAILED(rv = container->ChildAt(childIndex, *getter_AddRefs(child)))) return(rv);
|
||||
if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID))) return(rv);
|
||||
if (nameSpaceID == kNameSpaceID_XUL)
|
||||
{
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
|
||||
if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag))))
|
||||
return rv;
|
||||
nsString tagName;
|
||||
tag->ToString(tagName);
|
||||
for (PRInt32 indentLoop=0; indentLoop<indentLevel; indentLoop++) printf(" ");
|
||||
printf("Child #%d: tagName='%s'\n", childIndex, tagName.ToNewCString());
|
||||
|
||||
PRInt32 attribIndex, numAttribs;
|
||||
child->GetAttributeCount(numAttribs);
|
||||
for (attribIndex = 0; attribIndex < numAttribs; attribIndex++)
|
||||
{
|
||||
PRInt32 attribNameSpaceID;
|
||||
nsCOMPtr<nsIAtom> attribAtom;
|
||||
|
||||
if (NS_SUCCEEDED(rv = child->GetAttributeNameAt(attribIndex, attribNameSpaceID,
|
||||
*getter_AddRefs(attribAtom))))
|
||||
{
|
||||
nsString attribName, attribValue;
|
||||
attribAtom->ToString(attribName);
|
||||
rv = child->GetAttribute(attribNameSpaceID, attribAtom, attribValue);
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE)
|
||||
{
|
||||
for (PRInt32 indentLoop=0; indentLoop<indentLevel; indentLoop++) printf(" ");
|
||||
printf("Attrib #%d: name='%s' value='%s'\n", attribIndex,
|
||||
attribName.ToNewCString(),
|
||||
attribValue.ToNewCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((tag.get() == kTreeItemAtom) || (tag.get() == kTreeChildrenAtom) || (tag.get() == kTreeCellAtom))
|
||||
{
|
||||
PrintTreeChildren(child, colIndex, indentLevel+1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PRInt32 loop=0; loop<indentLevel; loop++) printf(" ");
|
||||
printf("(Non-XUL node) ");
|
||||
nsITextContent *text = nsnull;
|
||||
if (NS_SUCCEEDED(rv = child->QueryInterface(kITextContentIID, (void **)&text)))
|
||||
{
|
||||
for (PRInt32 indentLoop=0; indentLoop<indentLevel; indentLoop++) printf(" ");
|
||||
printf("(kITextContentIID) ");
|
||||
|
||||
const nsTextFragment *textFrags;
|
||||
PRInt32 numTextFrags;
|
||||
if (NS_SUCCEEDED(rv = text->GetText(textFrags, numTextFrags)))
|
||||
{
|
||||
const char *val = textFrags->Get1b();
|
||||
PRInt32 len = textFrags->GetLength();
|
||||
if (val) printf("value='%.*s'", len, val);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource,
|
||||
const nsString& sortDirection)
|
||||
{
|
||||
PRInt32 colIndex, treeBodyIndex;
|
||||
nsIContent *contentNode, *treeNode, *treeBody, *treeParent;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_FAILED(rv = node->QueryInterface(kIContentIID, (void**)&contentNode))) return(rv);
|
||||
if (NS_FAILED(rv = FindTreeElement(contentNode, &treeNode))) return(rv);
|
||||
if (NS_FAILED(rv = GetSortColumnIndex(treeNode, sortResource, sortDirection, &colIndex))) return(rv);
|
||||
if (NS_FAILED(rv = FindTreeBodyElement(treeNode, &treeBody))) return(rv);
|
||||
if (NS_FAILED(rv = treeBody->GetParent(treeParent))) return(rv);
|
||||
if (NS_FAILED(rv = treeParent->IndexOf(treeBody, treeBodyIndex))) return(rv);
|
||||
if (NS_FAILED(rv = treeParent->RemoveChildAt(treeBodyIndex, PR_TRUE))) return(rv);
|
||||
if (NS_SUCCEEDED(rv = SortTreeChildren(treeBody, colIndex, sortDirection, 0)))
|
||||
{
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv = treeBody->UnsetAttribute(kNameSpaceID_None,
|
||||
kTreeContentsGeneratedAtom,PR_FALSE)))
|
||||
{
|
||||
}
|
||||
if (NS_SUCCEEDED(rv = treeParent->UnsetAttribute(kNameSpaceID_None,
|
||||
kTreeContentsGeneratedAtom,PR_FALSE)))
|
||||
{
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE))) return(rv);
|
||||
|
||||
#if 0
|
||||
if (NS_FAILED(rv = PrintTreeChildren(treeBody, colIndex, 0))) return(rv);
|
||||
#endif
|
||||
return(NS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewXULSortService(nsIXULSortService** mgr)
|
||||
{
|
||||
return XULSortServiceImpl::GetSortService(mgr);
|
||||
}
|
||||
|
||||
1474
mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
Normal file
1474
mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
9
mozilla/dom/public/idl/xul/XULDocument.idl
Normal file
9
mozilla/dom/public/idl/xul/XULDocument.idl
Normal file
@@ -0,0 +1,9 @@
|
||||
interface XULDocument : Document {
|
||||
|
||||
/* IID: { 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
11
mozilla/dom/public/idl/xul/XULElement.idl
Normal file
11
mozilla/dom/public/idl/xul/XULElement.idl
Normal file
@@ -0,0 +1,11 @@
|
||||
interface XULElement : Element {
|
||||
|
||||
/* IID: { 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } } */
|
||||
|
||||
void addBroadcastListener(in DOMString attr, in Element element);
|
||||
void removeBroadcastListener(in DOMString attr, in Element element);
|
||||
void doCommand();
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
60
mozilla/dom/public/xul/nsIDOMXULDocument.h
Normal file
60
mozilla/dom/public/xul/nsIDOMXULDocument.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULDocument_h__
|
||||
#define nsIDOMXULDocument_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
{ 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMXULDocument : public nsIDOMDocument {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULDOCUMENT \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULDOCUMENT(_to) \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to##GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to##GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULDocument_h__
|
||||
68
mozilla/dom/public/xul/nsIDOMXULElement.h
Normal file
68
mozilla/dom/public/xul/nsIDOMXULElement.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULElement_h__
|
||||
#define nsIDOMXULElement_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULELEMENT_IID \
|
||||
{ 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
class nsIDOMXULElement : public nsIDOMElement {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULELEMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD DoCommand()=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULELEMENT \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD DoCommand(); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULELEMENT(_to) \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to##AddBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to##RemoveBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD DoCommand() { return _to##DoCommand(); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to##GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULElement_h__
|
||||
356
mozilla/dom/src/xul/nsJSXULDocument.cpp
Normal file
356
mozilla/dom/src/xul/nsJSXULDocument.cpp
Normal file
@@ -0,0 +1,356 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULDocument(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementById
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElement* nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 1) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementById(b0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementById requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULDocument
|
||||
//
|
||||
JSClass XULDocumentClass = {
|
||||
"XULDocument",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULDocumentProperty,
|
||||
SetXULDocumentProperty,
|
||||
EnumerateXULDocument,
|
||||
ResolveXULDocument,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULDocument
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class properties
|
||||
//
|
||||
static JSPropertySpec XULDocumentProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class methods
|
||||
//
|
||||
static JSFunctionSpec XULDocumentMethods[] =
|
||||
{
|
||||
{"getElementById", XULDocumentGetElementById, 1},
|
||||
{"getElementsByAttribute", XULDocumentGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULDocument", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitDocumentClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULDocumentClass, // JSClass
|
||||
XULDocument, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULDocumentProperties, // proto props
|
||||
XULDocumentMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULDocument JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULDocument");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULDocument *aXULDocument;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULDocumentClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULDocumentIID, (void **)&aXULDocument);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULDocumentClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULDocument);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULDocument);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
444
mozilla/dom/src/xul/nsJSXULElement.cpp
Normal file
444
mozilla/dom/src/xul/nsJSXULElement.cpp
Normal file
@@ -0,0 +1,444 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULElement);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULElement(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->AddBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function addBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method RemoveBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->RemoveBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method DoCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->DoCommand()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function doCommand requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULElement
|
||||
//
|
||||
JSClass XULElementClass = {
|
||||
"XULElement",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULElementProperty,
|
||||
SetXULElementProperty,
|
||||
EnumerateXULElement,
|
||||
ResolveXULElement,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULElement
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class properties
|
||||
//
|
||||
static JSPropertySpec XULElementProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class methods
|
||||
//
|
||||
static JSFunctionSpec XULElementMethods[] =
|
||||
{
|
||||
{"addBroadcastListener", XULElementAddBroadcastListener, 2},
|
||||
{"removeBroadcastListener", XULElementRemoveBroadcastListener, 2},
|
||||
{"doCommand", XULElementDoCommand, 0},
|
||||
{"getElementsByAttribute", XULElementGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULElement", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitElementClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULElementClass, // JSClass
|
||||
XULElement, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULElementProperties, // proto props
|
||||
XULElementMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULElement *aXULElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULElementClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULElementIID, (void **)&aXULElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULElementClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
33
mozilla/rdf/Makefile.in
Normal file
33
mozilla/rdf/Makefile.in
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = base util content datasource build
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
DIRS += tests
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
29
mozilla/rdf/base/Makefile.in
Normal file
29
mozilla/rdf/base/Makefile.in
Normal file
@@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
45
mozilla/rdf/base/idl/Makefile.in
Normal file
45
mozilla/rdf/base/idl/Makefile.in
Normal file
@@ -0,0 +1,45 @@
|
||||
#!gmake
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
IDLSRCS = \
|
||||
nsRDFInterfaces.idl \
|
||||
# nsIRDFArcsInCursor.idl \
|
||||
# nsIRDFArcsOutCursor.idl \
|
||||
# nsIRDFAssertionCursor.idl \
|
||||
# nsIRDFCursor.idl \
|
||||
# nsIRDFDataSource.idl \
|
||||
# nsIRDFLiteral.idl \
|
||||
# nsIRDFNode.idl \
|
||||
# nsIRDFObserver.idl \
|
||||
# nsIRDFResoruce.idl \
|
||||
# nsIRDFResourceCursor.idl \
|
||||
$(NULL)
|
||||
|
||||
# for testing purposes
|
||||
EXPORTS = $(IDLSRCS:.idl=.h)
|
||||
|
||||
# to build in the static methods
|
||||
CPPSRCS = $(IDLSRCS:.idl=.cpp)
|
||||
LIBRARY_NAME = rdfidl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
178
mozilla/rdf/base/idl/nsRDFInterfaces.idl
Normal file
178
mozilla/rdf/base/idl/nsRDFInterfaces.idl
Normal file
@@ -0,0 +1,178 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This file contains _all_ of the interface definitions, lumped into
|
||||
one big happy file. It's done this way to circumvent problems with
|
||||
forward declarations in the current version of `xpidl'.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
%{C++
|
||||
#include "nscore.h" // for PRUnichar
|
||||
%}
|
||||
|
||||
[uuid(0F78DA50-8321-11d2-8EAC-00805F29F370)]
|
||||
interface nsIRDFNode : nsISupports {
|
||||
void Init(in string uri);
|
||||
boolean EqualsNode(in nsIRDFNode aNode);
|
||||
};
|
||||
|
||||
|
||||
[uuid(E0C493D1-9542-11d2-8EB8-00805F29F370)]
|
||||
interface nsIRDFResource : nsIRDFNode {
|
||||
readonly attribute string Value;
|
||||
boolean EqualsResource(in nsIRDFResource aResource);
|
||||
boolean EqualsString(in string aURI);
|
||||
};
|
||||
|
||||
[uuid(E0C493D2-9542-11d2-8EB8-00805F29F370)]
|
||||
interface nsIRDFLiteral : nsIRDFNode {
|
||||
readonly attribute wstring Value;
|
||||
boolean EqualsLiteral(in nsIRDFLiteral literal);
|
||||
};
|
||||
|
||||
interface nsIRDFDataSource;
|
||||
|
||||
[uuid(1C2ABDB0-4CEF-11D2-BC16-00805F912FE7)]
|
||||
interface nsIRDFCursor : nsISupports {
|
||||
void Advance();
|
||||
readonly attribute nsIRDFDataSource DataSource;
|
||||
readonly attribute nsIRDFNode Value;
|
||||
};
|
||||
|
||||
[uuid(1ED57100-9904-11d2-8EBA-00805F29F370)]
|
||||
interface nsIRDFAssertionCursor : nsIRDFCursor {
|
||||
readonly attribute nsIRDFResource Source;
|
||||
readonly attribute nsIRDFResource Label;
|
||||
readonly attribute nsIRDFNode Target;
|
||||
readonly attribute boolean TruthValue;
|
||||
};
|
||||
|
||||
|
||||
[uuid(1ED57102-9904-11d2-8EBA-00805F29F370)]
|
||||
interface nsIRDFArcsInCursor : nsIRDFCursor {
|
||||
readonly attribute nsIRDFResource Label;
|
||||
readonly attribute nsIRDFNode Target;
|
||||
};
|
||||
|
||||
[uuid(1ED57101-9904-11d2-8EBA-00805F29F370)]
|
||||
interface nsIRDFArcsOutCursor : nsIRDFCursor {
|
||||
readonly attribute nsIRDFResource Source;
|
||||
readonly attribute nsIRDFResource Label;
|
||||
};
|
||||
|
||||
[uuid(C2850C10-B0CF-11d2-A684-00104BDE6048)]
|
||||
interface nsIRDFResourceCursor : nsIRDFCursor {
|
||||
readonly attribute nsIRDFResource Resource;
|
||||
};
|
||||
|
||||
[uuid(3CC75360-484A-11D2-BC16-00805F912FE7)]
|
||||
interface nsIRDFObserver : nsISupports {
|
||||
void OnAssert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aLabel,
|
||||
in nsIRDFNode aTarget);
|
||||
|
||||
void OnUnassert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aLabel,
|
||||
in nsIRDFNode aTarget);
|
||||
};
|
||||
|
||||
|
||||
[uuid(0F78DA58-8321-11d2-8EAC-00805F29F370)]
|
||||
interface nsIRDFDataSource : nsISupports {
|
||||
void Init(in string uri);
|
||||
readonly attribute string URI;
|
||||
|
||||
nsIRDFResource GetSource(in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget,
|
||||
in boolean aTruthValue);
|
||||
|
||||
nsIRDFAssertionCursor GetSources(in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget,
|
||||
in boolean aTruthValue);
|
||||
|
||||
nsIRDFNode GetTarget(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aProperty,
|
||||
in boolean aTruthValue);
|
||||
|
||||
nsIRDFAssertionCursor GetTargets(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aProperty,
|
||||
in boolean aTruthValue);
|
||||
|
||||
void Assert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget,
|
||||
in boolean aTruthValue);
|
||||
|
||||
void Unassert(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget);
|
||||
|
||||
boolean HasAssertion(in nsIRDFResource aSource,
|
||||
in nsIRDFResource aProperty,
|
||||
in nsIRDFNode aTarget,
|
||||
in boolean aTruthValue);
|
||||
|
||||
void AddObserver(in nsIRDFObserver aObserver);
|
||||
|
||||
void RemoveObserver(in nsIRDFObserver aObserver);
|
||||
|
||||
nsIRDFArcsInCursor ArcLabelsIn(in nsIRDFNode aNode);
|
||||
|
||||
nsIRDFArcsOutCursor ArcLabelsOut(in nsIRDFResource aSource);
|
||||
|
||||
nsIRDFResourceCursor GetAllResources();
|
||||
|
||||
void Flush();
|
||||
|
||||
boolean IsCommandEnabled(in string aCommand,
|
||||
in nsIRDFResource aCommandTarget);
|
||||
|
||||
void DoCommand(in string aCommand,
|
||||
in nsIRDFResource aCommandTarget);
|
||||
|
||||
};
|
||||
|
||||
[uuid(96343820-307C-11D2-BC15-00805F912FE7)]
|
||||
interface nsIRDFCompositeDataSource : nsIRDFDataSource {
|
||||
void AddDataSource(in nsIRDFDataSource aDataSource);
|
||||
void RemoveDataSource(in nsIRDFDataSource aDataSource);
|
||||
};
|
||||
|
||||
[uuid(BFD05261-834C-11d2-8EAC-00805F29F370)]
|
||||
interface nsIRDFService : nsISupports {
|
||||
// Resource management routines
|
||||
|
||||
nsIRDFResource GetResource(in string aURI);
|
||||
nsIRDFResource GetUnicodeResource(in wstring aURI);
|
||||
nsIRDFLiteral GetLiteral(in wstring aValue);
|
||||
|
||||
void RegisterResource(in nsIRDFResource aResource, in boolean aReplace);
|
||||
void UnregisterResource(in nsIRDFResource aResource);
|
||||
|
||||
void RegisterDataSource(in nsIRDFDataSource aDataSource,
|
||||
in boolean aReplace);
|
||||
|
||||
void UnregisterDataSource(in nsIRDFDataSource aDataSource);
|
||||
|
||||
nsIRDFDataSource GetDataSource(in string aURI);
|
||||
};
|
||||
27
mozilla/rdf/base/makefile.win
Normal file
27
mozilla/rdf/base/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS=\
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
12
mozilla/rdf/base/public/MANIFEST
Normal file
12
mozilla/rdf/base/public/MANIFEST
Normal file
@@ -0,0 +1,12 @@
|
||||
rdf.h
|
||||
nsIRDFCompositeDataSource.h
|
||||
nsIRDFContentSink.h
|
||||
nsIRDFCursor.h
|
||||
nsIRDFDataSource.h
|
||||
nsIRDFNode.h
|
||||
nsIRDFObserver.h
|
||||
nsIRDFResourceFactory.h
|
||||
nsIRDFService.h
|
||||
nsIRDFXMLDataSource.h
|
||||
nsIRDFXMLSource.h
|
||||
rdf_qsort.h
|
||||
47
mozilla/rdf/base/public/Makefile.in
Normal file
47
mozilla/rdf/base/public/Makefile.in
Normal file
@@ -0,0 +1,47 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
rdf.h \
|
||||
nsIRDFCompositeDataSource.h \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFCursor.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDataSource.h \
|
||||
nsIRDFXMLSource.h \
|
||||
nsRDFInterfaces.h \
|
||||
rdf_qsort.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
40
mozilla/rdf/base/public/makefile.win
Normal file
40
mozilla/rdf/base/public/makefile.win
Normal file
@@ -0,0 +1,40 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
MODULE=rdf
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS=\
|
||||
rdf.h \
|
||||
nsIRDFCompositeDataSource.h \
|
||||
nsIRDFContentSink.h \
|
||||
nsIRDFCursor.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFNode.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFResourceFactory.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFXMLDataSource.h \
|
||||
nsIRDFXMLSource.h \
|
||||
rdf_qsort.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
60
mozilla/rdf/base/public/nsIRDFCompositeDataSource.h
Normal file
60
mozilla/rdf/base/public/nsIRDFCompositeDataSource.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
RDF composite data source interface. A composite data source
|
||||
aggregates individual RDF data sources.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCompositeDataSource_h__
|
||||
#define nsIRDFCompositeDataSource_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
|
||||
// 96343820-307c-11d2-bc15-00805f912fe7
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID \
|
||||
{ 0x96343820, 0x307c, 0x11d2, { 0xb, 0x15, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
/**
|
||||
* An <tt>nsIRDFCompositeDataSource</tt> composes individual data sources, providing
|
||||
* the illusion of a single, coherent RDF graph.
|
||||
*/
|
||||
class nsIRDFCompositeDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCOMPOSITEDATASOURCE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Add a datasource the the database.
|
||||
*/
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* source) = 0;
|
||||
|
||||
/**
|
||||
* Remove a datasource from the database
|
||||
*/
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* source) = 0;
|
||||
};
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFCompositeDataSource(nsIRDFCompositeDataSource** result);
|
||||
|
||||
#endif /* nsIRDFCompositeDataSource_h__ */
|
||||
72
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
72
mozilla/rdf/base/public/nsIRDFContentSink.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An RDF-specific content sink. The content sink is targeted by the
|
||||
parser for building the RDF content model.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContentSink_h___
|
||||
#define nsIRDFContentSink_h___
|
||||
|
||||
#include "nsIXMLContentSink.h"
|
||||
class nsIDocument;
|
||||
class nsIRDFXMLDataSource;
|
||||
class nsINameSpaceManager;
|
||||
class nsIURL;
|
||||
|
||||
// {751843E2-8309-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFCONTENTSINK_IID \
|
||||
{ 0x751843e2, 0x8309, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* This interface represents a content sink for RDF files.
|
||||
*/
|
||||
|
||||
class nsIRDFContentSink : public nsIXMLContentSink {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCONTENTSINK_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Initialize the content sink.
|
||||
*/
|
||||
NS_IMETHOD Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager) = 0;
|
||||
|
||||
/**
|
||||
* Set the content sink's RDF Data source
|
||||
*/
|
||||
NS_IMETHOD SetDataSource(nsIRDFXMLDataSource* aDataSource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the content sink's RDF data source.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(nsIRDFXMLDataSource*& rDataSource) = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* This constructs a content sink that can be used without a
|
||||
* document, say, to create a stand-alone in-memory graph.
|
||||
*/
|
||||
nsresult
|
||||
NS_NewRDFContentSink(nsIRDFContentSink** aResult);
|
||||
|
||||
#endif // nsIRDFContentSink_h___
|
||||
174
mozilla/rdf/base/public/nsIRDFCursor.h
Normal file
174
mozilla/rdf/base/public/nsIRDFCursor.h
Normal file
@@ -0,0 +1,174 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Interfaces for RDF cursors, including nsIRDFCursor,
|
||||
nsIRDFAssertionCursor, nsIRDFArcsInCursor, nsIRDFArcsOutCursor,
|
||||
nad nsIRDFResourceCursor.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCursor_h__
|
||||
#define nsIRDFCursor_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "prtypes.h"
|
||||
#include "rdf.h" // for error codes
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
|
||||
// 1c2abdb0-4cef-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFCURSOR_IID \
|
||||
{ 0x1c2abdb0, 0x4cef, 0x11d2, { 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
/**
|
||||
* An abstract base interface that is the basis for all RDF cursors.
|
||||
*/
|
||||
class nsIRDFCursor : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCURSOR_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Advance the cursor to the next element.
|
||||
* @return NS_ERROR_RDF_CURSOR_EMPTY if the cursor has reached the end
|
||||
* and there are no more elements to enumerate; otherwise, NS_OK
|
||||
* unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD Advance(void) = 0;
|
||||
/* Retrieve the data source from which the current item was obtained.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) = 0;
|
||||
/**
|
||||
* Irrespective of the query, a cursor is an interator over a set.
|
||||
* This allows you to obtain the current value.
|
||||
*/
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {1ED57100-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFASSERTIONCURSOR_IID \
|
||||
{ 0x1ed57100, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates assertions
|
||||
* @seealso nsIRDFDataSource::GetTargetS(), nsIRDFDataSource::GetSources()
|
||||
*/
|
||||
class nsIRDFAssertionCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFASSERTIONCURSOR_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's subject resource.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's predicate resource.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's object node.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the assertion's truth value.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) = 0;
|
||||
};
|
||||
|
||||
|
||||
// {1ED57101-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFARCSOUTCURSOR_IID \
|
||||
{ 0x1ed57101, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates the outbound arcs from a resource node.
|
||||
* @seealso nsIRDFDataSource::ArcsOut()
|
||||
*/
|
||||
class nsIRDFArcsOutCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFARCSOUTCURSOR_IID; return iid; }
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the "subject" node from which the arcs originate.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aSubject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the predicate label of the arc.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {1ED57102-9904-11d2-8EBA-00805F29F370}
|
||||
#define NS_IRDFARCSINCURSOR_IID \
|
||||
{ 0x1ed57102, 0x9904, 0x11d2, { 0x8e, 0xba, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates the inbound arcs to a node.
|
||||
* @seealso nsIRDFDataSource::ArcsIn()
|
||||
*/
|
||||
class nsIRDFArcsInCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFARCSINCURSOR_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Retrieve the "object" node in which the arc terminates.
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the predicate label of the arc
|
||||
* @return NS_OK, unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) = 0;
|
||||
|
||||
};
|
||||
|
||||
// {C2850C10-B0CF-11d2-A684-00104BDE6048}
|
||||
#define NS_IRDFRESOURCECURSOR_IID \
|
||||
{ 0xc2850c10, 0xb0cf, 0x11d2, { 0xa6, 0x84, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
/**
|
||||
* A cursor that enumerates all of the resources in a data source.
|
||||
*/
|
||||
class nsIRDFResourceCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFRESOURCECURSOR_IID; return iid; }
|
||||
NS_IMETHOD GetResource(nsIRDFResource** aResource) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFCursor_h__ */
|
||||
210
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
210
mozilla/rdf/base/public/nsIRDFDataSource.h
Normal file
@@ -0,0 +1,210 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF data source interface. An RDF data source presents a
|
||||
graph-like interface to a back-end service.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataSource_h__
|
||||
#define nsIRDFDataSource_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// {0F78DA58-8321-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{ 0xf78da58, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFAssertionCursor;
|
||||
class nsIRDFArcsInCursor;
|
||||
class nsIRDFArcsOutCursor;
|
||||
class nsIRDFDataBase;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFObserver;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFResourceCursor;
|
||||
|
||||
/**
|
||||
* An RDF data source.
|
||||
*/
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFDATASOURCE_IID; return iid; }
|
||||
|
||||
// XXX I didn't make some of these methods "const" because it's
|
||||
// probably pretty likely that many data sources will just make
|
||||
// stuff up at runtime to answer queries.
|
||||
|
||||
/**
|
||||
* Specify the URI for the data source: this is the prefix
|
||||
* that will be used to register the data source in the
|
||||
* data source registry.
|
||||
*/
|
||||
NS_IMETHOD Init(const char* uri) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the URI of the data source.
|
||||
*/
|
||||
NS_IMETHOD GetURI(const char* *uri) const = 0;
|
||||
|
||||
/**
|
||||
* Find an RDF resource that points to a given node over the
|
||||
* specified arc & truth value
|
||||
*
|
||||
* @return NS_ERROR_FAILURE if there is no source that leads
|
||||
* to the target with the specified property.
|
||||
*/
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all RDF resources that point to a given node over the
|
||||
* specified arc & truth value
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs. If the
|
||||
* method returns NS_OK, you may assume that nsIRDFCursor points
|
||||
* to a valid (but possibly empty) cursor.
|
||||
*/
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find a child of that is related to the source by the given arc
|
||||
* arc and truth value
|
||||
*
|
||||
* @return NS_ERROR_FAILURE if there is no target accessable from the
|
||||
* source via the specified property.
|
||||
*/
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all children of that are related to the source by the given arc
|
||||
* arc and truth value.
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs. If the
|
||||
* method returns NS_OK, you may assume that nsIRDFCursor points
|
||||
* to a valid (but possibly empty) cursor.
|
||||
*/
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an assertion to the graph.
|
||||
*/
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv) = 0;
|
||||
|
||||
/**
|
||||
* Remove an assertion from the graph.
|
||||
*/
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target) = 0;
|
||||
|
||||
/**
|
||||
* Query whether an assertion exists in this graph.
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs.
|
||||
*/
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to this data source.
|
||||
*/
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from this data source
|
||||
*/
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n) = 0;
|
||||
|
||||
// XXX individual resource observers?
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that point into a node.
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs. If the method
|
||||
* returns NS_OK, you may assume that labels points to a valid (but
|
||||
* possible empty) nsIRDFCursor object.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that originate in
|
||||
* a resource.
|
||||
*
|
||||
* @return NS_OK unless a catastrophic error occurs. If the method
|
||||
* returns NS_OK, you may assume that labels points to a valid (but
|
||||
* possible empty) nsIRDFCursor object.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve all of the resources that the data source currently
|
||||
* refers to.
|
||||
*/
|
||||
NS_IMETHOD GetAllResources(nsIRDFResourceCursor** aCursor) = 0;
|
||||
|
||||
/**
|
||||
* Request that a data source write it's contents out to
|
||||
* permanent storage if applicable.
|
||||
*/
|
||||
NS_IMETHOD Flush(void) = 0;
|
||||
|
||||
/**
|
||||
* Determine whether the specified command is enabled for the
|
||||
* resource.
|
||||
*
|
||||
* XXX We will probably need to make this interface much more intricate
|
||||
* to handle arbitrary arguments and selection sets.
|
||||
*/
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult) = 0;
|
||||
|
||||
/**
|
||||
* Perform the specified command on the resource.
|
||||
*
|
||||
* XXX We will probably need to make this interface much more intricate
|
||||
* to handle arbitrary arguments and selection sets.
|
||||
*/
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget) = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIRDFDataSource_h__ */
|
||||
161
mozilla/rdf/base/public/nsIRDFNode.h
Normal file
161
mozilla/rdf/base/public/nsIRDFNode.h
Normal file
@@ -0,0 +1,161 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
RDF node interfaces, including nsIRDFNode, nsIRDFResource, and
|
||||
nsIRDFLiteral. Nodes are the elements that appear in RDF graphs.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFNode_h__
|
||||
#define nsIRDFNode_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "rdf.h"
|
||||
#include "nsISupports.h"
|
||||
#include "prtime.h"
|
||||
// {0F78DA50-8321-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFNODE_IID \
|
||||
{ 0xf78da50, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
/**
|
||||
*
|
||||
* Nodes are created using an instance of nsIRDFService, which
|
||||
* should be obtained from the service manager:
|
||||
*
|
||||
* nsIRDFService* service;
|
||||
* if (NS_SUCCEEDED(nsServiceManager::GetService(kCRDFServiceCID,
|
||||
* kIRDFServiceIID,
|
||||
* (nsISupports**) &service))) {
|
||||
* nsIRDFNode* node;
|
||||
* if (NS_SUCCEEDED(service->GetResource("http://foo.bar/", node))) {
|
||||
* // do something useful here...
|
||||
* NS_IF_RELEASE(node);
|
||||
* }
|
||||
* nsServiceManager::ReleaseService(kCRDFServiceCID, mgr);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
|
||||
class NS_RDF nsIRDFNode : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFNODE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Determine if two nodes are identical
|
||||
*/
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode* that, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* A resource node, which has unique object identity.
|
||||
*/
|
||||
|
||||
// {E0C493D1-9542-11d2-8EB8-00805F29F370}
|
||||
#define NS_IRDFRESOURCE_IID \
|
||||
{ 0xe0c493d1, 0x9542, 0x11d2, { 0x8e, 0xb8, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class NS_RDF nsIRDFResource : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFRESOURCE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Called by nsIRDFService after constructing a resource object to
|
||||
* initialize it's URI.
|
||||
*/
|
||||
NS_IMETHOD Init(const char* uri) = 0;
|
||||
|
||||
/**
|
||||
* Get the 8-bit string value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(const char* *uri) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two resources are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsResource(const nsIRDFResource* resource, PRBool* result) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two resources are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsString(const char* uri, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
|
||||
// {E0C493D2-9542-11d2-8EB8-00805F29F370}
|
||||
#define NS_IRDFLITERAL_IID \
|
||||
{ 0xe0c493d2, 0x9542, 0x11d2, { 0x8e, 0xb8, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class NS_RDF nsIRDFLiteral : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFLITERAL_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Get the Unicode string value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(const PRUnichar* *value) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two resources are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsLiteral(const nsIRDFLiteral* literal, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
// {E13A24E1-C77A-11d2-80BE-006097B76B8E}
|
||||
#define NS_IRDFDATE_IID \
|
||||
{ 0xe13a24e1, 0xc77a, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
|
||||
class nsIRDFDate : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_IRDFDATE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Get the PRTime value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(PRTime *value) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two ints are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsDate(const nsIRDFDate* literal, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
// {E13A24E3-C77A-11d2-80BE-006097B76B8E}
|
||||
#define NS_IRDFINT_IID \
|
||||
{ 0xe13a24e3, 0xc77a, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
class nsIRDFInt : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_IRDFINT_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Get the int32 value of the node.
|
||||
*/
|
||||
NS_IMETHOD GetValue(int32 *value) const = 0;
|
||||
|
||||
/**
|
||||
* Determine if two ints are identical.
|
||||
*/
|
||||
NS_IMETHOD EqualsInt(const nsIRDFInt* literal, PRBool* result) const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFNode_h__
|
||||
64
mozilla/rdf/base/public/nsIRDFObserver.h
Normal file
64
mozilla/rdf/base/public/nsIRDFObserver.h
Normal file
@@ -0,0 +1,64 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF data source observer interface. Data source observers are
|
||||
notified when the contents of the graph change.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFObserver_h__
|
||||
#define nsIRDFObserver_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFNode;
|
||||
|
||||
/**
|
||||
* An observer on an nsIRDFDataSource.
|
||||
*/
|
||||
|
||||
// 3cc75360-484a-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{ 0x3cc75360, 0x484a, 0x11d2, { 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } }
|
||||
|
||||
class nsIRDFObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFOBSERVER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Called whenever a new assertion is made in the data source.
|
||||
*/
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object) = 0;
|
||||
|
||||
/**
|
||||
* Called whenever an assertion is removed from the data source.
|
||||
*/
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFObserver_h__ */
|
||||
77
mozilla/rdf/base/public/nsIRDFResourceFactory.h
Normal file
77
mozilla/rdf/base/public/nsIRDFResourceFactory.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
The RDF resource factory interface. A resource factory produces
|
||||
nsIRDFResource objects for a specified URI prefix.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFResourceFactory_h__
|
||||
#define nsIRDFResourceFactory_h__
|
||||
|
||||
#if 0 // obsolete
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIRDFResource;
|
||||
|
||||
// {8CE57A20-A02C-11d2-8EBF-00805F29F370}
|
||||
#define NS_IRDFRESOURCEFACTORY_IID \
|
||||
{ 0x8ce57a20, 0xa02c, 0x11d2, { 0x8e, 0xbf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
/**
|
||||
* A resource factory can be registered with <tt>nsIRDFService</tt> to produce
|
||||
* resources with a certain <i>URI prefix</i>. The resource factory will be called
|
||||
* upon to create a new resource, which the resource manager will cache.
|
||||
*
|
||||
* @see nsIRDFService::RegisterResourceFactory
|
||||
* @see nsIRDFService::UnRegisterResourceFactory
|
||||
*/
|
||||
class nsIRDFResourceFactory : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFRESOURCEFACTORY_IID; return iid; }
|
||||
|
||||
/**
|
||||
* This method is called by the RDF service to create a new
|
||||
* resource.
|
||||
*
|
||||
* NOTE. After constructing a new resource via a call to
|
||||
* nsIRDFResourceFactory::CreateResource(), the implementation of
|
||||
* the RDF service calls nsIRDFResource::GetValue() on the
|
||||
* resulting resource. The resulting <tt>const char*</tt> is used
|
||||
* as a key for the resource cache. (The assumption is that the
|
||||
* custom resource implementation needs to store this information,
|
||||
* anyway.)
|
||||
*
|
||||
* This has important implications for a custom resource's
|
||||
* destructor; namely, that you must call
|
||||
* nsIRDFService::UnCacheResource() <b>before</b> releasing the
|
||||
* storage for the resource's URI. See
|
||||
* nsIRDFService::UnCacheResource() for more information.
|
||||
*/
|
||||
NS_IMETHOD CreateResource(const char* aURI, nsIRDFResource** aResult) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // nsIRDFResourceFactory_h__
|
||||
|
||||
194
mozilla/rdf/base/public/nsIRDFService.h
Normal file
194
mozilla/rdf/base/public/nsIRDFService.h
Normal file
@@ -0,0 +1,194 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF service interface. This is a singleton object, and should be
|
||||
obtained from the <tt>nsServiceManager</tt>.
|
||||
|
||||
XXX I'm not particularly happy with the current APIs for named data
|
||||
sources. The idea is that you want "rdf:bookmarks" to always map to
|
||||
the "bookmarks" data store. The thing that bothers me now is that
|
||||
the implementation has to pre-load all of the data sources: that
|
||||
means you need to parse the bookmarks file, read the history, etc.,
|
||||
rather than doing this on-demand. With a little thought, it may be
|
||||
able to enormously improve these APIs so that pre-loading data
|
||||
sources is unnecessary.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFService_h__
|
||||
#define nsIRDFService_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "prtime.h"
|
||||
class nsIRDFDataBase;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFLiteral;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFResourceFactory;
|
||||
class nsIRDFDate;
|
||||
class nsIRDFInt;
|
||||
|
||||
// {BFD05261-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{ 0xbfd05261, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFSERVICE_IID; return iid; }
|
||||
|
||||
// Resource management routines
|
||||
|
||||
/**
|
||||
* Construct an RDF resource from a single-byte URI. <tt>nsIRDFSerivce</tt>
|
||||
* caches resources that are in-use, so multiple calls to <tt>GetResource()</tt>
|
||||
* for the same <tt>uri</tt> will return identical pointers. FindResource
|
||||
* is used to find out whether there already exists a resource corresponding to that url.
|
||||
*/
|
||||
NS_IMETHOD GetResource(const char* uri, nsIRDFResource** resource) = 0;
|
||||
NS_IMETHOD FindResource(const char* uri, nsIRDFResource** resource, PRBool* found) = 0;
|
||||
|
||||
/**
|
||||
* Construct an RDF resource from a Unicode URI. This is provided
|
||||
* as a convenience method, allowing automatic, in-line C++
|
||||
* conversion from <tt>nsString</tt> objects. The <tt>uri</tt> will
|
||||
* be converted to a single-byte representation internally.
|
||||
*/
|
||||
NS_IMETHOD GetUnicodeResource(const PRUnichar* uri, nsIRDFResource** resource) = 0;
|
||||
|
||||
/**
|
||||
* Construct an RDF literal from a Unicode string.
|
||||
*/
|
||||
NS_IMETHOD GetLiteral(const PRUnichar* value, nsIRDFLiteral** literal) = 0;
|
||||
|
||||
/**
|
||||
|
||||
* Construct an RDF literal from a PRTime.
|
||||
*/
|
||||
NS_IMETHOD GetDateLiteral(const PRTime value, nsIRDFDate** date) = 0;
|
||||
|
||||
/**
|
||||
* Construct an RDF literal from an int.
|
||||
*/
|
||||
NS_IMETHOD GetIntLiteral(const int32 value, nsIRDFInt** intLiteral) = 0;
|
||||
|
||||
/**
|
||||
|
||||
* Registers a resource with the RDF system, making it unique w.r.t.
|
||||
* GetResource.
|
||||
*
|
||||
* An implementation of nsIRDFResource should call this in its
|
||||
* Init() method if it wishes the resource to be globally unique
|
||||
* (which is usually the case).
|
||||
*
|
||||
* NOTE that the resource will <i>not</i> be ref-counted by the
|
||||
* RDF service: the assumption is that the resource implementation
|
||||
* will call nsIRDFService::UnregisterResource() when the last
|
||||
* reference to the resource is released.
|
||||
*
|
||||
* NOTE that the nsIRDFService implementation may choose to
|
||||
* maintain a reference to the resource's URI; therefore, the
|
||||
* resource implementation should ensure that the resource's URI
|
||||
* (accessable via nsIRDFResource::GetValue(const char* *aURI)) is
|
||||
* valid before calling RegisterResource(). Furthermore, the
|
||||
* resource implementation should ensure that this pointer
|
||||
* <i>remains</i> valid for the lifetime of the resource. (The
|
||||
* implementation of the resource cache in nsIRDFService uses the
|
||||
* URI maintained "internally" in the resource as a key into the
|
||||
* cache rather than copying the resource URI itself.)
|
||||
*/
|
||||
NS_IMETHOD RegisterResource(nsIRDFResource* aResource, PRBool replace = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
|
||||
* Called to notify the resource manager that a resource is no
|
||||
* longer in use. This method should only be called from the
|
||||
* destructor of a "custom" resource implementation to notify the
|
||||
* RDF service that the last reference to the resource has been
|
||||
* released, so the resource is no longer valid.
|
||||
*
|
||||
* NOTE. As mentioned in nsIRDFResourceFactory::CreateResource(),
|
||||
* the RDF service will use the result of
|
||||
* nsIRDFResource::GetValue() as a key into its cache. For this
|
||||
* reason, you must always un-cache the resource <b>before</b>
|
||||
* releasing the storage for the <tt>const char*</tt> URI.
|
||||
*/
|
||||
NS_IMETHOD UnregisterResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
// Data source management routines
|
||||
|
||||
/**
|
||||
* Register a <i>named data source</i>. The RDF service will call
|
||||
* <tt>nsIRDFDataSource::GetURI()</tt> to determine the URI under
|
||||
* which to register the data source.
|
||||
*
|
||||
* Note that the data source will <i>not</i> be refcounted by the
|
||||
* RDF service! The assumption is that an RDF data source
|
||||
* registers with the service once it is initialized (via
|
||||
* <tt>nsIRDFDataSource::Init()</tt>), and unregisters when the
|
||||
* last reference to the data source is released.
|
||||
*/
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource* dataSource,
|
||||
PRBool replace = PR_FALSE) = 0;
|
||||
|
||||
/**
|
||||
* Unregister a <i>named data source</i>. The RDF service will call
|
||||
* <tt>nsIRDFDataSource::GetURI()</tt> to determine the URI under which the
|
||||
* data source was registered.
|
||||
*/
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
/**
|
||||
* Get the <i>named data source</i> corresponding to the URI. If a data
|
||||
* source has been registered via <tt>RegisterDataSource()</tt>, that
|
||||
* data source will be returned.
|
||||
*
|
||||
* If no data source is currently
|
||||
* registered for the specified URI, and a data source <i>constructor</i>
|
||||
* function has been registered via <tt>RegisterDatasourceConstructor()</tt>,
|
||||
* the RDF service will call the constructor to attempt to construct a
|
||||
* new data source. If construction is successful, the data source will
|
||||
* be initialized via <tt>nsIRDFDataSource::Init()</tt>.
|
||||
*/
|
||||
NS_IMETHOD GetDataSource(const char* uri, nsIRDFDataSource** dataSource) = 0;
|
||||
|
||||
/**
|
||||
* Create a database that contains the specified named data
|
||||
* sources. This is a convenience method whose functionality is
|
||||
* equivalent to (1) constructing a new nsIRDFDataBase object from
|
||||
* the repository, and (2) iteratively adding the named data sources
|
||||
* to it, in order.
|
||||
*/
|
||||
NS_IMETHOD CreateDatabase(const char** uris, nsIRDFDataBase** dataBase) = 0;
|
||||
|
||||
/**
|
||||
* Get the database aggregating all the stuff that Navigator sees as a default,
|
||||
* including a "local" store.
|
||||
*/
|
||||
NS_IMETHOD CreateBrowserDatabase(nsIRDFDataBase** dataBase) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
extern nsresult
|
||||
NS_NewRDFService(nsIRDFService** result);
|
||||
|
||||
#endif // nsIRDFService_h__
|
||||
60
mozilla/rdf/base/public/nsIRDFTree.h
Normal file
60
mozilla/rdf/base/public/nsIRDFTree.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFTree_h__
|
||||
#define nsIRDFTree_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "prtypes.h"
|
||||
#include "rdf.h" // for error codes
|
||||
|
||||
/*
|
||||
An interface for presenting a tree view of an rdf datasource (or
|
||||
database).
|
||||
|
||||
Any datasource can also support nsIRDFTree. The interface is purely
|
||||
syntactic sugar for traversing simple tree where the child relation
|
||||
corresponds to the property type nc:child (nc = http://home.netscape.com/NC-rdf#).
|
||||
Each leaf is assumed to have a certain predefined set of properties
|
||||
such as creationDate, size, lastModificationDate, lastVisitDate, etc.
|
||||
|
||||
This interface is substantially less general than nsIRDFDataSource,
|
||||
but is adequate for bookmarks, the file system, history and a few
|
||||
other very commonly used data sources.
|
||||
|
||||
*/
|
||||
|
||||
// {7D7EEBD1-AA41-11d2-80B7-006097B76B8E}
|
||||
#define NS_IRDFTREE_IID \
|
||||
{ 0x7d7eebd1, 0xaa41, 0x11d2, { 0x80, 0xb7, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } };
|
||||
|
||||
class nsIRDFTree : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD ListChildren (nsIRDFResource* folder, nsVoidArray** result);
|
||||
// XXX should define something called nsResourceArray and use that
|
||||
|
||||
NS_IMETHOD IsFolder (nsIRDFResource* node, PRBool* result);
|
||||
|
||||
NS_IMETHOD GetProperty (nsIRDFResource* node, nsIRDFResource* property,
|
||||
nsIRDFNode** result);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
200
mozilla/rdf/base/public/nsIRDFXMLDataSource.h
Normal file
200
mozilla/rdf/base/public/nsIRDFXMLDataSource.h
Normal file
@@ -0,0 +1,200 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This interface encapsulates information about an RDF/XML file,
|
||||
including the root resource, CSS style sheets, and named data
|
||||
sources.
|
||||
|
||||
This file also includes an observer interface for nsIRDFXMLDataSource
|
||||
objects.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLDataSource_h__
|
||||
#define nsIRDFXMLDataSource_h__
|
||||
|
||||
#include "nsIRDFDataSource.h"
|
||||
class nsIAtom;
|
||||
class nsIOutputStream;
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
// {EB1A5D30-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENTOBSERVER_IID \
|
||||
{ 0xeb1a5d30, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDataSource;
|
||||
|
||||
class nsIRDFXMLDataSourceObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLDOCUMENTOBSERVER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document begins to load.
|
||||
*/
|
||||
NS_IMETHOD OnBeginLoad(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document load is interrupted for some reason.
|
||||
*/
|
||||
NS_IMETHOD OnInterrupt(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when an interrupted RDF/XML document load is resumed.
|
||||
*/
|
||||
NS_IMETHOD OnResume(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called whtn the RDF/XML document load is complete.
|
||||
*/
|
||||
NS_IMETHOD OnEndLoad(nsIRDFXMLDataSource* aStream) = 0;
|
||||
|
||||
/**
|
||||
* Called when the root resource of the RDF/XML document is found
|
||||
*/
|
||||
NS_IMETHOD OnRootResourceFound(nsIRDFXMLDataSource* aStream, nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Called when a CSS style sheet is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnCSSStyleSheetAdded(nsIRDFXMLDataSource* aStream, nsIURL* aCSSStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Called when a named data source is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnNamedDataSourceAdded(nsIRDFXMLDataSource* aStream, const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// {EB1A5D31-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDATASOURCE_IID \
|
||||
{ 0xeb1a5d31, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDataSource : public nsIRDFDataSource
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLDATASOURCE_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Sets the RDF/XML stream to load either synchronously or
|
||||
* asynchronously when nsIRDFDataSource::Init() is called.
|
||||
* By default, the stream will load <em>asynchronously</em>.
|
||||
*/
|
||||
NS_IMETHOD SetSynchronous(PRBool aIsSynchronous) = 0;
|
||||
|
||||
/**
|
||||
* Sets the RDF/XML stream's read-only status. By default,
|
||||
* the stream will be read/write if the URL on which
|
||||
* nsIRDFDataSource::Init() is called is writable.
|
||||
*/
|
||||
NS_IMETHOD SetReadOnly(PRBool aIsReadOnly) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is beginning.
|
||||
*/
|
||||
NS_IMETHOD BeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is being interrupted.
|
||||
*/
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that an interrupted load is being resumed.
|
||||
*/
|
||||
NS_IMETHOD Resume(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is ending.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource) = 0;
|
||||
|
||||
/**
|
||||
* Add a CSS style sheet to the document.
|
||||
* @param aStyleSheetURL An nsIURL object that is the URL of the style
|
||||
* sheet to add to the document.
|
||||
*/
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of style sheets that have been included in the
|
||||
* document.
|
||||
* @param aStyleSheetURLs (out) A pointer to an array of pointers to nsIURL objects.
|
||||
* @param aCount (out) The number of nsIURL objects returned.
|
||||
*/
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a named data source to the document.
|
||||
* @param aNamedDataSoruceURI A URI identifying the data source.
|
||||
*/
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of named data sources that have been included in
|
||||
* the document
|
||||
* @param aNamedDataSourceURIs (out) A pointer to an array of C-style character
|
||||
* strings.
|
||||
* @param aCount (out) The number of named data sources in the array.
|
||||
*/
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a new namespace declaration to the RDF/XML document.
|
||||
*/
|
||||
NS_IMETHOD AddNameSpace(nsIAtom* aPrefix, const nsString& aURI) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to the document. The observer will be notified of
|
||||
* RDF/XML events via the nsIRDFXMLDataSourceObserver interface. Note that
|
||||
* the observer is <em>not</em> reference counted.
|
||||
*/
|
||||
NS_IMETHOD AddXMLStreamObserver(nsIRDFXMLDataSourceObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from the document.
|
||||
*/
|
||||
NS_IMETHOD RemoveXMLStreamObserver(nsIRDFXMLDataSourceObserver* aObserver) = 0;
|
||||
};
|
||||
|
||||
// Two different kinds of XML data sources exist for RDF: serialized RDF and XUL.
|
||||
// These are the methods that make these data sources.
|
||||
extern nsresult
|
||||
NS_NewRDFXMLDataSource(nsIRDFXMLDataSource** result);
|
||||
|
||||
extern nsresult
|
||||
NS_NewXULDataSource(nsIRDFXMLDataSource** result);
|
||||
|
||||
#endif // nsIRDFXMLDataSource_h__
|
||||
|
||||
165
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
165
mozilla/rdf/base/public/nsIRDFXMLDocument.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This interface encapsulates information about an RDF/XML file,
|
||||
including the root resource, CSS style sheets, and named data
|
||||
sources.
|
||||
|
||||
This file also includes an observer interface for nsIRDFXMLDocument
|
||||
objects.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLDocument_h__
|
||||
#define nsIRDFXMLDocument_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
class nsIOutputStream;
|
||||
class nsIURL;
|
||||
|
||||
// {EB1A5D30-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENTOBSERVER_IID \
|
||||
{ 0xeb1a5d30, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDocumentObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Called when the RDF/XML document begins to load.
|
||||
*/
|
||||
NS_IMETHOD OnBeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the RDF/XML document load is interrupted for some reason.
|
||||
*/
|
||||
NS_IMETHOD OnInterrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when an interrupted RDF/XML document load is resumed.
|
||||
*/
|
||||
NS_IMETHOD OnResume(void) = 0;
|
||||
|
||||
/**
|
||||
* Called whtn the RDF/XML document load is complete.
|
||||
*/
|
||||
NS_IMETHOD OnEndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Called when the root resource of the RDF/XML document is found
|
||||
*/
|
||||
NS_IMETHOD OnRootResourceFound(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Called when a CSS style sheet is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnCSSStyleSheetAdded(nsIURL* aCSSStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Called when a named data source is included (via XML processing
|
||||
* instruction) to the document.
|
||||
*/
|
||||
NS_IMETHOD OnNamedDataSourceAdded(const char* aNamedDataSourceURI) = 0;
|
||||
};
|
||||
|
||||
|
||||
// {EB1A5D31-AB33-11d2-8EC6-00805F29F370}
|
||||
#define NS_IRDFXMLDOCUMENT_IID \
|
||||
{ 0xeb1a5d31, 0xab33, 0x11d2, { 0x8e, 0xc6, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFXMLDocument : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Notify the document that the load is beginning.
|
||||
*/
|
||||
NS_IMETHOD BeginLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is being interrupted.
|
||||
*/
|
||||
NS_IMETHOD Interrupt(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that an interrupted load is being resumed.
|
||||
*/
|
||||
NS_IMETHOD Resume(void) = 0;
|
||||
|
||||
/**
|
||||
* Notify the document that the load is ending.
|
||||
*/
|
||||
NS_IMETHOD EndLoad(void) = 0;
|
||||
|
||||
/**
|
||||
* Set the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
/**
|
||||
* Retrieve the root resource for the document.
|
||||
*/
|
||||
NS_IMETHOD GetRootResource(nsIRDFResource** aResource) = 0;
|
||||
|
||||
/**
|
||||
* Add a CSS style sheet to the document.
|
||||
* @param aStyleSheetURL An nsIURL object that is the URL of the style
|
||||
* sheet to add to the document.
|
||||
*/
|
||||
NS_IMETHOD AddCSSStyleSheetURL(nsIURL* aStyleSheetURL) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of style sheets that have been included in the
|
||||
* document.
|
||||
* @param aStyleSheetURLs (out) A pointer to an array of pointers to nsIURL objects.
|
||||
* @param aCount (out) The number of nsIURL objects returned.
|
||||
*/
|
||||
NS_IMETHOD GetCSSStyleSheetURLs(nsIURL*** aStyleSheetURLs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add a named data source to the document.
|
||||
* @param aNamedDataSoruceURI A URI identifying the data source.
|
||||
*/
|
||||
NS_IMETHOD AddNamedDataSourceURI(const char* aNamedDataSourceURI) = 0;
|
||||
|
||||
/**
|
||||
* Get the set of named data sources that have been included in
|
||||
* the document
|
||||
* @param aNamedDataSourceURIs (out) A pointer to an array of C-style character
|
||||
* strings.
|
||||
* @param aCount (out) The number of named data sources in the array.
|
||||
*/
|
||||
NS_IMETHOD GetNamedDataSourceURIs(const char* const** aNamedDataSourceURIs, PRInt32* aCount) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to the document. The observer will be notified of
|
||||
* RDF/XML events via the nsIRDFXMLDocumentObserver interface. Note that
|
||||
* the observer is <em>not</em> reference counted.
|
||||
*/
|
||||
NS_IMETHOD AddDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from the document.
|
||||
*/
|
||||
NS_IMETHOD RemoveDocumentObserver(nsIRDFXMLDocumentObserver* aObserver) = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsIRDFXMLDocument_h__
|
||||
|
||||
44
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
44
mozilla/rdf/base/public/nsIRDFXMLSource.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF/XML source interface. An RDF/XML source is capable of
|
||||
producing serialized RDF/XML to an output stream.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFXMLSource_h__
|
||||
#define nsIRDFXMLSource_h__
|
||||
|
||||
class nsIOutputStream;
|
||||
|
||||
// {4DA56F10-99FE-11d2-8EBB-00805F29F370}
|
||||
#define NS_IRDFXMLSOURCE_IID \
|
||||
{ 0x4da56f10, 0x99fe, 0x11d2, { 0x8e, 0xbb, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
|
||||
class nsIRDFXMLSource : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFXMLSOURCE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD Serialize(nsIOutputStream* aStream) = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRDFXMLSource_h__
|
||||
421
mozilla/rdf/base/public/nsRDFInterfaces.h
Normal file
421
mozilla/rdf/base/public/nsRDFInterfaces.h
Normal file
@@ -0,0 +1,421 @@
|
||||
/*
|
||||
* DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../../rdf/base/idl/nsRDFInterfaces.idl
|
||||
*/
|
||||
|
||||
#ifndef __gen_nsRDFInterfaces_h__
|
||||
#define __gen_nsRDFInterfaces_h__
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsID.h" /* interface nsID */
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
#include "jsapi.h"
|
||||
#endif
|
||||
#include "nsDebug.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "nsID.h"
|
||||
#include "nsIID.h"
|
||||
#include "nsError.h"
|
||||
#include "nsISupportsUtils.h"
|
||||
|
||||
#include "nscore.h" // for PRUnichar
|
||||
|
||||
|
||||
/* starting interface nsIRDFNode */
|
||||
|
||||
/* {0F78DA50-8321-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFNODE_IID_STR "0F78DA50-8321-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFNODE_IID \
|
||||
{0x0F78DA50, 0x8321, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFNode : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFNODE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(char *uri) = 0;
|
||||
|
||||
/* boolean EqualsNode (in nsIRDFNode aNode); */
|
||||
NS_IMETHOD EqualsNode(nsIRDFNode *aNode, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFNode *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFResource */
|
||||
|
||||
/* {E0C493D1-9542-11d2-8EB8-00805F29F370} */
|
||||
#define NS_IRDFRESOURCE_IID_STR "E0C493D1-9542-11d2-8EB8-00805F29F370"
|
||||
#define NS_IRDFRESOURCE_IID \
|
||||
{0xE0C493D1, 0x9542, 0x11d2, \
|
||||
{ 0x8E, 0xB8, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFResource : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFRESOURCE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute string Value; */
|
||||
NS_IMETHOD GetValue(char * *aValue) = 0;
|
||||
|
||||
/* boolean EqualsResource (in nsIRDFResource aResource); */
|
||||
NS_IMETHOD EqualsResource(nsIRDFResource *aResource, PRBool *_retval) = 0;
|
||||
|
||||
/* boolean EqualsString (in string aURI); */
|
||||
NS_IMETHOD EqualsString(char *aURI, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFResource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFLiteral */
|
||||
|
||||
/* {E0C493D2-9542-11d2-8EB8-00805F29F370} */
|
||||
#define NS_IRDFLITERAL_IID_STR "E0C493D2-9542-11d2-8EB8-00805F29F370"
|
||||
#define NS_IRDFLITERAL_IID \
|
||||
{0xE0C493D2, 0x9542, 0x11d2, \
|
||||
{ 0x8E, 0xB8, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFLiteral : public nsIRDFNode {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFLITERAL_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute wstring Value; */
|
||||
NS_IMETHOD GetValue(PRUnichar * *aValue) = 0;
|
||||
|
||||
/* boolean EqualsLiteral (in nsIRDFLiteral literal); */
|
||||
NS_IMETHOD EqualsLiteral(nsIRDFLiteral *literal, PRBool *_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFLiteral *priv);
|
||||
#endif
|
||||
};
|
||||
class nsIRDFDataSource; /* forward decl */
|
||||
|
||||
/* starting interface nsIRDFCursor */
|
||||
|
||||
/* {1C2ABDB0-4CEF-11D2-BC16-00805F912FE7} */
|
||||
#define NS_IRDFCURSOR_IID_STR "1C2ABDB0-4CEF-11D2-BC16-00805F912FE7"
|
||||
#define NS_IRDFCURSOR_IID \
|
||||
{0x1C2ABDB0, 0x4CEF, 0x11D2, \
|
||||
{ 0xBC, 0x16, 0x00, 0x80, 0x5F, 0x91, 0x2F, 0xE7 }}
|
||||
|
||||
class nsIRDFCursor : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFCURSOR_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void Advance (); */
|
||||
NS_IMETHOD Advance() = 0;
|
||||
|
||||
/* readonly attribute nsIRDFDataSource DataSource; */
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource * *aDataSource) = 0;
|
||||
|
||||
/* readonly attribute nsIRDFNode Value; */
|
||||
NS_IMETHOD GetValue(nsIRDFNode * *aValue) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFCursor *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFAssertionCursor */
|
||||
|
||||
/* {1ED57100-9904-11d2-8EBA-00805F29F370} */
|
||||
#define NS_IRDFASSERTIONCURSOR_IID_STR "1ED57100-9904-11d2-8EBA-00805F29F370"
|
||||
#define NS_IRDFASSERTIONCURSOR_IID \
|
||||
{0x1ED57100, 0x9904, 0x11d2, \
|
||||
{ 0x8E, 0xBA, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFAssertionCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFASSERTIONCURSOR_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIRDFResource Source; */
|
||||
NS_IMETHOD GetSource(nsIRDFResource * *aSource) = 0;
|
||||
|
||||
/* readonly attribute nsIRDFResource Label; */
|
||||
NS_IMETHOD GetLabel(nsIRDFResource * *aLabel) = 0;
|
||||
|
||||
/* readonly attribute nsIRDFNode Target; */
|
||||
NS_IMETHOD GetTarget(nsIRDFNode * *aTarget) = 0;
|
||||
|
||||
/* readonly attribute boolean TruthValue; */
|
||||
NS_IMETHOD GetTruthValue(PRBool *aTruthValue) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFAssertionCursor *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFArcsInCursor */
|
||||
|
||||
/* {1ED57102-9904-11d2-8EBA-00805F29F370} */
|
||||
#define NS_IRDFARCSINCURSOR_IID_STR "1ED57102-9904-11d2-8EBA-00805F29F370"
|
||||
#define NS_IRDFARCSINCURSOR_IID \
|
||||
{0x1ED57102, 0x9904, 0x11d2, \
|
||||
{ 0x8E, 0xBA, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFArcsInCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFARCSINCURSOR_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIRDFResource Label; */
|
||||
NS_IMETHOD GetLabel(nsIRDFResource * *aLabel) = 0;
|
||||
|
||||
/* readonly attribute nsIRDFNode Target; */
|
||||
NS_IMETHOD GetTarget(nsIRDFNode * *aTarget) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFArcsInCursor *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFArcsOutCursor */
|
||||
|
||||
/* {1ED57101-9904-11d2-8EBA-00805F29F370} */
|
||||
#define NS_IRDFARCSOUTCURSOR_IID_STR "1ED57101-9904-11d2-8EBA-00805F29F370"
|
||||
#define NS_IRDFARCSOUTCURSOR_IID \
|
||||
{0x1ED57101, 0x9904, 0x11d2, \
|
||||
{ 0x8E, 0xBA, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFArcsOutCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFARCSOUTCURSOR_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIRDFResource Source; */
|
||||
NS_IMETHOD GetSource(nsIRDFResource * *aSource) = 0;
|
||||
|
||||
/* readonly attribute nsIRDFResource Label; */
|
||||
NS_IMETHOD GetLabel(nsIRDFResource * *aLabel) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFArcsOutCursor *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFResourceCursor */
|
||||
|
||||
/* {C2850C10-B0CF-11d2-A684-00104BDE6048} */
|
||||
#define NS_IRDFRESOURCECURSOR_IID_STR "C2850C10-B0CF-11d2-A684-00104BDE6048"
|
||||
#define NS_IRDFRESOURCECURSOR_IID \
|
||||
{0xC2850C10, 0xB0CF, 0x11d2, \
|
||||
{ 0xA6, 0x84, 0x00, 0x10, 0x4B, 0xDE, 0x60, 0x48 }}
|
||||
|
||||
class nsIRDFResourceCursor : public nsIRDFCursor {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFRESOURCECURSOR_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIRDFResource Resource; */
|
||||
NS_IMETHOD GetResource(nsIRDFResource * *aResource) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFResourceCursor *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFObserver */
|
||||
|
||||
/* {3CC75360-484A-11D2-BC16-00805F912FE7} */
|
||||
#define NS_IRDFOBSERVER_IID_STR "3CC75360-484A-11D2-BC16-00805F912FE7"
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{0x3CC75360, 0x484A, 0x11D2, \
|
||||
{ 0xBC, 0x16, 0x00, 0x80, 0x5F, 0x91, 0x2F, 0xE7 }}
|
||||
|
||||
class nsIRDFObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFOBSERVER_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void OnAssert (in nsIRDFResource aSource, in nsIRDFResource aLabel, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD OnAssert(nsIRDFResource *aSource, nsIRDFResource *aLabel, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
/* void OnUnassert (in nsIRDFResource aSource, in nsIRDFResource aLabel, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource *aSource, nsIRDFResource *aLabel, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFObserver *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFDataSource */
|
||||
|
||||
/* {0F78DA58-8321-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFDATASOURCE_IID_STR "0F78DA58-8321-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{0x0F78DA58, 0x8321, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFDATASOURCE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void Init (in string uri); */
|
||||
NS_IMETHOD Init(char *uri) = 0;
|
||||
|
||||
/* readonly attribute string URI; */
|
||||
NS_IMETHOD GetURI(char * *aURI) = 0;
|
||||
|
||||
/* nsIRDFResource GetSource (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSource(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsIRDFAssertionCursor GetSources (in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetSources(nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, nsIRDFAssertionCursor **_retval) = 0;
|
||||
|
||||
/* nsIRDFNode GetTarget (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTarget(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFNode **_retval) = 0;
|
||||
|
||||
/* nsIRDFAssertionCursor GetTargets (in nsIRDFResource aSource, in nsIRDFResource aProperty, in boolean aTruthValue); */
|
||||
NS_IMETHOD GetTargets(nsIRDFResource *aSource, nsIRDFResource *aProperty, PRBool aTruthValue, nsIRDFAssertionCursor **_retval) = 0;
|
||||
|
||||
/* void Assert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD Assert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue) = 0;
|
||||
|
||||
/* void Unassert (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget); */
|
||||
NS_IMETHOD Unassert(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget) = 0;
|
||||
|
||||
/* boolean HasAssertion (in nsIRDFResource aSource, in nsIRDFResource aProperty, in nsIRDFNode aTarget, in boolean aTruthValue); */
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource *aSource, nsIRDFResource *aProperty, nsIRDFNode *aTarget, PRBool aTruthValue, PRBool *_retval) = 0;
|
||||
|
||||
/* void AddObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver *aObserver) = 0;
|
||||
|
||||
/* void RemoveObserver (in nsIRDFObserver aObserver); */
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver) = 0;
|
||||
|
||||
/* nsIRDFArcsInCursor ArcLabelsIn (in nsIRDFNode aNode); */
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode, nsIRDFArcsInCursor **_retval) = 0;
|
||||
|
||||
/* nsIRDFArcsOutCursor ArcLabelsOut (in nsIRDFResource aSource); */
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource, nsIRDFArcsOutCursor **_retval) = 0;
|
||||
|
||||
/* nsIRDFResourceCursor GetAllResources (); */
|
||||
NS_IMETHOD GetAllResources(nsIRDFResourceCursor **_retval) = 0;
|
||||
|
||||
/* void Flush (); */
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
/* boolean IsCommandEnabled (in string aCommand, in nsIRDFResource aCommandTarget); */
|
||||
NS_IMETHOD IsCommandEnabled(char *aCommand, nsIRDFResource *aCommandTarget, PRBool *_retval) = 0;
|
||||
|
||||
/* void DoCommand (in string aCommand, in nsIRDFResource aCommandTarget); */
|
||||
NS_IMETHOD DoCommand(char *aCommand, nsIRDFResource *aCommandTarget) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFDataSource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFCompositeDataSource */
|
||||
|
||||
/* {96343820-307C-11D2-BC15-00805F912FE7} */
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID_STR "96343820-307C-11D2-BC15-00805F912FE7"
|
||||
#define NS_IRDFCOMPOSITEDATASOURCE_IID \
|
||||
{0x96343820, 0x307C, 0x11D2, \
|
||||
{ 0xBC, 0x15, 0x00, 0x80, 0x5F, 0x91, 0x2F, 0xE7 }}
|
||||
|
||||
class nsIRDFCompositeDataSource : public nsIRDFDataSource {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFCOMPOSITEDATASOURCE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* void AddDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
/* void RemoveDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFCompositeDataSource *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
/* starting interface nsIRDFService */
|
||||
|
||||
/* {BFD05261-834C-11d2-8EAC-00805F29F370} */
|
||||
#define NS_IRDFSERVICE_IID_STR "BFD05261-834C-11d2-8EAC-00805F29F370"
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{0xBFD05261, 0x834C, 0x11d2, \
|
||||
{ 0x8E, 0xAC, 0x00, 0x80, 0x5F, 0x29, 0xF3, 0x70 }}
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {
|
||||
static nsIID iid = NS_IRDFSERVICE_IID;
|
||||
return iid;
|
||||
}
|
||||
|
||||
/* nsIRDFResource GetResource (in string aURI); */
|
||||
NS_IMETHOD GetResource(char *aURI, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsIRDFResource GetUnicodeResource (in wstring aURI); */
|
||||
NS_IMETHOD GetUnicodeResource(PRUnichar *aURI, nsIRDFResource **_retval) = 0;
|
||||
|
||||
/* nsIRDFLiteral GetLiteral (in wstring aValue); */
|
||||
NS_IMETHOD GetLiteral(PRUnichar *aValue, nsIRDFLiteral **_retval) = 0;
|
||||
|
||||
/* void RegisterResource (in nsIRDFResource aResource, in boolean aReplace); */
|
||||
NS_IMETHOD RegisterResource(nsIRDFResource *aResource, PRBool aReplace) = 0;
|
||||
|
||||
/* void UnregisterResource (in nsIRDFResource aResource); */
|
||||
NS_IMETHOD UnregisterResource(nsIRDFResource *aResource) = 0;
|
||||
|
||||
/* void RegisterDataSource (in nsIRDFDataSource aDataSource, in boolean aReplace); */
|
||||
NS_IMETHOD RegisterDataSource(nsIRDFDataSource *aDataSource, PRBool aReplace) = 0;
|
||||
|
||||
/* void UnregisterDataSource (in nsIRDFDataSource aDataSource); */
|
||||
NS_IMETHOD UnregisterDataSource(nsIRDFDataSource *aDataSource) = 0;
|
||||
|
||||
/* nsIRDFDataSource GetDataSource (in string aURI); */
|
||||
NS_IMETHOD GetDataSource(char *aURI, nsIRDFDataSource **_retval) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
static NS_EXPORT_(JSObject *) GetJSObject(JSContext *cx, nsIRDFService *priv);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif /* __gen_nsRDFInterfaces_h__ */
|
||||
96
mozilla/rdf/base/public/rdf.h
Normal file
96
mozilla/rdf/base/public/rdf.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A catch-all header file for miscellaneous RDF stuff. Currently
|
||||
contains error codes and vocabulary macros.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef rdf_h___
|
||||
#define rdf_h___
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
/*
|
||||
* The following macros are to aid in vocabulary definition.
|
||||
* They creates const char*'s for "kURI[prefix]_[name]" and
|
||||
* "kTag[prefix]_[name]", with appropriate complete namespace
|
||||
* qualification on the URI, e.g.,
|
||||
*
|
||||
* #define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
* DEFINE_RDF_ELEMENT(RDF_NAMESPACE_URI, RDF, ID);
|
||||
*
|
||||
* will define:
|
||||
*
|
||||
* kURIRDF_ID to be "http://www.w3.org/TR/WD-rdf-syntax#ID", and
|
||||
* kTagRDF_ID to be "ID"
|
||||
*/
|
||||
|
||||
#define DEFINE_RDF_VOCAB(namespace, prefix, name) \
|
||||
static const char* kURI##prefix##_##name = ##namespace #name ;\
|
||||
static const char* kTag##prefix##_##name = #name
|
||||
|
||||
/**
|
||||
* Core RDF vocabularies that we use to infer semantic actions
|
||||
*/
|
||||
#define RDF_NAMESPACE_URI "http://www.w3.org/TR/WD-rdf-syntax#"
|
||||
#define WEB_NAMESPACE_URI "http://home.netscape.com/WEB-rdf#"
|
||||
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
|
||||
|
||||
|
||||
/**
|
||||
* @name Standard RDF error codes
|
||||
*/
|
||||
|
||||
/*@{*/
|
||||
|
||||
/* Returned from nsIRDFCursor::Advance() if the cursor has no more
|
||||
elements to enuemrate */
|
||||
#define NS_ERROR_RDF_CURSOR_EMPTY NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 1)
|
||||
#define NS_ERROR_RDF_NO_VALUE NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF, 2)
|
||||
|
||||
|
||||
|
||||
|
||||
/* ProgID prefixes for RDF DLL registration. */
|
||||
#define NS_RDF_PROGID "component:||netscape|rdf"
|
||||
#define NS_RDF_DATASOURCE_PROGID NS_RDF_PROGID "|datasource"
|
||||
#define NS_RDF_DATASOURCE_PROGID_PREFIX NS_RDF_DATASOURCE_PROGID "?name#"
|
||||
#define NS_RDF_RESOURCE_FACTORY_PROGID "component:||netscape|rdf|resource-factory"
|
||||
#define NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX NS_RDF_RESOURCE_FACTORY_PROGID "?name#"
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef _IMPL_NS_RDF
|
||||
#ifdef XP_PC
|
||||
#define NS_RDF _declspec(dllexport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_RDF
|
||||
#endif /* !XP_PC */
|
||||
#else /* !_IMPL_NS_RDF */
|
||||
#ifdef XP_PC
|
||||
#define NS_RDF _declspec(dllimport)
|
||||
#else /* !XP_PC */
|
||||
#define NS_RDF
|
||||
#endif /* !XP_PC */
|
||||
#endif /* !_IMPL_NS_RDF */
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
42
mozilla/rdf/base/public/rdf_qsort.h
Normal file
42
mozilla/rdf/base/public/rdf_qsort.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
/* We need this because Solaris' version of qsort is broken and
|
||||
* causes array bounds reads.
|
||||
*/
|
||||
|
||||
#ifndef rdf_qsort_h___
|
||||
#define rdf_qsort_h___
|
||||
|
||||
/* Had to pull the following define out of xp_core.h
|
||||
* to avoid including xp_core.h.
|
||||
* That brought in too many header file dependencies.
|
||||
*/
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void rdf_qsort(void *, size_t, size_t,
|
||||
int (*)(const void *, const void *, void *), void *);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* rdf_qsort_h___ */
|
||||
60
mozilla/rdf/base/src/Makefile.in
Normal file
60
mozilla/rdf/base/src/Makefile.in
Normal file
@@ -0,0 +1,60 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = rdfbase_s
|
||||
|
||||
CSRCS = \
|
||||
rdf_qsort.c \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsCompositeDataSource.cpp \
|
||||
nsContainerCursor.cpp \
|
||||
nsDefaultResourceFactory.cpp \
|
||||
nsEmptyCursor.cpp \
|
||||
nsInMemoryDataSource.cpp \
|
||||
nsRDFContentSink.cpp \
|
||||
nsRDFParserUtils.cpp \
|
||||
nsRDFService.cpp \
|
||||
nsRDFXMLDataSource.cpp \
|
||||
rdfutil.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdfbase
|
||||
|
||||
REQUIRES = netlib rdf rdfutil raptor xpcom
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
55
mozilla/rdf/base/src/makefile.win
Normal file
55
mozilla/rdf/base/src/makefile.win
Normal file
@@ -0,0 +1,55 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
LCFLAGS=-D_IMPL_NS_RDF -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
MODULE=rdf
|
||||
LIBRARY_NAME=rdfbase_s
|
||||
|
||||
C_OBJS=\
|
||||
.\$(OBJDIR)\rdf_qsort.obj \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsCompositeDataSource.obj \
|
||||
.\$(OBJDIR)\nsContainerCursor.obj \
|
||||
.\$(OBJDIR)\nsDefaultResourceFactory.obj \
|
||||
.\$(OBJDIR)\nsEmptyCursor.obj \
|
||||
.\$(OBJDIR)\nsInMemoryDataSource.obj \
|
||||
.\$(OBJDIR)\nsRDFContentSink.obj \
|
||||
.\$(OBJDIR)\nsRDFParserUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFService.obj \
|
||||
.\$(OBJDIR)\nsRDFXMLDataSource.obj \
|
||||
.\$(OBJDIR)\rdfutil.obj \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\rdfutil \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
951
mozilla/rdf/base/src/nsCompositeDataSource.cpp
Normal file
951
mozilla/rdf/base/src/nsCompositeDataSource.cpp
Normal file
@@ -0,0 +1,951 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A simple composite data source implementation. A composit data
|
||||
source is just a strategy for combining individual data sources into
|
||||
a collective graph.
|
||||
|
||||
|
||||
1) A composite data source holds a sequence of data sources. The set
|
||||
of data sources can be specified during creation of the
|
||||
database. Data sources can also be added/deleted from a database
|
||||
later.
|
||||
|
||||
2) The aggregation mechanism is based on simple super-positioning of
|
||||
the graphs from the datasources. If there is a conflict (i.e.,
|
||||
data source A has a true arc from foo to bar while data source B
|
||||
has a false arc from foo to bar), the data source that it earlier
|
||||
in the sequence wins.
|
||||
|
||||
The implementation below doesn't really do this and needs to be
|
||||
fixed.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsRepository.h"
|
||||
#include "nsVoidArray.h"
|
||||
#ifdef NS_DEBUG
|
||||
#include "prlog.h"
|
||||
#include "prprf.h"
|
||||
#include <stdio.h>
|
||||
PRLogModuleInfo* nsRDFLog = nsnull;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kIRDFArcsInCursorIID, NS_IRDFARCSINCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFArcsOutCursorIID, NS_IRDFARCSOUTCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCompositeDataSourceIID, NS_IRDFCOMPOSITEDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// CompositeDataSourceImpl
|
||||
|
||||
class CompositeDataSourceImpl : public nsIRDFCompositeDataSource,
|
||||
public nsIRDFObserver
|
||||
{
|
||||
public:
|
||||
CompositeDataSourceImpl(void);
|
||||
CompositeDataSourceImpl(char** dataSources);
|
||||
|
||||
nsVoidArray mDataSources;
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFDataSource interface
|
||||
NS_IMETHOD Init(const char* uri);
|
||||
|
||||
NS_IMETHOD GetURI(const char* *uri) const;
|
||||
|
||||
NS_IMETHOD GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source);
|
||||
|
||||
NS_IMETHOD GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** sources);
|
||||
|
||||
NS_IMETHOD GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target);
|
||||
|
||||
NS_IMETHOD GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets);
|
||||
|
||||
NS_IMETHOD Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
|
||||
NS_IMETHOD Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target);
|
||||
|
||||
NS_IMETHOD HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion);
|
||||
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver* n);
|
||||
|
||||
NS_IMETHOD ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels);
|
||||
|
||||
NS_IMETHOD ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels);
|
||||
|
||||
NS_IMETHOD GetAllResources(nsIRDFResourceCursor** aCursor);
|
||||
|
||||
NS_IMETHOD Flush();
|
||||
|
||||
NS_IMETHOD IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget);
|
||||
|
||||
|
||||
// nsIRDFCompositeDataSource interface
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* source);
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* source);
|
||||
|
||||
// nsIRDFObserver interface
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// Implementation methods
|
||||
PRBool HasAssertionN(int n, nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv);
|
||||
protected:
|
||||
nsVoidArray* mObservers;
|
||||
|
||||
virtual ~CompositeDataSourceImpl(void);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DBArcsInOutCursor : public nsIRDFArcsOutCursor,
|
||||
public nsIRDFArcsInCursor
|
||||
{
|
||||
public:
|
||||
DBArcsInOutCursor(CompositeDataSourceImpl* db, nsIRDFNode* node, PRBool arcsOutp);
|
||||
|
||||
virtual ~DBArcsInOutCursor();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return (mInCursor ? mInCursor->GetDataSource(aDataSource) :
|
||||
mOutCursor->GetDataSource(aDataSource));
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return mOutCursor->GetSubject(aResource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aNode) {
|
||||
return mInCursor->GetObject(aNode);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return (mInCursor ? mInCursor->GetPredicate(aPredicate) :
|
||||
mOutCursor->GetPredicate(aPredicate));
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return (mInCursor ? mInCursor->GetValue(aValue) :
|
||||
mOutCursor->GetValue(aValue));
|
||||
}
|
||||
|
||||
protected:
|
||||
CompositeDataSourceImpl* mCompositeDataSourceImpl;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFNode* mTarget;
|
||||
PRInt32 mCount;
|
||||
nsIRDFArcsOutCursor* mOutCursor;
|
||||
nsIRDFArcsInCursor* mInCursor;
|
||||
nsVoidArray mResults;
|
||||
};
|
||||
|
||||
|
||||
DBArcsInOutCursor::DBArcsInOutCursor(CompositeDataSourceImpl* db,
|
||||
nsIRDFNode* node,
|
||||
PRBool arcsOutp)
|
||||
: mCompositeDataSourceImpl(db),
|
||||
mTarget(0),
|
||||
mSource(0),
|
||||
mCount(0),
|
||||
mInCursor(0),
|
||||
mOutCursor(0)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mCompositeDataSourceImpl);
|
||||
|
||||
if (arcsOutp) {
|
||||
mSource = (nsIRDFResource*) node;
|
||||
} else {
|
||||
mTarget = node;
|
||||
}
|
||||
NS_IF_ADDREF(node);
|
||||
|
||||
// XXX there better be at least _one_ datasource in this here
|
||||
// CompositeDataSourceImpl, else this'll be a real short ride...
|
||||
// PR_ASSERT(db->mDataSources.Count() > 0);
|
||||
// but if there's not (because some datasource failed to initialize)
|
||||
// then just skip this...
|
||||
if (db->mDataSources.Count() > 0) {
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) db->mDataSources[mCount++];
|
||||
|
||||
if (mTarget) {
|
||||
ds->ArcLabelsIn(mTarget, &mInCursor);
|
||||
} else {
|
||||
ds->ArcLabelsOut(mSource, &mOutCursor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DBArcsInOutCursor::~DBArcsInOutCursor(void)
|
||||
{
|
||||
for (PRInt32 i = mResults.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFNode* node = (nsIRDFNode*) mResults[i];
|
||||
NS_RELEASE(node);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mSource);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_IF_RELEASE(mInCursor);
|
||||
NS_IF_RELEASE(mOutCursor);
|
||||
NS_RELEASE(mCompositeDataSourceImpl);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(DBArcsInOutCursor);
|
||||
NS_IMPL_RELEASE(DBArcsInOutCursor);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
DBArcsInOutCursor::QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsOutCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsOutCursor*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DBArcsInOutCursor::Advance(void)
|
||||
{
|
||||
nsIRDFDataSource* ds;
|
||||
while (mInCursor || mOutCursor) {
|
||||
nsresult result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
|
||||
|
||||
while (NS_SUCCEEDED(result)) {
|
||||
nsIRDFNode* obj ;
|
||||
result = GetValue(&obj);
|
||||
NS_ASSERTION(NS_SUCCEEDED(result), "Advance is broken");
|
||||
if (NS_SUCCEEDED(result) && mResults.IndexOf(obj) < 0) {
|
||||
mResults.AppendElement(obj);
|
||||
return NS_OK;
|
||||
}
|
||||
result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
|
||||
}
|
||||
|
||||
if (result != NS_ERROR_RDF_CURSOR_EMPTY)
|
||||
return result;
|
||||
|
||||
NS_IF_RELEASE(mInCursor);
|
||||
NS_IF_RELEASE(mOutCursor);
|
||||
|
||||
if (mCount >= mCompositeDataSourceImpl->mDataSources.Count())
|
||||
break;
|
||||
|
||||
ds = (nsIRDFDataSource*) mCompositeDataSourceImpl->mDataSources[mCount];
|
||||
++mCount;
|
||||
|
||||
if (mTarget) {
|
||||
ds->ArcLabelsIn(mTarget, &mInCursor);
|
||||
} else {
|
||||
ds->ArcLabelsOut(mSource, &mOutCursor);
|
||||
}
|
||||
}
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// DBAssertionCursor
|
||||
//
|
||||
// An assertion cursor implementation for the db.
|
||||
//
|
||||
class DBGetSTCursor : public nsIRDFAssertionCursor
|
||||
{
|
||||
public:
|
||||
DBGetSTCursor(CompositeDataSourceImpl* db, nsIRDFNode* u,
|
||||
nsIRDFResource* property, PRBool inversep, PRBool tv);
|
||||
|
||||
virtual ~DBGetSTCursor();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFAssertionCursor interface
|
||||
NS_IMETHOD Advance();
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return mCurrentCursor->GetDataSource(aDataSource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return mCurrentCursor->GetSubject(aResource);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return mCurrentCursor->GetPredicate(aPredicate);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
|
||||
nsresult rv = mCurrentCursor->GetObject(aObject);
|
||||
#ifdef NS_DEBUG
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
Trace(mSource ? "GetTargets" : "GetSources", *aObject);
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return mCurrentCursor->GetTruthValue(aTruthValue);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
nsresult rv = mCurrentCursor->GetValue(aValue);
|
||||
#ifdef NS_DEBUG
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
Trace(mSource ? "GetTargets" : "GetSources", *aValue);
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
void Trace(const char* msg, nsIRDFNode* valueNode) {
|
||||
if (PR_LOG_TEST(nsRDFLog, PR_LOG_ALWAYS)) {
|
||||
nsresult rv;
|
||||
nsIRDFResource* subRes;
|
||||
nsIRDFResource* predRes;
|
||||
nsIRDFResource* valRes;
|
||||
const char* subject;
|
||||
const char* predicate;
|
||||
char* value;
|
||||
nsIRDFDataSource* ds;
|
||||
|
||||
rv = GetDataSource(&ds);
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = GetSubject(&subRes);
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = subRes->GetValue(&subject);
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = GetPredicate(&predRes);
|
||||
if (NS_FAILED(rv)) return;
|
||||
rv = predRes->GetValue(&predicate);
|
||||
if (NS_FAILED(rv)) return;
|
||||
if (NS_SUCCEEDED(valueNode->QueryInterface(nsIRDFResource::GetIID(), (void**)&valRes))) {
|
||||
rv = valRes->GetValue((const char**)&value);
|
||||
if (NS_FAILED(rv)) return;
|
||||
NS_RELEASE(valRes);
|
||||
value = PR_smprintf("%s", value); // freed below
|
||||
}
|
||||
else {
|
||||
value = PR_smprintf("<nsIRDFNode 0x%x>", valueNode);
|
||||
}
|
||||
if (value == nsnull) return;
|
||||
printf("RDF %s: datasource=0x%x\n subject: %s\n pred: %s\n value: %s\n",
|
||||
msg, ds, subject, predicate, value);
|
||||
NS_RELEASE(predRes);
|
||||
NS_RELEASE(subRes);
|
||||
PR_smprintf_free(value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
CompositeDataSourceImpl* mCompositeDataSourceImpl;
|
||||
nsIRDFResource* mSource;
|
||||
nsIRDFResource* mLabel;
|
||||
nsIRDFNode* mTarget;
|
||||
PRInt32 mCount;
|
||||
PRBool mTruthValue;
|
||||
nsIRDFAssertionCursor* mCurrentCursor;
|
||||
};
|
||||
|
||||
//NS_IMPL_ISUPPORTS(DBGetSTCursor, kIRDFAssertionCursorIID);
|
||||
|
||||
DBGetSTCursor::DBGetSTCursor(CompositeDataSourceImpl* db,
|
||||
nsIRDFNode* u,
|
||||
nsIRDFResource* property,
|
||||
PRBool inversep,
|
||||
PRBool tv)
|
||||
: mCompositeDataSourceImpl(db),
|
||||
mSource(nsnull),
|
||||
mLabel(property),
|
||||
mTarget(nsnull),
|
||||
mCount(0),
|
||||
mTruthValue(tv),
|
||||
mCurrentCursor(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mCompositeDataSourceImpl);
|
||||
|
||||
if (!inversep) {
|
||||
mSource = (nsIRDFResource*) u;
|
||||
} else {
|
||||
mTarget = u;
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(mSource);
|
||||
NS_IF_ADDREF(mTarget);
|
||||
NS_IF_ADDREF(mLabel);
|
||||
|
||||
// XXX assume that at least one data source exists in the CompositeDataSourceImpl.
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) db->mDataSources[mCount++];
|
||||
if (mSource)
|
||||
ds->GetTargets(mSource, mLabel, mTruthValue, &mCurrentCursor);
|
||||
else
|
||||
ds->GetSources(mLabel, mTarget, mTruthValue, &mCurrentCursor);
|
||||
}
|
||||
|
||||
|
||||
DBGetSTCursor::~DBGetSTCursor(void)
|
||||
{
|
||||
NS_IF_RELEASE(mCurrentCursor);
|
||||
NS_IF_RELEASE(mLabel);
|
||||
NS_IF_RELEASE(mSource);
|
||||
NS_IF_RELEASE(mTarget);
|
||||
NS_RELEASE(mCompositeDataSourceImpl);
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(DBGetSTCursor);
|
||||
NS_IMPL_RELEASE(DBGetSTCursor);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
DBGetSTCursor::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
DBGetSTCursor::Advance(void)
|
||||
{
|
||||
nsIRDFDataSource* ds;
|
||||
while (mCurrentCursor) {
|
||||
nsresult result = mCurrentCursor->Advance();
|
||||
while (NS_ERROR_RDF_CURSOR_EMPTY != result) {
|
||||
nsIRDFResource* src;
|
||||
nsIRDFNode* trg;
|
||||
mCurrentCursor->GetSubject(&src);
|
||||
mCurrentCursor->GetObject(&trg);
|
||||
if (!mCompositeDataSourceImpl->HasAssertionN(mCount-1, src, mLabel, trg, !mTruthValue)) {
|
||||
return NS_OK;
|
||||
} else {
|
||||
result = mCurrentCursor->Advance();
|
||||
}
|
||||
}
|
||||
|
||||
if (mCount >= mCompositeDataSourceImpl->mDataSources.Count())
|
||||
break;
|
||||
|
||||
ds = (nsIRDFDataSource*) mCompositeDataSourceImpl->mDataSources[mCount];
|
||||
++mCount;
|
||||
|
||||
NS_RELEASE(mCurrentCursor);
|
||||
|
||||
if (mSource)
|
||||
ds->GetTargets(mSource, mLabel, mTruthValue, &mCurrentCursor);
|
||||
else
|
||||
ds->GetSources(mLabel, mTarget, mTruthValue, &mCurrentCursor);
|
||||
}
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFCompositeDataSource(nsIRDFCompositeDataSource** result)
|
||||
{
|
||||
CompositeDataSourceImpl* db = new CompositeDataSourceImpl();
|
||||
if (! db)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*result = db;
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
CompositeDataSourceImpl::CompositeDataSourceImpl(void)
|
||||
: mObservers(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
#ifdef NS_DEBUG
|
||||
if (nsRDFLog == nsnull) {
|
||||
nsRDFLog = PR_NewLogModule("RDF");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CompositeDataSourceImpl::~CompositeDataSourceImpl(void)
|
||||
{
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
ds->RemoveObserver(this);
|
||||
NS_IF_RELEASE(ds);
|
||||
}
|
||||
delete mObservers;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(CompositeDataSourceImpl);
|
||||
NS_IMPL_RELEASE(CompositeDataSourceImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::QueryInterface(REFNSIID iid, void** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFCompositeDataSourceIID) ||
|
||||
iid.Equals(kIRDFDataSourceIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFCompositeDataSource*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
*result = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDataSource interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::Init(const char* uri)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_UNEXPECTED; // XXX CompositeDataSourceImpl doesn't have a URI?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetURI(const char* *uri) const
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_UNEXPECTED; // XXX CompositeDataSourceImpl doesn't have a URI?
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetSource(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFResource** source)
|
||||
{
|
||||
PRInt32 count = mDataSources.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
|
||||
if (NS_FAILED(ds->GetSource(property, target, tv, source)))
|
||||
continue;
|
||||
|
||||
// okay, found it. make sure we don't have the opposite
|
||||
// asserted in a more local data source
|
||||
if (!HasAssertionN(count-1, *source, property, target, !tv))
|
||||
return NS_OK;
|
||||
|
||||
NS_RELEASE(*source);
|
||||
return NS_ERROR_RDF_NO_VALUE;
|
||||
}
|
||||
return NS_ERROR_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetSources(nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** result)
|
||||
{
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*result = new DBGetSTCursor(this, target, property, 1, tv);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetTarget(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFNode** target)
|
||||
{
|
||||
PRInt32 count = mDataSources.Count();
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
|
||||
if (NS_FAILED(ds->GetTarget(source, property, tv, target)))
|
||||
continue;
|
||||
|
||||
// okay, found it. make sure we don't have the opposite
|
||||
// asserted in the "local" data source
|
||||
if (!HasAssertionN(count-1, source, property, *target, !tv))
|
||||
return NS_OK;
|
||||
|
||||
NS_RELEASE(*target);
|
||||
return NS_ERROR_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
return NS_ERROR_RDF_NO_VALUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
CompositeDataSourceImpl::HasAssertionN(int n,
|
||||
nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
int m = 0;
|
||||
PRBool result = 0;
|
||||
while (m < n) {
|
||||
nsIRDFDataSource* ds = (nsIRDFDataSource*) mDataSources[m];
|
||||
ds->HasAssertion(source, property, target, tv, &result);
|
||||
if (result) return 1;
|
||||
m++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetTargets(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
PRBool tv,
|
||||
nsIRDFAssertionCursor** targets)
|
||||
{
|
||||
if (! targets)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFAssertionCursor* result;
|
||||
result = new DBGetSTCursor(this, source, property, 0, tv);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*targets = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::Assert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv)
|
||||
{
|
||||
// Need to add back the stuff for unblocking ...
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_SUCCEEDED(ds->Assert(source, property, target, tv)))
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::Unassert(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target)
|
||||
{
|
||||
nsresult rv;
|
||||
PRInt32 count = mDataSources.Count();
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_FAILED(rv = ds->Unassert(source, property, target)))
|
||||
break;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
nsIRDFDataSource* ds0 = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[0]);
|
||||
rv = ds0->Assert(source, property, target, PR_FALSE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::HasAssertion(nsIRDFResource* source,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
||||
// Otherwise, look through all the data sources to see if anyone
|
||||
// has the positive...
|
||||
PRInt32 count = mDataSources.Count();
|
||||
PRBool hasNegation = 0;
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
if (NS_FAILED(rv = ds->HasAssertion(source, property, target, tv, hasAssertion)))
|
||||
return rv;
|
||||
|
||||
if (*hasAssertion)
|
||||
return NS_OK;
|
||||
|
||||
if (NS_FAILED(rv = ds->HasAssertion(source, property, target, !tv, &hasNegation)))
|
||||
return rv;
|
||||
|
||||
if (hasNegation) {
|
||||
*hasAssertion = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, nobody had the assertion at all
|
||||
*hasAssertion = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::AddObserver(nsIRDFObserver* obs)
|
||||
{
|
||||
if (!mObservers) {
|
||||
if ((mObservers = new nsVoidArray()) == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// XXX ensure uniqueness?
|
||||
|
||||
mObservers->AppendElement(obs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::RemoveObserver(nsIRDFObserver* obs)
|
||||
{
|
||||
if (!mObservers)
|
||||
return NS_OK;
|
||||
|
||||
mObservers->RemoveElement(obs);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::ArcLabelsIn(nsIRDFNode* node,
|
||||
nsIRDFArcsInCursor** labels)
|
||||
{
|
||||
if (! labels)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFArcsInCursor* result = new DBArcsInOutCursor(this, node, 0);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::ArcLabelsOut(nsIRDFResource* source,
|
||||
nsIRDFArcsOutCursor** labels)
|
||||
{
|
||||
if (! labels)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsIRDFArcsOutCursor* result = new DBArcsInOutCursor(this, source, 1);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(result);
|
||||
*labels = result;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::GetAllResources(nsIRDFResourceCursor** aCursor)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::Flush()
|
||||
{
|
||||
for (PRInt32 i = mDataSources.Count() - 1; i >= 0; --i) {
|
||||
nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
|
||||
ds->Flush();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::IsCommandEnabled(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget,
|
||||
PRBool* aResult)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::DoCommand(const char* aCommand,
|
||||
nsIRDFResource* aCommandTarget)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFCompositeDataSource methods
|
||||
// XXX rvg We should make this take an additional argument specifying where
|
||||
// in the sequence of data sources (of the db), the new data source should
|
||||
// fit in. Right now, the new datasource gets stuck at the end.
|
||||
// need to add the observers of the CompositeDataSourceImpl to the new data source.
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::AddDataSource(nsIRDFDataSource* source)
|
||||
{
|
||||
NS_ASSERTION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
mDataSources.InsertElementAt(source, 0);
|
||||
source->AddObserver(this);
|
||||
NS_ADDREF(source);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::RemoveDataSource(nsIRDFDataSource* source)
|
||||
{
|
||||
NS_ASSERTION(source != nsnull, "null ptr");
|
||||
if (! source)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
|
||||
if (mDataSources.IndexOf(source) >= 0) {
|
||||
mDataSources.RemoveElement(source);
|
||||
source->RemoveObserver(this);
|
||||
NS_RELEASE(source);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::OnAssert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
if (mObservers) {
|
||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||
obs->OnAssert(subject, predicate, object);
|
||||
// XXX ignore return value?
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
CompositeDataSourceImpl::OnUnassert(nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object)
|
||||
{
|
||||
if (mObservers) {
|
||||
for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
|
||||
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
|
||||
obs->OnUnassert(subject, predicate, object);
|
||||
// XXX ignore return value?
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
339
mozilla/rdf/base/src/nsContainerCursor.cpp
Normal file
339
mozilla/rdf/base/src/nsContainerCursor.cpp
Normal file
@@ -0,0 +1,339 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A simple cursor that enumerates the elements of an RDF container
|
||||
(RDF:Bag, RDF:Seq, or RDF:Alt).
|
||||
|
||||
Caveats
|
||||
-------
|
||||
|
||||
1. This uses an implementation-specific detail to determine the
|
||||
index of the last element in the container; specifically, the RDF
|
||||
utilities maintain a counter attribute on the container that
|
||||
holds the numeric value of the next value that is to be
|
||||
assigned. So, this cursor will bust if you use it with a bag that
|
||||
hasn't been created using the RDF utility routines.
|
||||
|
||||
2. This is sort of a continuation of (1), but -- it's not smart
|
||||
enough to notice duplicates.
|
||||
|
||||
TODO. This is way too brain dead to handle aggregated RDF
|
||||
databases. It needs to be upgraded in a big way.
|
||||
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "prlog.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, nextVal); // ad hoc way to make containers fast
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class ContainerCursorImpl : public nsIRDFAssertionCursor {
|
||||
private:
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
static nsIRDFResource* kRDF_nextVal;
|
||||
|
||||
nsIRDFDataSource* mDataSource;
|
||||
nsIRDFResource* mContainer;
|
||||
nsIRDFNode* mCurrent;
|
||||
nsIRDFResource* mOrdinalProperty;
|
||||
PRInt32 mNextIndex;
|
||||
|
||||
public:
|
||||
ContainerCursorImpl(nsIRDFDataSource* ds, nsIRDFResource* container);
|
||||
virtual ~ContainerCursorImpl(void);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Advance(void);
|
||||
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource);
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource);
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate);
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject);
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue);
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue);
|
||||
};
|
||||
|
||||
nsrefcnt ContainerCursorImpl::gRefCnt;
|
||||
nsIRDFResource* ContainerCursorImpl::kRDF_nextVal;
|
||||
|
||||
ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container)
|
||||
: mDataSource(ds),
|
||||
mContainer(container),
|
||||
mCurrent(nsnull),
|
||||
mOrdinalProperty(nsnull),
|
||||
mNextIndex(1)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_IF_ADDREF(mDataSource);
|
||||
NS_IF_ADDREF(mContainer);
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
nsresult rv;
|
||||
nsIRDFService* service;
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
(nsISupports**) &service);
|
||||
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
|
||||
if (! service)
|
||||
return;
|
||||
|
||||
NS_VERIFY(NS_SUCCEEDED(rv = service->GetResource(kURIRDF_nextVal, &kRDF_nextVal)),
|
||||
"unable to get resource");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ContainerCursorImpl::~ContainerCursorImpl(void)
|
||||
{
|
||||
NS_IF_RELEASE(mCurrent);
|
||||
NS_IF_RELEASE(mOrdinalProperty);
|
||||
|
||||
NS_IF_RELEASE(mContainer);
|
||||
NS_IF_RELEASE(mDataSource);
|
||||
|
||||
if (--gRefCnt == 0) {
|
||||
NS_IF_RELEASE(kRDF_nextVal);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(ContainerCursorImpl);
|
||||
NS_IMPL_RELEASE(ContainerCursorImpl);
|
||||
|
||||
NS_IMETHODIMP_(nsresult)
|
||||
ContainerCursorImpl::QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::Advance(void)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// release the last value that we were holding
|
||||
NS_IF_RELEASE(mCurrent);
|
||||
|
||||
nsIRDFNode* nextNode = nsnull;
|
||||
nsIRDFLiteral* nextVal = nsnull;
|
||||
const PRUnichar* p;
|
||||
nsAutoString s;
|
||||
PRInt32 last;
|
||||
PRInt32 err;
|
||||
|
||||
// Figure out the upper bound so we'll know when we're done.
|
||||
|
||||
// XXX we could cache all this crap when the cursor gets created.
|
||||
if (NS_FAILED(rv = mDataSource->GetTarget(mContainer, kRDF_nextVal, PR_TRUE, &nextNode)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextNode->QueryInterface(kIRDFLiteralIID, (void**) &nextVal)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = nextVal->GetValue(&p)))
|
||||
goto done;
|
||||
|
||||
s = p;
|
||||
last = s.ToInteger(&err);
|
||||
if (NS_FAILED(err))
|
||||
goto done;
|
||||
|
||||
// initialize rv to the case where mNextIndex has advanced past the
|
||||
// last element
|
||||
rv = NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
|
||||
while (mNextIndex < last) {
|
||||
NS_IF_RELEASE(mOrdinalProperty);
|
||||
if (NS_FAILED(rv = rdf_IndexToOrdinalResource(mNextIndex, &mOrdinalProperty)))
|
||||
break;
|
||||
|
||||
rv = mDataSource->GetTarget(mContainer, mOrdinalProperty, PR_TRUE, &mCurrent);
|
||||
|
||||
++mNextIndex;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Don't bother releasing mCurrent; we'll let the AddRef
|
||||
// serve as the implicit addref that GetNext() should
|
||||
// perform.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(nextNode);
|
||||
NS_IF_RELEASE(nextVal);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetDataSource(nsIRDFDataSource** aDataSource)
|
||||
{
|
||||
NS_PRECONDITION(aDataSource != nsnull, "null ptr");
|
||||
if (! aDataSource)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(mDataSource);
|
||||
*aDataSource = mDataSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetSubject(nsIRDFResource** aSubject)
|
||||
{
|
||||
NS_PRECONDITION(aSubject != nsnull, "null ptr");
|
||||
if (! aSubject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ADDREF(mContainer);
|
||||
*aSubject = mContainer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetPredicate(nsIRDFResource** aPredicate)
|
||||
{
|
||||
NS_PRECONDITION(aPredicate != nsnull, "null ptr");
|
||||
if (! aPredicate)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(mOrdinalProperty, "unexpected");
|
||||
if (! mOrdinalProperty)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
NS_ADDREF(mOrdinalProperty);
|
||||
*aPredicate = mOrdinalProperty;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetObject(nsIRDFNode** aObject)
|
||||
{
|
||||
NS_PRECONDITION(aObject != nsnull, "null ptr");
|
||||
if (! aObject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(mCurrent, "unexpected");
|
||||
if (! mCurrent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
NS_ADDREF(mCurrent);
|
||||
*aObject = mCurrent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetValue(nsIRDFNode** aObject)
|
||||
{
|
||||
NS_PRECONDITION(aObject != nsnull, "null ptr");
|
||||
if (! aObject)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (! mCurrent)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
NS_ADDREF(mCurrent);
|
||||
*aObject = mCurrent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContainerCursorImpl::GetTruthValue(PRBool* aTruthValue)
|
||||
{
|
||||
NS_PRECONDITION(aTruthValue != nsnull, "null ptr");
|
||||
if (! aTruthValue)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aTruthValue = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewContainerCursor(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFAssertionCursor** cursor)
|
||||
{
|
||||
NS_PRECONDITION(ds != nsnull, "null ptr");
|
||||
NS_PRECONDITION(container != nsnull, "null ptr");
|
||||
NS_PRECONDITION(cursor != nsnull, "null ptr");
|
||||
|
||||
if (!ds || !container || !cursor)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_ASSERTION(rdf_IsContainer(ds, container), "not a container");
|
||||
if (! rdf_IsContainer(ds, container))
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
ContainerCursorImpl* result = new ContainerCursorImpl(ds, container);
|
||||
if (! result)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
*cursor = result;
|
||||
NS_ADDREF(result);
|
||||
return NS_OK;
|
||||
}
|
||||
43
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
43
mozilla/rdf/base/src/nsDefaultResourceFactory.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The default resource factory implementation. This resource factory
|
||||
produces nsIRDFResource objects for any URI prefix that is not
|
||||
covered by some other factory.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsRDFResource.h"
|
||||
|
||||
nsresult
|
||||
NS_NewDefaultResource(nsIRDFResource** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRDFResource* resource = new nsRDFResource();
|
||||
if (! resource)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(resource);
|
||||
*aResult = resource;
|
||||
return NS_OK;
|
||||
}
|
||||
240
mozilla/rdf/base/src/nsEmptyCursor.cpp
Normal file
240
mozilla/rdf/base/src/nsEmptyCursor.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A set of "empty cursors" (nsIRDFAssertionCursor,
|
||||
nsIRDFArcsOutCursor, nsIRDFArcsInCursor) that can be used to ensure
|
||||
that the data source methods which return a cursor always return
|
||||
*something*.
|
||||
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
|
||||
static NS_DEFINE_IID(kIRDFArcsInCursorIID, NS_IRDFARCSINCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFArcsOutCursorIID, NS_IRDFARCSOUTCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
|
||||
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyAssertionCursorImpl : public nsIRDFAssertionCursor
|
||||
{
|
||||
public:
|
||||
EmptyAssertionCursorImpl(void) {};
|
||||
virtual ~EmptyAssertionCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFAssertionCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFAssertionCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFAssertionCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aObject) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFAssertionCursor(nsIRDFAssertionCursor** result)
|
||||
{
|
||||
static EmptyAssertionCursorImpl gEmptyAssertionCursor;
|
||||
*result = &gEmptyAssertionCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyArcsOutCursorImpl : public nsIRDFArcsOutCursor
|
||||
{
|
||||
public:
|
||||
EmptyArcsOutCursorImpl(void) {};
|
||||
virtual ~EmptyArcsOutCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsOutCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsOutCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFArcsOutCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSubject(nsIRDFResource** aResource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFArcsOutCursor(nsIRDFArcsOutCursor** result)
|
||||
{
|
||||
static EmptyArcsOutCursorImpl gEmptyArcsOutCursor;
|
||||
*result = &gEmptyArcsOutCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class EmptyArcsInCursorImpl : public nsIRDFArcsInCursor
|
||||
{
|
||||
public:
|
||||
EmptyArcsInCursorImpl(void) {};
|
||||
virtual ~EmptyArcsInCursorImpl(void) {};
|
||||
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
NS_IMETHOD_(nsrefcnt) Release(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHOD QueryInterface(REFNSIID iid, void** result) {
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFArcsInCursorIID) ||
|
||||
iid.Equals(kIRDFCursorIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*result = NS_STATIC_CAST(nsIRDFArcsInCursor*, this);
|
||||
/* AddRef(); // not necessary */
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
// nsIRDFCursor
|
||||
NS_IMETHOD Advance(void) {
|
||||
return NS_ERROR_RDF_CURSOR_EMPTY;
|
||||
}
|
||||
|
||||
// nsIRDFArcsInCursor
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource** aDataSource) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetPredicate(nsIRDFResource** aPredicate) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetObject(nsIRDFNode** aNode) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetTruthValue(PRBool* aTruthValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetValue(nsIRDFNode** aValue) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
nsresult
|
||||
NS_NewEmptyRDFArcsInCursor(nsIRDFArcsInCursor** result)
|
||||
{
|
||||
static EmptyArcsInCursorImpl gEmptyArcsInCursor;
|
||||
*result = &gEmptyArcsInCursor;
|
||||
return NS_OK;
|
||||
}
|
||||
1474
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
1474
mozilla/rdf/base/src/nsInMemoryDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
40
mozilla/rdf/base/src/nsRDFBaseDataSources.h
Normal file
40
mozilla/rdf/base/src/nsRDFBaseDataSources.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
This header file just contains prototypes for the factory methods
|
||||
for "builtin" data sources that are included in rdf.dll.
|
||||
|
||||
Each of these data sources is exposed to the external world via its
|
||||
CID in ../include/nsRDFCID.h.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsBaseDataSources_h__
|
||||
#define nsBaseDataSources_h__
|
||||
|
||||
#include "nsError.h"
|
||||
class nsIRDFDataSource;
|
||||
|
||||
// in nsInMemoryDataSource.cpp
|
||||
nsresult NS_NewRDFInMemoryDataSource(nsIRDFDataSource** result);
|
||||
|
||||
#endif // nsBaseDataSources_h__
|
||||
|
||||
|
||||
1326
mozilla/rdf/base/src/nsRDFContentSink.cpp
Normal file
1326
mozilla/rdf/base/src/nsRDFContentSink.cpp
Normal file
File diff suppressed because it is too large
Load Diff
137
mozilla/rdf/base/src/nsRDFContentSink.h
Normal file
137
mozilla/rdf/base/src/nsRDFContentSink.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFContentSink_h__
|
||||
#define nsRDFContentSink_h__
|
||||
|
||||
#include "nsIRDFContentSink.h"
|
||||
|
||||
class nsIURL;
|
||||
class nsVoidArray;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFService;
|
||||
class nsINameSpaceManager;
|
||||
|
||||
typedef enum {
|
||||
eRDFContentSinkState_InProlog,
|
||||
eRDFContentSinkState_InDocumentElement,
|
||||
eRDFContentSinkState_InDescriptionElement,
|
||||
eRDFContentSinkState_InContainerElement,
|
||||
eRDFContentSinkState_InPropertyElement,
|
||||
eRDFContentSinkState_InMemberElement,
|
||||
eRDFContentSinkState_InEpilog
|
||||
} RDFContentSinkState;
|
||||
|
||||
|
||||
class RDFContentSinkImpl : public nsIRDFContentSink
|
||||
{
|
||||
public:
|
||||
RDFContentSinkImpl();
|
||||
virtual ~RDFContentSinkImpl();
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIContentSink
|
||||
NS_IMETHOD WillBuildModel(void);
|
||||
NS_IMETHOD DidBuildModel(PRInt32 aQualityLevel);
|
||||
NS_IMETHOD WillInterrupt(void);
|
||||
NS_IMETHOD WillResume(void);
|
||||
NS_IMETHOD SetParser(nsIParser* aParser);
|
||||
NS_IMETHOD OpenContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD CloseContainer(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddLeaf(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddComment(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
|
||||
NS_IMETHOD NotifyError(nsresult aErrorResult);
|
||||
|
||||
// nsIXMLContentSink
|
||||
NS_IMETHOD AddXMLDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddDocTypeDecl(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddCharacterData(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddUnparsedEntity(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddNotation(const nsIParserNode& aNode);
|
||||
NS_IMETHOD AddEntityReference(const nsIParserNode& aNode);
|
||||
|
||||
// nsIRDFContentSink
|
||||
NS_IMETHOD SetDataSource(nsIRDFDataSource* ds);
|
||||
NS_IMETHOD GetDataSource(nsIRDFDataSource*& ds);
|
||||
NS_IMETHOD Init(nsIURL* aURL, nsINameSpaceManager* aNameSpaceManager);
|
||||
|
||||
protected:
|
||||
// Text management
|
||||
nsresult FlushText(PRBool aCreateTextNode=PR_TRUE,
|
||||
PRBool* aDidFlush=nsnull);
|
||||
|
||||
PRUnichar* mText;
|
||||
PRInt32 mTextLength;
|
||||
PRInt32 mTextSize;
|
||||
PRBool mConstrainSize;
|
||||
|
||||
// namespace management
|
||||
void PushNameSpacesFrom(const nsIParserNode& aNode);
|
||||
nsIAtom* CutNameSpacePrefix(nsString& aString);
|
||||
PRInt32 GetNameSpaceID(nsIAtom* aPrefix);
|
||||
void GetNameSpaceURI(PRInt32 aID, nsString& aURI);
|
||||
void PopNameSpaces();
|
||||
|
||||
nsINameSpaceManager* mNameSpaceManager;
|
||||
nsVoidArray* mNameSpaceStack;
|
||||
PRInt32 mRDFNameSpaceID;
|
||||
|
||||
void SplitQualifiedName(const nsString& aQualifiedName,
|
||||
PRInt32& rNameSpaceID,
|
||||
nsString& rProperty);
|
||||
|
||||
// RDF-specific parsing
|
||||
nsresult GetIdAboutAttribute(const nsIParserNode& aNode, nsString& rResource);
|
||||
nsresult GetResourceAttribute(const nsIParserNode& aNode, nsString& rResource);
|
||||
nsresult AddProperties(const nsIParserNode& aNode, nsIRDFResource* aSubject);
|
||||
|
||||
virtual nsresult OpenRDF(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenObject(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenProperty(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenMember(const nsIParserNode& aNode);
|
||||
virtual nsresult OpenValue(const nsIParserNode& aNode);
|
||||
|
||||
// Miscellaneous RDF junk
|
||||
nsIRDFService* mRDFService;
|
||||
nsIRDFDataSource* mDataSource;
|
||||
RDFContentSinkState mState;
|
||||
|
||||
// content stack management
|
||||
PRInt32 PushContext(nsIRDFResource *aContext, RDFContentSinkState aState);
|
||||
nsresult PopContext(nsIRDFResource*& rContext, RDFContentSinkState& rState);
|
||||
nsIRDFResource* GetContextElement(PRInt32 ancestor = 0);
|
||||
|
||||
nsVoidArray* mContextStack;
|
||||
|
||||
nsIURL* mDocumentURL;
|
||||
PRUint32 mGenSym; // for generating anonymous resources
|
||||
};
|
||||
|
||||
|
||||
#endif // nsRDFContentSink_h__
|
||||
1783
mozilla/rdf/base/src/nsRDFInterfaces.cpp
Normal file
1783
mozilla/rdf/base/src/nsRDFInterfaces.cpp
Normal file
File diff suppressed because it is too large
Load Diff
245
mozilla/rdf/base/src/nsRDFParserUtils.cpp
Normal file
245
mozilla/rdf/base/src/nsRDFParserUtils.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Some useful parsing routines.
|
||||
|
||||
This isn't the best place for them: I wish that they'd go into some
|
||||
shared area (like mozilla/base).
|
||||
|
||||
*/
|
||||
|
||||
#include <stdlib.h> // XXX for atoi(), maybe this should go into nsCRT?
|
||||
#include "nsCRT.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsString.h"
|
||||
#include "nsRDFParserUtils.h"
|
||||
|
||||
// XXX This totally sucks. I wish that mozilla/base had this code.
|
||||
PRUnichar
|
||||
nsRDFParserUtils::EntityToUnicode(const char* buf)
|
||||
{
|
||||
if ((buf[0] == 'g' || buf[0] == 'G') &&
|
||||
(buf[1] == 't' || buf[1] == 'T'))
|
||||
return PRUnichar('>');
|
||||
|
||||
if ((buf[0] == 'l' || buf[0] == 'L') &&
|
||||
(buf[1] == 't' || buf[1] == 'T'))
|
||||
return PRUnichar('<');
|
||||
|
||||
if ((buf[0] == 'a' || buf[0] == 'A') &&
|
||||
(buf[1] == 'm' || buf[1] == 'M') &&
|
||||
(buf[2] == 'p' || buf[2] == 'P'))
|
||||
return PRUnichar('&');
|
||||
|
||||
NS_NOTYETIMPLEMENTED("this is a named entity that I can't handle...");
|
||||
return PRUnichar('?');
|
||||
}
|
||||
|
||||
// XXX Code copied from nsHTMLContentSink. It should be shared.
|
||||
void
|
||||
nsRDFParserUtils::StripAndConvert(nsString& aResult)
|
||||
{
|
||||
// Strip quotes if present
|
||||
PRUnichar first = aResult.First();
|
||||
if ((first == '"') || (first == '\'')) {
|
||||
if (aResult.Last() == first) {
|
||||
aResult.Cut(0, 1);
|
||||
PRInt32 pos = aResult.Length() - 1;
|
||||
if (pos >= 0) {
|
||||
aResult.Cut(pos, 1);
|
||||
}
|
||||
} else {
|
||||
// Mismatched quotes - leave them in
|
||||
}
|
||||
}
|
||||
|
||||
// Reduce any entities
|
||||
// XXX Note: as coded today, this will only convert well formed
|
||||
// entities. This may not be compatible enough.
|
||||
// XXX there is a table in navigator that translates some numeric entities
|
||||
// should we be doing that? If so then it needs to live in two places (bad)
|
||||
// so we should add a translate numeric entity method from the parser...
|
||||
char cbuf[100];
|
||||
PRInt32 index = 0;
|
||||
while (index < aResult.Length()) {
|
||||
// If we have the start of an entity (and it's not at the end of
|
||||
// our string) then translate the entity into it's unicode value.
|
||||
if ((aResult.CharAt(index++) == '&') && (index < aResult.Length())) {
|
||||
PRInt32 start = index - 1;
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == '#') {
|
||||
// Convert a numeric character reference
|
||||
index++;
|
||||
char* cp = cbuf;
|
||||
char* limit = cp + sizeof(cbuf) - 1;
|
||||
PRBool ok = PR_FALSE;
|
||||
PRInt32 slen = aResult.Length();
|
||||
while ((index < slen) && (cp < limit)) {
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == ';') {
|
||||
index++;
|
||||
ok = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
if ((e >= '0') && (e <= '9')) {
|
||||
*cp++ = char(e);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!ok || (cp == cbuf)) {
|
||||
continue;
|
||||
}
|
||||
*cp = '\0';
|
||||
if (cp - cbuf > 5) {
|
||||
continue;
|
||||
}
|
||||
PRInt32 ch = PRInt32( ::atoi(cbuf) );
|
||||
if (ch > 65535) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove entity from string and replace it with the integer
|
||||
// value.
|
||||
aResult.Cut(start, index - start);
|
||||
aResult.Insert(PRUnichar(ch), start);
|
||||
index = start + 1;
|
||||
}
|
||||
else if (((e >= 'A') && (e <= 'Z')) ||
|
||||
((e >= 'a') && (e <= 'z'))) {
|
||||
// Convert a named entity
|
||||
index++;
|
||||
char* cp = cbuf;
|
||||
char* limit = cp + sizeof(cbuf) - 1;
|
||||
*cp++ = char(e);
|
||||
PRBool ok = PR_FALSE;
|
||||
PRInt32 slen = aResult.Length();
|
||||
while ((index < slen) && (cp < limit)) {
|
||||
PRUnichar e = aResult.CharAt(index);
|
||||
if (e == ';') {
|
||||
index++;
|
||||
ok = PR_TRUE;
|
||||
break;
|
||||
}
|
||||
if (((e >= '0') && (e <= '9')) ||
|
||||
((e >= 'A') && (e <= 'Z')) ||
|
||||
((e >= 'a') && (e <= 'z'))) {
|
||||
*cp++ = char(e);
|
||||
index++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!ok || (cp == cbuf)) {
|
||||
continue;
|
||||
}
|
||||
*cp = '\0';
|
||||
PRInt32 ch;
|
||||
|
||||
// XXX Um, here's where we should be converting a
|
||||
// named entity. I removed this to avoid a link-time
|
||||
// dependency on core raptor.
|
||||
ch = EntityToUnicode(cbuf);
|
||||
|
||||
if (ch < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove entity from string and replace it with the integer
|
||||
// value.
|
||||
aResult.Cut(start, index - start);
|
||||
aResult.Insert(PRUnichar(ch), start);
|
||||
index = start + 1;
|
||||
}
|
||||
else if (e == '{') {
|
||||
// Convert a script entity
|
||||
// XXX write me!
|
||||
NS_NOTYETIMPLEMENTED("convert a script entity");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRDFParserUtils::GetQuotedAttributeValue(const nsString& aSource,
|
||||
const nsString& aAttribute,
|
||||
nsString& aValue)
|
||||
{
|
||||
static const char kQuote = '\"';
|
||||
static const char kApostrophe = '\'';
|
||||
|
||||
PRInt32 offset;
|
||||
PRInt32 endOffset = -1;
|
||||
nsresult result = NS_OK;
|
||||
|
||||
offset = aSource.Find(aAttribute);
|
||||
if (-1 != offset) {
|
||||
offset = aSource.Find('=', offset);
|
||||
|
||||
PRUnichar next = aSource.CharAt(++offset);
|
||||
if (kQuote == next) {
|
||||
endOffset = aSource.Find(kQuote, ++offset);
|
||||
}
|
||||
else if (kApostrophe == next) {
|
||||
endOffset = aSource.Find(kApostrophe, ++offset);
|
||||
}
|
||||
|
||||
if (-1 != endOffset) {
|
||||
aSource.Mid(aValue, offset, endOffset-offset);
|
||||
}
|
||||
else {
|
||||
// Mismatched quotes - return an error
|
||||
result = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aValue.Truncate();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
nsRDFParserUtils::IsJavaScriptLanguage(const nsString& aName)
|
||||
{
|
||||
if (aName.EqualsIgnoreCase("JavaScript") ||
|
||||
aName.EqualsIgnoreCase("LiveScript") ||
|
||||
aName.EqualsIgnoreCase("Mocha")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.1")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.2")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.3")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else if (aName.EqualsIgnoreCase("JavaScript1.4")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
else {
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
56
mozilla/rdf/base/src/nsRDFParserUtils.h
Normal file
56
mozilla/rdf/base/src/nsRDFParserUtils.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Some useful parsing routines.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFParserUtils_h__
|
||||
#define nsRDFParserUtils_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsError.h"
|
||||
class nsIURL;
|
||||
class nsString;
|
||||
|
||||
class nsRDFParserUtils {
|
||||
public:
|
||||
static PRUnichar
|
||||
EntityToUnicode(const char* buf);
|
||||
|
||||
static void
|
||||
StripAndConvert(nsString& aResult);
|
||||
|
||||
static nsresult
|
||||
GetQuotedAttributeValue(const nsString& aSource,
|
||||
const nsString& aAttribute,
|
||||
nsString& aValue);
|
||||
|
||||
|
||||
static PRBool
|
||||
IsJavaScriptLanguage(const nsString& aName);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // nsRDFPasrserUtils_h__
|
||||
|
||||
1004
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
1004
mozilla/rdf/base/src/nsRDFService.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1452
mozilla/rdf/base/src/nsRDFXMLDataSource.cpp
Normal file
1452
mozilla/rdf/base/src/nsRDFXMLDataSource.cpp
Normal file
File diff suppressed because it is too large
Load Diff
186
mozilla/rdf/base/src/rdf_qsort.c
Normal file
186
mozilla/rdf/base/src/rdf_qsort.c
Normal file
@@ -0,0 +1,186 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* We need this because Solaris' version of qsort is broken and
|
||||
* causes array bounds reads.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "prtypes.h"
|
||||
|
||||
#if !defined(DEBUG) && (defined(__cplusplus) || defined(__gcc))
|
||||
# ifndef INLINE
|
||||
# define INLINE inline
|
||||
# endif
|
||||
#else
|
||||
# define INLINE
|
||||
#endif
|
||||
|
||||
typedef int cmp_t(const void *, const void *, void *);
|
||||
static INLINE char *med3(char *, char *, char *, cmp_t *, void *);
|
||||
static INLINE void swapfunc(char *, char *, int, int);
|
||||
|
||||
/*
|
||||
* Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
|
||||
*/
|
||||
#define swapcode(TYPE, parmi, parmj, n) { \
|
||||
long i = (n) / sizeof (TYPE); \
|
||||
register TYPE *pi = (TYPE *) (parmi); \
|
||||
register TYPE *pj = (TYPE *) (parmj); \
|
||||
do { \
|
||||
register TYPE t = *pi; \
|
||||
*pi++ = *pj; \
|
||||
*pj++ = t; \
|
||||
} while (--i > 0); \
|
||||
}
|
||||
|
||||
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
||||
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
||||
|
||||
static INLINE void
|
||||
swapfunc(a, b, n, swaptype)
|
||||
char *a, *b;
|
||||
int n, swaptype;
|
||||
{
|
||||
if(swaptype <= 1)
|
||||
swapcode(long, a, b, n)
|
||||
else
|
||||
swapcode(char, a, b, n)
|
||||
}
|
||||
|
||||
#define swap(a, b) \
|
||||
if (swaptype == 0) { \
|
||||
long t = *(long *)(a); \
|
||||
*(long *)(a) = *(long *)(b); \
|
||||
*(long *)(b) = t; \
|
||||
} else \
|
||||
swapfunc(a, b, es, swaptype)
|
||||
|
||||
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
|
||||
|
||||
static INLINE char *
|
||||
med3(a, b, c, cmp, data)
|
||||
char *a, *b, *c;
|
||||
cmp_t *cmp;
|
||||
void *data;
|
||||
{
|
||||
return cmp(a, b, data) < 0 ?
|
||||
(cmp(b, c, data) < 0 ? b : (cmp(a, c, data) < 0 ? c : a ))
|
||||
:(cmp(b, c, data) > 0 ? b : (cmp(a, c, data) < 0 ? a : c ));
|
||||
}
|
||||
|
||||
void rdf_qsort (
|
||||
void *a,
|
||||
unsigned n,
|
||||
unsigned es,
|
||||
cmp_t *cmp,
|
||||
void *data
|
||||
)
|
||||
{
|
||||
char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
|
||||
int d, r, swaptype, swap_cnt;
|
||||
|
||||
loop: SWAPINIT(a, es);
|
||||
swap_cnt = 0;
|
||||
if (n < 7) {
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
pl -= es)
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
pm = (char *)a + (n / 2) * es;
|
||||
if (n > 7) {
|
||||
pl = a;
|
||||
pn = (char *)a + (n - 1) * es;
|
||||
if (n > 40) {
|
||||
d = (n / 8) * es;
|
||||
pl = med3(pl, pl + d, pl + 2 * d, cmp, data);
|
||||
pm = med3(pm - d, pm, pm + d, cmp, data);
|
||||
pn = med3(pn - 2 * d, pn - d, pn, cmp, data);
|
||||
}
|
||||
pm = med3(pl, pm, pn, cmp, data);
|
||||
}
|
||||
swap(a, pm);
|
||||
pa = pb = (char *)a + es;
|
||||
|
||||
pc = pd = (char *)a + (n - 1) * es;
|
||||
for (;;) {
|
||||
while (pb <= pc && (r = cmp(pb, a, data)) <= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pa, pb);
|
||||
pa += es;
|
||||
}
|
||||
pb += es;
|
||||
}
|
||||
while (pb <= pc && (r = cmp(pc, a, data)) >= 0) {
|
||||
if (r == 0) {
|
||||
swap_cnt = 1;
|
||||
swap(pc, pd);
|
||||
pd -= es;
|
||||
}
|
||||
pc -= es;
|
||||
}
|
||||
if (pb > pc)
|
||||
break;
|
||||
swap(pb, pc);
|
||||
swap_cnt = 1;
|
||||
pb += es;
|
||||
pc -= es;
|
||||
}
|
||||
if (swap_cnt == 0) { /* Switch to insertion sort */
|
||||
for (pm = (char *)a + es; pm < (char *)a + n * es; pm += es)
|
||||
for (pl = pm; pl > (char *)a && cmp(pl - es, pl, data) > 0;
|
||||
pl -= es)
|
||||
swap(pl, pl - es);
|
||||
return;
|
||||
}
|
||||
|
||||
pn = (char *)a + n * es;
|
||||
r = PR_MIN(pa - (char *)a, pb - pa);
|
||||
vecswap(a, pb - r, r);
|
||||
r = PR_MIN(pd - pc, pn - pd - es);
|
||||
vecswap(pb, pn - r, r);
|
||||
if ((r = pb - pa) > es)
|
||||
rdf_qsort(a, r / es, es, cmp, data);
|
||||
if ((r = pd - pc) > es) {
|
||||
/* Iterate rather than recurse to save stack space */
|
||||
a = pn - r;
|
||||
n = r / es;
|
||||
goto loop;
|
||||
}
|
||||
/* rdf_qsort(pn - r, r / es, es, cmp, data);*/
|
||||
}
|
||||
1118
mozilla/rdf/base/src/rdfutil.cpp
Normal file
1118
mozilla/rdf/base/src/rdfutil.cpp
Normal file
File diff suppressed because it is too large
Load Diff
244
mozilla/rdf/base/src/rdfutil.h
Normal file
244
mozilla/rdf/base/src/rdfutil.h
Normal file
@@ -0,0 +1,244 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A bunch of useful RDF utility routines. Many of these will
|
||||
eventually be exported outside of RDF.DLL via the nsIRDFService
|
||||
interface.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef rdfutil_h__
|
||||
#define rdfutil_h__
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsIRDFArcsInCursor;
|
||||
class nsIRDFArcsOutCursor;
|
||||
class nsIRDFAssertionCursor;
|
||||
class nsIRDFCursor;
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFResource;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
class nsString;
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if the URI is an RDF ordinal property; e.g., rdf:_1,
|
||||
* rdf:_2, etc.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsOrdinalProperty(const nsIRDFResource* property);
|
||||
|
||||
/**
|
||||
* Converts an ordinal property to an index
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_OrdinalResourceToIndex(nsIRDFResource* aOrdinal, PRInt32* aIndex);
|
||||
|
||||
/**
|
||||
* Converts an index to an ordinal property
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_IndexToOrdinalResource(PRInt32 aIndex, nsIRDFResource** aOrdinal);
|
||||
|
||||
|
||||
/**
|
||||
* Returns PR_TRUE if the resource is a container resource; e.g., an
|
||||
* rdf:Bag.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsContainer(nsIRDFDataSource* db,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsBag(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aResource);
|
||||
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsSeq(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aResource);
|
||||
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsAlt(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aResource);
|
||||
|
||||
/**
|
||||
* Various utilities routines for making assertions in a data source
|
||||
*/
|
||||
|
||||
// 0. node, node, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// 1. string, string, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 2. node, node, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
nsIRDFResource* predicate,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 3. node, string, string
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
const nsString& objectURI);
|
||||
|
||||
// 4. node, string, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* subject,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object);
|
||||
|
||||
// 5. string, string, node
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_Assert(nsIRDFDataSource* ds,
|
||||
const nsString& subjectURI,
|
||||
const nsString& predicateURI,
|
||||
nsIRDFNode* object);
|
||||
|
||||
/**
|
||||
* Construct a new, "anonymous" node; that is, a node with an internal
|
||||
* resource URI.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_CreateAnonymousResource(const nsString& aContextURI, nsIRDFResource** result);
|
||||
|
||||
/**
|
||||
* Determine if a resource is an "anonymous" resource that we've constructed
|
||||
* ourselves.
|
||||
*/
|
||||
PR_EXTERN(PRBool)
|
||||
rdf_IsAnonymousResource(const nsString& aContextURI, nsIRDFResource* aResource);
|
||||
|
||||
/**
|
||||
* Try to convert the absolute URL into a relative URL.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeRelative(const nsString& aContextURI, nsString& aURI);
|
||||
|
||||
|
||||
/**
|
||||
* Try to convert the possibly-relative URL into an absolute URL.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_PossiblyMakeAbsolute(const nsString& aContextURI, nsString& aURI);
|
||||
|
||||
/**
|
||||
* Create a bag resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeBag(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
/**
|
||||
* Create a sequence resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeSeq(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
/**
|
||||
* Create an alternation resource.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_MakeAlt(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* resource);
|
||||
|
||||
|
||||
/**
|
||||
* Add an element to the end of container.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_ContainerAppendElement(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFNode* element);
|
||||
|
||||
|
||||
/**
|
||||
* Remove an element from a container
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_ContainerRemoveElement(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer,
|
||||
nsIRDFNode* aElement);
|
||||
|
||||
|
||||
/**
|
||||
* Insert an element into a container at the specified index.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_ContainerInsertElementAt(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer,
|
||||
nsIRDFNode* aElement,
|
||||
PRInt32 aIndex);
|
||||
|
||||
/**
|
||||
* Determine the index of an element in a container.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
rdf_ContainerIndexOf(nsIRDFDataSource* aDataSource,
|
||||
nsIRDFResource* aContainer,
|
||||
nsIRDFNode* aElement,
|
||||
PRInt32* aIndex);
|
||||
|
||||
|
||||
/**
|
||||
* Create a cursor on a container that enumerates its contents in
|
||||
* order
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewContainerCursor(nsIRDFDataSource* ds,
|
||||
nsIRDFResource* container,
|
||||
nsIRDFAssertionCursor** cursor);
|
||||
|
||||
|
||||
/**
|
||||
* Create an empty nsIRDFCursor. This will *never* fail, and will *always*
|
||||
* return the same object.
|
||||
*/
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFAssertionCursor(nsIRDFAssertionCursor** result);
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFArcsInCursor(nsIRDFArcsInCursor** result);
|
||||
|
||||
PR_EXTERN(nsresult)
|
||||
NS_NewEmptyRDFArcsOutCursor(nsIRDFArcsOutCursor** result);
|
||||
|
||||
PR_EXTERN(void) SHTtest ();
|
||||
// XXX need to move nsEmptyCursor stuff here.
|
||||
|
||||
#endif // rdfutil_h__
|
||||
|
||||
|
||||
1
mozilla/rdf/build/MANIFEST
Normal file
1
mozilla/rdf/build/MANIFEST
Normal file
@@ -0,0 +1 @@
|
||||
nsRDFCID.h
|
||||
76
mozilla/rdf/build/Makefile.in
Normal file
76
mozilla/rdf/build/Makefile.in
Normal file
@@ -0,0 +1,76 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = rdf
|
||||
IS_COMPONENT = 1
|
||||
|
||||
CPPSRCS = \
|
||||
dlldeps.cpp \
|
||||
nsRDFFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsRDFCID.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
REQUIRES = dom js netlib rdf raptor xpcom
|
||||
|
||||
# XXX Note dependencies on implementation headers for factory functions
|
||||
|
||||
INCLUDES += -I$(srcdir)/../base/src \
|
||||
-I$(srcdir)/../content/src \
|
||||
-I$(srcdir)/../datasource/src \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/librdfbase_s.a \
|
||||
$(DIST)/lib/librdfcontent_s.a \
|
||||
$(DIST)/lib/librdfdatasource_s.a \
|
||||
$(DIST)/lib/librdfutil_s.a \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MKSHLIB_FORCE_ALL) \
|
||||
$(SHARED_LIBRARY_LIBS) \
|
||||
$(MKSHLIB_UNFORCE_ALL) \
|
||||
-L$(DIST)/bin \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
$(SHARED_LIBRARY): $(SHARED_LIBRARY_LIBS) Makefile
|
||||
|
||||
install:: $(TARGETS)
|
||||
$(INSTALL) $(srcdir)/../resources/sidebar.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/sidebar.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.xul $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.css $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/bookmarks.html $(DIST)/bin/res/rdf
|
||||
$(INSTALL) $(srcdir)/../resources/History/h1.hst $(DIST)/bin/res/rdf/History
|
||||
63
mozilla/rdf/build/dlldeps.cpp
Normal file
63
mozilla/rdf/build/dlldeps.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nsRDFParserUtils.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsString.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
void XXXNeverCalled()
|
||||
{
|
||||
static nsAutoString s;
|
||||
|
||||
// nsRDFParserUtils
|
||||
nsRDFParserUtils::EntityToUnicode("");
|
||||
nsRDFParserUtils::StripAndConvert(s);
|
||||
nsRDFParserUtils::GetQuotedAttributeValue(s, s, s);
|
||||
nsRDFParserUtils::IsJavaScriptLanguage(s);
|
||||
|
||||
// rdfutils
|
||||
rdf_IsOrdinalProperty(nsnull);
|
||||
rdf_OrdinalResourceToIndex(nsnull, nsnull);
|
||||
rdf_IndexToOrdinalResource(0, nsnull);
|
||||
rdf_IsContainer(nsnull, nsnull);
|
||||
rdf_IsBag(nsnull, nsnull);
|
||||
rdf_IsSeq(nsnull, nsnull);
|
||||
rdf_IsAlt(nsnull, nsnull);
|
||||
rdf_CreateAnonymousResource(s, nsnull);
|
||||
rdf_IsAnonymousResource(s, nsnull);
|
||||
rdf_PossiblyMakeRelative(s, s);
|
||||
rdf_MakeBag(nsnull, nsnull);
|
||||
rdf_MakeSeq(nsnull, nsnull);
|
||||
rdf_MakeAlt(nsnull, nsnull);
|
||||
rdf_ContainerAppendElement(nsnull, nsnull, nsnull);
|
||||
rdf_ContainerRemoveElement(nsnull, nsnull, nsnull);
|
||||
rdf_ContainerInsertElementAt(nsnull, nsnull, nsnull, 0);
|
||||
rdf_ContainerIndexOf(nsnull, nsnull, nsnull, nsnull);
|
||||
NS_NewContainerCursor(nsnull, nsnull, nsnull);
|
||||
NS_NewEmptyRDFAssertionCursor(nsnull);
|
||||
NS_NewEmptyRDFArcsInCursor(nsnull);
|
||||
NS_NewEmptyRDFArcsOutCursor(nsnull);
|
||||
|
||||
// nsRDFResource
|
||||
nsRDFResource r();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
82
mozilla/rdf/build/makefile.win
Normal file
82
mozilla/rdf/build/makefile.win
Normal file
@@ -0,0 +1,82 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
MODULE=rdf
|
||||
|
||||
MAKE_OBJ_TYPE=DLL
|
||||
DLLNAME=rdf
|
||||
DLL=.\$(OBJDIR)\$(DLLNAME).dll
|
||||
|
||||
EXPORTS=\
|
||||
nsRDFCID.h \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsRDFFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX linking in raptor is a heinous crime that will go away once we
|
||||
# have a more DOM-based mechanism for constructing elements and
|
||||
# hooking in to their changes.
|
||||
|
||||
LLIBS=\
|
||||
$(DIST)\lib\rdfbase_s.lib \
|
||||
$(DIST)\lib\rdfutil_s.lib \
|
||||
$(DIST)\lib\rdfcontent_s.lib \
|
||||
$(DIST)\lib\rdfdatasource_s.lib \
|
||||
$(DIST)\lib\xpcom32.lib \
|
||||
$(DIST)\lib\raptorbase.lib \
|
||||
$(DIST)\lib\raptorgfxwin.lib \
|
||||
$(DIST)\lib\netlib.lib \
|
||||
$(DIST)\lib\libplc21.lib \
|
||||
$(DIST)\lib\raptorhtml.lib \
|
||||
$(DIST)\lib\jsdom.lib \
|
||||
$(DIST)\lib\js3250.lib \
|
||||
$(LIBNSPR)
|
||||
|
||||
MISCDEP=$(LLIBS)
|
||||
|
||||
# XXX Note dependencies on implementation dirs for factory methods.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(DEPTH)\rdf\base\src \
|
||||
-I$(DEPTH)\rdf\content\src \
|
||||
-I$(DEPTH)\rdf\datasource\src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install:: $(DLL)
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
|
||||
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
|
||||
$(MAKE_INSTALL) ..\resources\sidebar.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\sidebar.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.xul $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.css $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\bookmarks.html $(DIST)\bin\res\rdf
|
||||
$(MAKE_INSTALL) ..\resources\History\h1.hst $(DIST)\bin\res\rdf\History
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
101
mozilla/rdf/build/nsRDFCID.h
Normal file
101
mozilla/rdf/build/nsRDFCID.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
XPCOM Class IDs for RDF objects that can be constructed via the RDF
|
||||
factory.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFCID_h__
|
||||
#define nsRDFCID_h__
|
||||
|
||||
// {0F78DA56-8321-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFDEFAULTRESOURCE_CID \
|
||||
{ 0xf78da56, 0x8321, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {BFD05264-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFSERVICE_CID \
|
||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {BFD05264-834C-11d2-8EAC-00805F29F371}
|
||||
#define NS_XULSORTSERVICE_CID \
|
||||
{ 0xbfd05264, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } }
|
||||
|
||||
// {BFD0526D-834C-11d2-8EAC-00805F29F370}
|
||||
#define NS_RDFINMEMORYDATASOURCE_CID \
|
||||
{ 0xbfd0526d, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFBOOKMARKDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {E638D760-8687-11d2-B530-000000000001}
|
||||
#define NS_RDFFILESYSTEMDATASOURCE_CID \
|
||||
{ 0xe638d760, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x01 } }
|
||||
|
||||
// {E638D761-8687-11d2-B530-000000000000}
|
||||
#define NS_RDFCOMPOSITEDATASOURCE_CID \
|
||||
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {954F0813-81DC-11d2-B52A-000000000000}
|
||||
#define NS_RDFHTMLBUILDER_CID \
|
||||
{ 0x954f0813, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
// {3D262D00-8B5A-11d2-8EB0-00805F29F370}
|
||||
#define NS_RDFTREEBUILDER_CID \
|
||||
{ 0x3d262d00, 0x8b5a, 0x11d2, { 0x8e, 0xb0, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {CF6547E1-D427-11d2-96ED-00104B7B7DEB}
|
||||
#define NS_RDFMENUBUILDER_CID \
|
||||
{ 0xcf6547e1, 0xd427, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } };
|
||||
|
||||
// {FEA36A61-D48F-11d2-96ED-00104B7B7DEB}
|
||||
#define NS_RDFTOOLBARBUILDER_CID \
|
||||
{ 0xfea36a61, 0xd48f, 0x11d2, { 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } };
|
||||
|
||||
// {7BAF62E0-8E61-11d2-8EB1-00805F29F370}
|
||||
#define NS_RDFXMLDATASOURCE_CID \
|
||||
{ 0x7baf62e0, 0x8e61, 0x11d2, { 0x8e, 0xb1, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {6791B601-B9FE-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULDATASOURCE_CID \
|
||||
{ 0x6791b601, 0xb9fe, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {0958B101-9ADA-11d2-8EBC-00805F29F370}
|
||||
#define NS_RDFCONTENTSINK_CID \
|
||||
{ 0x958b101, 0x9ada, 0x11d2, { 0x8e, 0xbc, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {E45313F0-B59C-11d2-A68C-00104BDE6048}
|
||||
#define NS_RDFXULBUILDER_CID \
|
||||
{ 0xe45313f0, 0xb59c, 0x11d2, { 0xa6, 0x8c, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
// {CE058B21-BA9C-11d2-BF86-00105A1B0627}
|
||||
#define NS_XULCONTENTSINK_CID \
|
||||
{ 0xce058b21, 0xba9c, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
|
||||
|
||||
// {541AFCB2-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_XULDOCUMENT_CID \
|
||||
{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
// {1EAAFD60-D596-11d2-80BE-006097B76B8E}
|
||||
#define NS_RDFHISTORYDATASOURCE_CID \
|
||||
{ 0x1eaafd60, 0xd596, 0x11d2, { 0x80, 0xbe, 0x0, 0x60, 0x97, 0xb7, 0x6b, 0x8e } }
|
||||
|
||||
#endif // nsRDFCID_h__
|
||||
381
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
381
mozilla/rdf/build/nsRDFFactory.cpp
Normal file
@@ -0,0 +1,381 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The RDF factory implementation.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFContentSink.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFXMLDataSource.h"
|
||||
#include "nsIXULContentSink.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsRDFBaseDataSources.h"
|
||||
#include "nsRDFBuiltInDataSources.h"
|
||||
#include "nsIRDFFileSystem.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRepository.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIXULSortService.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFCompositeDataSourceCID, NS_RDFCOMPOSITEDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContentSinkCID, NS_RDFCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kRDFDefaultResourceCID, NS_RDFDEFAULTRESOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFFileSystemDataSourceCID,NS_RDFFILESYSTEMDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFHistoryDataSourceCID, NS_RDFHISTORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFMenuBuilderCID, NS_RDFMENUBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFToolbarBuilderCID, NS_RDFTOOLBARBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
|
||||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID);
|
||||
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
|
||||
static NS_DEFINE_CID(kXULDataSourceCID, NS_XULDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kXULDocumentCID, NS_XULDOCUMENT_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
|
||||
class RDFFactoryImpl : public nsIFactory
|
||||
{
|
||||
public:
|
||||
RDFFactoryImpl(const nsCID &aClass, const char* className, const char* progID);
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
virtual ~RDFFactoryImpl();
|
||||
|
||||
protected:
|
||||
nsCID mClassID;
|
||||
const char* mClassName;
|
||||
const char* mProgID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
RDFFactoryImpl::RDFFactoryImpl(const nsCID &aClass,
|
||||
const char* className,
|
||||
const char* progID)
|
||||
: mClassID(aClass), mClassName(className), mProgID(progID)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
RDFFactoryImpl::~RDFFactoryImpl()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(RDFFactoryImpl);
|
||||
NS_IMPL_RELEASE(RDFFactoryImpl);
|
||||
|
||||
extern nsresult
|
||||
NS_NewDefaultResource(nsIRDFResource** aResult);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kRDFServiceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFService((nsIRDFService**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULSortServiceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULSortService((nsIXULSortService**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFInMemoryDataSourceCID)) {
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFInMemoryDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFXMLDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFXMLDataSource((nsIRDFXMLDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFBookmarkDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFBookmarkDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFFileSystemDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFFileSystemDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFCompositeDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFCompositeDataSource((nsIRDFCompositeDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFHistoryDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFHistoryDataSource((nsIRDFDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULDocumentCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULDocument((nsIRDFDocument**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFHTMLBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFHTMLBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFMenuBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFMenuBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFToolbarBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFToolbarBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFTreeBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFTreeBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFXULBuilderCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFXULBuilder((nsIRDFContentModelBuilder**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFContentSinkCID)) {
|
||||
if (NS_FAILED(rv = NS_NewRDFContentSink((nsIRDFContentSink**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULDataSourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULDataSource((nsIRDFXMLDataSource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kXULContentSinkCID)) {
|
||||
if (NS_FAILED(rv = NS_NewXULContentSink((nsIXULContentSink**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else if (mClassID.Equals(kRDFDefaultResourceCID)) {
|
||||
if (NS_FAILED(rv = NS_NewDefaultResource((nsIRDFResource**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (! inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
|
||||
// We didn't get the right interface.
|
||||
NS_ERROR("didn't support the interface you wanted");
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(inst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult RDFFactoryImpl::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* serviceMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (! aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFFactoryImpl* factory = new RDFFactoryImpl(aClass, aClassName, aProgID);
|
||||
if (factory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* serviceMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
// XXX return error codes!
|
||||
|
||||
// register our build-in datasources:
|
||||
rv = nsRepository::RegisterComponent(kRDFBookmarkDataSourceCID,
|
||||
"Bookmarks",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "bookmarks",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFFileSystemDataSourceCID,
|
||||
"RDF File System Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "files",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFHistoryDataSourceCID,
|
||||
"RDF History Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "history",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFCompositeDataSourceCID,
|
||||
"RDF Composite Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "composite-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFInMemoryDataSourceCID,
|
||||
"RDF In-Memory Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "in-memory-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFXMLDataSourceCID,
|
||||
"RDF XML Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "xml-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kXULDataSourceCID,
|
||||
"XUL Data Source",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "xul-datasource",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
// register our built-in resource factories:
|
||||
rv = nsRepository::RegisterComponent(kRDFDefaultResourceCID,
|
||||
"RDF Default Resource Factory",
|
||||
NS_RDF_RESOURCE_FACTORY_PROGID, // default resource factory has no name= part
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
// register all the other rdf components:
|
||||
rv = nsRepository::RegisterComponent(kRDFContentSinkCID,
|
||||
"RDF Content Sink",
|
||||
NS_RDF_PROGID "|content-sink",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFHTMLBuilderCID,
|
||||
"RDF HTML Builder",
|
||||
NS_RDF_PROGID "|html-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFServiceCID,
|
||||
"RDF Service",
|
||||
NS_RDF_PROGID "|rdf-service",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kXULSortServiceCID,
|
||||
"XUL Sort Service",
|
||||
NS_RDF_PROGID "|xul-sort-service",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFTreeBuilderCID,
|
||||
"RDF Tree Builder",
|
||||
NS_RDF_PROGID "|tree-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFMenuBuilderCID,
|
||||
"RDF Menu Builder",
|
||||
NS_RDF_PROGID "|menu-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFToolbarBuilderCID,
|
||||
"RDF Toolbar Builder",
|
||||
NS_RDF_PROGID "|toolbar-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kRDFXULBuilderCID,
|
||||
"RDF XUL Builder",
|
||||
NS_RDF_PROGID "|xul-builder",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kXULContentSinkCID,
|
||||
"XUL Content Sink",
|
||||
NS_RDF_PROGID "|xul-content-sink",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
rv = nsRepository::RegisterComponent(kXULDocumentCID,
|
||||
"XUL Document",
|
||||
NS_RDF_PROGID "|xul-document",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* serviceMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
// XXX return error codes!
|
||||
|
||||
rv = nsRepository::UnregisterComponent(kRDFBookmarkDataSourceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFFileSystemDataSourceCID,aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFHistoryDataSourceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFCompositeDataSourceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFInMemoryDataSourceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFXMLDataSourceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kXULDataSourceCID, aPath);
|
||||
|
||||
rv = nsRepository::UnregisterComponent(kRDFDefaultResourceCID, aPath);
|
||||
|
||||
rv = nsRepository::UnregisterComponent(kRDFContentSinkCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFHTMLBuilderCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFServiceCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFTreeBuilderCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kRDFXULBuilderCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kXULContentSinkCID, aPath);
|
||||
rv = nsRepository::UnregisterComponent(kXULDocumentCID, aPath);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
29
mozilla/rdf/content/Makefile.in
Normal file
29
mozilla/rdf/content/Makefile.in
Normal file
@@ -0,0 +1,29 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
27
mozilla/rdf/content/makefile.win
Normal file
27
mozilla/rdf/content/makefile.win
Normal file
@@ -0,0 +1,27 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DIRS=\
|
||||
public \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
7
mozilla/rdf/content/public/MANIFEST
Normal file
7
mozilla/rdf/content/public/MANIFEST
Normal file
@@ -0,0 +1,7 @@
|
||||
nsIDOMElementObserver.h
|
||||
nsIDOMNodeObserver.h
|
||||
nsIDOMXULDocument.h
|
||||
nsIDOMXULElement.h
|
||||
nsIRDFContentModelBuilder.h
|
||||
nsIRDFDocument.h
|
||||
nsIXULSortService.h
|
||||
41
mozilla/rdf/content/public/Makefile.in
Normal file
41
mozilla/rdf/content/public/Makefile.in
Normal file
@@ -0,0 +1,41 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
EXPORTS = \
|
||||
nsIDOMElementObserver.h \
|
||||
nsIDOMNodeObserver.h \
|
||||
nsIDOMXULDocument.h \
|
||||
nsIDOMXULElement.h \
|
||||
nsIRDFContentModelBuilder.h \
|
||||
nsIRDFDocument.h \
|
||||
nsIXULSortService.h \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
9
mozilla/rdf/content/public/idl/ElementObserver.idl
Normal file
9
mozilla/rdf/content/public/idl/ElementObserver.idl
Normal file
@@ -0,0 +1,9 @@
|
||||
interface ElementObserver {
|
||||
/* IID: { 0x17ddd8c2, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
void onSetAttribute(in Element element, in DOMString name, in DOMString value);
|
||||
void onRemoveAttribute(in Element element, in DOMString name);
|
||||
void onSetAttributeNode(in Element element, in Attr newAttr);
|
||||
void onRemoveAttributeNode(in Element element, in Attr oldAttr);
|
||||
};
|
||||
10
mozilla/rdf/content/public/idl/NodeObserver.idl
Normal file
10
mozilla/rdf/content/public/idl/NodeObserver.idl
Normal file
@@ -0,0 +1,10 @@
|
||||
interface NodeObserver {
|
||||
/* IID: { 0x3e969070, 0xc301, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
void onSetNodeValue(in Node node, in DOMString value);
|
||||
void onInsertBefore(in Node parent, in Node newChild, in Node refChild);
|
||||
void onReplaceChild(in Node parent, in Node newChild, in Node oldChild);
|
||||
void onRemoveChild(in Node parent, in Node oldChild);
|
||||
void onAppendChild(in Node parent, in Node newChild);
|
||||
};
|
||||
9
mozilla/rdf/content/public/idl/XULDocument.idl
Normal file
9
mozilla/rdf/content/public/idl/XULDocument.idl
Normal file
@@ -0,0 +1,9 @@
|
||||
interface XULDocument : Document {
|
||||
|
||||
/* IID: { 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
11
mozilla/rdf/content/public/idl/XULElement.idl
Normal file
11
mozilla/rdf/content/public/idl/XULElement.idl
Normal file
@@ -0,0 +1,11 @@
|
||||
interface XULElement : Element {
|
||||
|
||||
/* IID: { 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } } */
|
||||
|
||||
void addBroadcastListener(in DOMString attr, in Element element);
|
||||
void removeBroadcastListener(in DOMString attr, in Element element);
|
||||
void doCommand();
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
55
mozilla/rdf/content/public/idl/makefile.win
Normal file
55
mozilla/rdf/content/public/idl/makefile.win
Normal file
@@ -0,0 +1,55 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
IGNORE_MANIFEST=1
|
||||
|
||||
MODULE=rdf
|
||||
|
||||
IDLSRCS = \
|
||||
ElementObserver.idl \
|
||||
NodeObserver.idl \
|
||||
XULDocument.idl \
|
||||
XULElement.idl \
|
||||
$(NULL)
|
||||
|
||||
XPCOM_DESTDIR=$(DEPTH)\rdf\content\public
|
||||
JSSTUB_DESTDIR=$(DEPTH)\rdf\content\src
|
||||
|
||||
GENXDIR=genx
|
||||
GENJSDIR=genjs
|
||||
|
||||
!include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
$(GENXDIR):
|
||||
-mkdir $(GENXDIR)
|
||||
|
||||
$(GENJSDIR):
|
||||
-mkdir $(GENJSDIR)
|
||||
|
||||
IDLC=$(DIST)\bin\idlc.exe
|
||||
GENIID=$(DIST)\bin\geniid.pl
|
||||
|
||||
export:: $(GENXDIR) $(GENJSDIR) $(IDLSRCS)
|
||||
@echo +++ make: generating xpcom headers
|
||||
$(IDLC) -d $(GENXDIR) -x $(IDLSRCS)
|
||||
@echo +++ make: generating JavaScript stubs
|
||||
$(IDLC) -d $(GENJSDIR) -j $(IDLSRCS)
|
||||
|
||||
install::
|
||||
$(MAKE_INSTALL:/=\) $(GENXDIR)\nsIDOM*.h $(XPCOM_DESTDIR)
|
||||
$(MAKE_INSTALL:/=\) $(GENJSDIR)\nsJS*.cpp $(JSSTUB_DESTDIR)
|
||||
34
mozilla/rdf/content/public/makefile.win
Normal file
34
mozilla/rdf/content/public/makefile.win
Normal file
@@ -0,0 +1,34 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
MODULE=rdf
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
EXPORTS = \
|
||||
nsIDOMElementObserver.h \
|
||||
nsIDOMNodeObserver.h \
|
||||
nsIDOMXULDocument.h \
|
||||
nsIDOMXULElement.h \
|
||||
nsIRDFContentModelBuilder.h \
|
||||
nsIRDFDocument.h \
|
||||
nsIXULSortService.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
67
mozilla/rdf/content/public/nsIDOMElementObserver.h
Normal file
67
mozilla/rdf/content/public/nsIDOMElementObserver.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMElementObserver_h__
|
||||
#define nsIDOMElementObserver_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMAttr;
|
||||
|
||||
#define NS_IDOMELEMENTOBSERVER_IID \
|
||||
{ 0x17ddd8c2, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMElementObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMELEMENTOBSERVER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName)=0;
|
||||
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMELEMENTOBSERVER \
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue); \
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName); \
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr); \
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMELEMENTOBSERVER(_to) \
|
||||
NS_IMETHOD OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue) { return _to##OnSetAttribute(aElement, aName, aValue); } \
|
||||
NS_IMETHOD OnRemoveAttribute(nsIDOMElement* aElement, const nsString& aName) { return _to##OnRemoveAttribute(aElement, aName); } \
|
||||
NS_IMETHOD OnSetAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aNewAttr) { return _to##OnSetAttributeNode(aElement, aNewAttr); } \
|
||||
NS_IMETHOD OnRemoveAttributeNode(nsIDOMElement* aElement, nsIDOMAttr* aOldAttr) { return _to##OnRemoveAttributeNode(aElement, aOldAttr); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitElementObserverClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptElementObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMElementObserver_h__
|
||||
70
mozilla/rdf/content/public/nsIDOMNodeObserver.h
Normal file
70
mozilla/rdf/content/public/nsIDOMNodeObserver.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMNodeObserver_h__
|
||||
#define nsIDOMNodeObserver_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIDOMNode;
|
||||
|
||||
#define NS_IDOMNODEOBSERVER_IID \
|
||||
{ 0x3e969070, 0xc301, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMNodeObserver : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMNODEOBSERVER_IID; return iid; }
|
||||
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue)=0;
|
||||
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild)=0;
|
||||
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild)=0;
|
||||
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild)=0;
|
||||
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMNODEOBSERVER \
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue); \
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild); \
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild); \
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild); \
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMNODEOBSERVER(_to) \
|
||||
NS_IMETHOD OnSetNodeValue(nsIDOMNode* aNode, const nsString& aValue) { return _to##OnSetNodeValue(aNode, aValue); } \
|
||||
NS_IMETHOD OnInsertBefore(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aRefChild) { return _to##OnInsertBefore(aParent, aNewChild, aRefChild); } \
|
||||
NS_IMETHOD OnReplaceChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild, nsIDOMNode* aOldChild) { return _to##OnReplaceChild(aParent, aNewChild, aOldChild); } \
|
||||
NS_IMETHOD OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild) { return _to##OnRemoveChild(aParent, aOldChild); } \
|
||||
NS_IMETHOD OnAppendChild(nsIDOMNode* aParent, nsIDOMNode* aNewChild) { return _to##OnAppendChild(aParent, aNewChild); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitNodeObserverClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMNodeObserver_h__
|
||||
60
mozilla/rdf/content/public/nsIDOMXULDocument.h
Normal file
60
mozilla/rdf/content/public/nsIDOMXULDocument.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULDocument_h__
|
||||
#define nsIDOMXULDocument_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
{ 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } }
|
||||
|
||||
class nsIDOMXULDocument : public nsIDOMDocument {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULDOCUMENT \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULDOCUMENT(_to) \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to##GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to##GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULDocument_h__
|
||||
68
mozilla/rdf/content/public/nsIDOMXULElement.h
Normal file
68
mozilla/rdf/content/public/nsIDOMXULElement.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#ifndef nsIDOMXULElement_h__
|
||||
#define nsIDOMXULElement_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMElement.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULELEMENT_IID \
|
||||
{ 0x574ed81, 0xc088, 0x11d2, \
|
||||
{ 0x96, 0xed, 0x0, 0x10, 0x4b, 0x7b, 0x7d, 0xeb } }
|
||||
|
||||
class nsIDOMXULElement : public nsIDOMElement {
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULELEMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement)=0;
|
||||
|
||||
NS_IMETHOD DoCommand()=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
};
|
||||
|
||||
|
||||
#define NS_DECL_IDOMXULELEMENT \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement); \
|
||||
NS_IMETHOD DoCommand(); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULELEMENT(_to) \
|
||||
NS_IMETHOD AddBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to##AddBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD RemoveBroadcastListener(const nsString& aAttr, nsIDOMElement* aElement) { return _to##RemoveBroadcastListener(aAttr, aElement); } \
|
||||
NS_IMETHOD DoCommand() { return _to##DoCommand(); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to##GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
|
||||
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype);
|
||||
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn);
|
||||
|
||||
#endif // nsIDOMXULElement_h__
|
||||
76
mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
Normal file
76
mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A content model builder interface. An object that implements this
|
||||
interface is associated with an nsIRDFDocument object to construct
|
||||
an NGLayout content model.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFContentModelBuilder_h__
|
||||
#define nsIRDFContentModelBuilder_h__
|
||||
|
||||
#include "nsISupports.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIRDFDocument;
|
||||
class nsIRDFNode;
|
||||
class nsIRDFResource;
|
||||
|
||||
// {541AFCB0-A9A3-11d2-8EC5-00805F29F370}
|
||||
#define NS_IRDFCONTENTMODELBUILDER_IID \
|
||||
{ 0x541afcb0, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
|
||||
|
||||
class nsIRDFContentModelBuilder : public nsISupports
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFCONTENTMODELBUILDER_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Point the content model builder to the document. The content model
|
||||
* builder must not reference count the document.
|
||||
*/
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument) = 0;
|
||||
|
||||
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase) = 0;
|
||||
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase) = 0;
|
||||
|
||||
/**
|
||||
* Set the root element from which this content model will
|
||||
* operate.
|
||||
*/
|
||||
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource) = 0;
|
||||
NS_IMETHOD SetRootContent(nsIContent* aElement) = 0;
|
||||
|
||||
/**
|
||||
* Construct the contents for a container element.
|
||||
*/
|
||||
NS_IMETHOD CreateContents(nsIContent* aElement) = 0;
|
||||
};
|
||||
|
||||
extern nsresult NS_NewRDFHTMLBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
extern nsresult NS_NewRDFMenuBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
extern nsresult NS_NewRDFToolbarBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
extern nsresult NS_NewRDFTreeBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
extern nsresult NS_NewRDFXULBuilder(nsIRDFContentModelBuilder** aResult);
|
||||
|
||||
#endif // nsIRDFContentModelBuilder_h__
|
||||
81
mozilla/rdf/content/public/nsIRDFDocument.h
Normal file
81
mozilla/rdf/content/public/nsIRDFDocument.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/* -*- 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.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An RDF-specific extension to nsIXMLDocument. Includes methods for
|
||||
setting the root resource of the document content model, a factory
|
||||
method for constructing the children of a node, etc.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDocument_h___
|
||||
#define nsIRDFDocument_h___
|
||||
|
||||
class nsIContent; // XXX nsIXMLDocument.h is bad and doesn't declare this class...
|
||||
|
||||
#include "nsIXMLDocument.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIRDFContent;
|
||||
class nsIRDFContentModelBuilder;
|
||||
class nsISupportsArray;
|
||||
class nsIRDFResource;
|
||||
|
||||
// {954F0811-81DC-11d2-B52A-000000000000}
|
||||
#define NS_IRDFDOCUMENT_IID \
|
||||
{ 0x954f0811, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
|
||||
|
||||
/**
|
||||
* RDF document extensions to nsIDocument
|
||||
*/
|
||||
class nsIRDFDocument : public nsIXMLDocument
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IRDFDOCUMENT_IID; return iid; }
|
||||
|
||||
/**
|
||||
* Set the document's "root" resource.
|
||||
*/
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* aResource) = 0;
|
||||
|
||||
// XXX the following two methods should probably accept strings as
|
||||
// parameters so you can mess with them via JS. Also, should they
|
||||
// take a "notify" parameter that would control whether any viewers
|
||||
// of the content model should be informed that the content model is
|
||||
// invalid?
|
||||
|
||||
NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag) = 0;
|
||||
|
||||
NS_IMETHOD AddElementForResource(nsIRDFResource* aResource, nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD RemoveElementForResource(nsIRDFResource* aResource, nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements) = 0;
|
||||
|
||||
NS_IMETHOD CreateContents(nsIContent* aElement) = 0;
|
||||
|
||||
NS_IMETHOD AddContentModelBuilder(nsIRDFContentModelBuilder* aBuilder) = 0;
|
||||
};
|
||||
|
||||
// factory functions
|
||||
nsresult NS_NewXULDocument(nsIRDFDocument** result);
|
||||
|
||||
#endif // nsIRDFDocument_h___
|
||||
56
mozilla/rdf/content/public/nsIXULSortService.h
Normal file
56
mozilla/rdf/content/public/nsIXULSortService.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
The sort service interface. This is a singleton object, and should be
|
||||
obtained from the <tt>nsServiceManager</tt>.
|
||||
*/
|
||||
|
||||
#ifndef nsIXULSortService_h__
|
||||
#define nsIXULSortService_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsString.h"
|
||||
|
||||
|
||||
// {BFD05261-834C-11d2-8EAC-00805F29F371}
|
||||
#define NS_IXULSORTSERVICE_IID \
|
||||
{ 0xbfd05261, 0x834c, 0x11d2, { 0x8e, 0xac, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x71 } }
|
||||
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIContent;
|
||||
class nsIRDFResource;
|
||||
class nsIDOMNode;
|
||||
|
||||
class nsIXULSortService : public nsISupports {
|
||||
public:
|
||||
static const nsIID& IID() { static nsIID iid = NS_IXULSORTSERVICE_IID; return iid; }
|
||||
|
||||
NS_IMETHOD DoSort(nsIDOMNode* node, const nsString& sortResource, const nsString& sortDirection) = 0;
|
||||
NS_IMETHOD OpenContainer(nsIRDFCompositeDataSource *db, nsIContent *container,
|
||||
nsIRDFResource **flatArray, PRInt32 numElements, PRInt32 elementSize) = 0;
|
||||
};
|
||||
|
||||
|
||||
extern nsresult
|
||||
NS_NewXULSortService(nsIXULSortService** result);
|
||||
|
||||
#endif // nsIXULSortService_h__
|
||||
72
mozilla/rdf/content/src/Makefile.in
Normal file
72
mozilla/rdf/content/src/Makefile.in
Normal file
@@ -0,0 +1,72 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
LIBRARY_NAME = rdfcontent_s
|
||||
|
||||
CPPSRCS = \
|
||||
nsXULAttributes.cpp \
|
||||
nsJSElementObserver.cpp \
|
||||
nsJSNodeObserver.cpp \
|
||||
nsJSXULDocument.cpp \
|
||||
nsJSXULElement.cpp \
|
||||
nsRDFContentUtils.cpp \
|
||||
nsRDFDOMNodeList.cpp \
|
||||
nsRDFElement.cpp \
|
||||
nsRDFGenericBuilder.cpp \
|
||||
nsRDFHTMLBuilder.cpp \
|
||||
nsRDFMenuBuilder.cpp \
|
||||
nsRDFToolbarBuilder.cpp \
|
||||
nsRDFTreeBuilder.cpp \
|
||||
nsRDFXULBuilder.cpp \
|
||||
nsXULDocument.cpp \
|
||||
nsXULSortService.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
REQUIRES = dom js netlib rdf raptor xpcom
|
||||
|
||||
# XXX This is a dependency on rdfutil.h: it'll go away once that becomes
|
||||
# a first-class XPCOM interface.
|
||||
INCLUDES += -I$(srcdir)/../../base/src
|
||||
|
||||
# XXX This is a dependency on Raptor for constructing HTML
|
||||
# content. It'll go away once we move RDF content model construction
|
||||
# outside the DOM APIs.
|
||||
INCLUDES += -I$(srcdir)/../../../layout/html/base/src
|
||||
|
||||
MKSHLIB :=
|
||||
|
||||
# we don't want the shared lib
|
||||
NO_SHARED_LIB=1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
71
mozilla/rdf/content/src/makefile.win
Normal file
71
mozilla/rdf/content/src/makefile.win
Normal file
@@ -0,0 +1,71 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
DEPTH=..\..\..
|
||||
MODULE=rdf
|
||||
LIBRARY_NAME=rdfcontent_s
|
||||
|
||||
DEFINES=-D_IMPL_NS_DOM
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
$(DEFINES) \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS=\
|
||||
.\$(OBJDIR)\nsXULAttributes.obj \
|
||||
.\$(OBJDIR)\nsJSElementObserver.obj \
|
||||
.\$(OBJDIR)\nsJSNodeObserver.obj \
|
||||
.\$(OBJDIR)\nsJSXULDocument.obj \
|
||||
.\$(OBJDIR)\nsJSXULElement.obj \
|
||||
.\$(OBJDIR)\nsRDFContentUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFDOMNodeList.obj \
|
||||
.\$(OBJDIR)\nsRDFHTMLBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFElement.obj \
|
||||
.\$(OBJDIR)\nsRDFGenericBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFMenuBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFToolbarBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFTreeBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFXULBuilder.obj \
|
||||
.\$(OBJDIR)\nsXULDocument.obj \
|
||||
.\$(OBJDIR)\nsXULSortService.obj \
|
||||
$(NULL)
|
||||
|
||||
# XXX we are including layout\html\base\src to get HTML elements
|
||||
# constructed directly from Raptor. The hope is that this'll
|
||||
# eventually be replaced by a DOM-based mechanism.
|
||||
|
||||
LINCS= -I$(PUBLIC)\rdf \
|
||||
-I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\lwbrk \
|
||||
-I$(PUBLIC)\js \
|
||||
-I$(PUBLIC)\dom \
|
||||
-I$(DEPTH)\rdf\base\src \
|
||||
-I$(DEPTH)\layout\html\base\src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
libs:: $(LIBRARY)
|
||||
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib
|
||||
|
||||
|
||||
473
mozilla/rdf/content/src/nsJSElementObserver.cpp
Normal file
473
mozilla/rdf/content/src/nsJSElementObserver.cpp
Normal file
@@ -0,0 +1,473 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMAttr.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIAttrIID, NS_IDOMATTR_IID);
|
||||
static NS_DEFINE_IID(kIElementObserverIID, NS_IDOMELEMENTOBSERVER_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMAttr);
|
||||
NS_DEF_PTR(nsIDOMElementObserver);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ElementObserver Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetElementObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMElementObserver *a = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// ElementObserver Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetElementObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMElementObserver *a = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeElementObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateElementObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveElementObserver(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnSetAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElementPtr b0;
|
||||
nsAutoString b1;
|
||||
nsAutoString b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b2, cx, argv[2]);
|
||||
|
||||
if (NS_OK != nativeThis->OnSetAttribute(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onSetAttribute requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnRemoveAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElementPtr b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveAttribute(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onRemoveAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetAttributeNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnSetAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElementPtr b0;
|
||||
nsIDOMAttrPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIAttrIID,
|
||||
"Attr",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnSetAttributeNode(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onSetAttributeNode requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveAttributeNode
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserverOnRemoveAttributeNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMElementObserver *nativeThis = (nsIDOMElementObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElementPtr b0;
|
||||
nsIDOMAttrPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIAttrIID,
|
||||
"Attr",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveAttributeNode(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onRemoveAttributeNode requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for ElementObserver
|
||||
//
|
||||
JSClass ElementObserverClass = {
|
||||
"ElementObserver",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetElementObserverProperty,
|
||||
SetElementObserverProperty,
|
||||
EnumerateElementObserver,
|
||||
ResolveElementObserver,
|
||||
JS_ConvertStub,
|
||||
FinalizeElementObserver
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class properties
|
||||
//
|
||||
static JSPropertySpec ElementObserverProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class methods
|
||||
//
|
||||
static JSFunctionSpec ElementObserverMethods[] =
|
||||
{
|
||||
{"onSetAttribute", ElementObserverOnSetAttribute, 3},
|
||||
{"onRemoveAttribute", ElementObserverOnRemoveAttribute, 2},
|
||||
{"onSetAttributeNode", ElementObserverOnSetAttributeNode, 2},
|
||||
{"onRemoveAttributeNode", ElementObserverOnRemoveAttributeNode, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ElementObserver(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ElementObserver class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitElementObserverClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "ElementObserver", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&ElementObserverClass, // JSClass
|
||||
ElementObserver, // JSNative ctor
|
||||
0, // ctor args
|
||||
ElementObserverProperties, // proto props
|
||||
ElementObserverMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new ElementObserver JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptElementObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptElementObserver");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMElementObserver *aElementObserver;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitElementObserverClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIElementObserverIID, (void **)&aElementObserver);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &ElementObserverClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aElementObserver);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aElementObserver);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
543
mozilla/rdf/content/src/nsJSNodeObserver.cpp
Normal file
543
mozilla/rdf/content/src/nsJSNodeObserver.cpp
Normal file
@@ -0,0 +1,543 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kINodeObserverIID, NS_IDOMNODEOBSERVER_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
NS_DEF_PTR(nsIDOMNodeObserver);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// NodeObserver Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetNodeObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeObserver *a = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// NodeObserver Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetNodeObserverProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMNodeObserver *a = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeNodeObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateNodeObserver(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveNodeObserver(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnSetNodeValue
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnSetNodeValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodePtr b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->OnSetNodeValue(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onSetNodeValue requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnInsertBefore
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnInsertBefore(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
nsIDOMNodePtr b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b2,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[2])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnInsertBefore(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onInsertBefore requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnReplaceChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnReplaceChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
nsIDOMNodePtr b2;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 3) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b2,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[2])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnReplaceChild(b0, b1, b2)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onReplaceChild requires 3 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnRemoveChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnRemoveChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnRemoveChild(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onRemoveChild requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method OnAppendChild
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserverOnAppendChild(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMNodeObserver *nativeThis = (nsIDOMNodeObserver*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodePtr b0;
|
||||
nsIDOMNodePtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kINodeIID,
|
||||
"Node",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->OnAppendChild(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function onAppendChild requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for NodeObserver
|
||||
//
|
||||
JSClass NodeObserverClass = {
|
||||
"NodeObserver",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetNodeObserverProperty,
|
||||
SetNodeObserverProperty,
|
||||
EnumerateNodeObserver,
|
||||
ResolveNodeObserver,
|
||||
JS_ConvertStub,
|
||||
FinalizeNodeObserver
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class properties
|
||||
//
|
||||
static JSPropertySpec NodeObserverProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class methods
|
||||
//
|
||||
static JSFunctionSpec NodeObserverMethods[] =
|
||||
{
|
||||
{"onSetNodeValue", NodeObserverOnSetNodeValue, 2},
|
||||
{"onInsertBefore", NodeObserverOnInsertBefore, 3},
|
||||
{"onReplaceChild", NodeObserverOnReplaceChild, 3},
|
||||
{"onRemoveChild", NodeObserverOnRemoveChild, 2},
|
||||
{"onAppendChild", NodeObserverOnAppendChild, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NodeObserver(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// NodeObserver class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitNodeObserverClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "NodeObserver", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&NodeObserverClass, // JSClass
|
||||
NodeObserver, // JSNative ctor
|
||||
0, // ctor args
|
||||
NodeObserverProperties, // proto props
|
||||
NodeObserverMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new NodeObserver JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptNodeObserver(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptNodeObserver");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNodeObserver *aNodeObserver;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitNodeObserverClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kINodeObserverIID, (void **)&aNodeObserver);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &NodeObserverClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aNodeObserver);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aNodeObserver);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
356
mozilla/rdf/content/src/nsJSXULDocument.cpp
Normal file
356
mozilla/rdf/content/src/nsJSXULDocument.cpp
Normal file
@@ -0,0 +1,356 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULDocument Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULDocument *a = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULDocument(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULDocument(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementById
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementById(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMElement* nativeRet;
|
||||
nsAutoString b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 1) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementById(b0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementById requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocumentGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULDocument *nativeThis = (nsIDOMXULDocument*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULDocument
|
||||
//
|
||||
JSClass XULDocumentClass = {
|
||||
"XULDocument",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULDocumentProperty,
|
||||
SetXULDocumentProperty,
|
||||
EnumerateXULDocument,
|
||||
ResolveXULDocument,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULDocument
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class properties
|
||||
//
|
||||
static JSPropertySpec XULDocumentProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class methods
|
||||
//
|
||||
static JSFunctionSpec XULDocumentMethods[] =
|
||||
{
|
||||
{"getElementById", XULDocumentGetElementById, 1},
|
||||
{"getElementsByAttribute", XULDocumentGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULDocument constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULDocument class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULDocumentClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULDocument", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitDocumentClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULDocumentClass, // JSClass
|
||||
XULDocument, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULDocumentProperties, // proto props
|
||||
XULDocumentMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULDocument JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULDocument(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULDocument");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULDocument *aXULDocument;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULDocumentClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULDocumentIID, (void **)&aXULDocument);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULDocumentClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULDocument);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULDocument);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
444
mozilla/rdf/content/src/nsJSXULElement.cpp
Normal file
444
mozilla/rdf/content/src/nsJSXULElement.cpp
Normal file
@@ -0,0 +1,444 @@
|
||||
/* -*- 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULElement);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Getter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
GetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// XULElement Properties Setter
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
SetXULElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
{
|
||||
nsIDOMXULElement *a = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == a) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement finalizer
|
||||
//
|
||||
PR_STATIC_CALLBACK(void)
|
||||
FinalizeXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
nsJSUtils::nsGenericFinalize(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement enumerate
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
EnumerateXULElement(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
return nsJSUtils::nsGenericEnumerate(cx, obj);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement resolve
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
ResolveXULElement(JSContext *cx, JSObject *obj, jsval id)
|
||||
{
|
||||
return nsJSUtils::nsGenericResolve(cx, obj, id);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementAddBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->AddBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function addBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method RemoveBroadcastListener
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementRemoveBroadcastListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsAutoString b0;
|
||||
nsIDOMElementPtr b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1,
|
||||
kIElementIID,
|
||||
"Element",
|
||||
cx,
|
||||
argv[1])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->RemoveBroadcastListener(b0, b1)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function removeBroadcastListener requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method DoCommand
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementDoCommand(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
|
||||
if (NS_OK != nativeThis->DoCommand()) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function doCommand requires 0 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetElementsByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElementGetElementsByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMXULElement *nativeThis = (nsIDOMXULElement*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMNodeList* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 2) {
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
if (NS_OK != nativeThis->GetElementsByAttribute(b0, b1, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function getElementsByAttribute requires 2 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for XULElement
|
||||
//
|
||||
JSClass XULElementClass = {
|
||||
"XULElement",
|
||||
JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub,
|
||||
JS_PropertyStub,
|
||||
GetXULElementProperty,
|
||||
SetXULElementProperty,
|
||||
EnumerateXULElement,
|
||||
ResolveXULElement,
|
||||
JS_ConvertStub,
|
||||
FinalizeXULElement
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class properties
|
||||
//
|
||||
static JSPropertySpec XULElementProperties[] =
|
||||
{
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement class methods
|
||||
//
|
||||
static JSFunctionSpec XULElementMethods[] =
|
||||
{
|
||||
{"addBroadcastListener", XULElementAddBroadcastListener, 2},
|
||||
{"removeBroadcastListener", XULElementRemoveBroadcastListener, 2},
|
||||
{"doCommand", XULElementDoCommand, 0},
|
||||
{"getElementsByAttribute", XULElementGetElementsByAttribute, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// XULElement constructor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// XULElement class initialization
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_InitXULElementClass(nsIScriptContext *aContext, void **aPrototype)
|
||||
{
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
JSObject *proto = nsnull;
|
||||
JSObject *constructor = nsnull;
|
||||
JSObject *parent_proto = nsnull;
|
||||
JSObject *global = JS_GetGlobalObject(jscontext);
|
||||
jsval vp;
|
||||
|
||||
if ((PR_TRUE != JS_LookupProperty(jscontext, global, "XULElement", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp) ||
|
||||
((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
|
||||
(PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) ||
|
||||
!JSVAL_IS_OBJECT(vp)) {
|
||||
|
||||
if (NS_OK != NS_InitElementClass(aContext, (void **)&parent_proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
proto = JS_InitClass(jscontext, // context
|
||||
global, // global object
|
||||
parent_proto, // parent proto
|
||||
&XULElementClass, // JSClass
|
||||
XULElement, // JSNative ctor
|
||||
0, // ctor args
|
||||
XULElementProperties, // proto props
|
||||
XULElementMethods, // proto funcs
|
||||
nsnull, // ctor props (static)
|
||||
nsnull); // ctor funcs (static)
|
||||
if (nsnull == proto) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) {
|
||||
proto = JSVAL_TO_OBJECT(vp);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aPrototype) {
|
||||
*aPrototype = proto;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Method for creating a new XULElement JavaScript object
|
||||
//
|
||||
extern "C" NS_DOM nsresult NS_NewScriptXULElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptXULElement");
|
||||
JSObject *proto;
|
||||
JSObject *parent;
|
||||
nsIScriptObjectOwner *owner;
|
||||
JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMXULElement *aXULElement;
|
||||
|
||||
if (nsnull == aParent) {
|
||||
parent = nsnull;
|
||||
}
|
||||
else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
|
||||
if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
|
||||
NS_RELEASE(owner);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_RELEASE(owner);
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (NS_OK != NS_InitXULElementClass(aContext, (void **)&proto)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
result = aSupports->QueryInterface(kIXULElementIID, (void **)&aXULElement);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// create a js object for this class
|
||||
*aReturn = JS_NewObject(jscontext, &XULElementClass, proto, parent);
|
||||
if (nsnull != *aReturn) {
|
||||
// connect the native object to the js object
|
||||
JS_SetPrivate(jscontext, (JSObject *)*aReturn, aXULElement);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(aXULElement);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
95
mozilla/rdf/content/src/nsRDFContentUtils.cpp
Normal file
95
mozilla/rdf/content/src/nsRDFContentUtils.cpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A package of routines shared by the RDF content code.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "nsIContent.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsITextContent.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFContentUtils::AttachTextNode(nsIContent* parent, nsIRDFNode* value)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString s;
|
||||
nsIContent* node = nsnull;
|
||||
nsITextContent* text = nsnull;
|
||||
nsIRDFResource* resource = nsnull;
|
||||
nsIRDFLiteral* literal = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
|
||||
const char* p;
|
||||
if (NS_FAILED(rv = resource->GetValue(&p)))
|
||||
goto error;
|
||||
|
||||
s = p;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &literal))) {
|
||||
const PRUnichar* p;
|
||||
if (NS_FAILED(rv = literal->GetValue(&p)))
|
||||
goto error;
|
||||
|
||||
s = p;
|
||||
}
|
||||
else {
|
||||
PR_ASSERT(0);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = nsRepository::CreateInstance(kTextNodeCID,
|
||||
nsnull,
|
||||
kIContentIID,
|
||||
(void**) &node)))
|
||||
goto error;
|
||||
|
||||
if (NS_FAILED(rv = node->QueryInterface(kITextContentIID, (void**) &text)))
|
||||
goto error;
|
||||
|
||||
if (NS_FAILED(rv = text->SetText(s.GetUnicode(), s.Length(), PR_FALSE)))
|
||||
goto error;
|
||||
|
||||
// hook it up to the child
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(NS_STATIC_CAST(nsIContent*, node), PR_TRUE)))
|
||||
goto error;
|
||||
|
||||
error:
|
||||
NS_IF_RELEASE(node);
|
||||
NS_IF_RELEASE(text);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
52
mozilla/rdf/content/src/nsRDFContentUtils.h
Normal file
52
mozilla/rdf/content/src/nsRDFContentUtils.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A package of routines shared by the RDF content code.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFContentUtils_h__
|
||||
#define nsRDFContentUtils_h__
|
||||
|
||||
#include "nsError.h"
|
||||
|
||||
class nsIAtom;
|
||||
class nsIContent;
|
||||
class nsIDOMNodeList;
|
||||
class nsIRDFNode;
|
||||
class nsString;
|
||||
|
||||
|
||||
class nsRDFContentUtils
|
||||
{
|
||||
public:
|
||||
|
||||
static nsresult
|
||||
AttachTextNode(nsIContent* parent, nsIRDFNode* value);
|
||||
};
|
||||
|
||||
|
||||
// in nsRDFElement.cpp
|
||||
extern nsresult
|
||||
NS_NewRDFElement(PRInt32 aNameSpaceID, nsIAtom* aTag, nsIContent** aResult);
|
||||
|
||||
#endif // nsRDFContentUtils_h__
|
||||
|
||||
305
mozilla/rdf/content/src/nsRDFDOMNodeList.cpp
Normal file
305
mozilla/rdf/content/src/nsRDFDOMNodeList.cpp
Normal file
@@ -0,0 +1,305 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Helper class to implement the nsIDOMNodeList interface.
|
||||
|
||||
XXX It's probably wrong in some sense, as it uses the "naked"
|
||||
content interface to look for kids. (I assume in general this is
|
||||
bad because there may be pseudo-elements created for presentation
|
||||
that aren't visible to the DOM.)
|
||||
|
||||
*/
|
||||
|
||||
#include "nsDOMCID.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMScriptObjectFactory.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFDOMNodeList.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GUID definitions
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIDOMNodeListIID, NS_IDOMNODELIST_IID);
|
||||
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
class RDFHTMLCollectionImpl : public nsIDOMHTMLCollection
|
||||
{
|
||||
private:
|
||||
nsRDFDOMNodeList* mOuter;
|
||||
|
||||
public:
|
||||
RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter);
|
||||
virtual ~RDFHTMLCollectionImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
NS_IMETHOD_(nsrefcnt) Release(void);
|
||||
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
|
||||
|
||||
// nsIDOMHTMLCollection interface
|
||||
NS_DECL_IDOMHTMLCOLLECTION
|
||||
};
|
||||
|
||||
|
||||
RDFHTMLCollectionImpl::RDFHTMLCollectionImpl(nsRDFDOMNodeList* aOuter)
|
||||
: mOuter(aOuter)
|
||||
{
|
||||
}
|
||||
|
||||
RDFHTMLCollectionImpl::~RDFHTMLCollectionImpl(void)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::AddRef(void)
|
||||
{
|
||||
return mOuter->AddRef();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(nsrefcnt)
|
||||
RDFHTMLCollectionImpl::Release(void)
|
||||
{
|
||||
return mOuter->Release();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMHTMLCollection*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else {
|
||||
return mOuter->QueryInterface(aIID, aResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::GetLength(PRUint32* aLength)
|
||||
{
|
||||
return mOuter->GetLength(aLength);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
return mOuter->Item(aIndex, aReturn);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLCollectionImpl::NamedItem(const nsString& aName, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// ctors & dtors
|
||||
|
||||
nsRDFDOMNodeList::nsRDFDOMNodeList(void)
|
||||
: mInner(nsnull),
|
||||
mElements(nsnull),
|
||||
mScriptObject(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsRDFDOMNodeList::~nsRDFDOMNodeList(void)
|
||||
{
|
||||
NS_IF_RELEASE(mElements);
|
||||
delete mInner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Create(nsRDFDOMNodeList** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRDFDOMNodeList* list = new nsRDFDOMNodeList();
|
||||
if (! list)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = list->Init())) {
|
||||
delete list;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_ADDREF(list);
|
||||
*aResult = list;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports interface
|
||||
|
||||
NS_IMPL_ADDREF(nsRDFDOMNodeList);
|
||||
NS_IMPL_RELEASE(nsRDFDOMNodeList);
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::QueryInterface(REFNSIID aIID, void** aResult)
|
||||
{
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
||||
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aIID.Equals(nsIDOMNodeList::GetIID()) ||
|
||||
aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIDOMNodeList*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(kIScriptObjectOwnerIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIScriptObjectOwner*, this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
else if (aIID.Equals(nsIDOMHTMLCollection::GetIID())) {
|
||||
// Aggregate this interface
|
||||
if (! mInner) {
|
||||
if (! (mInner = new RDFHTMLCollectionImpl(this)))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return mInner->QueryInterface(aIID, aResult);
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMNodeList interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetLength(PRUint32* aLength)
|
||||
{
|
||||
NS_ASSERTION(aLength != nsnull, "null ptr");
|
||||
if (! aLength)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLength = mElements->Count();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::Item(PRUint32 aIndex, nsIDOMNode** aReturn)
|
||||
{
|
||||
NS_PRECONDITION(aReturn != nsnull, "null ptr");
|
||||
if (! aReturn)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(aIndex < (PRUint32) mElements->Count(), "invalid arg");
|
||||
if (aIndex >= (PRUint32) mElements->Count())
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
// Cast is okay because we're in a closed system.
|
||||
*aReturn = (nsIDOMNode*) mElements->ElementAt(aIndex);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIScriptObjectOwner interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsIScriptGlobalObject* global = aContext->GetGlobalObject();
|
||||
|
||||
if (nsnull == mScriptObject) {
|
||||
nsIDOMScriptObjectFactory *factory;
|
||||
|
||||
if (NS_SUCCEEDED(rv = nsServiceManager::GetService(kDOMScriptObjectFactoryCID,
|
||||
kIDOMScriptObjectFactoryIID,
|
||||
(nsISupports **)&factory))) {
|
||||
rv = factory->NewScriptHTMLCollection(aContext,
|
||||
(nsISupports*)(nsIDOMNodeList*)this,
|
||||
global,
|
||||
(void**)&mScriptObject);
|
||||
|
||||
nsServiceManager::ReleaseService(kDOMScriptObjectFactoryCID, factory);
|
||||
}
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
NS_RELEASE(global);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMNodeList::SetScriptObject(void* aScriptObject)
|
||||
{
|
||||
mScriptObject = aScriptObject;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::Init(void)
|
||||
{
|
||||
nsresult rv;
|
||||
if (NS_FAILED(rv = NS_NewISupportsArray(&mElements))) {
|
||||
NS_ERROR("unable to create elements array");
|
||||
return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsRDFDOMNodeList::AppendNode(nsIDOMNode* aNode)
|
||||
{
|
||||
NS_PRECONDITION(aNode != nsnull, "null ptr");
|
||||
if (! aNode)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
return mElements->AppendElement(aNode);
|
||||
}
|
||||
58
mozilla/rdf/content/src/nsRDFDOMNodeList.h
Normal file
58
mozilla/rdf/content/src/nsRDFDOMNodeList.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
#ifndef nsRDFDOMNodeList_h__
|
||||
#define nsRDFDOMNodeList_h__
|
||||
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
class nsIDOMNode;
|
||||
class nsISupportsArray;
|
||||
|
||||
class nsRDFDOMNodeList : public nsIDOMNodeList,
|
||||
public nsIScriptObjectOwner
|
||||
{
|
||||
private:
|
||||
nsISupports* mInner;
|
||||
nsISupportsArray* mElements;
|
||||
void* mScriptObject;
|
||||
|
||||
nsRDFDOMNodeList(void);
|
||||
nsresult Init(void);
|
||||
|
||||
public:
|
||||
static nsresult Create(nsRDFDOMNodeList** aResult);
|
||||
virtual ~nsRDFDOMNodeList(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIDOMNodeList interface
|
||||
NS_DECL_IDOMNODELIST
|
||||
|
||||
// nsIScriptObjectOwner interface
|
||||
NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject);
|
||||
NS_IMETHOD SetScriptObject(void* aScriptObject);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AppendNode(nsIDOMNode* aNode);
|
||||
};
|
||||
|
||||
#endif // nsRDFDOMNodeList_h__
|
||||
|
||||
2172
mozilla/rdf/content/src/nsRDFDocument.cpp
Normal file
2172
mozilla/rdf/content/src/nsRDFDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2590
mozilla/rdf/content/src/nsRDFElement.cpp
Normal file
2590
mozilla/rdf/content/src/nsRDFElement.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1474
mozilla/rdf/content/src/nsRDFGenericBuilder.cpp
Normal file
1474
mozilla/rdf/content/src/nsRDFGenericBuilder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
180
mozilla/rdf/content/src/nsRDFGenericBuilder.h
Normal file
180
mozilla/rdf/content/src/nsRDFGenericBuilder.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An implementation that builds a XUL
|
||||
content model that is to be used with a certain widget. This class
|
||||
is abstract.
|
||||
*/
|
||||
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
|
||||
class nsIRDFDocument;
|
||||
class nsIRDFCompositeDataSource;
|
||||
class nsIRDFResource;
|
||||
class nsIContent;
|
||||
class nsIRDFNode;
|
||||
class nsIAtom;
|
||||
class nsIRDFService;
|
||||
|
||||
class RDFGenericBuilderImpl : public nsIRDFContentModelBuilder,
|
||||
public nsIRDFObserver,
|
||||
public nsIDOMNodeObserver,
|
||||
public nsIDOMElementObserver
|
||||
{
|
||||
public:
|
||||
RDFGenericBuilderImpl();
|
||||
virtual ~RDFGenericBuilderImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContentModelBuilder interface
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
|
||||
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase);
|
||||
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase);
|
||||
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource);
|
||||
NS_IMETHOD SetRootContent(nsIContent* aElement);
|
||||
NS_IMETHOD CreateContents(nsIContent* aElement);
|
||||
|
||||
// nsIRDFObserver interface
|
||||
NS_IMETHOD OnAssert(nsIRDFResource* aSubject, nsIRDFResource* aPredicate, nsIRDFNode* aObject);
|
||||
NS_IMETHOD OnUnassert(nsIRDFResource* aSubject, nsIRDFResource* aPredicate, nsIRDFNode* aObjetct);
|
||||
|
||||
// nsIDOMNodeObserver interface
|
||||
NS_DECL_IDOMNODEOBSERVER
|
||||
|
||||
// nsIDOMElementObserver interface
|
||||
NS_DECL_IDOMELEMENTOBSERVER
|
||||
|
||||
// Implementation methods
|
||||
nsresult
|
||||
FindChildByTag(nsIContent* aElement,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIContent** aChild);
|
||||
|
||||
nsresult
|
||||
FindChildByTagAndResource(nsIContent* aElement,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIRDFResource* aResource,
|
||||
nsIContent** aChild);
|
||||
|
||||
nsresult
|
||||
EnsureElementHasGenericChild(nsIContent* aParent,
|
||||
PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIContent** aResult);
|
||||
|
||||
nsresult
|
||||
FindWidgetRootElement(nsIContent* aElement,
|
||||
nsIContent** aRootElement);
|
||||
|
||||
virtual nsresult
|
||||
AddWidgetItem(nsIContent* aWidgetElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue,
|
||||
PRInt32 naturalOrderPos) = 0;
|
||||
|
||||
virtual PRBool
|
||||
IsWidgetProperty(nsIContent* aElement, nsIRDFResource* aProperty);
|
||||
|
||||
PRBool
|
||||
IsOpen(nsIContent* aElement);
|
||||
|
||||
PRBool
|
||||
IsElementInWidget(nsIContent* aElement);
|
||||
|
||||
PRBool
|
||||
IsWidgetElement(nsIContent* aElement);
|
||||
|
||||
PRBool
|
||||
IsWidgetInsertionRootElement(nsIContent* aElement);
|
||||
|
||||
nsresult
|
||||
GetDOMNodeResource(nsIDOMNode* aNode, nsIRDFResource** aResource);
|
||||
|
||||
nsresult
|
||||
CreateResourceElement(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIRDFResource* aResource,
|
||||
nsIContent** aResult);
|
||||
|
||||
nsresult
|
||||
GetResource(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aNameAtom,
|
||||
nsIRDFResource** aResource);
|
||||
|
||||
virtual nsresult
|
||||
OpenWidgetItem(nsIContent* aElement);
|
||||
|
||||
virtual nsresult
|
||||
CloseWidgetItem(nsIContent* aElement);
|
||||
|
||||
nsresult
|
||||
GetElementResource(nsIContent* aElement, nsIRDFResource** aResult);
|
||||
|
||||
virtual nsresult
|
||||
GetRootWidgetAtom(nsIAtom** aResult) = 0;
|
||||
|
||||
virtual nsresult
|
||||
GetWidgetItemAtom(nsIAtom** aResult) = 0;
|
||||
|
||||
virtual nsresult
|
||||
GetWidgetFolderAtom(nsIAtom** aResult) = 0;
|
||||
|
||||
virtual nsresult
|
||||
GetInsertionRootAtom(nsIAtom** aResult) = 0;
|
||||
|
||||
virtual nsresult
|
||||
GetItemAtomThatContainsTheChildren(nsIAtom** aResult) = 0;
|
||||
// Well, you come up with a better name.
|
||||
|
||||
protected:
|
||||
nsIRDFDocument* mDocument;
|
||||
nsIRDFCompositeDataSource* mDB;
|
||||
nsIContent* mRoot;
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
static nsINameSpaceManager* gNameSpaceManager;
|
||||
|
||||
static nsIAtom* kContainerAtom;
|
||||
static nsIAtom* kItemContentsGeneratedAtom;
|
||||
static nsIAtom* kNaturalOrderPosAtom;
|
||||
static nsIAtom* kIdAtom;
|
||||
static nsIAtom* kOpenAtom;
|
||||
static nsIAtom* kResourceAtom;
|
||||
static nsIAtom* kContainmentAtom;
|
||||
|
||||
static PRInt32 kNameSpaceID_RDF;
|
||||
static PRInt32 kNameSpaceID_XUL;
|
||||
|
||||
static nsIRDFResource* kNC_Title;
|
||||
static nsIRDFResource* kNC_child;
|
||||
static nsIRDFResource* kNC_Column;
|
||||
static nsIRDFResource* kNC_Folder;
|
||||
static nsIRDFResource* kRDF_child;
|
||||
};
|
||||
445
mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
Normal file
445
mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
Normal file
@@ -0,0 +1,445 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An nsIRDFDocument implementation that builds an HTML-like model,
|
||||
complete with text nodes. The model can be displayed in a vanilla
|
||||
HTML content viewer by applying CSS2 styles to the text.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFHTMLBuilderImpl : public nsIRDFContentModelBuilder
|
||||
{
|
||||
private:
|
||||
nsIRDFDocument* mDocument;
|
||||
nsIRDFCompositeDataSource* mDB;
|
||||
|
||||
// pseudo constants
|
||||
PRInt32 kNameSpaceID_RDF; // note that this is a bona fide member
|
||||
|
||||
static nsrefcnt gRefCnt;
|
||||
static nsIAtom* kIdAtom;
|
||||
|
||||
public:
|
||||
RDFHTMLBuilderImpl();
|
||||
virtual ~RDFHTMLBuilderImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIRDFContentModelBuilder interface
|
||||
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
|
||||
NS_IMETHOD SetDataBase(nsIRDFCompositeDataSource* aDataBase);
|
||||
NS_IMETHOD GetDataBase(nsIRDFCompositeDataSource** aDataBase);
|
||||
NS_IMETHOD CreateRootContent(nsIRDFResource* aResource);
|
||||
NS_IMETHOD SetRootContent(nsIContent* aElement);
|
||||
NS_IMETHOD CreateContents(nsIContent* aElement);
|
||||
NS_IMETHOD OnAssert(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
NS_IMETHOD OnUnassert(nsIContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
|
||||
|
||||
// Implementation methods
|
||||
nsresult AddTreeChild(nsIContent* aParent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value);
|
||||
|
||||
nsresult AddLeafChild(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* value);
|
||||
|
||||
PRBool IsTreeProperty(nsIRDFResource* aProperty);
|
||||
|
||||
nsresult CreateResourceElement(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIRDFResource* aResource,
|
||||
nsIContent** aResult);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsrefcnt RDFHTMLBuilderImpl::gRefCnt;
|
||||
nsIAtom* RDFHTMLBuilderImpl::kIdAtom;
|
||||
|
||||
RDFHTMLBuilderImpl::RDFHTMLBuilderImpl(void)
|
||||
: mDocument(nsnull),
|
||||
mDB(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
if (gRefCnt++ == 0) {
|
||||
kIdAtom = NS_NewAtom("id");
|
||||
}
|
||||
}
|
||||
|
||||
RDFHTMLBuilderImpl::~RDFHTMLBuilderImpl(void)
|
||||
{
|
||||
NS_IF_RELEASE(mDB);
|
||||
// NS_IF_RELEASE(mDocument) not refcounted
|
||||
|
||||
if (--gRefCnt == 0) {
|
||||
NS_RELEASE(kIdAtom);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_IMPL_ISUPPORTS(RDFHTMLBuilderImpl, kIRDFContentModelBuilderIID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
RDFHTMLBuilderImpl::AddTreeChild(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFResource* value)
|
||||
{
|
||||
// If it's a tree property, then create a child element whose
|
||||
// value is the value of the property. We'll also attach an "ID="
|
||||
// attribute to the new child; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// <property id="value">
|
||||
// <!-- recursively generated -->
|
||||
// </property>
|
||||
// ...
|
||||
// </parent>
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIContent* child = nsnull;
|
||||
const char* p;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = CreateResourceElement(nameSpaceID, tag, value, &child)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = value->GetValue(&p)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, p, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
rv = parent->AppendChildTo(child, PR_TRUE);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(child);
|
||||
NS_IF_RELEASE(tag);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFHTMLBuilderImpl::AddLeafChild(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFLiteral* value)
|
||||
{
|
||||
// Otherwise, it's not a tree property. So we'll just create a
|
||||
// new element for the property, and a simple text node for
|
||||
// its value; e.g.,
|
||||
//
|
||||
// <parent>
|
||||
// <property>value</property>
|
||||
// ...
|
||||
// </parent>
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 nameSpaceID;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIContent* child = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, &tag)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = CreateResourceElement(nameSpaceID, tag, property, &child)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = parent->AppendChildTo(child, PR_TRUE)))
|
||||
goto done;
|
||||
|
||||
rv = nsRDFContentUtils::AttachTextNode(child, value);
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(child);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::SetDocument(nsIRDFDocument* aDocument)
|
||||
{
|
||||
NS_PRECONDITION(aDocument != nsnull, "null ptr");
|
||||
if (! aDocument)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(mDocument == nsnull, "already initialized");
|
||||
if (mDocument)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mDocument = aDocument; // not refcounted
|
||||
|
||||
nsCOMPtr<nsIDocument> doc( do_QueryInterface(mDocument) );
|
||||
if (doc) {
|
||||
nsCOMPtr<nsINameSpaceManager> mgr;
|
||||
doc->GetNameSpaceManager( *getter_AddRefs(mgr) );
|
||||
if (mgr) {
|
||||
static const char kRDFNameSpaceURI[] = RDF_NAMESPACE_URI;
|
||||
mgr->GetNameSpaceID(kRDFNameSpaceURI, kNameSpaceID_RDF);
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::SetDataBase(nsIRDFCompositeDataSource* aDataBase)
|
||||
{
|
||||
NS_PRECONDITION(aDataBase != nsnull, "null ptr");
|
||||
if (! aDataBase)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
NS_PRECONDITION(mDB == nsnull, "already initialized");
|
||||
if (mDB)
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
|
||||
mDB = aDataBase;
|
||||
NS_ADDREF(mDB);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::GetDataBase(nsIRDFCompositeDataSource** aDataBase)
|
||||
{
|
||||
NS_PRECONDITION(aDataBase != nsnull, "null ptr");
|
||||
if (! aDataBase)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aDataBase = mDB;
|
||||
NS_ADDREF(mDB);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::CreateRootContent(nsIRDFResource* aResource)
|
||||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "not initialized");
|
||||
if (! mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
nsIAtom* tag = nsnull;
|
||||
nsIDocument* doc = nsnull;
|
||||
nsIContent* root = nsnull;
|
||||
nsIContent* body = nsnull;
|
||||
|
||||
if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID, (void**) &doc)))
|
||||
goto done;
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
if ((tag = NS_NewAtom("document")) == nsnull)
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_None, tag, &root)))
|
||||
goto done;
|
||||
|
||||
doc->SetRootContent(NS_STATIC_CAST(nsIContent*, root));
|
||||
|
||||
NS_RELEASE(tag);
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
if ((tag = NS_NewAtom("body")) == nsnull)
|
||||
goto done;
|
||||
|
||||
// PR_TRUE indicates that children should be recursively generated on demand
|
||||
if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_None, tag, aResource, &body)))
|
||||
goto done;
|
||||
|
||||
if (NS_FAILED(rv = root->AppendChildTo(body, PR_FALSE)))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(body);
|
||||
NS_IF_RELEASE(root);
|
||||
NS_IF_RELEASE(tag);
|
||||
NS_IF_RELEASE(doc);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::SetRootContent(nsIContent* aElement)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::CreateContents(nsIContent* aElement)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("Adapt the implementation from RDFTreeBuilderImpl");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::OnAssert(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
NS_PRECONDITION(mDocument != nsnull, "not initialized");
|
||||
if (! mDocument)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsIRDFResource* valueResource;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &valueResource))) {
|
||||
// If it's a tree property or an RDF container, then add it as
|
||||
// a tree child and return.
|
||||
if (IsTreeProperty(property) || rdf_IsContainer(mDB, valueResource)) {
|
||||
rv = AddTreeChild(parent, property, valueResource);
|
||||
NS_RELEASE(valueResource);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Otherwise, fall through and add try to add it as a property
|
||||
NS_RELEASE(valueResource);
|
||||
}
|
||||
|
||||
nsIRDFLiteral* valueLiteral;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &valueLiteral))) {
|
||||
rv = AddLeafChild(parent, property, valueLiteral);
|
||||
NS_RELEASE(valueLiteral);
|
||||
}
|
||||
else {
|
||||
return NS_OK; // ignore resources on the leaf.
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFHTMLBuilderImpl::OnUnassert(nsIContent* parent,
|
||||
nsIRDFResource* property,
|
||||
nsIRDFNode* value)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFHTMLBuilderImpl::IsTreeProperty(nsIRDFResource* aProperty)
|
||||
{
|
||||
// XXX This whole method is a mega-kludge. This should be read off
|
||||
// of the element somehow...
|
||||
|
||||
#define TREE_PROPERTY_HACK
|
||||
#if defined(TREE_PROPERTY_HACK)
|
||||
const char* p;
|
||||
aProperty->GetValue(&p);
|
||||
nsAutoString s(p);
|
||||
if (s.Equals(NC_NAMESPACE_URI "child") ||
|
||||
s.Equals(NC_NAMESPACE_URI "Folder") ||
|
||||
s.Equals(NC_NAMESPACE_URI "Columns") ||
|
||||
s.Equals(RDF_NAMESPACE_URI "child")) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif // defined(TREE_PROPERTY_HACK)
|
||||
if (rdf_IsOrdinalProperty(aProperty)) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
RDFHTMLBuilderImpl::CreateResourceElement(PRInt32 aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIRDFResource* aResource,
|
||||
nsIContent** aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> result;
|
||||
if (NS_FAILED(rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(result))))
|
||||
return rv;
|
||||
|
||||
const char* uri;
|
||||
if (NS_FAILED(rv = aResource->GetValue(&uri)))
|
||||
return rv;
|
||||
|
||||
if (NS_FAILED(rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, uri, PR_FALSE)))
|
||||
return rv;
|
||||
|
||||
*aResult = result;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFHTMLBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFHTMLBuilderImpl* builder = new RDFHTMLBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
293
mozilla/rdf/content/src/nsRDFMenuBuilder.cpp
Normal file
293
mozilla/rdf/content/src/nsRDFMenuBuilder.cpp
Normal file
@@ -0,0 +1,293 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "rdf_qsort.h"
|
||||
|
||||
#include "nsRDFGenericBuilder.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Columns);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Column);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Title);
|
||||
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, child);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFMenuBuilderImpl : public RDFGenericBuilderImpl
|
||||
{
|
||||
public:
|
||||
RDFMenuBuilderImpl();
|
||||
virtual ~RDFMenuBuilderImpl();
|
||||
|
||||
// Implementation methods
|
||||
nsresult
|
||||
AddWidgetItem(nsIContent* aMenuItemElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue, PRInt32 aNaturalOrderPos);
|
||||
|
||||
nsresult
|
||||
GetRootWidgetAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kMenuAtom);
|
||||
*aResult = kMenuAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetItemAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kMenuItemAtom);
|
||||
*aResult = kMenuItemAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetFolderAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kMenuAtom);
|
||||
*aResult = kMenuAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetInsertionRootAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kMenuBarAtom);
|
||||
*aResult = kMenuBarAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetItemAtomThatContainsTheChildren(nsIAtom** aResult) {
|
||||
NS_ADDREF(kMenuAtom);
|
||||
*aResult = kMenuAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
||||
static nsIAtom* kMenuBarAtom;
|
||||
static nsIAtom* kMenuAtom;
|
||||
static nsIAtom* kMenuItemAtom;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsrefcnt RDFMenuBuilderImpl::gRefCnt = 0;
|
||||
|
||||
nsIAtom* RDFMenuBuilderImpl::kMenuAtom;
|
||||
nsIAtom* RDFMenuBuilderImpl::kMenuItemAtom;
|
||||
nsIAtom* RDFMenuBuilderImpl::kMenuBarAtom;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFMenuBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFMenuBuilderImpl* builder = new RDFMenuBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFMenuBuilderImpl::RDFMenuBuilderImpl(void)
|
||||
: RDFGenericBuilderImpl()
|
||||
{
|
||||
if (gRefCnt == 0) {
|
||||
kMenuAtom = NS_NewAtom("menu");
|
||||
kMenuItemAtom = NS_NewAtom("menuitem");
|
||||
kMenuBarAtom = NS_NewAtom("menubar");
|
||||
}
|
||||
|
||||
++gRefCnt;
|
||||
}
|
||||
|
||||
RDFMenuBuilderImpl::~RDFMenuBuilderImpl(void)
|
||||
{
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0) {
|
||||
|
||||
NS_RELEASE(kMenuAtom);
|
||||
NS_RELEASE(kMenuItemAtom);
|
||||
NS_RELEASE(kMenuBarAtom);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
RDFMenuBuilderImpl::AddWidgetItem(nsIContent* aElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue,
|
||||
PRInt32 naturalOrderPos)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> menuParent;
|
||||
menuParent = dont_QueryInterface(aElement);
|
||||
if (!IsWidgetElement(aElement) && !IsWidgetInsertionRootElement(aElement))
|
||||
{
|
||||
NS_ERROR("Can't add something here!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Create the <xul:menuitem> element
|
||||
nsCOMPtr<nsIContent> menuItem;
|
||||
if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL,
|
||||
kMenuItemAtom,
|
||||
aValue,
|
||||
getter_AddRefs(menuItem))))
|
||||
return rv;
|
||||
|
||||
// Add the <xul:menuitem> to the <xul:menu> element.
|
||||
menuParent->AppendChildTo(menuItem, PR_TRUE);
|
||||
|
||||
// Add miscellaneous attributes by iterating _all_ of the
|
||||
// properties out of the resource.
|
||||
nsCOMPtr<nsIRDFArcsOutCursor> arcs;
|
||||
if (NS_FAILED(rv = mDB->ArcLabelsOut(aValue, getter_AddRefs(arcs)))) {
|
||||
NS_ERROR("unable to get arcs out");
|
||||
return rv;
|
||||
}
|
||||
|
||||
while (NS_SUCCEEDED(rv = arcs->Advance())) {
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = arcs->GetPredicate(getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to get cursor value");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Ignore ordinal properties
|
||||
if (rdf_IsOrdinalProperty(property))
|
||||
continue;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to split property");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
if (NS_FAILED(rv = mDB->GetTarget(aValue, property, PR_TRUE, getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to get target");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
nsAutoString s;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, getter_AddRefs(resource)))) {
|
||||
const char* uri;
|
||||
resource->GetValue(&uri);
|
||||
s = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, getter_AddRefs(literal)))) {
|
||||
const PRUnichar* p;
|
||||
literal->GetValue(&p);
|
||||
s = p;
|
||||
}
|
||||
else {
|
||||
NS_ERROR("not a resource or a literal");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
menuItem->SetAttribute(nameSpaceID, tag, s, PR_FALSE);
|
||||
|
||||
nsString nameAtom;
|
||||
tag->ToString(nameAtom);
|
||||
if (nameAtom == "Name")
|
||||
{
|
||||
nsIAtom* lowerName = NS_NewAtom("name");
|
||||
// Hack to ensure that we add in a lowercase name attribute also.
|
||||
menuItem->SetAttribute(kNameSpaceID_None, lowerName, s, PR_FALSE);
|
||||
NS_RELEASE(lowerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
|
||||
NS_ERROR("error advancing cursor");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Finally, mark this as a "container" so that we know to
|
||||
// recursively generate kids if they're asked for.
|
||||
if (NS_FAILED(rv = menuItem->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
296
mozilla/rdf/content/src/nsRDFToolbarBuilder.cpp
Normal file
296
mozilla/rdf/content/src/nsRDFToolbarBuilder.cpp
Normal file
@@ -0,0 +1,296 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/* XXX: Teach this how to make toolboxes as well as toolbars. */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "rdf_qsort.h"
|
||||
|
||||
#include "nsRDFGenericBuilder.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Columns);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Column);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Title);
|
||||
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, child);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFToolbarBuilderImpl : public RDFGenericBuilderImpl
|
||||
{
|
||||
public:
|
||||
RDFToolbarBuilderImpl();
|
||||
virtual ~RDFToolbarBuilderImpl();
|
||||
|
||||
// Implementation methods
|
||||
nsresult
|
||||
AddWidgetItem(nsIContent* aToolbarItemElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue, PRInt32 aNaturalOrderPos);
|
||||
|
||||
nsresult
|
||||
GetRootWidgetAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kToolbarAtom);
|
||||
*aResult = kToolbarAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetItemAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTitledButtonAtom);
|
||||
*aResult = kTitledButtonAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetFolderAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTitledButtonAtom);
|
||||
*aResult = kTitledButtonAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetInsertionRootAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kToolbarAtom);
|
||||
*aResult = kToolbarAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetItemAtomThatContainsTheChildren(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTitledButtonAtom);
|
||||
*aResult = kTitledButtonAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
||||
static nsIAtom* kToolbarAtom;
|
||||
static nsIAtom* kTitledButtonAtom;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsrefcnt RDFToolbarBuilderImpl::gRefCnt = 0;
|
||||
|
||||
nsIAtom* RDFToolbarBuilderImpl::kToolbarAtom;
|
||||
nsIAtom* RDFToolbarBuilderImpl::kTitledButtonAtom;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFToolbarBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFToolbarBuilderImpl* builder = new RDFToolbarBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFToolbarBuilderImpl::RDFToolbarBuilderImpl(void)
|
||||
: RDFGenericBuilderImpl()
|
||||
{
|
||||
if (gRefCnt == 0) {
|
||||
kToolbarAtom = NS_NewAtom("toolbar");
|
||||
kTitledButtonAtom = NS_NewAtom("titledbutton");
|
||||
}
|
||||
|
||||
++gRefCnt;
|
||||
}
|
||||
|
||||
RDFToolbarBuilderImpl::~RDFToolbarBuilderImpl(void)
|
||||
{
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0) {
|
||||
|
||||
NS_RELEASE(kToolbarAtom);
|
||||
NS_RELEASE(kTitledButtonAtom);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
RDFToolbarBuilderImpl::AddWidgetItem(nsIContent* aElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue,
|
||||
PRInt32 naturalOrderPos)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> toolbarParent;
|
||||
toolbarParent = dont_QueryInterface(aElement);
|
||||
if (!IsWidgetElement(aElement) && !IsWidgetInsertionRootElement(aElement))
|
||||
{
|
||||
NS_ERROR("Can't add something here!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Create the <xul:titledbutton> element
|
||||
nsCOMPtr<nsIContent> toolbarItem;
|
||||
if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL,
|
||||
kTitledButtonAtom,
|
||||
aValue,
|
||||
getter_AddRefs(toolbarItem))))
|
||||
return rv;
|
||||
|
||||
// Add the <xul:titledbutton> to the <xul:toolbar> element.
|
||||
toolbarParent->AppendChildTo(toolbarItem, PR_TRUE);
|
||||
|
||||
// Add miscellaneous attributes by iterating _all_ of the
|
||||
// properties out of the resource.
|
||||
nsCOMPtr<nsIRDFArcsOutCursor> arcs;
|
||||
if (NS_FAILED(rv = mDB->ArcLabelsOut(aValue, getter_AddRefs(arcs)))) {
|
||||
NS_ERROR("unable to get arcs out");
|
||||
return rv;
|
||||
}
|
||||
|
||||
while (NS_SUCCEEDED(rv = arcs->Advance())) {
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = arcs->GetPredicate(getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to get cursor value");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Ignore ordinal properties
|
||||
if (rdf_IsOrdinalProperty(property))
|
||||
continue;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to split property");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
if (NS_FAILED(rv = mDB->GetTarget(aValue, property, PR_TRUE, getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to get target");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
nsAutoString s;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, getter_AddRefs(resource)))) {
|
||||
const char* uri;
|
||||
resource->GetValue(&uri);
|
||||
s = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, getter_AddRefs(literal)))) {
|
||||
const PRUnichar* p;
|
||||
literal->GetValue(&p);
|
||||
s = p;
|
||||
}
|
||||
else {
|
||||
NS_ERROR("not a resource or a literal");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
toolbarItem->SetAttribute(nameSpaceID, tag, s, PR_FALSE);
|
||||
|
||||
nsString nameAtom;
|
||||
tag->ToString(nameAtom);
|
||||
if (nameAtom == "Name")
|
||||
{
|
||||
nsIAtom* lowerName = NS_NewAtom("value");
|
||||
// Hack to ensure that we add in a lowercase value attribute also.
|
||||
toolbarItem->SetAttribute(kNameSpaceID_None, lowerName, s, PR_FALSE);
|
||||
NS_RELEASE(lowerName);
|
||||
}
|
||||
|
||||
// XXX (Dave) I want these to go away. Style sheets should be used for these.
|
||||
nsIAtom* alignment = NS_NewAtom("align");
|
||||
nsIAtom* imagesrc = NS_NewAtom("src");
|
||||
toolbarItem->SetAttribute(kNameSpaceID_None, alignment, "right", PR_FALSE);
|
||||
toolbarItem->SetAttribute(kNameSpaceID_None, imagesrc, "resource:/res/toolbar/TB_Location.gif", PR_FALSE);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
|
||||
NS_ERROR("error advancing cursor");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Finally, mark this as a "container" so that we know to
|
||||
// recursively generate kids if they're asked for.
|
||||
if (NS_FAILED(rv = toolbarItem->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
773
mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
Normal file
773
mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
Normal file
@@ -0,0 +1,773 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
An nsIRDFDocument implementation that builds a tree widget XUL
|
||||
content model that is to be used with a tree control.
|
||||
|
||||
TO DO
|
||||
|
||||
1) Get a real namespace for XUL. This should go in a
|
||||
header file somewhere.
|
||||
|
||||
2) We have a serious problem if all the columns aren't created by
|
||||
the time that we start inserting rows into the table. Need to fix
|
||||
this so that columns can be dynamically added and removed (we
|
||||
need to do this anyway to handle column re-ordering or
|
||||
manipulation via DOM calls).
|
||||
|
||||
3) There's lots of stuff screwed up with the ordering of walking the
|
||||
tree, creating children, getting assertions, etc. A lot of this
|
||||
has to do with the "are children already generated" state
|
||||
variable that lives in the RDFResourceElementImpl. I need to sit
|
||||
down and really figure out what the heck this needs to do.
|
||||
|
||||
4) Can we do sorting as an insertion sort? This is especially
|
||||
important in the case where content streams in; e.g., gets added
|
||||
in the OnAssert() method as opposed to the CreateContents()
|
||||
method.
|
||||
|
||||
5) There is a fair amount of shared code (~5%) between
|
||||
nsRDFTreeBuilder and nsRDFXULBuilder. It might make sense to make
|
||||
a base class nsGenericBuilder that holds common routines.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMElementObserver.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNodeObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIRDFContentModelBuilder.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
#include "nsIRDFCompositeDataSource.h"
|
||||
#include "nsIRDFDocument.h"
|
||||
#include "nsIRDFNode.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsRDFContentUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
#include "rdf_qsort.h"
|
||||
|
||||
#include "nsRDFGenericBuilder.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, child);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Columns);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Column);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Folder);
|
||||
DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Title);
|
||||
|
||||
DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, child);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class RDFTreeBuilderImpl : public RDFGenericBuilderImpl
|
||||
{
|
||||
public:
|
||||
RDFTreeBuilderImpl();
|
||||
virtual ~RDFTreeBuilderImpl();
|
||||
|
||||
// Implementation methods
|
||||
nsresult
|
||||
AddWidgetItem(nsIContent* aTreeItemElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue, PRInt32 aNaturalOrderPos);
|
||||
|
||||
nsresult
|
||||
EnsureCell(nsIContent* aTreeItemElement, PRInt32 aIndex, nsIContent** aCellElement);
|
||||
|
||||
nsresult
|
||||
CreateTreeItemCells(nsIContent* aTreeItemElement);
|
||||
|
||||
nsresult
|
||||
FindTreeCellForProperty(nsIContent* aTreeRowElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIContent** aTreeCell);
|
||||
|
||||
nsresult
|
||||
GetColumnForProperty(nsIContent* aTreeElement,
|
||||
nsIRDFResource* aProperty,
|
||||
PRInt32* aIndex);
|
||||
|
||||
nsresult
|
||||
SetCellValue(nsIContent* aTreeRowElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aValue);
|
||||
|
||||
nsresult
|
||||
GetRootWidgetAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTreeAtom);
|
||||
*aResult = kTreeAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetItemAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTreeItemAtom);
|
||||
*aResult = kTreeItemAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetWidgetFolderAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTreeItemAtom);
|
||||
*aResult = kTreeItemAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetInsertionRootAtom(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTreeBodyAtom);
|
||||
*aResult = kTreeBodyAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetItemAtomThatContainsTheChildren(nsIAtom** aResult) {
|
||||
NS_ADDREF(kTreeChildrenAtom);
|
||||
*aResult = kTreeChildrenAtom;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
||||
static nsIAtom* kTreeAtom;
|
||||
static nsIAtom* kTreeBodyAtom;
|
||||
static nsIAtom* kTreeCellAtom;
|
||||
static nsIAtom* kTreeChildrenAtom;
|
||||
static nsIAtom* kTreeColAtom;
|
||||
static nsIAtom* kTreeHeadAtom;
|
||||
static nsIAtom* kTreeIconAtom;
|
||||
static nsIAtom* kTreeIndentationAtom;
|
||||
static nsIAtom* kTreeItemAtom;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsrefcnt RDFTreeBuilderImpl::gRefCnt = 0;
|
||||
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeBodyAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeCellAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeChildrenAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeColAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeHeadAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeIconAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeIndentationAtom;
|
||||
nsIAtom* RDFTreeBuilderImpl::kTreeItemAtom;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewRDFTreeBuilder(nsIRDFContentModelBuilder** result)
|
||||
{
|
||||
NS_PRECONDITION(result != nsnull, "null ptr");
|
||||
if (! result)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
RDFTreeBuilderImpl* builder = new RDFTreeBuilderImpl();
|
||||
if (! builder)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(builder);
|
||||
*result = builder;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFTreeBuilderImpl::RDFTreeBuilderImpl(void)
|
||||
: RDFGenericBuilderImpl()
|
||||
{
|
||||
if (gRefCnt == 0) {
|
||||
kTreeAtom = NS_NewAtom("tree");
|
||||
kTreeBodyAtom = NS_NewAtom("treebody");
|
||||
kTreeCellAtom = NS_NewAtom("treecell");
|
||||
kTreeChildrenAtom = NS_NewAtom("treechildren");
|
||||
kTreeColAtom = NS_NewAtom("treecol");
|
||||
kTreeHeadAtom = NS_NewAtom("treehead");
|
||||
kTreeIconAtom = NS_NewAtom("treeicon");
|
||||
kTreeIndentationAtom = NS_NewAtom("treeindentation");
|
||||
kTreeItemAtom = NS_NewAtom("treeitem");
|
||||
}
|
||||
|
||||
++gRefCnt;
|
||||
}
|
||||
|
||||
RDFTreeBuilderImpl::~RDFTreeBuilderImpl(void)
|
||||
{
|
||||
--gRefCnt;
|
||||
if (gRefCnt == 0) {
|
||||
|
||||
NS_RELEASE(kTreeAtom);
|
||||
NS_RELEASE(kTreeBodyAtom);
|
||||
NS_RELEASE(kTreeCellAtom);
|
||||
NS_RELEASE(kTreeChildrenAtom);
|
||||
NS_RELEASE(kTreeColAtom);
|
||||
NS_RELEASE(kTreeHeadAtom);
|
||||
NS_RELEASE(kTreeIconAtom);
|
||||
NS_RELEASE(kTreeIndentationAtom);
|
||||
NS_RELEASE(kTreeItemAtom);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Implementation methods
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::AddWidgetItem(nsIContent* aElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFResource* aValue,
|
||||
PRInt32 aNaturalOrderPos)
|
||||
{
|
||||
// If it's a tree property, then we need to add the new child
|
||||
// element to a special "children" element in the parent. The
|
||||
// child element's value will be the value of the
|
||||
// property. We'll also attach an "ID=" attribute to the new
|
||||
// child; e.g.,
|
||||
//
|
||||
// <xul:treeitem>
|
||||
// ...
|
||||
// <xul:treechildren>
|
||||
// <xul:treeitem RDF:ID="value">
|
||||
// <xul:treerow>
|
||||
// <xul:treecell RDF:ID="column1">
|
||||
// <!-- value not specified until SetCellValue() -->
|
||||
// </xul:treecell>
|
||||
//
|
||||
// </xul:treecell RDF:ID="column2"/>
|
||||
// <!-- value not specified until SetCellValue() -->
|
||||
// </xul:treecell>
|
||||
//
|
||||
// ...
|
||||
//
|
||||
// </xul:treerow>
|
||||
//
|
||||
// <!-- Other content recursively generated -->
|
||||
//
|
||||
// </xul:treeitem>
|
||||
// </xul:treechildren>
|
||||
// ...
|
||||
// </xul:treeitem>
|
||||
//
|
||||
// We can also handle the case where they've specified RDF
|
||||
// contents on the <xul:treebody> tag, in which case we'll just
|
||||
// dangle the new row directly off the treebody.
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIContent> treeChildren;
|
||||
if (IsWidgetElement(aElement)) {
|
||||
// Ensure that the <xul:treechildren> element exists on the parent.
|
||||
if (NS_FAILED(rv = EnsureElementHasGenericChild(aElement,
|
||||
kNameSpaceID_XUL,
|
||||
kTreeChildrenAtom,
|
||||
getter_AddRefs(treeChildren))))
|
||||
return rv;
|
||||
}
|
||||
else if (IsWidgetInsertionRootElement(aElement)) {
|
||||
// We'll just use the <xul:treebody> as the element onto which
|
||||
// we'll dangle a new row.
|
||||
treeChildren = do_QueryInterface(aElement);
|
||||
if (! treeChildren) {
|
||||
NS_ERROR("aElement is not nsIContent!?!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ERROR("new tree row doesn't fit here!");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
// Create the <xul:treeitem> element
|
||||
nsCOMPtr<nsIContent> treeItem;
|
||||
if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL,
|
||||
kTreeItemAtom,
|
||||
aValue,
|
||||
getter_AddRefs(treeItem))))
|
||||
return rv;
|
||||
|
||||
// Create the cell substructure
|
||||
if (NS_FAILED(rv = CreateTreeItemCells(treeItem)))
|
||||
return rv;
|
||||
|
||||
// Add the <xul:treeitem> to the <xul:treechildren> element.
|
||||
treeChildren->AppendChildTo(treeItem, PR_TRUE);
|
||||
|
||||
// Add miscellaneous attributes by iterating _all_ of the
|
||||
// properties out of the resource.
|
||||
nsCOMPtr<nsIRDFArcsOutCursor> arcs;
|
||||
if (NS_FAILED(rv = mDB->ArcLabelsOut(aValue, getter_AddRefs(arcs)))) {
|
||||
NS_ERROR("unable to get arcs out");
|
||||
return rv;
|
||||
}
|
||||
|
||||
while (NS_SUCCEEDED(rv = arcs->Advance())) {
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(rv = arcs->GetPredicate(getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to get cursor value");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Ignore properties that are used to indicate "tree-ness"
|
||||
if (IsWidgetProperty(aElement, property))
|
||||
continue;
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = mDocument->SplitProperty(property, &nameSpaceID, getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to split property");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
if (NS_FAILED(rv = mDB->GetTarget(aValue, property, PR_TRUE, getter_AddRefs(value)))) {
|
||||
NS_ERROR("unable to get target");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFResource> resource;
|
||||
nsCOMPtr<nsIRDFLiteral> literal;
|
||||
|
||||
nsAutoString s;
|
||||
if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, getter_AddRefs(resource)))) {
|
||||
const char* uri;
|
||||
resource->GetValue(&uri);
|
||||
s = uri;
|
||||
}
|
||||
else if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, getter_AddRefs(literal)))) {
|
||||
const PRUnichar* p;
|
||||
literal->GetValue(&p);
|
||||
s = p;
|
||||
}
|
||||
else {
|
||||
NS_ERROR("not a resource or a literal");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
treeItem->SetAttribute(nameSpaceID, tag, s, PR_FALSE);
|
||||
|
||||
if (aNaturalOrderPos > 0)
|
||||
{
|
||||
// XXX Add this to menu builder as well, or better yet, abstract out.
|
||||
nsAutoString pos, zero("0");;
|
||||
pos.Append(aNaturalOrderPos, 10);
|
||||
if (pos.Length() < 4)
|
||||
{
|
||||
pos.Insert(zero, 0, 4-pos.Length());
|
||||
}
|
||||
treeItem->SetAttribute(kNameSpaceID_None, kNaturalOrderPosAtom, pos, PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) && (rv != NS_ERROR_RDF_CURSOR_EMPTY)) {
|
||||
NS_ERROR("error advancing cursor");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Finally, mark this as a "container" so that we know to
|
||||
// recursively generate kids if they're asked for.
|
||||
if (NS_FAILED(rv = treeItem->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::EnsureCell(nsIContent* aTreeItemElement,
|
||||
PRInt32 aIndex,
|
||||
nsIContent** aCellElement)
|
||||
{
|
||||
// This method returns that the aIndex-th <xul:treecell> element
|
||||
// if it is already present, and if not, will create up to aIndex
|
||||
// nodes to create it.
|
||||
NS_PRECONDITION(aIndex >= 0, "invalid arg");
|
||||
if (aIndex < 0)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// XXX at this point, we should probably ensure that aElement is
|
||||
// actually a <xul:treeitem>...
|
||||
|
||||
|
||||
// Iterate through the children of the <xul:treeitem>, counting
|
||||
// <xul:treecell> tags until we get to the aIndex-th one.
|
||||
PRInt32 count;
|
||||
if (NS_FAILED(rv = aTreeItemElement->ChildCount(count))) {
|
||||
NS_ERROR("unable to get xul:treeitem's child count");
|
||||
return rv;
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> kid;
|
||||
if (NS_FAILED(rv = aTreeItemElement->ChildAt(i, *getter_AddRefs(kid)))) {
|
||||
NS_ERROR("unable to retrieve xul:treeitem's child");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
if (NS_FAILED(rv = kid->GetNameSpaceID(nameSpaceID))) {
|
||||
NS_ERROR("unable to get child namespace");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (nameSpaceID != kNameSpaceID_XUL)
|
||||
continue; // not <xul:*>
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = kid->GetTag(*getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to get child tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (tag.get() != kTreeCellAtom)
|
||||
continue; // not <xul:treecell>
|
||||
|
||||
// Okay, it's a xul:treecell; see if it's the right one...
|
||||
if (aIndex == 0) {
|
||||
*aCellElement = kid;
|
||||
NS_ADDREF(*aCellElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Nope, decrement the counter and move on...
|
||||
--aIndex;
|
||||
}
|
||||
|
||||
// Create all of the xul:treecell elements up to and including the
|
||||
// index of the cell that was asked for.
|
||||
NS_ASSERTION(aIndex >= 0, "uh oh, I thought aIndex was s'posed t' be >= 0...");
|
||||
|
||||
nsCOMPtr<nsIContent> cellElement;
|
||||
while (aIndex-- >= 0) {
|
||||
if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_XUL,
|
||||
kTreeCellAtom,
|
||||
getter_AddRefs(cellElement)))) {
|
||||
NS_ERROR("unable to create new xul:treecell");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = aTreeItemElement->AppendChildTo(cellElement, PR_FALSE))) {
|
||||
NS_ERROR("unable to append xul:treecell to treeitem");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
*aCellElement = cellElement;
|
||||
NS_ADDREF(*aCellElement);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::CreateTreeItemCells(nsIContent* aTreeItemElement)
|
||||
{
|
||||
// <xul:treeitem>
|
||||
// <xul:treecell RDF:ID="property">value</xul:treecell>
|
||||
// ...
|
||||
// </xul:treeitem>
|
||||
nsresult rv;
|
||||
|
||||
// XXX at this point, we should probably ensure that aElement is
|
||||
// actually a <xul:treeitem>...
|
||||
|
||||
// Get the treeitem's resource so that we can generate cell
|
||||
// values. We could QI for the nsIRDFResource here, but doing this
|
||||
// via the nsIContent interface allows us to support generic nodes
|
||||
// that might get added in by DOM calls.
|
||||
nsCOMPtr<nsIRDFResource> treeItemResource;
|
||||
if (NS_FAILED(rv = GetElementResource(aTreeItemElement, getter_AddRefs(treeItemResource)))) {
|
||||
NS_ERROR("unable to get tree item resource");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 count;
|
||||
if (NS_FAILED(rv = mRoot->ChildCount(count))) {
|
||||
NS_ERROR("unable to count xul:tree element's kids");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Iterate through all the columns that have been specified,
|
||||
// constructing a cell in the content model for each one.
|
||||
PRInt32 cellIndex = 0;
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> kid;
|
||||
if (NS_FAILED(rv = mRoot->ChildAt(i, *getter_AddRefs(kid)))) {
|
||||
NS_ERROR("unable to get xul:tree's child");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
if (NS_FAILED(rv = kid->GetNameSpaceID(nameSpaceID))) {
|
||||
NS_ERROR("unable to get child's namespace");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (nameSpaceID != kNameSpaceID_XUL)
|
||||
continue; // not <xul:*>
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = kid->GetTag(*getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to get child's tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (tag.get() != kTreeColAtom)
|
||||
continue; // not <xul:treecol>
|
||||
|
||||
// Okay, we've found a column. Ensure that we've got a real
|
||||
// tree cell that lives beneath _this_ tree item for its
|
||||
// value.
|
||||
nsCOMPtr<nsIContent> cellElement;
|
||||
if (NS_FAILED(rv = EnsureCell(aTreeItemElement, cellIndex, getter_AddRefs(cellElement)))) {
|
||||
NS_ERROR("unable to find/create cell element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIContent* textParent = cellElement;
|
||||
|
||||
// The first cell gets a <xul:treeindentation> element and a
|
||||
// <xul:treeicon> element...
|
||||
//
|
||||
// XXX This is bogus: dogfood ready crap. We need to figure
|
||||
// out a better way to specify this.
|
||||
if (cellIndex == 0) {
|
||||
nsCOMPtr<nsIContent> indentationElement;
|
||||
if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_XUL,
|
||||
kTreeIndentationAtom,
|
||||
getter_AddRefs(indentationElement)))) {
|
||||
NS_ERROR("unable to create indentation node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = cellElement->AppendChildTo(indentationElement, PR_FALSE))) {
|
||||
NS_ERROR("unable to append indentation element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> iconElement;
|
||||
if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_XUL,
|
||||
kTreeIconAtom,
|
||||
getter_AddRefs(iconElement)))) {
|
||||
NS_ERROR("unable to create icon node");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv = cellElement->AppendChildTo(iconElement, PR_FALSE))) {
|
||||
NS_ERROR("uanble to append icon element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
textParent = iconElement;
|
||||
}
|
||||
|
||||
|
||||
// The column property is stored in the RDF:resource attribute
|
||||
// of the tag.
|
||||
nsAutoString uri;
|
||||
if (NS_FAILED(rv = kid->GetAttribute(kNameSpaceID_RDF, kResourceAtom, uri))) {
|
||||
NS_ERROR("severe error occured retrieving attribute");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Set its value, if we know it.
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
|
||||
// First construct a property resource from the URI...
|
||||
nsCOMPtr<nsIRDFResource> property;
|
||||
if (NS_FAILED(gRDFService->GetUnicodeResource(uri, getter_AddRefs(property)))) {
|
||||
NS_ERROR("unable to construct resource for xul:treecell");
|
||||
return rv; // XXX fatal
|
||||
}
|
||||
|
||||
// ...then query the RDF back-end
|
||||
nsCOMPtr<nsIRDFNode> value;
|
||||
if (NS_SUCCEEDED(rv = mDB->GetTarget(treeItemResource,
|
||||
property,
|
||||
PR_TRUE,
|
||||
getter_AddRefs(value)))) {
|
||||
|
||||
// Attach a plain old text node: nothing fancy. Here's
|
||||
// where we'd do wacky stuff like pull in an icon or
|
||||
// whatever.
|
||||
if (NS_FAILED(rv = nsRDFContentUtils::AttachTextNode(textParent, value))) {
|
||||
NS_ERROR("unable to attach text node to xul:treecell");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else if (rv == NS_ERROR_RDF_NO_VALUE) {
|
||||
// otherwise, there was no value for this. It'll have to
|
||||
// get set later, when an OnAssert() comes in (if it even
|
||||
// has a value at all...)
|
||||
}
|
||||
else {
|
||||
NS_ERROR("error getting cell's value");
|
||||
return rv; // XXX something serious happened
|
||||
}
|
||||
}
|
||||
|
||||
++cellIndex;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::GetColumnForProperty(nsIContent* aTreeElement,
|
||||
nsIRDFResource* aProperty,
|
||||
PRInt32* aIndex)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
const char* propertyURI;
|
||||
if (NS_FAILED(rv = aProperty->GetValue(&propertyURI))) {
|
||||
NS_ERROR("unable to get property's URI");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX should ensure that aTreeElement really is a xul:tree
|
||||
|
||||
PRInt32 count;
|
||||
if (NS_FAILED(rv = aTreeElement->ChildCount(count))) {
|
||||
NS_ERROR("unable to count xul:tree element's kids");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Iterate through the columns to find the one that's appropriate
|
||||
// for this cell.
|
||||
PRInt32 index = 0;
|
||||
for (PRInt32 i = 0; i < count; ++i) {
|
||||
nsCOMPtr<nsIContent> kid;
|
||||
if (NS_FAILED(rv = aTreeElement->ChildAt(i, *getter_AddRefs(kid)))) {
|
||||
NS_ERROR("unable to get xul:tree's child");
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRInt32 nameSpaceID;
|
||||
if (NS_FAILED(rv = kid->GetNameSpaceID(nameSpaceID))) {
|
||||
NS_ERROR("unable to get child's namespace");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (nameSpaceID != kNameSpaceID_XUL)
|
||||
continue; // not <xul:*>
|
||||
|
||||
nsCOMPtr<nsIAtom> tag;
|
||||
if (NS_FAILED(rv = kid->GetTag(*getter_AddRefs(tag)))) {
|
||||
NS_ERROR("unable to get child's tag");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (tag.get() != kTreeColAtom)
|
||||
continue; // not <xul:treecol>
|
||||
|
||||
// Okay, we've found a column. Is it the right one? The
|
||||
// column property is stored in the RDF:resource attribute of
|
||||
// the tag....
|
||||
nsAutoString uri;
|
||||
if (NS_FAILED(rv = kid->GetAttribute(kNameSpaceID_RDF, kResourceAtom, uri))) {
|
||||
NS_ERROR("severe error occured retrieving attribute");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (rv == NS_CONTENT_ATTR_HAS_VALUE) {
|
||||
if (0 == nsCRT::strcmp(uri, propertyURI)) {
|
||||
*aIndex = index;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
++index;
|
||||
}
|
||||
|
||||
// Nope, couldn't find it.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
RDFTreeBuilderImpl::SetCellValue(nsIContent* aTreeItemElement,
|
||||
nsIRDFResource* aProperty,
|
||||
nsIRDFNode* aValue)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// XXX We assume that aTreeItemElement is actually a
|
||||
// <xul:treeitem>, it'd be good to enforce this...
|
||||
|
||||
PRInt32 index;
|
||||
if (NS_FAILED(rv = GetColumnForProperty(mRoot, aProperty, &index))) {
|
||||
// If we can't find a column for the specified property, that
|
||||
// just means there isn't a column in the tree for that
|
||||
// property. No big deal. Bye!
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> cellElement;
|
||||
if (NS_FAILED(rv = EnsureCell(aTreeItemElement, index, getter_AddRefs(cellElement)))) {
|
||||
NS_ERROR("unable to find/create cell element");
|
||||
return rv;
|
||||
}
|
||||
|
||||
// XXX if the cell already has a value, we need to replace it, not
|
||||
// just append new text...
|
||||
|
||||
if (NS_FAILED(rv = nsRDFContentUtils::AttachTextNode(cellElement, aValue)))
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
1893
mozilla/rdf/content/src/nsRDFXULBuilder.cpp
Normal file
1893
mozilla/rdf/content/src/nsRDFXULBuilder.cpp
Normal file
File diff suppressed because it is too large
Load Diff
144
mozilla/rdf/content/src/nsXULAttributes.cpp
Normal file
144
mozilla/rdf/content/src/nsXULAttributes.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A helper class used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsXULAttributes.h"
|
||||
#include "nsICSSParser.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
const PRUnichar kNullCh = PRUnichar('\0');
|
||||
|
||||
static void ParseClasses(const nsString& aClassString, nsClassList** aClassList)
|
||||
{
|
||||
NS_ASSERTION(nsnull == *aClassList, "non null start list");
|
||||
|
||||
nsAutoString classStr(aClassString); // copy to work buffer
|
||||
classStr.Append(kNullCh); // put an extra null at the end
|
||||
|
||||
PRUnichar* start = (PRUnichar*)(const PRUnichar*)classStr;
|
||||
PRUnichar* end = start;
|
||||
|
||||
while (kNullCh != *start) {
|
||||
while ((kNullCh != *start) && nsString::IsSpace(*start)) { // skip leading space
|
||||
start++;
|
||||
}
|
||||
end = start;
|
||||
|
||||
while ((kNullCh != *end) && (PR_FALSE == nsString::IsSpace(*end))) { // look for space or end
|
||||
end++;
|
||||
}
|
||||
*end = kNullCh; // end string here
|
||||
|
||||
if (start < end) {
|
||||
*aClassList = new nsClassList(NS_NewAtom(start));
|
||||
aClassList = &((*aClassList)->mNext);
|
||||
}
|
||||
|
||||
start = ++end;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::GetClasses(nsVoidArray& aArray) const
|
||||
{
|
||||
aArray.Clear();
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
aArray.AppendElement(classList->mAtom); // NOTE atom is not addrefed
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXULAttributes::HasClass(nsIAtom* aClass) const
|
||||
{
|
||||
const nsClassList* classList = mClassList;
|
||||
while (nsnull != classList) {
|
||||
if (classList->mAtom == aClass) {
|
||||
return NS_OK;
|
||||
}
|
||||
classList = classList->mNext;
|
||||
}
|
||||
return NS_COMFALSE;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateClassList(const nsString& aValue)
|
||||
{
|
||||
if (mClassList != nsnull)
|
||||
{
|
||||
delete mClassList;
|
||||
mClassList = nsnull;
|
||||
}
|
||||
|
||||
if (aValue != "")
|
||||
ParseClasses(aValue, &mClassList);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue)
|
||||
{
|
||||
if (aValue == "")
|
||||
{
|
||||
// XXX: Removing the rule. Is this sufficient?
|
||||
NS_IF_RELEASE(mStyleRule);
|
||||
mStyleRule = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsICSSParser* css;
|
||||
nsresult result = NS_NewCSSParser(&css);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
nsIStyleRule* rule;
|
||||
result = css->ParseDeclarations(aValue, aDocURL, rule);
|
||||
//NS_IF_RELEASE(docURL);
|
||||
|
||||
if ((NS_OK == result) && (nsnull != rule)) {
|
||||
mStyleRule = rule; //Addrefed already during parse, so don't need to addref again.
|
||||
//result = SetHTMLAttribute(aAttribute, nsHTMLValue(rule), aNotify);
|
||||
}
|
||||
//else {
|
||||
// result = SetHTMLAttribute(aAttribute, nsHTMLValue(aValue), aNotify);
|
||||
//}
|
||||
NS_RELEASE(css);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsXULAttributes::GetInlineStyleRule(nsIStyleRule*& aRule)
|
||||
{
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
if (mStyleRule != nsnull)
|
||||
{
|
||||
aRule = mStyleRule;
|
||||
NS_ADDREF(aRule);
|
||||
result = NS_OK;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
128
mozilla/rdf/content/src/nsXULAttributes.h
Normal file
128
mozilla/rdf/content/src/nsXULAttributes.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (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 Communicator client 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.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
|
||||
A helper class used to implement attributes.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsXULAttributes_h__
|
||||
#define nsXULAttributes_h__
|
||||
|
||||
#include "nsIStyleRule.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
class nsIURL;
|
||||
|
||||
struct nsClassList {
|
||||
nsClassList(nsIAtom* aAtom)
|
||||
: mAtom(aAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
}
|
||||
nsClassList(const nsClassList& aCopy)
|
||||
: mAtom(aCopy.mAtom),
|
||||
mNext(nsnull)
|
||||
{
|
||||
NS_ADDREF(mAtom);
|
||||
if (nsnull != aCopy.mNext) {
|
||||
mNext = new nsClassList(*(aCopy.mNext));
|
||||
}
|
||||
}
|
||||
~nsClassList(void)
|
||||
{
|
||||
NS_RELEASE(mAtom);
|
||||
if (nsnull != mNext) {
|
||||
delete mNext;
|
||||
}
|
||||
}
|
||||
|
||||
nsIAtom* mAtom;
|
||||
nsClassList* mNext;
|
||||
};
|
||||
|
||||
struct nsXULAttribute
|
||||
{
|
||||
nsXULAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue)
|
||||
{
|
||||
mNameSpaceID = aNameSpaceID;
|
||||
NS_IF_ADDREF(aName);
|
||||
mName = aName;
|
||||
mValue = aValue;
|
||||
}
|
||||
|
||||
~nsXULAttribute()
|
||||
{
|
||||
NS_IF_RELEASE(mName);
|
||||
}
|
||||
|
||||
PRInt32 mNameSpaceID;
|
||||
nsIAtom* mName;
|
||||
nsString mValue;
|
||||
};
|
||||
|
||||
class nsXULAttributes
|
||||
{
|
||||
public:
|
||||
nsXULAttributes()
|
||||
: mClassList(nsnull), mStyleRule(nsnull)
|
||||
{
|
||||
mAttributes = new nsVoidArray();
|
||||
}
|
||||
|
||||
~nsXULAttributes(void)
|
||||
{
|
||||
if (nsnull != mAttributes) {
|
||||
PRInt32 count = mAttributes->Count();
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
nsXULAttribute* attr = (nsXULAttribute*)mAttributes->ElementAt(index);
|
||||
delete attr;
|
||||
}
|
||||
}
|
||||
delete mAttributes;
|
||||
}
|
||||
|
||||
// VoidArray Helpers
|
||||
PRInt32 Count() { return mAttributes->Count(); };
|
||||
nsXULAttribute* ElementAt(PRInt32 i) { return (nsXULAttribute*)mAttributes->ElementAt(i); };
|
||||
void AppendElement(nsXULAttribute* aElement) { mAttributes->AppendElement((void*)aElement); };
|
||||
void RemoveElementAt(PRInt32 index) { mAttributes->RemoveElementAt(index); };
|
||||
|
||||
// Style Helpers
|
||||
nsresult GetClasses(nsVoidArray& aArray) const;
|
||||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
|
||||
nsresult UpdateClassList(const nsString& aValue);
|
||||
nsresult UpdateStyleRule(nsIURL* aDocURL, const nsString& aValue);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aRule);
|
||||
|
||||
public:
|
||||
nsClassList* mClassList;
|
||||
nsIStyleRule* mStyleRule;
|
||||
nsVoidArray* mAttributes;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsXULAttributes_h__
|
||||
|
||||
3077
mozilla/rdf/content/src/nsXULDocument.cpp
Normal file
3077
mozilla/rdf/content/src/nsXULDocument.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user