diff --git a/mozilla/rdf/base/public/nsIRDFDataSource.h b/mozilla/rdf/base/public/nsIRDFDataSource.h
index 0fc271837e7..510de2e5f2a 100644
--- a/mozilla/rdf/base/public/nsIRDFDataSource.h
+++ b/mozilla/rdf/base/public/nsIRDFDataSource.h
@@ -177,6 +177,25 @@ public:
*/
NS_IMETHOD Flush() = 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__ */
diff --git a/mozilla/rdf/base/src/nsContainerCursor.cpp b/mozilla/rdf/base/src/nsContainerCursor.cpp
index b8b5da7ee73..f16610ec31b 100644
--- a/mozilla/rdf/base/src/nsContainerCursor.cpp
+++ b/mozilla/rdf/base/src/nsContainerCursor.cpp
@@ -109,7 +109,7 @@ ContainerCursorImpl::ContainerCursorImpl(nsIRDFDataSource* ds,
NS_ASSERTION(NS_SUCCEEDED(rv), "unable to acquire resource manager");
- NS_ASSERTION(rdf_IsContainer(mRDFService, mDataSource, container), "not a container");
+ NS_ASSERTION(rdf_IsContainer(mDataSource, container), "not a container");
}
diff --git a/mozilla/rdf/base/src/nsDataBase.cpp b/mozilla/rdf/base/src/nsDataBase.cpp
index b1ad582c461..cea4d1bf038 100644
--- a/mozilla/rdf/base/src/nsDataBase.cpp
+++ b/mozilla/rdf/base/src/nsDataBase.cpp
@@ -41,7 +41,7 @@
#include "nsIRDFCursor.h"
#include "nsIRDFNode.h"
#include "nsIRDFDataBase.h"
-#include "nsISupportsArray.h"
+#include "nsIRDFObserver.h"
#include "nsRepository.h"
#include "nsVoidArray.h"
#include "prlog.h"
@@ -52,12 +52,15 @@ static NS_DEFINE_IID(kIRDFAssertionCursorIID, NS_IRDFASSERTIONCURSOR_IID);
static NS_DEFINE_IID(kIRDFCursorIID, NS_IRDFCURSOR_IID);
static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_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);
////////////////////////////////////////////////////////////////////////
// DataBase
-class DataBase : public nsIRDFDataBase {
+class DataBase : public nsIRDFDataBase,
+ public nsIRDFObserver
+{
protected:
nsVoidArray* mObservers;
@@ -124,32 +127,46 @@ public:
NS_IMETHOD Flush();
+ NS_IMETHOD IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult);
+
+ NS_IMETHOD DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget);
+
+
// nsIRDFDataBase 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);
-
-
};
-//NS_IMPL_ISUPPORTS(DataBase, kIRDFDataBaseIID);
-
class DBArcsInOutCursor : public nsIRDFArcsOutCursor,
public nsIRDFArcsInCursor
{
- DataBase* mDataBase;
- nsIRDFResource* mSource;
- nsIRDFNode* mTarget;
- PRInt32 mCount;
+ DataBase* mDataBase;
+ nsIRDFResource* mSource;
+ nsIRDFNode* mTarget;
+ PRInt32 mCount;
nsIRDFArcsOutCursor* mOutCursor;
- nsIRDFArcsInCursor* mInCursor;
- nsVoidArray mResults;
+ nsIRDFArcsInCursor* mInCursor;
+ nsVoidArray mResults;
public:
DBArcsInOutCursor(DataBase* db, nsIRDFNode* node, PRBool arcsOutp);
@@ -186,8 +203,6 @@ public:
};
-// NS_IMPL_ISUPPORTS(DBArcsInOutCursor, kIRDFArcsOutCursorIID);
-//NS_IMPL_ISUPPORTS(DBArcsInOutCursor, kIRDFArcsInCursorIID);
DBArcsInOutCursor::DBArcsInOutCursor (DataBase* db, nsIRDFNode* node, PRBool arcsOutp)
: mDataBase(db),
@@ -219,6 +234,11 @@ DBArcsInOutCursor::DBArcsInOutCursor (DataBase* db, nsIRDFNode* node, PRBool arc
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);
}
@@ -247,8 +267,9 @@ DBArcsInOutCursor::Advance(void)
{
nsIRDFDataSource* ds;
while (mInCursor || mOutCursor) {
- nsresult result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
- while (NS_ERROR_RDF_CURSOR_EMPTY != result) {
+ nsresult result = (mInCursor ? mInCursor->Advance() : mOutCursor->Advance());
+
+ while (NS_SUCCEEDED(result)) {
nsIRDFNode* obj ;
GetValue(&obj);
if (mResults.IndexOf(obj) < 0) {
@@ -258,6 +279,12 @@ DBArcsInOutCursor::Advance(void)
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 >= mDataBase->mDataSources.Count())
break;
@@ -421,8 +448,8 @@ DBGetSTCursor::Advance(void)
DataBase::DataBase(void)
+ : mObservers(nsnull)
{
- mObservers = 0;
NS_INIT_REFCNT();
}
@@ -431,8 +458,10 @@ DataBase::~DataBase(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;
}
////////////////////////////////////////////////////////////////////////
@@ -447,7 +476,6 @@ DataBase::QueryInterface(REFNSIID iid, void** result)
if (! result)
return NS_ERROR_NULL_POINTER;
- *result = nsnull;
if (iid.Equals(kIRDFDataBaseIID) ||
iid.Equals(kIRDFDataSourceIID) ||
iid.Equals(kISupportsIID)) {
@@ -455,7 +483,15 @@ DataBase::QueryInterface(REFNSIID iid, void** result)
NS_ADDREF(this);
return NS_OK;
}
- return NS_NOINTERFACE;
+ else if (iid.Equals(kIRDFObserverIID)) {
+ *result = NS_STATIC_CAST(nsIRDFObserver*, this);
+ NS_ADDREF(this);
+ return NS_OK;
+ }
+ else {
+ *result = nsnull;
+ return NS_NOINTERFACE;
+ }
}
@@ -520,9 +556,9 @@ DataBase::GetSources(nsIRDFResource* property,
NS_IMETHODIMP
DataBase::GetTarget(nsIRDFResource* source,
- nsIRDFResource* property,
- PRBool tv,
- nsIRDFNode** target)
+ nsIRDFResource* property,
+ PRBool tv,
+ nsIRDFNode** target)
{
PRInt32 count = mDataSources.Count();
for (PRInt32 i = 0; i < count; ++i) {
@@ -652,34 +688,26 @@ DataBase::HasAssertion(nsIRDFResource* source,
}
NS_IMETHODIMP
-DataBase::AddObserver(nsIRDFObserver* n)
+DataBase::AddObserver(nsIRDFObserver* obs)
{
- PRInt32 count = mDataSources.Count();
- for (PRInt32 i = 0; i < count; ++i) {
- nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
- ds->AddObserver(n);
- }
-
if (!mObservers) {
if ((mObservers = new nsVoidArray()) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
}
- mObservers->AppendElement(n);
+ // XXX ensure uniqueness
+ mObservers->AppendElement(obs);
return NS_OK;
}
NS_IMETHODIMP
-DataBase::RemoveObserver(nsIRDFObserver* n)
+DataBase::RemoveObserver(nsIRDFObserver* obs)
{
- if (!mObservers) return NS_OK;
+ if (!mObservers)
+ return NS_OK;
- PRInt32 count = mDataSources.Count();
- for (PRInt32 i = 0; i < count; ++i) {
- nsIRDFDataSource* ds = NS_STATIC_CAST(nsIRDFDataSource*, mDataSources[i]);
- ds->RemoveObserver(n);
- }
+ mObservers->RemoveElement(obs);
return NS_OK;
}
@@ -725,6 +753,23 @@ DataBase::Flush()
return NS_OK;
}
+NS_IMETHODIMP
+DataBase::IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult)
+{
+ PR_ASSERT(0);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+DataBase::DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget)
+{
+ PR_ASSERT(0);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
////////////////////////////////////////////////////////////////////////
// nsIRDFDataBase methods
// XXX rvg We should make this take an additional argument specifying where
@@ -739,6 +784,7 @@ DataBase::AddDataSource(nsIRDFDataSource* source)
return NS_ERROR_NULL_POINTER;
mDataSources.InsertElementAt(source, 0);
+ source->AddObserver(this);
NS_ADDREF(source);
return NS_OK;
}
@@ -754,11 +800,44 @@ DataBase::RemoveDataSource(nsIRDFDataSource* source)
if (mDataSources.IndexOf(source) >= 0) {
mDataSources.RemoveElement(source);
+ source->RemoveObserver(this);
NS_RELEASE(source);
}
return NS_OK;
}
+NS_IMETHODIMP
+DataBase::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
+DataBase::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;
+}
+
+
+
////////////////////////////////////////////////////////////////////////
nsresult
diff --git a/mozilla/rdf/base/src/nsInMemoryDataSource.cpp b/mozilla/rdf/base/src/nsInMemoryDataSource.cpp
index ee2a7570d7e..cb230d45c86 100644
--- a/mozilla/rdf/base/src/nsInMemoryDataSource.cpp
+++ b/mozilla/rdf/base/src/nsInMemoryDataSource.cpp
@@ -213,6 +213,13 @@ public:
NS_IMETHOD Flush();
+ NS_IMETHOD IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult);
+
+ NS_IMETHOD DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget);
+
// nsIRDFXMLSource methods
NS_IMETHOD Serialize(nsIOutputStream* aStream);
@@ -504,6 +511,7 @@ InMemoryArcsCursor::InMemoryArcsCursor(InMemoryDataSource* ds,
mCurrent(nsnull),
mDirection(direction)
{
+ NS_INIT_REFCNT();
NS_ADDREF(mDataSource);
// Hopefully this won't suck too much because most arcs will have
@@ -996,7 +1004,7 @@ InMemoryDataSource::Assert(nsIRDFResource* source,
// notify observers
if (mObservers) {
- for (PRInt32 i = mObservers->Count(); i >= 0; --i) {
+ for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
obs->OnAssert(source, property, target);
// XXX ignore return value?
@@ -1067,7 +1075,7 @@ InMemoryDataSource::Unassert(nsIRDFResource* source,
// Notify the world
if (mObservers) {
- for (PRInt32 i = mObservers->Count(); i >= 0; --i) {
+ for (PRInt32 i = mObservers->Count() - 1; i >= 0; --i) {
nsIRDFObserver* obs = (nsIRDFObserver*) mObservers->ElementAt(i);
obs->OnUnassert(source, property, target);
// XXX ignore return value?
@@ -1081,6 +1089,10 @@ InMemoryDataSource::Unassert(nsIRDFResource* source,
NS_IMETHODIMP
InMemoryDataSource::AddObserver(nsIRDFObserver* observer)
{
+ NS_ASSERTION(observer != nsnull, "null ptr");
+ if (! observer)
+ return NS_ERROR_NULL_POINTER;
+
if (! mObservers) {
if ((mObservers = new nsVoidArray()) == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
@@ -1093,6 +1105,10 @@ InMemoryDataSource::AddObserver(nsIRDFObserver* observer)
NS_IMETHODIMP
InMemoryDataSource::RemoveObserver(nsIRDFObserver* observer)
{
+ NS_ASSERTION(observer != nsnull, "null ptr");
+ if (! observer)
+ return NS_ERROR_NULL_POINTER;
+
if (! mObservers)
return NS_OK;
@@ -1143,6 +1159,20 @@ InMemoryDataSource::Flush()
return NS_OK;
}
+NS_IMETHODIMP
+InMemoryDataSource::IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult)
+{
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+InMemoryDataSource::DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget)
+{
+ return NS_OK;
+}
// XXX This is a total kludge that takes a property resource (like
// "http://www.w3.org/TR/WD-rdf-syntax#Description") and converts it
diff --git a/mozilla/rdf/base/src/rdfutil.cpp b/mozilla/rdf/base/src/rdfutil.cpp
index 4eab00737a0..25a6ec1fad6 100644
--- a/mozilla/rdf/base/src/rdfutil.cpp
+++ b/mozilla/rdf/base/src/rdfutil.cpp
@@ -29,6 +29,8 @@
#include "nsIRDFDataBase.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
+#include "nsIServiceManager.h"
+#include "nsRDFCID.h"
#include "nsString.h"
#include "rdfutil.h"
@@ -57,6 +59,24 @@ DEFINE_RDF_VOCAB(RDF_NAMESPACE_URI, RDF, nextVal); // ad hoc way to make contain
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
+static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
+
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+
+////////////////////////////////////////////////////////////////////////
+
+static nsIRDFService* gRDFService = nsnull;
+
+static nsresult
+rdf_EnsureRDFService(void)
+{
+ if (gRDFService)
+ return NS_OK;
+
+ return nsServiceManager::GetService(kRDFServiceCID,
+ kIRDFServiceIID,
+ (nsISupports**) &gRDFService);
+}
////////////////////////////////////////////////////////////////////////
@@ -88,8 +108,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property)
PRBool
-rdf_IsContainer(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_IsContainer(nsIRDFDataSource* ds,
nsIRDFResource* resource)
{
PRBool result = PR_FALSE;
@@ -99,10 +118,13 @@ rdf_IsContainer(nsIRDFService* service,
nsIRDFResource* RDF_Seq = nsnull;
nsresult rv;
- if (NS_FAILED(rv = service->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
+ goto done;
+
+ if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_instanceOf, &RDF_instanceOf)))
goto done;
- if (NS_FAILED(rv = service->GetResource(kURIRDF_Bag, &RDF_Bag)))
+ if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_Bag, &RDF_Bag)))
goto done;
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Bag, PR_TRUE, &result)))
@@ -111,7 +133,7 @@ rdf_IsContainer(nsIRDFService* service,
if (result)
goto done;
- if (NS_FAILED(rv = service->GetResource(kURIRDF_Seq, &RDF_Seq)))
+ if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_Seq, &RDF_Seq)))
goto done;
if (NS_FAILED(rv = ds->HasAssertion(resource, RDF_instanceOf, RDF_Seq, PR_TRUE, &result)))
@@ -151,8 +173,7 @@ rdf_IsResource(const nsString& s)
// 0. node, node, node
nsresult
-rdf_Assert(nsIRDFService* service, // unused
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsIRDFNode* object)
@@ -193,21 +214,22 @@ rdf_Assert(nsIRDFService* service, // unused
// 1. string, string, string
nsresult
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
const nsString& objectURI)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
nsresult rv;
nsIRDFResource* subject;
- if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
return rv;
- rv = rdf_Assert(service, ds, subject, predicateURI, objectURI);
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(subjectURI, &subject)))
+ return rv;
+
+ rv = rdf_Assert(ds, subject, predicateURI, objectURI);
NS_RELEASE(subject);
return rv;
@@ -215,37 +237,38 @@ rdf_Assert(nsIRDFService* service,
// 2. node, node, string
nsresult
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
const nsString& objectURI)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
nsresult rv;
nsIRDFNode* object;
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
+ return rv;
+
// XXX Make a guess *here* if the object should be a resource or a
// literal. If you don't like it, then call ds->Assert() yerself.
if (rdf_IsResource(objectURI)) {
nsIRDFResource* resource;
- if (NS_FAILED(rv = service->GetUnicodeResource(objectURI, &resource)))
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(objectURI, &resource)))
return rv;
object = resource;
}
else {
nsIRDFLiteral* literal;
- if (NS_FAILED(rv = service->GetLiteral(objectURI, &literal)))
+ if (NS_FAILED(rv = gRDFService->GetLiteral(objectURI, &literal)))
return rv;
object = literal;
}
- rv = rdf_Assert(service, ds, subject, predicate, object);
+ rv = rdf_Assert(ds, subject, predicate, object);
NS_RELEASE(object);
return rv;
@@ -254,32 +277,24 @@ rdf_Assert(nsIRDFService* service,
// 3. node, string, string
nsresult
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
const nsString& objectURI)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
nsresult rv;
- nsIRDFResource* predicate;
- //XXX gross hack for now since I can't seem to get namespaces working in the parser
- if (predicateURI.Equals("child") || predicateURI.Equals("subject")) {
- nsAutoString prefix("http://home.netscape.com/NC-rdf#");
- prefix.Append(predicateURI);
- if (NS_FAILED(rv = service->GetUnicodeResource(prefix, &predicate)))
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
return rv;
- } else {
- if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
- return rv;
- }
-
- rv = rdf_Assert(service, ds, subject, predicate, objectURI);
+ nsIRDFResource* predicate;
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(predicateURI, &predicate)))
+ return rv;
+
+ rv = rdf_Assert(ds, subject, predicate, objectURI);
NS_RELEASE(predicate);
return rv;
@@ -287,23 +302,24 @@ rdf_Assert(nsIRDFService* service,
// 4. node, string, node
nsresult
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
nsIRDFNode* object)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(subject, "null ptr");
NS_ASSERTION(object, "null ptr");
nsresult rv;
- nsIRDFResource* predicate;
- if (NS_FAILED(rv = service->GetUnicodeResource(predicateURI, &predicate)))
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
return rv;
- rv = rdf_Assert(service, ds, subject, predicate, object);
+ nsIRDFResource* predicate;
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(predicateURI, &predicate)))
+ return rv;
+
+ rv = rdf_Assert(ds, subject, predicate, object);
NS_RELEASE(predicate);
return rv;
@@ -311,21 +327,22 @@ rdf_Assert(nsIRDFService* service,
// 5. string, string, node
nsresult
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
nsIRDFNode* object)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
nsresult rv;
- nsIRDFResource* subject;
- if (NS_FAILED(rv = service->GetUnicodeResource(subjectURI, &subject)))
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
return rv;
- rv = rdf_Assert(service, ds, subject, predicateURI, object);
+ nsIRDFResource* subject;
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(subjectURI, &subject)))
+ return rv;
+
+ rv = rdf_Assert(ds, subject, predicateURI, object);
NS_RELEASE(subject);
return rv;
@@ -334,23 +351,24 @@ rdf_Assert(nsIRDFService* service,
nsresult
-rdf_CreateAnonymousResource(nsIRDFService* service,
- nsIRDFResource** result)
+rdf_CreateAnonymousResource(nsIRDFResource** result)
{
static PRUint32 gCounter = 0;
nsAutoString s = "$";
s.Append(++gCounter, 10);
- return service->GetUnicodeResource(s, result);
+ nsresult rv;
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
+ return rv;
+
+ return gRDFService->GetUnicodeResource(s, result);
}
nsresult
-rdf_MakeBag(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeBag(nsIRDFDataSource* ds,
nsIRDFResource* bag)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(bag, "null ptr");
@@ -358,10 +376,10 @@ rdf_MakeBag(nsIRDFService* service,
// XXX check to see if someone else has already made this into a container.
- if (NS_FAILED(rv = rdf_Assert(service, ds, bag, kURIRDF_instanceOf, kURIRDF_Bag)))
+ if (NS_FAILED(rv = rdf_Assert(ds, bag, kURIRDF_instanceOf, kURIRDF_Bag)))
return rv;
- if (NS_FAILED(rv = rdf_Assert(service, ds, bag, kURIRDF_nextVal, "1")))
+ if (NS_FAILED(rv = rdf_Assert(ds, bag, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@@ -369,11 +387,9 @@ rdf_MakeBag(nsIRDFService* service,
nsresult
-rdf_MakeSeq(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeSeq(nsIRDFDataSource* ds,
nsIRDFResource* seq)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(seq, "null ptr");
@@ -381,10 +397,10 @@ rdf_MakeSeq(nsIRDFService* service,
// XXX check to see if someone else has already made this into a container.
- if (NS_FAILED(rv = rdf_Assert(service, ds, seq, kURIRDF_instanceOf, kURIRDF_Seq)))
+ if (NS_FAILED(rv = rdf_Assert(ds, seq, kURIRDF_instanceOf, kURIRDF_Seq)))
return rv;
- if (NS_FAILED(rv = rdf_Assert(service, ds, seq, kURIRDF_nextVal, "1")))
+ if (NS_FAILED(rv = rdf_Assert(ds, seq, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@@ -392,11 +408,9 @@ rdf_MakeSeq(nsIRDFService* service,
nsresult
-rdf_MakeAlt(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeAlt(nsIRDFDataSource* ds,
nsIRDFResource* alt)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(alt, "null ptr");
@@ -404,10 +418,10 @@ rdf_MakeAlt(nsIRDFService* service,
// XXX check to see if someone else has already made this into a container.
- if (NS_FAILED(rv = rdf_Assert(service, ds, alt, kURIRDF_instanceOf, kURIRDF_Alt)))
+ if (NS_FAILED(rv = rdf_Assert(ds, alt, kURIRDF_instanceOf, kURIRDF_Alt)))
return rv;
- if (NS_FAILED(rv = rdf_Assert(service, ds, alt, kURIRDF_nextVal, "1")))
+ if (NS_FAILED(rv = rdf_Assert(ds, alt, kURIRDF_nextVal, "1")))
return rv;
return NS_OK;
@@ -415,16 +429,17 @@ rdf_MakeAlt(nsIRDFService* service,
static nsresult
-rdf_ContainerGetNextValue(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_ContainerGetNextValue(nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFResource** result)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(container, "null ptr");
nsresult rv;
+ if (NS_FAILED(rv = rdf_EnsureRDFService()))
+ return rv;
+
nsIRDFResource* RDF_nextVal = nsnull;
nsIRDFNode* nextValNode = nsnull;
nsIRDFLiteral* nextValLiteral = nsnull;
@@ -435,7 +450,7 @@ rdf_ContainerGetNextValue(nsIRDFService* service,
// Get the next value, which hangs off of the bag via the
// RDF:nextVal property.
- if (NS_FAILED(rv = service->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
+ if (NS_FAILED(rv = gRDFService->GetResource(kURIRDF_nextVal, &RDF_nextVal)))
goto done;
if (NS_FAILED(rv = ds->GetTarget(container, RDF_nextVal, PR_TRUE, &nextValNode)))
@@ -457,7 +472,7 @@ rdf_ContainerGetNextValue(nsIRDFService* service,
nextValStr.Append("_");
nextValStr.Append(nextVal, 10);
- if (NS_FAILED(rv = service->GetUnicodeResource(nextValStr, result)))
+ if (NS_FAILED(rv = gRDFService->GetUnicodeResource(nextValStr, result)))
goto done;
// Now increment the RDF:nextVal property.
@@ -470,10 +485,10 @@ rdf_ContainerGetNextValue(nsIRDFService* service,
nextValStr.Truncate();
nextValStr.Append(nextVal, 10);
- if (NS_FAILED(rv = service->GetLiteral(nextValStr, &nextValLiteral)))
+ if (NS_FAILED(rv = gRDFService->GetLiteral(nextValStr, &nextValLiteral)))
goto done;
- if (NS_FAILED(rv = rdf_Assert(service, ds, container, RDF_nextVal, nextValLiteral)))
+ if (NS_FAILED(rv = rdf_Assert(ds, container, RDF_nextVal, nextValLiteral)))
goto done;
done:
@@ -486,12 +501,10 @@ done:
nsresult
-rdf_ContainerAddElement(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_ContainerAddElement(nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFNode* element)
{
- NS_ASSERTION(service, "null ptr");
NS_ASSERTION(ds, "null ptr");
NS_ASSERTION(container, "null ptr");
NS_ASSERTION(element, "null ptr");
@@ -500,10 +513,10 @@ rdf_ContainerAddElement(nsIRDFService* service,
nsIRDFResource* nextVal;
- if (NS_FAILED(rv = rdf_ContainerGetNextValue(service, ds, container, &nextVal)))
+ if (NS_FAILED(rv = rdf_ContainerGetNextValue(ds, container, &nextVal)))
goto done;
- if (rv = rdf_Assert(service, ds, container, nextVal, element))
+ if (rv = rdf_Assert(ds, container, nextVal, element))
goto done;
done:
diff --git a/mozilla/rdf/base/src/rdfutil.h b/mozilla/rdf/base/src/rdfutil.h
index 5e4bff68b52..cbf467b3df2 100644
--- a/mozilla/rdf/base/src/rdfutil.h
+++ b/mozilla/rdf/base/src/rdfutil.h
@@ -35,7 +35,6 @@ class nsIRDFCursor;
class nsIRDFDataBase;
class nsIRDFDataSource;
class nsIRDFNode;
-class nsIRDFService;
class nsString;
/**
@@ -51,8 +50,7 @@ rdf_IsOrdinalProperty(const nsIRDFResource* property);
* rdf:Bag.
*/
PR_EXTERN(PRBool)
-rdf_IsContainer(nsIRDFService* service,
- nsIRDFDataSource* db,
+rdf_IsContainer(nsIRDFDataSource* db,
nsIRDFResource* resource);
@@ -62,48 +60,42 @@ rdf_IsContainer(nsIRDFService* service,
// 0. node, node, node
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service, // unused
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
nsIRDFNode* object);
// 1. string, string, string
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
const nsString& objectURI);
// 2. node, node, string
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
nsIRDFResource* predicate,
const nsString& objectURI);
// 3. node, string, string
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
const nsString& objectURI);
// 4. node, string, node
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
nsIRDFResource* subject,
const nsString& predicateURI,
nsIRDFNode* object);
// 5. string, string, node
PR_EXTERN(nsresult)
-rdf_Assert(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_Assert(nsIRDFDataSource* ds,
const nsString& subjectURI,
const nsString& predicateURI,
nsIRDFNode* object);
@@ -113,32 +105,28 @@ rdf_Assert(nsIRDFService* service,
* resource URI.
*/
PR_EXTERN(nsresult)
-rdf_CreateAnonymousResource(nsIRDFService* service,
- nsIRDFResource** result);
+rdf_CreateAnonymousResource(nsIRDFResource** result);
/**
* Create a bag resource.
*/
PR_EXTERN(nsresult)
-rdf_MakeBag(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeBag(nsIRDFDataSource* ds,
nsIRDFResource* resource);
/**
* Create a sequence resource.
*/
PR_EXTERN(nsresult)
-rdf_MakeSeq(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeSeq(nsIRDFDataSource* ds,
nsIRDFResource* resource);
/**
* Create an alternation resource.
*/
PR_EXTERN(nsresult)
-rdf_MakeAlt(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_MakeAlt(nsIRDFDataSource* ds,
nsIRDFResource* resource);
@@ -146,8 +134,7 @@ rdf_MakeAlt(nsIRDFService* service,
* Add an element to the container.
*/
PR_EXTERN(nsresult)
-rdf_ContainerAddElement(nsIRDFService* service,
- nsIRDFDataSource* ds,
+rdf_ContainerAddElement(nsIRDFDataSource* ds,
nsIRDFResource* container,
nsIRDFNode* element);
diff --git a/mozilla/rdf/build/makefile.win b/mozilla/rdf/build/makefile.win
index a59b56a368d..98207b33c8f 100644
--- a/mozilla/rdf/build/makefile.win
+++ b/mozilla/rdf/build/makefile.win
@@ -63,6 +63,7 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).lib $(DIST)\lib
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\inbox $(DIST)\bin\res\rdf\Mail\joe@meer.net
$(MAKE_INSTALL) ..\resources\LocalStore.rdf $(DIST)\bin\res\rdf
+ $(MAKE_INSTALL) ..\resources\LocalStore.css $(DIST)\bin\res\rdf
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\work $(DIST)\bin\res\rdf\Mail\joe@meer.net
$(MAKE_INSTALL) ..\resources\Mail\joe@meer.net\other $(DIST)\bin\res\rdf\Mail\joe@meer.net
$(MAKE_INSTALL) ..\resources\Mail\jane@aol.com\inbox $(DIST)\bin\res\rdf\Mail\jane@aol.com
diff --git a/mozilla/rdf/build/nsRDFCID.h b/mozilla/rdf/build/nsRDFCID.h
index 0f98b6d631a..bcd6f92a6e7 100644
--- a/mozilla/rdf/build/nsRDFCID.h
+++ b/mozilla/rdf/build/nsRDFCID.h
@@ -46,12 +46,16 @@
#define NS_RDFDATABASE_CID \
{ 0xe638d761, 0x8687, 0x11d2, { 0xb5, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
+// {541AFCB2-A9A3-11d2-8EC5-00805F29F370}
+#define NS_RDFDOCUMENT_CID \
+{ 0x541afcb2, 0xa9a3, 0x11d2, { 0x8e, 0xc5, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
+
// {954F0813-81DC-11d2-B52A-000000000000}
-#define NS_RDFHTMLDOCUMENT_CID \
+#define NS_RDFHTMLBUILDER_CID \
{ 0x954f0813, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
// {3D262D00-8B5A-11d2-8EB0-00805F29F370}
-#define NS_RDFTREEDOCUMENT_CID \
+#define NS_RDFTREEBUILDER_CID \
{ 0x3d262d00, 0x8b5a, 0x11d2, { 0x8e, 0xb0, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
// {7BAF62E0-8E61-11d2-8EB1-00805F29F370}
diff --git a/mozilla/rdf/build/nsRDFFactory.cpp b/mozilla/rdf/build/nsRDFFactory.cpp
index bb9745e85a0..aa558a73dd6 100644
--- a/mozilla/rdf/build/nsRDFFactory.cpp
+++ b/mozilla/rdf/build/nsRDFFactory.cpp
@@ -22,13 +22,14 @@
*/
-#include "nsISupports.h"
#include "nsIFactory.h"
+#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFContentSink.h"
+#include "nsIRDFDocument.h"
#include "nsIRDFService.h"
+#include "nsISupports.h"
#include "nsRDFBaseDataSources.h"
#include "nsRDFBuiltInDataSources.h"
-#include "nsRDFDocument.h"
#include "nsRDFCID.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
@@ -36,12 +37,13 @@ static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
-static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFDocumentCID, NS_RDFDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
static NS_DEFINE_CID(kRDFStreamDataSourceCID, NS_RDFSTREAMDATASOURCE_CID);
-static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
class RDFFactoryImpl : public nsIFactory
{
@@ -141,12 +143,16 @@ RDFFactoryImpl::CreateInstance(nsISupports *aOuter,
if (NS_FAILED(rv = NS_NewRDFDataBase((nsIRDFDataBase**) &inst)))
return rv;
}
- else if (mClassID.Equals(kRDFHTMLDocumentCID)) {
- if (NS_FAILED(rv = NS_NewRDFHTMLDocument((nsIRDFDocument**) &inst)))
+ else if (mClassID.Equals(kRDFDocumentCID)) {
+ if (NS_FAILED(rv = NS_NewRDFDocument((nsIRDFDocument**) &inst)))
return rv;
}
- else if (mClassID.Equals(kRDFTreeDocumentCID)) {
- if (NS_FAILED(rv = NS_NewRDFTreeDocument((nsIRDFDocument**) &inst)))
+ else if (mClassID.Equals(kRDFHTMLBuilderCID)) {
+ if (NS_FAILED(rv = NS_NewRDFHTMLBuilder((nsIRDFContentModelBuilder**) &inst)))
+ return rv;
+ }
+ else if (mClassID.Equals(kRDFTreeBuilderCID)) {
+ if (NS_FAILED(rv = NS_NewRDFTreeBuilder((nsIRDFContentModelBuilder**) &inst)))
return rv;
}
else if (mClassID.Equals(kRDFSimpleContentSinkCID)) {
diff --git a/mozilla/rdf/content/public/MANIFEST b/mozilla/rdf/content/public/MANIFEST
index 2a3e601c328..aebd7311a62 100644
--- a/mozilla/rdf/content/public/MANIFEST
+++ b/mozilla/rdf/content/public/MANIFEST
@@ -1,3 +1,4 @@
nsIRDFContent.h
+nsIRDFContentModelBuilder.h
nsIRDFContentSink.h
nsIRDFDocument.h
diff --git a/mozilla/rdf/content/public/Makefile.in b/mozilla/rdf/content/public/Makefile.in
index 6a9ce9c9b78..42a8d0db5fc 100644
--- a/mozilla/rdf/content/public/Makefile.in
+++ b/mozilla/rdf/content/public/Makefile.in
@@ -26,6 +26,7 @@ MODULE = rdf
EXPORTS = \
nsIRDFContent.h \
+ nsIRDFContentModelBuilder.h \
nsIRDFContentSink.h \
nsIRDFDocument.h \
$(NULL)
diff --git a/mozilla/rdf/content/public/makefile.win b/mozilla/rdf/content/public/makefile.win
index 24c801f9504..ac4036a04ca 100644
--- a/mozilla/rdf/content/public/makefile.win
+++ b/mozilla/rdf/content/public/makefile.win
@@ -21,9 +21,10 @@ MODULE=rdf
DEPTH=..\..\..
EXPORTS = \
- nsIRDFContent.h \
- nsIRDFContentSink.h \
- nsIRDFDocument.h \
+ nsIRDFContent.h \
+ nsIRDFContentModelBuilder.h \
+ nsIRDFContentSink.h \
+ nsIRDFDocument.h \
$(NULL)
include <$(DEPTH)/config/rules.mak>
diff --git a/mozilla/rdf/content/public/nsIRDFContent.h b/mozilla/rdf/content/public/nsIRDFContent.h
index 1777a1068aa..aa5116266f6 100644
--- a/mozilla/rdf/content/public/nsIRDFContent.h
+++ b/mozilla/rdf/content/public/nsIRDFContent.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/* -*- 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
@@ -29,8 +29,6 @@
#include "nsISupports.h"
#include "nsIXMLContent.h"
-class nsIRDFContent;
-class nsIRDFDocument;
class nsIRDFResource;
// {954F0810-81DC-11d2-B52A-000000000000}
@@ -38,27 +36,25 @@ class nsIRDFResource;
{ 0x954f0810, 0x81dc, 0x11d2, { 0xb5, 0x2a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } }
/**
- * RDF content extensions to nsIXMLContent
+ * RDF content extensions to nsIContent
*/
-class nsIRDFContent : public nsIXMLContent {
+class nsIRDFContent : public nsIContent {
public:
- NS_IMETHOD Init(nsIRDFDocument* doc,
- const nsString& tag,
- nsIRDFResource* resource,
- PRBool childrenMustBeGenerated) = 0;
-
- NS_IMETHOD SetResource(const nsString& aURI) = 0;
- NS_IMETHOD GetResource(nsString& rURI) const = 0;
-
- NS_IMETHOD SetResource(nsIRDFResource* aResource) = 0;
- NS_IMETHOD GetResource(nsIRDFResource*& aResource) = 0;
-
- NS_IMETHOD SetProperty(const nsString& aPropertyURI, const nsString& aValue) = 0;
- NS_IMETHOD GetProperty(const nsString& aPropertyURI, nsString& rValue) const = 0;
+ NS_IMETHOD GetResource(nsIRDFResource*& aResource) const = 0;
+ NS_IMETHOD ChildrenHaveBeenGenerated(PRBool& aResult) const = 0;
};
+nsresult
+NS_NewRDFResourceElement(nsIRDFContent** aResult,
+ nsIRDFResource* aResource,
+ PRInt32 aNameSpaceID,
+ nsIAtom* aTag,
+ PRBool aChildrenMustBeGenerated);
+
+nsresult
+NS_NewRDFGenericElement(nsIContent** aResult,
+ PRInt32 aNameSpaceID,
+ nsIAtom* aTag);
-extern nsresult
-NS_NewRDFElement(nsIRDFContent** aResult);
#endif // nsIRDFContent_h___
diff --git a/mozilla/rdf/content/public/nsIRDFContentModelBuilder.h b/mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
index 431927743a5..1cc0935a332 100644
--- a/mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
+++ b/mozilla/rdf/content/public/nsIRDFContentModelBuilder.h
@@ -19,7 +19,9 @@
/*
- A content model builder.
+ A content model builder interface. An object that implements this
+ interface is associated with an nsIRDFDocument object to construct
+ an NGLayout content model.
*/
@@ -40,10 +42,32 @@ class nsIRDFResource;
class nsIRDFContentModelBuilder : public nsISupports
{
public:
+ /**
+ * Point the content model builder to the document. The content model
+ * builder must not reference count the document.
+ */
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument) = 0;
+
+ /**
+ * Called to instruct the content model builder to construct the root
+ * document element. The content model builder should construct an
+ * nsIContent object and set the document's content root to that object
+ * via the nsIDocument::SetDocumentRoot() method.
+ */
NS_IMETHOD CreateRoot(nsIRDFResource* aResource) = 0;
- NS_IMETHOD CreateChildrenFor(nsIRDFContent* aElement) = 0;
+
+ /**
+ * Called when a new assertion is made to the RDF graph that affects an
+ * element in the content model. The content model builder should update
+ * the document's content model as appropriate.
+ */
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue) = 0;
+
+ /**
+ * Called when an assertion is removed from the RDF graph that affects
+ * an element in the content model. The content model builder should
+ * update the document's content model as appropriate.
+ */
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue) = 0;
};
diff --git a/mozilla/rdf/content/public/nsIRDFDocument.h b/mozilla/rdf/content/public/nsIRDFDocument.h
index 5a458704fb6..7f0b5666015 100644
--- a/mozilla/rdf/content/public/nsIRDFDocument.h
+++ b/mozilla/rdf/content/public/nsIRDFDocument.h
@@ -28,9 +28,13 @@
#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 nsIRDFContent;
+class nsIRDFContentModelBuilder;
class nsIRDFDataBase;
class nsISupportsArray;
class nsIRDFResource;
@@ -42,13 +46,14 @@ class nsIRDFResource;
/**
* RDF document extensions to nsIDocument
*/
-class nsIRDFDocument : public nsIXMLDocument {
+class nsIRDFDocument : public nsIXMLDocument
+{
public:
/**
* Initialize the document object. This will force the document to create
* its internal RDF database.
*/
- NS_IMETHOD Init(void) = 0;
+ NS_IMETHOD Init(nsIRDFContentModelBuilder* aBuilder) = 0;
/**
* Set the document's "root" resource.
@@ -86,10 +91,18 @@ public:
* RDF graph.
*/
NS_IMETHOD RemoveTreeProperty(nsIRDFResource* resource) = 0;
+
+ /**
+ * Determine whether the specified property is a "tree" property.
+ */
+ NS_IMETHOD IsTreeProperty(nsIRDFResource* aProperty, PRBool* aResult) const = 0;
+
+ NS_IMETHOD MapResource(nsIRDFResource* aResource, nsIRDFContent* aContent) = 0;
+ NS_IMETHOD UnMapResource(nsIRDFResource* aResource, nsIRDFContent* aContent) = 0;
+ NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag) = 0;
};
// factory functions
-nsresult NS_NewRDFHTMLDocument(nsIRDFDocument** result);
-nsresult NS_NewRDFTreeDocument(nsIRDFDocument** result);
+nsresult NS_NewRDFDocument(nsIRDFDocument** result);
#endif // nsIRDFDocument_h___
diff --git a/mozilla/rdf/content/src/Makefile.in b/mozilla/rdf/content/src/Makefile.in
index 8a88ce24682..967663fb0ce 100644
--- a/mozilla/rdf/content/src/Makefile.in
+++ b/mozilla/rdf/content/src/Makefile.in
@@ -28,11 +28,15 @@ LIBRARY_NAME = rdfcontent_s
CPPSRCS = \
nsRDFContentSink.cpp \
+ nsRDFContentUtils.cpp \
+ nsRDFDOMNodeList.cpp \
nsRDFDocument.cpp \
nsRDFDocumentContentSink.cpp \
- nsRDFElement.cpp \
- nsRDFHTMLDocument.cpp \
- nsRDFTreeDocument.cpp \
+ nsRDFGenericElement.cpp \
+ nsRDFHTMLBuilder.cpp \
+ nsRDFResourceElement.cpp \
+ nsRDFSimpleContentSink.cpp \
+ nsRDFTreeBuilder.cpp \
$(NULL)
EXPORTS = \
diff --git a/mozilla/rdf/content/src/makefile.win b/mozilla/rdf/content/src/makefile.win
index fef6d7b6421..51d65816935 100644
--- a/mozilla/rdf/content/src/makefile.win
+++ b/mozilla/rdf/content/src/makefile.win
@@ -21,12 +21,15 @@ LIBRARY_NAME=rdfcontent_s
CPP_OBJS=\
.\$(OBJDIR)\nsRDFContentSink.obj \
+ .\$(OBJDIR)\nsRDFContentUtils.obj \
+ .\$(OBJDIR)\nsRDFDOMNodeList.obj \
.\$(OBJDIR)\nsRDFDocument.obj \
.\$(OBJDIR)\nsRDFDocumentContentSink.obj \
- .\$(OBJDIR)\nsRDFElement.obj \
- .\$(OBJDIR)\nsRDFHTMLDocument.obj \
+ .\$(OBJDIR)\nsRDFGenericElement.obj \
+ .\$(OBJDIR)\nsRDFHTMLBuilder.obj \
+ .\$(OBJDIR)\nsRDFResourceElement.obj \
.\$(OBJDIR)\nsRDFSimpleContentSink.obj \
- .\$(OBJDIR)\nsRDFTreeDocument.obj \
+ .\$(OBJDIR)\nsRDFTreeBuilder.obj \
$(NULL)
LINCS= -I$(PUBLIC)\rdf \
diff --git a/mozilla/rdf/content/src/nsRDFContentSink.cpp b/mozilla/rdf/content/src/nsRDFContentSink.cpp
index 3b542a8f12a..36f83bdd469 100644
--- a/mozilla/rdf/content/src/nsRDFContentSink.cpp
+++ b/mozilla/rdf/content/src/nsRDFContentSink.cpp
@@ -57,6 +57,7 @@
#include "nsVoidArray.h"
#include "nsINameSpaceManager.h"
#include "nsINameSpace.h"
+#include "nsRDFContentUtils.h"
#include "prlog.h"
#include "prmem.h"
#include "rdfutil.h"
@@ -681,8 +682,7 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
nsIRDFLiteral* literal;
if (NS_SUCCEEDED(rv = mRDFService->GetLiteral(value, &literal))) {
- rv = rdf_ContainerAddElement(mRDFService,
- mDataSource,
+ rv = rdf_ContainerAddElement(mDataSource,
GetContextElement(1),
literal);
NS_RELEASE(literal);
@@ -694,8 +694,7 @@ nsRDFContentSink::FlushText(PRBool aCreateTextNode, PRBool* aDidFlush)
value.Append(mText, mTextLength);
value.Trim(" \t\n\r");
- rv = rdf_Assert(mRDFService,
- mDataSource,
+ rv = rdf_Assert(mDataSource,
GetContextElement(1),
GetContextElement(0),
value);
@@ -856,7 +855,7 @@ nsRDFContentSink::AddProperties(const nsIParserNode& aNode,
k.Append(attr);
// Add the attribute to RDF
- rdf_Assert(mRDFService, mDataSource, aSubject, k, v);
+ rdf_Assert(mDataSource, aSubject, k, v);
}
return NS_OK;
}
@@ -918,7 +917,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
// member/property.
switch (mState) {
case eRDFContentSinkState_InMemberElement: {
- rdf_ContainerAddElement(mRDFService, mDataSource, GetContextElement(1), rdfResource);
+ rdf_ContainerAddElement(mDataSource, GetContextElement(1), rdfResource);
} break;
case eRDFContentSinkState_InPropertyElement: {
@@ -946,17 +945,17 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
}
else if (tag.Equals(kTagRDF_Bag)) {
// it's a bag container
- rdf_MakeBag(mRDFService, mDataSource, rdfResource);
+ rdf_MakeBag(mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else if (tag.Equals(kTagRDF_Seq)) {
// it's a seq container
- rdf_MakeSeq(mRDFService, mDataSource, rdfResource);
+ rdf_MakeSeq(mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else if (tag.Equals(kTagRDF_Alt)) {
// it's an alt container
- rdf_MakeAlt(mRDFService, mDataSource, rdfResource);
+ rdf_MakeAlt(mDataSource, rdfResource);
mState = eRDFContentSinkState_InContainerElement;
}
else {
@@ -971,7 +970,7 @@ nsRDFContentSink::OpenObject(const nsIParserNode& aNode)
nsAutoString nameSpace;
GetNameSpaceURI(nameSpaceID, nameSpace); // XXX append ':' too?
nameSpace.Append(tag);
- rdf_Assert(mRDFService, mDataSource, rdfResource, kURIRDF_type, nameSpace);
+ rdf_Assert(mDataSource, rdfResource, kURIRDF_type, nameSpace);
mState = eRDFContentSinkState_InDescriptionElement;
}
@@ -1018,8 +1017,7 @@ nsRDFContentSink::OpenProperty(const nsIParserNode& aNode)
nsIRDFResource* rdfResource;
if (NS_SUCCEEDED(rv = mRDFService->GetUnicodeResource(resourceURI, &rdfResource))) {
if (NS_SUCCEEDED(rv = AddProperties(aNode, rdfResource))) {
- rv = rdf_Assert(mRDFService,
- mDataSource,
+ rv = rdf_Assert(mDataSource,
GetContextElement(0),
rdfProperty,
rdfResource);
@@ -1074,7 +1072,7 @@ nsRDFContentSink::OpenMember(const nsIParserNode& aNode)
nsIRDFResource* resource;
if (NS_SUCCEEDED(rv = mRDFService->GetUnicodeResource(resourceURI, &resource))) {
- rv = rdf_ContainerAddElement(mRDFService, mDataSource, container, resource);
+ rv = rdf_ContainerAddElement(mDataSource, container, resource);
}
// XXX Technically, we should _not_ fall through here and push
diff --git a/mozilla/rdf/content/src/nsRDFContentUtils.cpp b/mozilla/rdf/content/src/nsRDFContentUtils.cpp
new file mode 100644
index 00000000000..c00704b859a
--- /dev/null
+++ b/mozilla/rdf/content/src/nsRDFContentUtils.cpp
@@ -0,0 +1,126 @@
+/* -*- 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 "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
+rdf_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;
+}
+
+
+
+nsresult
+rdf_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;
+}
+
diff --git a/mozilla/rdf/content/src/nsRDFContentUtils.h b/mozilla/rdf/content/src/nsRDFContentUtils.h
new file mode 100644
index 00000000000..67432f98e96
--- /dev/null
+++ b/mozilla/rdf/content/src/nsRDFContentUtils.h
@@ -0,0 +1,49 @@
+/* -*- 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.
+ */
+
+/*
+
+ Utility routines used throughout the content model library.
+
+ */
+
+#ifndef nsRDFContentUtils_h__
+#define nsRDFContentUtils_h__
+
+#include "nsError.h"
+
+class nsIContent;
+class nsIDOMNodeList;
+class nsIRDFNode;
+class nsString;
+
+nsresult
+rdf_GetQuotedAttributeValue(const nsString& aSource,
+ const nsString& aAttribute,
+ nsString& aValue);
+
+nsresult
+rdf_AttachTextNode(nsIContent* parent, nsIRDFNode* value);
+
+// In nsRDFDOMNodeList.cpp
+extern nsresult
+NS_NewRDFDOMNodeList(nsIDOMNodeList** aChildNodes, nsIContent* aElement);
+
+#endif // nsRDFContentUtils_h__
+
diff --git a/mozilla/rdf/content/src/nsRDFDocument.cpp b/mozilla/rdf/content/src/nsRDFDocument.cpp
index e475582fb5d..ab0c0cf9118 100644
--- a/mozilla/rdf/content/src/nsRDFDocument.cpp
+++ b/mozilla/rdf/content/src/nsRDFDocument.cpp
@@ -26,26 +26,31 @@
*/
#include "nsIArena.h"
+#include "nsICollection.h"
#include "nsIContent.h"
#include "nsIDTD.h"
+#include "nsIDocument.h"
#include "nsIDocumentObserver.h"
#include "nsIHTMLStyleSheet.h"
+#include "nsINameSpaceManager.h"
#include "nsIParser.h"
+#include "nsIPresContext.h"
+#include "nsIPresShell.h"
#include "nsIRDFContent.h"
+#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFCursor.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFDataSource.h"
+#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
+#include "nsIRDFObserver.h"
#include "nsIRDFService.h"
-#include "nsIPresShell.h"
#include "nsIScriptContextOwner.h"
#include "nsIServiceManager.h"
-#include "nsINameSpaceManager.h"
-#include "nsISupportsArray.h"
-#include "nsICollection.h"
#include "nsIStreamListener.h"
#include "nsIStyleSet.h"
#include "nsIStyleSheet.h"
+#include "nsISupportsArray.h"
#include "nsIURL.h"
#include "nsIURLGroup.h"
#include "nsIWebShell.h"
@@ -53,10 +58,8 @@
#include "nsParserCIID.h"
#include "nsRDFCID.h"
#include "nsRDFContentSink.h"
-#include "nsRDFDocument.h"
-#include "nsITextContent.h"
-#include "nsIDTD.h"
-#include "nsLayoutCID.h"
+#include "nsVoidArray.h"
+#include "plhash.h"
#include "rdfutil.h"
////////////////////////////////////////////////////////////////////////
@@ -77,7 +80,6 @@ static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
static NS_DEFINE_IID(kIWebShellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
@@ -89,12 +91,230 @@ static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
-static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
////////////////////////////////////////////////////////////////////////
-nsRDFDocument::nsRDFDocument()
+static PLHashNumber
+rdf_HashPointer(const void* key)
+{
+ return (PLHashNumber) key;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+
+class RDFDocumentImpl : public nsIDocument,
+ public nsIRDFDocument,
+ public nsIRDFObserver
+{
+public:
+ RDFDocumentImpl();
+ virtual ~RDFDocumentImpl();
+
+ // nsISupports interface
+ NS_DECL_ISUPPORTS
+
+ // nsIDocument interface
+ virtual nsIArena* GetArena();
+
+ NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
+ nsIContentViewerContainer* aContainer,
+ nsIStreamListener **aDocListener,
+ const char* aCommand);
+
+ virtual const nsString* GetDocumentTitle() const;
+
+ virtual nsIURL* GetDocumentURL() const;
+
+ virtual nsIURLGroup* GetDocumentURLGroup() const;
+
+ virtual nsCharSetID GetDocumentCharacterSet() const;
+
+ virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID);
+
+ virtual nsresult CreateShell(nsIPresContext* aContext,
+ nsIViewManager* aViewManager,
+ nsIStyleSet* aStyleSet,
+ nsIPresShell** aInstancePtrResult);
+
+ virtual PRBool DeleteShell(nsIPresShell* aShell);
+
+ virtual PRInt32 GetNumberOfShells();
+
+ virtual nsIPresShell* GetShellAt(PRInt32 aIndex);
+
+ virtual nsIDocument* GetParentDocument();
+
+ virtual void SetParentDocument(nsIDocument* aParent);
+
+ virtual void AddSubDocument(nsIDocument* aSubDoc);
+
+ virtual PRInt32 GetNumberOfSubDocuments();
+
+ virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex);
+
+ virtual nsIContent* GetRootContent();
+
+ virtual void SetRootContent(nsIContent* aRoot);
+
+ virtual PRInt32 GetNumberOfStyleSheets();
+
+ virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex);
+
+ virtual void AddStyleSheet(nsIStyleSheet* aSheet);
+
+ virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
+ PRBool mDisabled);
+
+ virtual nsIScriptContextOwner *GetScriptContextOwner();
+
+ virtual void SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner);
+
+ NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
+
+ virtual void AddObserver(nsIDocumentObserver* aObserver);
+
+ virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
+
+ NS_IMETHOD BeginLoad();
+
+ NS_IMETHOD EndLoad();
+
+ NS_IMETHOD ContentChanged(nsIContent* aContent,
+ nsISupports* aSubContent);
+
+ NS_IMETHOD AttributeChanged(nsIContent* aChild,
+ nsIAtom* aAttribute,
+ PRInt32 aHint); // See nsStyleConsts fot hint values
+
+ NS_IMETHOD ContentAppended(nsIContent* aContainer,
+ PRInt32 aNewIndexInContainer);
+
+ NS_IMETHOD ContentInserted(nsIContent* aContainer,
+ nsIContent* aChild,
+ PRInt32 aIndexInContainer);
+
+ NS_IMETHOD ContentReplaced(nsIContent* aContainer,
+ nsIContent* aOldChild,
+ nsIContent* aNewChild,
+ PRInt32 aIndexInContainer);
+
+ NS_IMETHOD ContentRemoved(nsIContent* aContainer,
+ nsIContent* aChild,
+ PRInt32 aIndexInContainer);
+
+ NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule,
+ PRInt32 aHint); // See nsStyleConsts fot hint values
+
+ NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule);
+
+ NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
+ nsIStyleRule* aStyleRule);
+
+ NS_IMETHOD GetSelection(nsICollection** aSelection);
+
+ NS_IMETHOD SelectAll();
+
+ NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
+
+ virtual void CreateXIF(nsString & aBuffer, PRBool aUseSelection);
+
+ virtual void ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
+
+ virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
+
+ virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
+
+ virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
+
+ virtual PRBool IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const;
+
+ virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const;
+
+ virtual PRBool IsInSelection(const nsIContent *aContent) const;
+
+ virtual nsIContent* GetPrevContent(const nsIContent *aContent) const;
+
+ virtual nsIContent* GetNextContent(const nsIContent *aContent) const;
+
+ virtual void SetDisplaySelection(PRBool aToggle);
+
+ virtual PRBool GetDisplaySelection() const;
+
+ NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
+ nsEvent* aEvent,
+ nsIDOMEvent** aDOMEvent,
+ PRUint32 aFlags,
+ nsEventStatus& aEventStatus);
+
+
+ // nsIXMLDocument interface
+ NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent);
+ NS_IMETHOD PrologCount(PRInt32* aCount);
+ NS_IMETHOD AppendToProlog(nsIContent* aContent);
+
+ NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent);
+ NS_IMETHOD EpilogCount(PRInt32* aCount);
+ NS_IMETHOD AppendToEpilog(nsIContent* aContent);
+
+ // nsIRDFDocument interface
+ NS_IMETHOD Init(nsIRDFContentModelBuilder* aBuilder);
+ NS_IMETHOD SetRootResource(nsIRDFResource* resource);
+ NS_IMETHOD GetDataBase(nsIRDFDataBase*& result);
+ NS_IMETHOD CreateChildren(nsIRDFContent* element);
+ NS_IMETHOD AddTreeProperty(nsIRDFResource* resource);
+ NS_IMETHOD RemoveTreeProperty(nsIRDFResource* resource);
+ NS_IMETHOD IsTreeProperty(nsIRDFResource* aProperty, PRBool* aResult) const;
+ NS_IMETHOD MapResource(nsIRDFResource* aResource, nsIRDFContent* aContent);
+ NS_IMETHOD UnMapResource(nsIRDFResource* aResource, nsIRDFContent* aContent);
+ NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag);
+
+ // nsIRDFObserver interface
+ NS_IMETHOD OnAssert(nsIRDFResource* subject,
+ nsIRDFResource* predicate,
+ nsIRDFNode* object);
+
+ NS_IMETHOD OnUnassert(nsIRDFResource* subject,
+ nsIRDFResource* predicate,
+ nsIRDFNode* object);
+
+protected:
+ nsIContent*
+ FindContent(const nsIContent* aStartNode,
+ const nsIContent* aTest1,
+ const nsIContent* aTest2) const;
+
+ nsIArena* mArena;
+ nsVoidArray mObservers;
+ nsAutoString mDocumentTitle;
+ nsIURL* mDocumentURL;
+ nsIURLGroup* mDocumentURLGroup;
+ nsIContent* mRootContent;
+ nsIDocument* mParentDocument;
+ nsIScriptContextOwner* mScriptContextOwner;
+ nsCharSetID mCharSetID;
+ nsVoidArray mStyleSheets;
+ nsICollection* mSelection;
+ PRBool mDisplaySelection;
+ nsVoidArray mPresShells;
+ nsINameSpaceManager* mNameSpaceManager;
+ nsIStyleSheet* mAttrStyleSheet;
+ nsIParser* mParser;
+ nsIRDFDataBase* mDB;
+ nsIRDFService* mRDFService;
+ nsISupportsArray* mTreeProperties;
+ nsIRDFContentModelBuilder* mBuilder;
+ PLHashTable* mResources;
+};
+
+
+////////////////////////////////////////////////////////////////////////
+// ctors & dtors
+
+RDFDocumentImpl::RDFDocumentImpl(void)
: mArena(nsnull),
mDocumentURL(nsnull),
mDocumentURLGroup(nsnull),
@@ -108,7 +328,9 @@ nsRDFDocument::nsRDFDocument()
mParser(nsnull),
mDB(nsnull),
mRDFService(nsnull),
- mTreeProperties(nsnull)
+ mTreeProperties(nsnull),
+ mBuilder(nsnull),
+ mResources(nsnull)
{
NS_INIT_REFCNT();
@@ -124,8 +346,11 @@ nsRDFDocument::nsRDFDocument()
}
-nsRDFDocument::~nsRDFDocument()
+RDFDocumentImpl::~RDFDocumentImpl()
{
+ if (mResources)
+ PL_HashTableDestroy(mResources);
+
NS_IF_RELEASE(mParser);
if (mRDFService) {
@@ -134,20 +359,27 @@ nsRDFDocument::~nsRDFDocument()
}
// mParentDocument is never refcounted
+ NS_IF_RELEASE(mBuilder);
NS_IF_RELEASE(mSelection);
NS_IF_RELEASE(mScriptContextOwner);
NS_IF_RELEASE(mAttrStyleSheet);
NS_IF_RELEASE(mTreeProperties);
NS_IF_RELEASE(mRootContent);
- NS_IF_RELEASE(mDB);
+ if (mDB) {
+ mDB->RemoveObserver(this);
+ NS_RELEASE(mDB);
+ }
NS_IF_RELEASE(mDocumentURLGroup);
NS_IF_RELEASE(mDocumentURL);
NS_IF_RELEASE(mArena);
NS_IF_RELEASE(mNameSpaceManager);
}
+////////////////////////////////////////////////////////////////////////
+// nsISupports interface
+
NS_IMETHODIMP
-nsRDFDocument::QueryInterface(REFNSIID iid, void** result)
+RDFDocumentImpl::QueryInterface(REFNSIID iid, void** result)
{
if (! result)
return NS_ERROR_NULL_POINTER;
@@ -156,36 +388,36 @@ nsRDFDocument::QueryInterface(REFNSIID iid, void** result)
if (iid.Equals(kIDocumentIID) ||
iid.Equals(kISupportsIID)) {
*result = NS_STATIC_CAST(nsIDocument*, this);
- AddRef();
+ NS_ADDREF(this);
return NS_OK;
}
else if (iid.Equals(kIRDFDocumentIID) ||
iid.Equals(kIXMLDocumentIID)) {
*result = NS_STATIC_CAST(nsIRDFDocument*, this);
- AddRef();
+ NS_ADDREF(this);
return NS_OK;
}
return NS_NOINTERFACE;
}
-NS_IMPL_ADDREF(nsRDFDocument);
-NS_IMPL_RELEASE(nsRDFDocument);
+NS_IMPL_ADDREF(RDFDocumentImpl);
+NS_IMPL_RELEASE(RDFDocumentImpl);
////////////////////////////////////////////////////////////////////////
// nsIDocument interface
nsIArena*
-nsRDFDocument::GetArena()
+RDFDocumentImpl::GetArena()
{
NS_IF_ADDREF(mArena);
return mArena;
}
NS_IMETHODIMP
-nsRDFDocument::StartDocumentLoad(nsIURL *aURL,
- nsIContentViewerContainer* aContainer,
- nsIStreamListener **aDocListener,
- const char* aCommand)
+RDFDocumentImpl::StartDocumentLoad(nsIURL *aURL,
+ nsIContentViewerContainer* aContainer,
+ nsIStreamListener **aDocListener,
+ const char* aCommand)
{
nsresult rv;
@@ -215,17 +447,12 @@ nsRDFDocument::StartDocumentLoad(nsIURL *aURL,
if (NS_FAILED(rv))
return rv;
- nsIWebShell* webShell = nsnull;
- nsIRDFContentSink* sink = nsnull;
- nsIRDFDataSource* ds = nsnull;
- nsIHTMLStyleSheet* sheet = nsnull;
+ nsIWebShell* webShell = nsnull;
+ nsIRDFContentSink* sink = nsnull;
+ nsIRDFDataSource* ds = nsnull;
+ nsIHTMLStyleSheet* sheet = nsnull;
nsIDTD* dtd = nsnull;
- if (NS_FAILED(rv = Init())) {
- PR_ASSERT(0);
- goto done;
- }
-
if (NS_FAILED(rv = aContainer->QueryInterface(kIWebShellIID, (void**)&webShell))) {
PR_ASSERT(0);
goto done;
@@ -308,39 +535,39 @@ done:
}
const nsString*
-nsRDFDocument::GetDocumentTitle() const
+RDFDocumentImpl::GetDocumentTitle() const
{
return &mDocumentTitle;
}
nsIURL*
-nsRDFDocument::GetDocumentURL() const
+RDFDocumentImpl::GetDocumentURL() const
{
NS_IF_ADDREF(mDocumentURL);
return mDocumentURL;
}
nsIURLGroup*
-nsRDFDocument::GetDocumentURLGroup() const
+RDFDocumentImpl::GetDocumentURLGroup() const
{
NS_IF_ADDREF(mDocumentURLGroup);
return mDocumentURLGroup;
}
nsCharSetID
-nsRDFDocument::GetDocumentCharacterSet() const
+RDFDocumentImpl::GetDocumentCharacterSet() const
{
return mCharSetID;
}
void
-nsRDFDocument::SetDocumentCharacterSet(nsCharSetID aCharSetID)
+RDFDocumentImpl::SetDocumentCharacterSet(nsCharSetID aCharSetID)
{
mCharSetID = aCharSetID;
}
nsresult
-nsRDFDocument::CreateShell(nsIPresContext* aContext,
+RDFDocumentImpl::CreateShell(nsIPresContext* aContext,
nsIViewManager* aViewManager,
nsIStyleSet* aStyleSet,
nsIPresShell** aInstancePtrResult)
@@ -370,19 +597,19 @@ nsRDFDocument::CreateShell(nsIPresContext* aContext,
}
PRBool
-nsRDFDocument::DeleteShell(nsIPresShell* aShell)
+RDFDocumentImpl::DeleteShell(nsIPresShell* aShell)
{
return mPresShells.RemoveElement(aShell);
}
PRInt32
-nsRDFDocument::GetNumberOfShells()
+RDFDocumentImpl::GetNumberOfShells()
{
return mPresShells.Count();
}
nsIPresShell*
-nsRDFDocument::GetShellAt(PRInt32 aIndex)
+RDFDocumentImpl::GetShellAt(PRInt32 aIndex)
{
nsIPresShell* shell = NS_STATIC_CAST(nsIPresShell*, mPresShells[aIndex]);
NS_IF_ADDREF(shell);
@@ -390,14 +617,14 @@ nsRDFDocument::GetShellAt(PRInt32 aIndex)
}
nsIDocument*
-nsRDFDocument::GetParentDocument()
+RDFDocumentImpl::GetParentDocument()
{
NS_IF_ADDREF(mParentDocument);
return mParentDocument;
}
void
-nsRDFDocument::SetParentDocument(nsIDocument* aParent)
+RDFDocumentImpl::SetParentDocument(nsIDocument* aParent)
{
// Note that we do *not* AddRef our parent because that would
// create a circular reference.
@@ -405,20 +632,20 @@ nsRDFDocument::SetParentDocument(nsIDocument* aParent)
}
void
-nsRDFDocument::AddSubDocument(nsIDocument* aSubDoc)
+RDFDocumentImpl::AddSubDocument(nsIDocument* aSubDoc)
{
// we don't do subdocs.
PR_ASSERT(0);
}
PRInt32
-nsRDFDocument::GetNumberOfSubDocuments()
+RDFDocumentImpl::GetNumberOfSubDocuments()
{
return 0;
}
nsIDocument*
-nsRDFDocument::GetSubDocumentAt(PRInt32 aIndex)
+RDFDocumentImpl::GetSubDocumentAt(PRInt32 aIndex)
{
// we don't do subdocs.
PR_ASSERT(0);
@@ -426,28 +653,34 @@ nsRDFDocument::GetSubDocumentAt(PRInt32 aIndex)
}
nsIContent*
-nsRDFDocument::GetRootContent()
+RDFDocumentImpl::GetRootContent()
{
NS_IF_ADDREF(mRootContent);
return mRootContent;
}
void
-nsRDFDocument::SetRootContent(nsIContent* aRoot)
+RDFDocumentImpl::SetRootContent(nsIContent* aRoot)
{
- NS_IF_RELEASE(mRootContent);
+ if (mRootContent) {
+ mRootContent->SetDocument(nsnull, PR_TRUE);
+ NS_RELEASE(mRootContent);
+ }
mRootContent = aRoot;
- NS_IF_ADDREF(mRootContent);
+ if (mRootContent) {
+ mRootContent->SetDocument(this, PR_TRUE);
+ NS_ADDREF(mRootContent);
+ }
}
PRInt32
-nsRDFDocument::GetNumberOfStyleSheets()
+RDFDocumentImpl::GetNumberOfStyleSheets()
{
return mStyleSheets.Count();
}
nsIStyleSheet*
-nsRDFDocument::GetStyleSheetAt(PRInt32 aIndex)
+RDFDocumentImpl::GetStyleSheetAt(PRInt32 aIndex)
{
nsIStyleSheet* sheet = NS_STATIC_CAST(nsIStyleSheet*, mStyleSheets[aIndex]);
NS_IF_ADDREF(sheet);
@@ -455,7 +688,7 @@ nsRDFDocument::GetStyleSheetAt(PRInt32 aIndex)
}
void
-nsRDFDocument::AddStyleSheet(nsIStyleSheet* aSheet)
+RDFDocumentImpl::AddStyleSheet(nsIStyleSheet* aSheet)
{
NS_PRECONDITION(aSheet, "null arg");
if (!aSheet)
@@ -492,7 +725,7 @@ nsRDFDocument::AddStyleSheet(nsIStyleSheet* aSheet)
}
void
-nsRDFDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
+RDFDocumentImpl::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
PRBool aDisabled)
{
NS_PRECONDITION(nsnull != aSheet, "null arg");
@@ -525,14 +758,14 @@ nsRDFDocument::SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
}
nsIScriptContextOwner *
-nsRDFDocument::GetScriptContextOwner()
+RDFDocumentImpl::GetScriptContextOwner()
{
NS_IF_ADDREF(mScriptContextOwner);
return mScriptContextOwner;
}
void
-nsRDFDocument::SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner)
+RDFDocumentImpl::SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner)
{
// XXX HACK ALERT! If the script context owner is null, the document
// will soon be going away. So tell our content that to lose its
@@ -548,7 +781,7 @@ nsRDFDocument::SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner)
}
NS_IMETHODIMP
-nsRDFDocument::GetNameSpaceManager(nsINameSpaceManager*& aManager)
+RDFDocumentImpl::GetNameSpaceManager(nsINameSpaceManager*& aManager)
{
aManager = mNameSpaceManager;
NS_IF_ADDREF(aManager);
@@ -559,7 +792,7 @@ nsRDFDocument::GetNameSpaceManager(nsINameSpaceManager*& aManager)
// Note: We don't hold a reference to the document observer; we assume
// that it has a live reference to the document.
void
-nsRDFDocument::AddObserver(nsIDocumentObserver* aObserver)
+RDFDocumentImpl::AddObserver(nsIDocumentObserver* aObserver)
{
// XXX Make sure the observer isn't already in the list
if (mObservers.IndexOf(aObserver) == -1) {
@@ -568,13 +801,13 @@ nsRDFDocument::AddObserver(nsIDocumentObserver* aObserver)
}
PRBool
-nsRDFDocument::RemoveObserver(nsIDocumentObserver* aObserver)
+RDFDocumentImpl::RemoveObserver(nsIDocumentObserver* aObserver)
{
return mObservers.RemoveElement(aObserver);
}
NS_IMETHODIMP
-nsRDFDocument::BeginLoad()
+RDFDocumentImpl::BeginLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
@@ -585,20 +818,21 @@ nsRDFDocument::BeginLoad()
}
NS_IMETHODIMP
-nsRDFDocument::EndLoad()
+RDFDocumentImpl::EndLoad()
{
PRInt32 i, count = mObservers.Count();
for (i = 0; i < count; i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];
observer->EndLoad(this);
}
+
NS_IF_RELEASE(mParser);
return NS_OK;
}
NS_IMETHODIMP
-nsRDFDocument::ContentChanged(nsIContent* aContent,
+RDFDocumentImpl::ContentChanged(nsIContent* aContent,
nsISupports* aSubContent)
{
PRInt32 count = mObservers.Count();
@@ -610,7 +844,7 @@ nsRDFDocument::ContentChanged(nsIContent* aContent,
}
NS_IMETHODIMP
-nsRDFDocument::AttributeChanged(nsIContent* aChild,
+RDFDocumentImpl::AttributeChanged(nsIContent* aChild,
nsIAtom* aAttribute,
PRInt32 aHint)
{
@@ -623,7 +857,7 @@ nsRDFDocument::AttributeChanged(nsIContent* aChild,
}
NS_IMETHODIMP
-nsRDFDocument::ContentAppended(nsIContent* aContainer,
+RDFDocumentImpl::ContentAppended(nsIContent* aContainer,
PRInt32 aNewIndexInContainer)
{
PRInt32 count = mObservers.Count();
@@ -635,10 +869,11 @@ nsRDFDocument::ContentAppended(nsIContent* aContainer,
}
NS_IMETHODIMP
-nsRDFDocument::ContentInserted(nsIContent* aContainer,
+RDFDocumentImpl::ContentInserted(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
+
PRInt32 count = mObservers.Count();
for (PRInt32 i = 0; i < count; i++) {
nsIDocumentObserver* observer = (nsIDocumentObserver*)mObservers[i];
@@ -648,7 +883,7 @@ nsRDFDocument::ContentInserted(nsIContent* aContainer,
}
NS_IMETHODIMP
-nsRDFDocument::ContentReplaced(nsIContent* aContainer,
+RDFDocumentImpl::ContentReplaced(nsIContent* aContainer,
nsIContent* aOldChild,
nsIContent* aNewChild,
PRInt32 aIndexInContainer)
@@ -663,7 +898,7 @@ nsRDFDocument::ContentReplaced(nsIContent* aContainer,
}
NS_IMETHODIMP
-nsRDFDocument::ContentRemoved(nsIContent* aContainer,
+RDFDocumentImpl::ContentRemoved(nsIContent* aContainer,
nsIContent* aChild,
PRInt32 aIndexInContainer)
{
@@ -677,7 +912,7 @@ nsRDFDocument::ContentRemoved(nsIContent* aContainer,
}
NS_IMETHODIMP
-nsRDFDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet,
+RDFDocumentImpl::StyleRuleChanged(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule,
PRInt32 aHint)
{
@@ -690,7 +925,7 @@ nsRDFDocument::StyleRuleChanged(nsIStyleSheet* aStyleSheet,
}
NS_IMETHODIMP
-nsRDFDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet,
+RDFDocumentImpl::StyleRuleAdded(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
@@ -702,7 +937,7 @@ nsRDFDocument::StyleRuleAdded(nsIStyleSheet* aStyleSheet,
}
NS_IMETHODIMP
-nsRDFDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
+RDFDocumentImpl::StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
nsIStyleRule* aStyleRule)
{
PRInt32 count = mObservers.Count();
@@ -714,7 +949,7 @@ nsRDFDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
}
NS_IMETHODIMP
-nsRDFDocument::GetSelection(nsICollection** aSelection)
+RDFDocumentImpl::GetSelection(nsICollection** aSelection)
{
if (!mSelection) {
PR_ASSERT(0);
@@ -727,7 +962,7 @@ nsRDFDocument::GetSelection(nsICollection** aSelection)
}
NS_IMETHODIMP
-nsRDFDocument::SelectAll()
+RDFDocumentImpl::SelectAll()
{
nsIContent * start = nsnull;
@@ -798,44 +1033,44 @@ nsRDFDocument::SelectAll()
}
NS_IMETHODIMP
-nsRDFDocument::FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
+RDFDocumentImpl::FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound)
{
aIsFound = PR_FALSE;
return NS_ERROR_FAILURE;
}
void
-nsRDFDocument::CreateXIF(nsString & aBuffer, PRBool aUseSelection)
+RDFDocumentImpl::CreateXIF(nsString & aBuffer, PRBool aUseSelection)
{
PR_ASSERT(0);
}
void
-nsRDFDocument::ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
+RDFDocumentImpl::ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
{
PR_ASSERT(0);
}
void
-nsRDFDocument::BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
+RDFDocumentImpl::BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
{
PR_ASSERT(0);
}
void
-nsRDFDocument::ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
+RDFDocumentImpl::ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
{
PR_ASSERT(0);
}
void
-nsRDFDocument::FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
+RDFDocumentImpl::FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode)
{
PR_ASSERT(0);
}
PRBool
-nsRDFDocument::IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const
+RDFDocumentImpl::IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const
{
PRBool result;
@@ -854,7 +1089,7 @@ nsRDFDocument::IsInRange(const nsIContent *aStartContent, const nsIContent* aEnd
}
PRBool
-nsRDFDocument::IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const
+RDFDocumentImpl::IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const
{
PRBool result = PR_FALSE;
@@ -869,7 +1104,7 @@ nsRDFDocument::IsBefore(const nsIContent *aNewContent, const nsIContent* aCurren
}
PRBool
-nsRDFDocument::IsInSelection(const nsIContent *aContent) const
+RDFDocumentImpl::IsInSelection(const nsIContent *aContent) const
{
PRBool result = PR_FALSE;
@@ -892,7 +1127,7 @@ nsRDFDocument::IsInSelection(const nsIContent *aContent) const
}
nsIContent*
-nsRDFDocument::GetPrevContent(const nsIContent *aContent) const
+RDFDocumentImpl::GetPrevContent(const nsIContent *aContent) const
{
nsIContent* result = nsnull;
@@ -916,7 +1151,7 @@ nsRDFDocument::GetPrevContent(const nsIContent *aContent) const
}
nsIContent*
-nsRDFDocument::GetNextContent(const nsIContent *aContent) const
+RDFDocumentImpl::GetNextContent(const nsIContent *aContent) const
{
nsIContent* result = nsnull;
@@ -955,19 +1190,19 @@ nsRDFDocument::GetNextContent(const nsIContent *aContent) const
}
void
-nsRDFDocument::SetDisplaySelection(PRBool aToggle)
+RDFDocumentImpl::SetDisplaySelection(PRBool aToggle)
{
mDisplaySelection = aToggle;
}
PRBool
-nsRDFDocument::GetDisplaySelection() const
+RDFDocumentImpl::GetDisplaySelection() const
{
return mDisplaySelection;
}
NS_IMETHODIMP
-nsRDFDocument::HandleDOMEvent(nsIPresContext& aPresContext,
+RDFDocumentImpl::HandleDOMEvent(nsIPresContext& aPresContext,
nsEvent* aEvent,
nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
@@ -982,21 +1217,21 @@ nsRDFDocument::HandleDOMEvent(nsIPresContext& aPresContext,
// nsIXMLDocument interface
NS_IMETHODIMP
-nsRDFDocument::PrologElementAt(PRInt32 aOffset, nsIContent** aContent)
+RDFDocumentImpl::PrologElementAt(PRInt32 aOffset, nsIContent** aContent)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
-nsRDFDocument::PrologCount(PRInt32* aCount)
+RDFDocumentImpl::PrologCount(PRInt32* aCount)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
-nsRDFDocument::AppendToProlog(nsIContent* aContent)
+RDFDocumentImpl::AppendToProlog(nsIContent* aContent)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
@@ -1004,21 +1239,21 @@ nsRDFDocument::AppendToProlog(nsIContent* aContent)
NS_IMETHODIMP
-nsRDFDocument::EpilogElementAt(PRInt32 aOffset, nsIContent** aContent)
+RDFDocumentImpl::EpilogElementAt(PRInt32 aOffset, nsIContent** aContent)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
-nsRDFDocument::EpilogCount(PRInt32* aCount)
+RDFDocumentImpl::EpilogCount(PRInt32* aCount)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
-nsRDFDocument::AppendToEpilog(nsIContent* aContent)
+RDFDocumentImpl::AppendToEpilog(nsIContent* aContent)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
@@ -1028,54 +1263,72 @@ nsRDFDocument::AppendToEpilog(nsIContent* aContent)
// nsIRDFDocument interface
NS_IMETHODIMP
-nsRDFDocument::Init(void)
+RDFDocumentImpl::Init(nsIRDFContentModelBuilder* aBuilder)
{
+ NS_PRECONDITION(aBuilder != nsnull, "null ptr");
+ if (! aBuilder)
+ return NS_ERROR_NULL_POINTER;
+
nsresult rv;
+
+ NS_ADDREF(aBuilder);
+ mBuilder = aBuilder;
+
if (NS_FAILED(rv = NS_NewHeapArena(&mArena, nsnull)))
return rv;
- rv = nsRepository::CreateInstance(kNameSpaceManagerCID,
- nsnull,
- kINameSpaceManagerIID,
- (void**) &mNameSpaceManager);
- if (NS_FAILED(rv))
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kNameSpaceManagerCID,
+ nsnull,
+ kINameSpaceManagerIID,
+ (void**) &mNameSpaceManager)))
return rv;
+ static PRInt32 kInitialResourceTableSize = 1023;
+
+ if ((mResources = PL_NewHashTable(kInitialResourceTableSize,
+ rdf_HashPointer,
+ PL_CompareValues,
+ PL_CompareValues,
+ nsnull,
+ nsnull)) == nsnull)
+ return NS_ERROR_OUT_OF_MEMORY;
+
if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFDataBaseCID,
nsnull,
kIRDFDataBaseIID,
(void**) &mDB)))
return rv;
+ if (NS_FAILED(rv = mDB->AddObserver(this)))
+ return rv;
+
if (NS_FAILED(rv = nsServiceManager::GetService(kRDFServiceCID,
kIRDFServiceIID,
(nsISupports**) &mRDFService)))
return rv;
+ // The builder may try to ask us for our DB, so do this last...
+ if (NS_FAILED(rv = mBuilder->SetDocument(this)))
+ return rv;
+
return NS_OK;
}
NS_IMETHODIMP
-nsRDFDocument::SetRootResource(nsIRDFResource* aResource)
+RDFDocumentImpl::SetRootResource(nsIRDFResource* aResource)
{
- nsresult rv;
+ NS_ASSERTION(mBuilder != nsnull, "not initialized");
+ if (! mBuilder)
+ return NS_ERROR_NOT_INITIALIZED;
- nsIRDFContent* root;
- if (NS_FAILED(rv = NS_NewRDFElement(&root)))
- return rv;
-
- if (NS_FAILED(rv = root->Init(this, "ROOT", aResource, PR_TRUE)))
- return rv;
-
- SetRootContent(NS_STATIC_CAST(nsIContent*, root));
-
- NS_RELEASE(root); // release our local reference
- return NS_OK;
+ nsresult rv = mBuilder->CreateRoot(aResource);
+ return rv;
}
NS_IMETHODIMP
-nsRDFDocument::GetDataBase(nsIRDFDataBase*& result)
+RDFDocumentImpl::GetDataBase(nsIRDFDataBase*& result)
{
+ NS_PRECONDITION(mDB != nsnull, "not initialized");
if (! mDB)
return NS_ERROR_NOT_INITIALIZED;
@@ -1086,8 +1339,12 @@ nsRDFDocument::GetDataBase(nsIRDFDataBase*& result)
}
+// XXX It may make sense to factor the implementation of this method
+// into the content model builder: maybe the content model builder can
+// do a more efficient implementation?
+
NS_IMETHODIMP
-nsRDFDocument::CreateChildren(nsIRDFContent* element)
+RDFDocumentImpl::CreateChildren(nsIRDFContent* element)
{
nsresult rv;
@@ -1107,6 +1364,10 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
goto done;
// Create a cursor that'll enumerate all of the outbound arcs
+ //
+ // XXX This is really horrendous and could use a good does of
+ // special casing. For example, we should treat RDF containers
+ // specially and _not_ enumerate each of the arcs.
if (NS_FAILED(rv = mDB->ArcLabelsOut(resource, &properties)))
goto done;
@@ -1116,13 +1377,12 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
if (NS_FAILED(rv = properties->GetValue((nsIRDFNode**)&property)))
break;
- const char* s;
- if (NS_FAILED(rv = property->GetValue(&s))) {
- NS_RELEASE(property);
- break;
+#ifdef DEBUG
+ {
+ const char* s;
+ property->GetValue(&s);
}
-
- nsAutoString uri(s);
+#endif
// Create a second cursor that'll enumerate all of the values
// for all of the arcs.
@@ -1135,10 +1395,10 @@ nsRDFDocument::CreateChildren(nsIRDFContent* element)
while (NS_SUCCEEDED(rv = assertions->Advance())) {
nsIRDFNode* value;
if (NS_SUCCEEDED(rv = assertions->GetValue((nsIRDFNode**)&value))) {
- // At this point, the specific nsRDFDocument
+ // At this point, the specific RDFDocumentImpl
// implementations will create an appropriate child
// element (or elements).
- rv = AddChild(element, property, value);
+ rv = mBuilder->OnAssert(element, property, value);
NS_RELEASE(value);
}
@@ -1162,7 +1422,7 @@ done:
}
NS_IMETHODIMP
-nsRDFDocument::AddTreeProperty(nsIRDFResource* resource)
+RDFDocumentImpl::AddTreeProperty(nsIRDFResource* resource)
{
nsresult rv;
if (! mTreeProperties) {
@@ -1182,7 +1442,7 @@ nsRDFDocument::AddTreeProperty(nsIRDFResource* resource)
NS_IMETHODIMP
-nsRDFDocument::RemoveTreeProperty(nsIRDFResource* resource)
+RDFDocumentImpl::RemoveTreeProperty(nsIRDFResource* resource)
{
if (! mTreeProperties) {
// XXX no properties have ever been inserted!
@@ -1199,11 +1459,157 @@ nsRDFDocument::RemoveTreeProperty(nsIRDFResource* resource)
return NS_OK;
}
+NS_IMETHODIMP
+RDFDocumentImpl::IsTreeProperty(nsIRDFResource* aProperty, PRBool* aResult) const
+{
+#define TREE_PROPERTY_HACK
+#if defined(TREE_PROPERTY_HACK)
+ const char* p;
+ aProperty->GetValue(&p);
+ nsAutoString s(p);
+ if (s.Equals("http://home.netscape.com/NC-rdf#child") ||
+ s.Equals("http://home.netscape.com/NC-rdf#Folder")) {
+ *aResult = PR_TRUE;
+ return NS_OK;
+ }
+#endif // defined(TREE_PROPERTY_HACK)
+ if (rdf_IsOrdinalProperty(aProperty)) {
+ *aResult = PR_TRUE;
+ return NS_OK;
+ }
+ if (! mTreeProperties) {
+ *aResult = PR_FALSE;
+ return NS_OK;
+ }
+ if (mTreeProperties->IndexOf(aProperty) == -1) {
+ *aResult = PR_FALSE;
+ return NS_OK;
+ }
+ // XXX return "true" by default???
+ *aResult = PR_TRUE;
+ return NS_OK;
+}
+
+
+NS_IMETHODIMP
+RDFDocumentImpl::MapResource(nsIRDFResource* aResource, nsIRDFContent* aContent)
+{
+ // XXX busted: a resource might be located in multiple content
+ // elements in the tree. This needs to map to a set, not a single
+ // instance.
+ PL_HashTableAdd(mResources, aResource, aContent);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RDFDocumentImpl::UnMapResource(nsIRDFResource* aResource, nsIRDFContent* aContent)
+{
+ // XXX busted: a resource might be located in multiple content
+ // elements in the tree. This needs to map to a set, not a single
+ // instance.
+ PL_HashTableRemove(mResources, aResource);
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RDFDocumentImpl::SplitProperty(nsIRDFResource* aProperty,
+ PRInt32* aNameSpaceID,
+ nsIAtom** aTag)
+{
+ NS_PRECONDITION(aProperty != nsnull, "null ptr");
+ if (! aProperty)
+ return NS_ERROR_NULL_POINTER;
+
+ // XXX okay, this is a total hack. for this to work right, we need
+ // to remember what the namespace and the tag were when the
+ // property was created, which we don't do...
+
+ const char* p;
+ aProperty->GetValue(&p);
+ nsAutoString uri(p);
+
+ PRInt32 index;
+
+ if ((index = uri.RFind('#')) < 0) {
+ if ((index = uri.RFind('/')) < 0) {
+ NS_ASSERTION(PR_FALSE, "make this smarter!");
+ }
+ }
+
+ nsAutoString tag;
+ PRInt32 count = uri.Length() - (index + 1);
+ uri.Right(tag, count);
+ uri.Cut(index + 1, count);
+
+ tag.ToUpperCase();
+ *aTag = NS_NewAtom(tag);
+
+ nsresult rv = mNameSpaceManager->GetNameSpaceID(uri, *aNameSpaceID);
+ NS_ASSERTION(NS_SUCCEEDED(rv) && *aNameSpaceID != kNameSpaceID_Unknown, "unknown namespace");
+
+ return rv;
+}
+
+
+////////////////////////////////////////////////////////////////////////
+// nsIRDFObserver methods
+
+NS_IMETHODIMP
+RDFDocumentImpl::OnAssert(nsIRDFResource* subject,
+ nsIRDFResource* predicate,
+ nsIRDFNode* object)
+{
+ NS_PRECONDITION(mResources != nsnull, "not initialized");
+ if (! mResources)
+ return NS_ERROR_NOT_INITIALIZED;
+
+ nsIRDFContent* element = (nsIRDFContent*) PL_HashTableLookup(mResources, subject);
+
+ if (! element)
+ // it's not in the tree: we're done!
+ return NS_OK;
+
+ PRBool hasLiveKids;
+ if (NS_SUCCEEDED(element->ChildrenHaveBeenGenerated(hasLiveKids)) && hasLiveKids) {
+ // that is, if the children have _already_ been generated,
+ // manually add this new one. Otherwise, just ignore it: it'll
+ // get generated when someone asks the content model for it.
+ mBuilder->OnAssert(element, predicate, object);
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RDFDocumentImpl::OnUnassert(nsIRDFResource* subject,
+ nsIRDFResource* predicate,
+ nsIRDFNode* object)
+{
+ NS_PRECONDITION(mResources != nsnull, "not initialized");
+ if (! mResources)
+ return NS_ERROR_NOT_INITIALIZED;
+
+ nsIRDFContent* element = (nsIRDFContent*) PL_HashTableLookup(mResources, subject);
+ if (! element)
+ // it's not in the tree: we're done!
+ return NS_OK;
+
+ PRBool hasLiveKids;
+ if (NS_SUCCEEDED(element->ChildrenHaveBeenGenerated(hasLiveKids)) && hasLiveKids) {
+ // that is, if the children have _already_ been generated,
+ // manually remove this one. Otherwise, just ignore it: it'll
+ // never get generated anyway...
+ mBuilder->OnUnassert(element, predicate, object);
+ }
+ return NS_OK;
+}
+
+
+
////////////////////////////////////////////////////////////////////////
// Implementation methods
nsIContent*
-nsRDFDocument::FindContent(const nsIContent* aStartNode,
+RDFDocumentImpl::FindContent(const nsIContent* aStartNode,
const nsIContent* aTest1,
const nsIContent* aTest2) const
{
@@ -1230,113 +1636,21 @@ nsRDFDocument::FindContent(const nsIContent* aStartNode,
}
-PRBool
-nsRDFDocument::IsTreeProperty(const nsIRDFResource* property) const
-{
-#define TREE_PROPERTY_HACK
-#if defined(TREE_PROPERTY_HACK)
- const char* p;
- property->GetValue(&p);
- nsAutoString s(p);
- if (s.Equals("http://home.netscape.com/NC-rdf#child") ||
- s.Equals("http://home.netscape.com/NC-rdf#Folder")) {
- return PR_TRUE;
- }
-#endif // defined(TREE_PROPERTY_HACK)
- if (rdf_IsOrdinalProperty(property)) {
- return PR_TRUE;
- }
- if (! mTreeProperties) {
- return PR_FALSE;
- }
- if (mTreeProperties->IndexOf(property) == -1) {
- return PR_FALSE;
- }
- return PR_TRUE;
-}
+////////////////////////////////////////////////////////////////////////
nsresult
-nsRDFDocument::NewChild(const nsString& tag,
- nsIRDFResource* resource,
- nsIRDFContent*& result,
- PRBool childrenMustBeGenerated)
+NS_NewRDFDocument(nsIRDFDocument** result)
{
- nsresult rv;
+ NS_PRECONDITION(result != nsnull, "null ptr");
+ if (! result)
+ return NS_ERROR_NULL_POINTER;
- nsIRDFContent* child;
- if (NS_FAILED(rv = NS_NewRDFElement(&child)))
- return rv;
+ RDFDocumentImpl* doc = new RDFDocumentImpl();
+ if (! doc)
+ return NS_ERROR_OUT_OF_MEMORY;
- if (NS_FAILED(rv = child->Init(this, tag, resource, childrenMustBeGenerated))) {
- NS_RELEASE(child);
- return rv;
- }
-
- result = child;
+ NS_ADDREF(doc);
+ *result = doc;
return NS_OK;
}
-
-nsresult
-nsRDFDocument::AttachTextNode(nsIContent* parent,
- nsIRDFNode* value)
-{
- nsresult rv;
- nsAutoString s;
- nsIContent* node = nsnull;
- nsITextContent* text = nsnull;
- nsIDocument* doc = 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 = QueryInterface(kIDocumentIID, (void**) &doc)))
- goto error;
-
- if (NS_FAILED(rv = node->SetDocument(doc, PR_FALSE)))
- 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 = node->SetParent(parent)))
- goto error;
-
- if (NS_FAILED(rv = parent->AppendChildTo(NS_STATIC_CAST(nsIContent*, node), PR_TRUE)))
- goto error;
-
-error:
- NS_IF_RELEASE(node);
- NS_IF_RELEASE(text);
- NS_IF_RELEASE(doc);
- return rv;
-}
-
diff --git a/mozilla/rdf/content/src/nsRDFDocument.h b/mozilla/rdf/content/src/nsRDFDocument.h
deleted file mode 100644
index c0ba5ffc655..00000000000
--- a/mozilla/rdf/content/src/nsRDFDocument.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/* -*- 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.
- */
-
-/*
-
- Class declaration for an implementation of the nsIRDFDocument
- interface.
-
- */
-
-#ifndef nsRDFDocument_h___
-#define nsRDFDocument_h___
-
-#include "nsIDocument.h"
-#include "nsIRDFDocument.h"
-#include "nsVoidArray.h"
-
-class nsIArena;
-class nsIParser;
-class nsISupportsArray;
-class nsINameSpaceManager;
-class nsIRDFNode;
-class nsIRDFService;
-
-/**
- * An NGLayout document context for displaying an RDF graph.
- * XXX This should implement nsIDOMDocument, too.
- */
-class nsRDFDocument : public nsIDocument,
- public nsIRDFDocument
-{
-public:
- nsRDFDocument();
- virtual ~nsRDFDocument();
-
- // nsISupports interface
- NS_DECL_ISUPPORTS
-
- // nsIDocument interface
- virtual nsIArena* GetArena();
-
- NS_IMETHOD StartDocumentLoad(nsIURL *aUrl,
- nsIContentViewerContainer* aContainer,
- nsIStreamListener **aDocListener,
- const char* aCommand);
-
- virtual const nsString* GetDocumentTitle() const;
-
- virtual nsIURL* GetDocumentURL() const;
-
- virtual nsIURLGroup* GetDocumentURLGroup() const;
-
- virtual nsCharSetID GetDocumentCharacterSet() const;
-
- virtual void SetDocumentCharacterSet(nsCharSetID aCharSetID);
-
- virtual nsresult CreateShell(nsIPresContext* aContext,
- nsIViewManager* aViewManager,
- nsIStyleSet* aStyleSet,
- nsIPresShell** aInstancePtrResult);
-
- virtual PRBool DeleteShell(nsIPresShell* aShell);
-
- virtual PRInt32 GetNumberOfShells();
-
- virtual nsIPresShell* GetShellAt(PRInt32 aIndex);
-
- virtual nsIDocument* GetParentDocument();
-
- virtual void SetParentDocument(nsIDocument* aParent);
-
- virtual void AddSubDocument(nsIDocument* aSubDoc);
-
- virtual PRInt32 GetNumberOfSubDocuments();
-
- virtual nsIDocument* GetSubDocumentAt(PRInt32 aIndex);
-
- virtual nsIContent* GetRootContent();
-
- virtual void SetRootContent(nsIContent* aRoot);
-
- virtual PRInt32 GetNumberOfStyleSheets();
-
- virtual nsIStyleSheet* GetStyleSheetAt(PRInt32 aIndex);
-
- virtual void AddStyleSheet(nsIStyleSheet* aSheet);
-
- virtual void SetStyleSheetDisabledState(nsIStyleSheet* aSheet,
- PRBool mDisabled);
-
- virtual nsIScriptContextOwner *GetScriptContextOwner();
-
- virtual void SetScriptContextOwner(nsIScriptContextOwner *aScriptContextOwner);
-
- NS_IMETHOD GetNameSpaceManager(nsINameSpaceManager*& aManager);
-
- virtual void AddObserver(nsIDocumentObserver* aObserver);
-
- virtual PRBool RemoveObserver(nsIDocumentObserver* aObserver);
-
- NS_IMETHOD BeginLoad();
-
- NS_IMETHOD EndLoad();
-
- NS_IMETHOD ContentChanged(nsIContent* aContent,
- nsISupports* aSubContent);
-
- NS_IMETHOD AttributeChanged(nsIContent* aChild,
- nsIAtom* aAttribute,
- PRInt32 aHint); // See nsStyleConsts fot hint values
-
- NS_IMETHOD ContentAppended(nsIContent* aContainer,
- PRInt32 aNewIndexInContainer);
-
- NS_IMETHOD ContentInserted(nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer);
-
- NS_IMETHOD ContentReplaced(nsIContent* aContainer,
- nsIContent* aOldChild,
- nsIContent* aNewChild,
- PRInt32 aIndexInContainer);
-
- NS_IMETHOD ContentRemoved(nsIContent* aContainer,
- nsIContent* aChild,
- PRInt32 aIndexInContainer);
-
- NS_IMETHOD StyleRuleChanged(nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule,
- PRInt32 aHint); // See nsStyleConsts fot hint values
-
- NS_IMETHOD StyleRuleAdded(nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule);
-
- NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet,
- nsIStyleRule* aStyleRule);
-
- NS_IMETHOD GetSelection(nsICollection** aSelection);
-
- NS_IMETHOD SelectAll();
-
- NS_IMETHOD FindNext(const nsString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound);
-
- virtual void CreateXIF(nsString & aBuffer, PRBool aUseSelection);
-
- virtual void ToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
-
- virtual void BeginConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
-
- virtual void ConvertChildrenToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
-
- virtual void FinishConvertToXIF(nsXIFConverter& aConverter, nsIDOMNode* aNode);
-
- virtual PRBool IsInRange(const nsIContent *aStartContent, const nsIContent* aEndContent, const nsIContent* aContent) const;
-
- virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const;
-
- virtual PRBool IsInSelection(const nsIContent *aContent) const;
-
- virtual nsIContent* GetPrevContent(const nsIContent *aContent) const;
-
- virtual nsIContent* GetNextContent(const nsIContent *aContent) const;
-
- virtual void SetDisplaySelection(PRBool aToggle);
-
- virtual PRBool GetDisplaySelection() const;
-
- NS_IMETHOD HandleDOMEvent(nsIPresContext& aPresContext,
- nsEvent* aEvent,
- nsIDOMEvent** aDOMEvent,
- PRUint32 aFlags,
- nsEventStatus& aEventStatus);
-
-
- // nsIXMLDocument interface
- NS_IMETHOD PrologElementAt(PRInt32 aOffset, nsIContent** aContent);
- NS_IMETHOD PrologCount(PRInt32* aCount);
- NS_IMETHOD AppendToProlog(nsIContent* aContent);
-
- NS_IMETHOD EpilogElementAt(PRInt32 aOffset, nsIContent** aContent);
- NS_IMETHOD EpilogCount(PRInt32* aCount);
- NS_IMETHOD AppendToEpilog(nsIContent* aContent);
-
- // nsIRDFDocument interface
- NS_IMETHOD Init(void);
- NS_IMETHOD SetRootResource(nsIRDFResource* resource);
- NS_IMETHOD GetDataBase(nsIRDFDataBase*& result);
- NS_IMETHOD CreateChildren(nsIRDFContent* element);
- NS_IMETHOD AddTreeProperty(nsIRDFResource* resource);
- NS_IMETHOD RemoveTreeProperty(nsIRDFResource* resource);
-
-protected:
- nsIContent*
- FindContent(const nsIContent* aStartNode,
- const nsIContent* aTest1,
- const nsIContent* aTest2) const;
-
- PRBool IsTreeProperty(const nsIRDFResource* resource) const;
-
- nsresult AttachTextNode(nsIContent* parent,
- nsIRDFNode* value);
-
- nsresult NewChild(const nsString& tag,
- nsIRDFResource* resource,
- nsIRDFContent*& result,
- PRBool childrenMustBeGenerated);
-
- virtual nsresult AddChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value) = 0;
-
- nsIArena* mArena;
- nsVoidArray mObservers;
- nsAutoString mDocumentTitle;
- nsIURL* mDocumentURL;
- nsIURLGroup* mDocumentURLGroup;
- nsIContent* mRootContent;
- nsIDocument* mParentDocument;
- nsIScriptContextOwner* mScriptContextOwner;
- nsCharSetID mCharSetID;
- nsVoidArray mStyleSheets;
- nsICollection* mSelection;
- PRBool mDisplaySelection;
- nsVoidArray mPresShells;
- nsINameSpaceManager* mNameSpaceManager;
- nsIStyleSheet* mAttrStyleSheet;
- nsIParser* mParser;
- nsIRDFDataBase* mDB;
- nsIRDFService* mRDFService;
- nsISupportsArray* mTreeProperties;
-};
-
-
-#endif // nsRDFDocument_h___
diff --git a/mozilla/rdf/content/src/nsRDFDocumentContentSink.cpp b/mozilla/rdf/content/src/nsRDFDocumentContentSink.cpp
index 21d413c9a81..39e51d79e19 100644
--- a/mozilla/rdf/content/src/nsRDFDocumentContentSink.cpp
+++ b/mozilla/rdf/content/src/nsRDFDocumentContentSink.cpp
@@ -32,6 +32,7 @@
#include "nsIPresContext.h"
#include "nsICSSStyleSheet.h"
#include "nsIRDFContent.h"
+#include "nsIRDFDataBase.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
@@ -39,6 +40,7 @@
#include "nsIWebShell.h"
#include "nsLayoutCID.h"
#include "nsRDFContentSink.h"
+#include "nsRDFContentUtils.h"
#include "nsINameSpaceManager.h"
////////////////////////////////////////////////////////////////////////
@@ -46,13 +48,15 @@
static NS_DEFINE_IID(kICSSParserIID, NS_ICSS_PARSER_IID); // XXX grr..
static NS_DEFINE_IID(kIDOMCommentIID, NS_IDOMCOMMENT_IID);
static NS_DEFINE_IID(kIRDFContentSinkIID, NS_IRDFCONTENTSINK_IID);
-static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
+static NS_DEFINE_IID(kIRDFContentIID, NS_IRDFCONTENT_IID);
static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
+static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
-class nsRDFDocumentContentSink : public nsRDFContentSink {
+class nsRDFDocumentContentSink : public nsRDFContentSink
+{
public:
nsRDFDocumentContentSink(void);
virtual ~nsRDFDocumentContentSink(void);
@@ -67,14 +71,14 @@ public:
NS_IMETHOD AddProcessingInstruction(const nsIParserNode& aNode);
protected:
- void StartLayout(void);
-
virtual nsresult OpenObject(const nsIParserNode& aNode);
// Style sheets
nsresult LoadStyleSheet(nsIURL* aURL,
nsIUnicharInputStream* aUIN);
+ nsresult StartLayout(void);
+
nsIStyleSheet* mStyleSheet;
// Document, webshell, etc.
@@ -129,83 +133,6 @@ nsRDFDocumentContentSink::Init(nsIDocument* aDoc,
}
-void
-nsRDFDocumentContentSink::StartLayout(void)
-{
- PRInt32 i, ns = mDocument->GetNumberOfShells();
- for (i = 0; i < ns; i++) {
- nsIPresShell* shell = mDocument->GetShellAt(i);
- if (nsnull != shell) {
- // Make shell an observer for next time
- shell->BeginObservingDocument();
-
- // Resize-reflow this time
- nsIPresContext* cx = shell->GetPresContext();
- nsRect r;
- cx->GetVisibleArea(r);
- shell->InitialReflow(r.width, r.height);
- NS_RELEASE(cx);
-
- // Now trigger a refresh
- nsIViewManager* vm = shell->GetViewManager();
- if (nsnull != vm) {
- vm->EnableRefresh();
- NS_RELEASE(vm);
- }
-
- NS_RELEASE(shell);
- }
- }
-
- // If the document we are loading has a reference or it is a top level
- // frameset document, disable the scroll bars on the views.
- const char* ref;
- (void)mDocumentURL->GetRef(&ref);
- PRBool topLevelFrameset = PR_FALSE;
- if (mWebShell) {
- nsIWebShell* rootWebShell;
- mWebShell->GetRootWebShell(rootWebShell);
- if (mWebShell == rootWebShell) {
- topLevelFrameset = PR_TRUE;
- }
- NS_IF_RELEASE(rootWebShell);
- }
-
- if ((nsnull != ref) || topLevelFrameset) {
- // XXX support more than one presentation-shell here
-
- // Get initial scroll preference and save it away; disable the
- // scroll bars.
- PRInt32 i, ns = mDocument->GetNumberOfShells();
- for (i = 0; i < ns; i++) {
- nsIPresShell* shell = mDocument->GetShellAt(i);
- if (nsnull != shell) {
- nsIViewManager* vm = shell->GetViewManager();
- if (nsnull != vm) {
- nsIView* rootView = nsnull;
- vm->GetRootView(rootView);
- if (nsnull != rootView) {
- nsIScrollableView* sview = nsnull;
- rootView->QueryInterface(kIScrollableViewIID, (void**) &sview);
- if (nsnull != sview) {
-#if 0
- if (topLevelFrameset)
- mOriginalScrollPreference = nsScrollPreference_kNeverScroll;
- else
- sview->GetScrollPreference(mOriginalScrollPreference);
-#endif
- sview->SetScrollPreference(nsScrollPreference_kNeverScroll);
- }
- }
- NS_RELEASE(vm);
- }
- NS_RELEASE(shell);
- }
- }
- }
-}
-
-
// XXX Borrowed from HTMLContentSink. Should be shared.
nsresult
nsRDFDocumentContentSink::LoadStyleSheet(nsIURL* aURL,
@@ -237,86 +164,58 @@ nsRDFDocumentContentSink::LoadStyleSheet(nsIURL* aURL,
}
+nsresult
+nsRDFDocumentContentSink::StartLayout(void)
+{
+ PRInt32 count = mDocument->GetNumberOfShells();
+ for (PRInt32 i = 0; i < count; i++) {
+ nsIPresShell* shell = mDocument->GetShellAt(i);
+ if (nsnull != shell) {
+ // Resize-reflow this time
+ nsIPresContext* cx = shell->GetPresContext();
+ nsRect r;
+ cx->GetVisibleArea(r);
+ shell->InitialReflow(r.width, r.height);
+ NS_RELEASE(cx);
+
+ // Now trigger a refresh
+ nsIViewManager* vm = shell->GetViewManager();
+ if (nsnull != vm) {
+ vm->EnableRefresh();
+ NS_RELEASE(vm);
+ }
+
+ // Start observing the document _after_ we do the initial
+ // reflow. Otherwise, we'll get into an trouble trying to
+ // creat kids before the root frame is established.
+ shell->BeginObservingDocument();
+
+ NS_RELEASE(shell);
+ }
+ }
+ return NS_OK;
+}
+
+
////////////////////////////////////////////////////////////////////////
// nsIContentSink interface
NS_IMETHODIMP
nsRDFDocumentContentSink::WillBuildModel(void)
{
- // Notify document that the load is beginning
mDocument->BeginLoad();
- nsresult result = NS_OK;
-
- return result;
+ return NS_OK;
}
NS_IMETHODIMP
nsRDFDocumentContentSink::DidBuildModel(PRInt32 aQualityLevel)
{
- // XXX this is silly; who cares?
- PRInt32 i, ns = mDocument->GetNumberOfShells();
- for (i = 0; i < ns; i++) {
- nsIPresShell* shell = mDocument->GetShellAt(i);
- if (nsnull != shell) {
- nsIViewManager* vm = shell->GetViewManager();
- if(vm) {
- vm->SetQuality(nsContentQuality(aQualityLevel));
- }
- NS_RELEASE(vm);
- NS_RELEASE(shell);
- }
- }
-
- StartLayout();
-
- // XXX Should scroll to ref when that makes sense
- // ScrollToRef();
-
+ //StartLayout();
mDocument->EndLoad();
return NS_OK;
}
-static nsresult
-rdf_GetQuotedAttributeValue(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;
-}
-
-
NS_IMETHODIMP
nsRDFDocumentContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
@@ -324,21 +223,19 @@ nsRDFDocumentContentSink::AddProcessingInstruction(const nsIParserNode& aNode)
static const char kStyleSheetPI[] = "GetNamedDataSource(uri, &ds))) {
+ nsIRDFDocument* rdfDoc;
+ if (NS_SUCCEEDED(mDocument->QueryInterface(kIRDFDocumentIID, (void**) &rdfDoc))) {
+ nsIRDFDataBase* db;
+ if (NS_SUCCEEDED(rv = rdfDoc->GetDataBase(db))) {
+ rv = db->AddDataSource(ds);
+ NS_RELEASE(db);
+ }
+ NS_RELEASE(rdfDoc);
+ }
+ NS_RELEASE(ds);
+ }
+ }
return rv;
}
@@ -419,6 +340,10 @@ nsRDFDocumentContentSink::OpenObject(const nsIParserNode& aNode)
NS_RELEASE(resource);
+ // Start layout. We need to wait until _now_ to ensure that we
+ // actually have a root document element.
+ StartLayout();
+
// don't release the rdfElement since we're keeping
// a reference to it in mRootElement
}
diff --git a/mozilla/rdf/content/src/nsRDFGenericElement.cpp b/mozilla/rdf/content/src/nsRDFGenericElement.cpp
index 126b35bce68..383eb581050 100644
--- a/mozilla/rdf/content/src/nsRDFGenericElement.cpp
+++ b/mozilla/rdf/content/src/nsRDFGenericElement.cpp
@@ -42,6 +42,7 @@
#include "nsINameSpaceManager.h"
#include "nsIScriptObjectOwner.h"
#include "nsISupportsArray.h"
+#include "nsRDFContentUtils.h"
#include "nsString.h"
#include "prlog.h"
@@ -102,6 +103,8 @@ public:
NS_IMETHOD IsSynthetic(PRBool& aResult);
NS_IMETHOD GetNameSpaceID(PRInt32& aResult) const;
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
+ NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID);
+ NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify);
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
@@ -295,8 +298,6 @@ RDFGenericElementImpl::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP
RDFGenericElementImpl::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
- // XXX put me in a header file somewhere
- extern nsresult NS_NewRDFDOMNodeList(nsIDOMNodeList** aChildNodes, nsIContent* aElement);
return NS_NewRDFDOMNodeList(aChildNodes, this);
}
@@ -417,7 +418,7 @@ RDFGenericElementImpl::GetTagName(nsString& aTagName)
NS_IMETHODIMP
-RDFGenericElementImpl::GetDOMAttribute(const nsString& aName, nsString& aReturn)
+RDFGenericElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
@@ -425,7 +426,7 @@ RDFGenericElementImpl::GetDOMAttribute(const nsString& aName, nsString& aReturn)
NS_IMETHODIMP
-RDFGenericElementImpl::SetDOMAttribute(const nsString& aName, const nsString& aValue)
+RDFGenericElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
@@ -825,6 +826,25 @@ RDFGenericElementImpl::GetTag(nsIAtom*& aResult) const
return NS_OK;
}
+NS_IMETHODIMP
+RDFGenericElementImpl::ParseAttributeString(const nsString& aStr,
+ nsIAtom*& aName,
+ PRInt32& aNameSpaceID)
+{
+ // XXX Need to implement
+ aName = nsnull;
+ aNameSpaceID = kNameSpaceID_None;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+RDFGenericElementImpl::GetNameSpacePrefix(PRInt32 aNameSpaceID,
+ nsIAtom*& aPrefix)
+{
+ // XXX Need to implement
+ aPrefix = nsnull;
+ return NS_OK;
+}
// XXX attribute code swiped from nsGenericContainerElement
// this class could probably just use nsGenericContainerElement
diff --git a/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp b/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
index 373297272c8..49ec14c8b21 100644
--- a/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
+++ b/mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
@@ -36,6 +36,7 @@
#include "nsIServiceManager.h"
#include "nsINameSpaceManager.h"
#include "nsISupportsArray.h"
+#include "nsRDFContentUtils.h"
#include "rdfutil.h"
////////////////////////////////////////////////////////////////////////
@@ -48,62 +49,6 @@ static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID
////////////////////////////////////////////////////////////////////////
-#include "nsITextContent.h"
-#include "nsLayoutCID.h"
-static NS_DEFINE_IID(kITextContentIID, NS_ITEXT_CONTENT_IID); // XXX grr...
-static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
-
-nsresult
-rdf_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;
-}
-
////////////////////////////////////////////////////////////////////////
class RDFHTMLBuilderImpl : public nsIRDFContentModelBuilder
@@ -122,7 +67,6 @@ public:
// nsIRDFContentModelBuilder interface
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
NS_IMETHOD CreateRoot(nsIRDFResource* aResource);
- NS_IMETHOD CreateChildrenFor(nsIRDFContent* aElement);
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
@@ -235,10 +179,10 @@ RDFHTMLBuilderImpl::AddLeafChild(nsIRDFContent* parent,
if (NS_FAILED(rv = NS_NewRDFResourceElement(&child, property, nameSpaceID, tag, PR_FALSE)))
goto done;
- if (NS_FAILED(rv = rdf_AttachTextNode(child, value)))
+ if (NS_FAILED(rv = parent->AppendChildTo(child, PR_TRUE)))
goto done;
- rv = parent->AppendChildTo(child, PR_TRUE);
+ rv = rdf_AttachTextNode(child, value);
done:
NS_IF_RELEASE(tag);
@@ -311,14 +255,6 @@ done:
}
-NS_IMETHODIMP
-RDFHTMLBuilderImpl::CreateChildrenFor(nsIRDFContent* aElement)
-{
- PR_ASSERT(0);
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-
NS_IMETHODIMP
RDFHTMLBuilderImpl::OnAssert(nsIRDFContent* parent,
diff --git a/mozilla/rdf/content/src/nsRDFHTMLDocument.cpp b/mozilla/rdf/content/src/nsRDFHTMLDocument.cpp
deleted file mode 100644
index dc0c176e7b0..00000000000
--- a/mozilla/rdf/content/src/nsRDFHTMLDocument.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-/* -*- 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 "nsIRDFContent.h"
-#include "nsIRDFCursor.h"
-#include "nsIRDFDataBase.h"
-#include "nsIRDFNode.h"
-#include "nsIRDFService.h"
-#include "nsIServiceManager.h"
-#include "nsINameSpaceManager.h"
-#include "nsISupportsArray.h"
-#include "nsRDFDocument.h"
-#include "rdfutil.h"
-
-////////////////////////////////////////////////////////////////////////
-
-static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
-static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
-
-////////////////////////////////////////////////////////////////////////
-
-class RDFHTMLDocumentImpl : public nsRDFDocument {
-public:
- RDFHTMLDocumentImpl();
- virtual ~RDFHTMLDocumentImpl();
-
-protected:
- nsresult AddTreeChild(nsIRDFContent* parent,
- const nsString& tag,
- nsIRDFResource* property,
- nsIRDFResource* value);
-
- nsresult AddLeafChild(nsIRDFContent* parent,
- const nsString& tag,
- nsIRDFResource* property,
- nsIRDFLiteral* value);
-
- virtual nsresult AddChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value);
-};
-
-////////////////////////////////////////////////////////////////////////
-
-static nsIAtom* kIdAtom;
-
-RDFHTMLDocumentImpl::RDFHTMLDocumentImpl(void)
-{
- if (nsnull == kIdAtom) {
- kIdAtom = NS_NewAtom("ID");
- }
- else {
- NS_ADDREF(kIdAtom);
- }
-}
-
-RDFHTMLDocumentImpl::~RDFHTMLDocumentImpl(void)
-{
- nsrefcnt refcnt;
- NS_RELEASE2(kIdAtom, refcnt);
-}
-
-nsresult
-RDFHTMLDocumentImpl::AddTreeChild(nsIRDFContent* parent,
- const nsString& tag,
- 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.,
- //
- //
- //
- //
- //
- // ...
- //
-
- nsresult rv;
- const char* p;
- nsAutoString s;
- nsIRDFContent* child = nsnull;
-
- // PR_TRUE indicates that we want the child to dynamically
- // generate its own kids.
- if (NS_FAILED(rv = NewChild(tag, value, child, PR_TRUE)))
- goto done;
-
- if (NS_FAILED(rv = value->GetValue(&p)))
- goto done;
-
- s = p;
-
- if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, s, PR_FALSE)))
- goto done;
-
- rv = parent->AppendChildTo(child, PR_TRUE);
-
-done:
- NS_IF_RELEASE(child);
- return rv;
-}
-
-
-nsresult
-RDFHTMLDocumentImpl::AddLeafChild(nsIRDFContent* parent,
- const nsString& tag,
- 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.,
- //
- //
- // value
- // ...
- //
-
- nsresult rv;
- nsIRDFContent* child = nsnull;
-
- if (NS_FAILED(rv = NewChild(tag, property, child, PR_FALSE)))
- goto done;
-
- if (NS_FAILED(rv = AttachTextNode(child, value)))
- goto done;
-
- rv = parent->AppendChildTo(child, PR_TRUE);
-
-done:
- NS_IF_RELEASE(child);
- return rv;
-}
-
-nsresult
-RDFHTMLDocumentImpl::AddChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value)
-{
- nsresult rv;
-
- // The tag we'll use for the new child will be the string value of
- // the property.
- const char* s;
- if (NS_FAILED(rv = property->GetValue(&s)))
- return rv;
-
- nsAutoString tag = s;
-
- nsIRDFResource* valueResource;
- if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &valueResource))) {
- if (IsTreeProperty(property) || rdf_IsContainer(mRDFService, mDB, valueResource)) {
- rv = AddTreeChild(parent, tag, property, valueResource);
- NS_RELEASE(valueResource);
- return rv;
- }
- NS_RELEASE(valueResource);
- }
-
- nsIRDFLiteral* valueLiteral;
- if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFLiteralIID, (void**) &valueLiteral))) {
- rv = AddLeafChild(parent, tag, property, valueLiteral);
- NS_RELEASE(valueLiteral);
- }
- return rv;
-}
-
-
-////////////////////////////////////////////////////////////////////////
-
-nsresult NS_NewRDFHTMLDocument(nsIRDFDocument** result)
-{
- nsIRDFDocument* doc = new RDFHTMLDocumentImpl();
- if (! doc)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(doc);
- *result = doc;
- return NS_OK;
-}
diff --git a/mozilla/rdf/content/src/nsRDFResourceElement.cpp b/mozilla/rdf/content/src/nsRDFResourceElement.cpp
index 75b313704d6..c0dddeca0e8 100644
--- a/mozilla/rdf/content/src/nsRDFResourceElement.cpp
+++ b/mozilla/rdf/content/src/nsRDFResourceElement.cpp
@@ -52,21 +52,27 @@
#include "nsGenericAttribute.h"
#include "nsHashtable.h"
#include "nsIAtom.h"
+#include "nsIContent.h"
+#include "nsIDOMElement.h"
+#include "nsIDOMEventReceiver.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIDocument.h"
#include "nsIEventListenerManager.h"
#include "nsIEventStateManager.h"
+#include "nsIJSScriptObject.h"
#include "nsINameSpaceManager.h"
+#include "nsIRDFContent.h"
#include "nsIRDFCursor.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFDocument.h"
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
+#include "nsIScriptObjectOwner.h"
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h"
-#include "nsRDFResourceElement.h"
+#include "nsRDFContentUtils.h"
////////////////////////////////////////////////////////////////////////
@@ -138,6 +144,8 @@ public:
NS_IMETHOD IsSynthetic(PRBool& aResult);
NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpeceID) const;
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
+ NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID);
+ NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify);
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
@@ -159,6 +167,8 @@ public:
NS_IMETHOD GetRangeList(nsVoidArray*& aResult) const;
// nsIXMLContent (from nsIRDFContent)
+ //NS_IMETHOD SetContainingNameSpace(nsINameSpace* aNameSpace);
+ //NS_IMETHOD GetContainingNameSpace(nsINameSpace*& aNameSpace) const;
//NS_IMETHOD SetNameSpacePrefix(nsIAtom* aNameSpace);
//NS_IMETHOD GetNameSpacePrefix(nsIAtom*& aNameSpace) const;
//NS_IMETHOD SetNameSpaceID(PRInt32 aNameSpaceID);
@@ -360,8 +370,6 @@ RDFResourceElementImpl::GetParentNode(nsIDOMNode** aParentNode)
NS_IMETHODIMP
RDFResourceElementImpl::GetChildNodes(nsIDOMNodeList** aChildNodes)
{
- // XXX put me in a header file somewhere
- extern nsresult NS_NewRDFDOMNodeList(nsIDOMNodeList** aChildNodes, nsIContent* aElement);
return NS_NewRDFDOMNodeList(aChildNodes, this);
}
@@ -481,8 +489,29 @@ RDFResourceElementImpl::GetTagName(nsString& aTagName)
}
+NS_IMETHODIMP
+RDFResourceElementImpl::ParseAttributeString(const nsString& aStr,
+ nsIAtom*& aName,
+ PRInt32& aNameSpaceID)
+{
+ // XXX Need to implement
+ aName = nsnull;
+ aNameSpaceID = kNameSpaceID_None;
+ return NS_OK;
+}
+
NS_IMETHODIMP
-RDFResourceElementImpl::GetDOMAttribute(const nsString& aName, nsString& aReturn)
+RDFResourceElementImpl::GetNameSpacePrefix(PRInt32 aNameSpaceID,
+ nsIAtom*& aPrefix)
+{
+ // XXX Need to implement
+ aPrefix = nsnull;
+ return NS_OK;
+}
+
+
+NS_IMETHODIMP
+RDFResourceElementImpl::GetAttribute(const nsString& aName, nsString& aReturn)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
@@ -490,7 +519,7 @@ RDFResourceElementImpl::GetDOMAttribute(const nsString& aName, nsString& aReturn
NS_IMETHODIMP
-RDFResourceElementImpl::SetDOMAttribute(const nsString& aName, const nsString& aValue)
+RDFResourceElementImpl::SetAttribute(const nsString& aName, const nsString& aValue)
{
PR_ASSERT(0);
return NS_ERROR_NOT_IMPLEMENTED;
diff --git a/mozilla/rdf/content/src/nsRDFTreeBuilder.cpp b/mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
index 06c996eacf1..2445e6a7015 100644
--- a/mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
+++ b/mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
@@ -38,15 +38,11 @@
#include "nsIServiceManager.h"
#include "nsISupportsArray.h"
#include "nsRDFCID.h"
+#include "nsRDFContentUtils.h"
#include "nsString.h"
#include "rdf.h"
#include "rdfutil.h"
-// XXX should go in a header file...
-extern nsresult
-rdf_AttachTextNode(nsIContent* parent, nsIRDFNode* value);
-
-
////////////////////////////////////////////////////////////////////////
#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
@@ -85,7 +81,6 @@ public:
// nsIRDFContentModelBuilder interface
NS_IMETHOD SetDocument(nsIRDFDocument* aDocument);
NS_IMETHOD CreateRoot(nsIRDFResource* aResource);
- NS_IMETHOD CreateChildrenFor(nsIRDFContent* aElement);
NS_IMETHOD OnAssert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
NS_IMETHOD OnUnassert(nsIRDFContent* aElement, nsIRDFResource* aProperty, nsIRDFNode* aValue);
@@ -283,13 +278,6 @@ done:
}
-NS_IMETHODIMP
-RDFTreeBuilderImpl::CreateChildrenFor(nsIRDFContent* aElement)
-{
- PR_ASSERT(0);
- return NS_ERROR_NOT_IMPLEMENTED;
-}
-
NS_IMETHODIMP
RDFTreeBuilderImpl::OnAssert(nsIRDFContent* parent,
nsIRDFResource* property,
diff --git a/mozilla/rdf/content/src/nsRDFTreeDocument.cpp b/mozilla/rdf/content/src/nsRDFTreeDocument.cpp
deleted file mode 100644
index c5f2d5ebc07..00000000000
--- a/mozilla/rdf/content/src/nsRDFTreeDocument.cpp
+++ /dev/null
@@ -1,606 +0,0 @@
-/* -*- 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.
-
- */
-
-#include "nsIRDFContent.h"
-#include "nsIRDFCursor.h"
-#include "nsIRDFDataBase.h"
-#include "nsIRDFNode.h"
-#include "nsIRDFService.h"
-#include "nsIServiceManager.h"
-#include "nsINameSpaceManager.h"
-#include "nsISupportsArray.h"
-#include "nsRDFDocument.h"
-#include "rdf.h"
-#include "rdfutil.h"
-
-////////////////////////////////////////////////////////////////////////
-
-#define NC_NAMESPACE_URI "http://home.netscape.com/NC-rdf#"
-DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Columns);
-DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Column);
-DEFINE_RDF_VOCAB(NC_NAMESPACE_URI, NC, Title);
-
-static const char* kChildrenTag = "CHILDREN";
-static const char* kFolderTag = "FOLDER";
-static const char* kColumnsTag = "COLUMNS";
-
-////////////////////////////////////////////////////////////////////////
-
-static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
-static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
-
-////////////////////////////////////////////////////////////////////////
-
-class RDFTreeDocumentImpl : public nsRDFDocument {
-public:
- RDFTreeDocumentImpl();
- virtual ~RDFTreeDocumentImpl();
-
- //NS_IMETHOD SetRootResource(nsIRDFNode* resource);
-
-protected:
- virtual nsresult
- AddChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value);
-
- /**
- * Ensure that the specified tag exists as a child of the
- * parent element.
- */
- nsresult
- EnsureChildElement(nsIContent* parent,
- const nsString& tag,
- nsIContent*& result);
-
- /**
- * Add a new child to the content model from a tree property. This creates
- * the necessary cruft in the content model to ensure that content will
- * recursively be generated as the content model is descended.
- */
- nsresult
- AddTreeChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFResource* value);
-
- /**
- * Add a single column to the content model.
- */
- nsresult
- AddColumn(nsIContent* parent,
- nsIRDFResource* property,
- nsIRDFLiteral* title);
-
-
- /**
- * Add columns to the content model from an RDF container (sequence or bag)
- */
- nsresult
- AddColumnsFromContainer(nsIContent* parent,
- nsIRDFResource* columns);
-
-
- /**
- * Add columns to the content model from a set of multi-attributes
- */
- nsresult
- AddColumnsFromMultiAttributes(nsIContent* parent,
- nsIRDFResource* columns);
-
- /**
- * Add columns to the content model.
- */
- nsresult
- AddColumns(nsIContent* parent,
- nsIRDFResource* columns);
-
- /**
- * Add a new property element to the content model
- */
- nsresult
- AddPropertyChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value);
-};
-
-////////////////////////////////////////////////////////////////////////
-
-static nsIAtom* kIdAtom;
-static nsIAtom* kOpenAtom;
-
-RDFTreeDocumentImpl::RDFTreeDocumentImpl(void)
-{
- if (nsnull == kIdAtom) {
- kIdAtom = NS_NewAtom("ID");
- kOpenAtom = NS_NewAtom("open");
- }
- else {
- NS_ADDREF(kIdAtom);
- NS_ADDREF(kOpenAtom);
- }
-}
-
-RDFTreeDocumentImpl::~RDFTreeDocumentImpl(void)
-{
- nsrefcnt refcnt;
- NS_RELEASE2(kIdAtom, refcnt);
- NS_RELEASE2(kOpenAtom, refcnt);
-}
-
-
-nsresult
-RDFTreeDocumentImpl::EnsureChildElement(nsIContent* parent,
- const nsString& tag,
- nsIContent*& result)
-{
- nsresult rv;
- result = nsnull; // reasonable default
-
- nsIAtom* tagAtom = NS_NewAtom(tag);
- if (! tagAtom)
- return NS_ERROR_OUT_OF_MEMORY;
-
- PRInt32 count;
- if (NS_FAILED(rv = parent->ChildCount(count))) {
- NS_RELEASE(tagAtom);
- return rv;
- }
-
- for (PRInt32 i = 0; i < count; ++i) {
- nsIContent* kid;
- if (NS_FAILED(rv = parent->ChildAt(i, kid)))
- break;
-
- nsIAtom* kidTagAtom;
- if (NS_FAILED(rv = kid->GetTag(kidTagAtom))) {
- NS_RELEASE(kid);
- break;
- }
-
- if (kidTagAtom == tagAtom) {
- NS_RELEASE(kidTagAtom);
- NS_RELEASE(tagAtom);
- result = kid; // no need to addref, got it from ChildAt().
- return NS_OK;
- }
-
- NS_RELEASE(kidTagAtom);
- NS_RELEASE(kid);
- }
-
- NS_RELEASE(tagAtom);
-
- if (NS_FAILED(rv))
- return rv;
-
- // if we get here, we need to construct a new element.
-
- // XXX this should be a generic XML container element, not an nsRDFElement
- nsIRDFContent* children = nsnull;
-
- if (NS_FAILED(rv = NS_NewRDFElement(&children)))
- goto done;
-
- if (NS_FAILED(rv = children->Init(this, tag, nsnull /* XXX */, PR_FALSE)))
- goto done;
-
- if (NS_FAILED(rv = parent->AppendChildTo(children, PR_FALSE)))
- goto done;
-
- result = children;
- NS_ADDREF(result);
-
-done:
- NS_IF_RELEASE(children);
- return rv;
-}
-
-nsresult
-RDFTreeDocumentImpl::AddTreeChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFResource* value)
-{
- // 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.,
- //
- //
- // ...
- //
- // -
- //
- //
- //
- // ...
- //
-
- nsresult rv;
- nsIRDFContent* child = nsnull;
- nsIContent* children = nsnull;
- const char* p;
- nsAutoString s;
-
- // Ensure that the element exists on the parent.
- if (NS_FAILED(rv = EnsureChildElement(parent, kChildrenTag, children)))
- goto done;
-
- // Create a new child that represents the "value"
- // resource. PR_TRUE indicates that we want the child to
- // dynamically generate its own kids.
- if (NS_FAILED(rv = NewChild(kFolderTag, value, child, PR_TRUE)))
- goto done;
-
- if (NS_FAILED(rv = value->GetValue(&p)))
- goto done;
-
- s = p;
-
- if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_HTML, kIdAtom, s, PR_FALSE)))
- goto done;
-
-#define ALL_NODES_OPEN_HACK
-#ifdef ALL_NODES_OPEN_HACK
- if (NS_FAILED(rv = child->SetAttribute(kNameSpaceID_None, kOpenAtom, "TRUE", PR_FALSE)))
- goto done;
-#endif
-
- // Finally, add the thing to the element.
- children->AppendChildTo(child, PR_TRUE);
-
-done:
- NS_IF_RELEASE(child);
- NS_IF_RELEASE(children);
- return rv;
-}
-
-nsresult
-RDFTreeDocumentImpl::AddColumn(nsIContent* parent,
- nsIRDFResource* property,
- nsIRDFLiteral* title)
-{
- nsresult rv;
-
- const char* s;
- if (NS_FAILED(rv = property->GetValue(&s)))
- return rv;
-
- nsAutoString tag = s;
-
- // XXX this should be a generic XML container element, not an nsRDFElement
- nsIRDFContent* column = nsnull;
-
- if (NS_FAILED(rv = NS_NewRDFElement(&column)))
- goto done;
-
- if (NS_FAILED(rv = column->Init(this, tag, nsnull /* XXX */, PR_FALSE)))
- goto done;
-
- if (NS_FAILED(rv = parent->AppendChildTo(column, PR_FALSE)))
- goto done;
-
- rv = AttachTextNode(column, title);
-
-done:
- NS_IF_RELEASE(column);
- return rv;
-}
-
-
-/*
-
- When columns are specified using a container, the data model is
- assumed to look something like the following example:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- */
-
-nsresult
-RDFTreeDocumentImpl::AddColumnsFromContainer(nsIContent* parent,
- nsIRDFResource* columns)
-{
- nsresult rv;
-
- nsIContent* columnsElement;
- if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsTag, columnsElement)))
- return rv;
-
- nsIRDFResource* NC_Column = nsnull;
- nsIRDFResource* NC_Title = nsnull;
- nsIRDFAssertionCursor* cursor = nsnull;
-
- if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Column, &NC_Column)))
- goto done;
-
- if (NS_FAILED(rv = mRDFService->GetResource(kURINC_Title, &NC_Title)))
- goto done;
-
- if (NS_FAILED(rv = NS_NewContainerCursor(mDB, columns, &cursor)))
- goto done;
-
- while (NS_SUCCEEDED(rv = cursor->Advance())) {
- nsIRDFNode* columnNode;
- if (NS_SUCCEEDED(rv = cursor->GetObject(&columnNode))) {
- nsIRDFResource* column;
- if (NS_SUCCEEDED(rv = columnNode->QueryInterface(kIRDFResourceIID, (void**) &column))) {
- // XXX okay, error recovery leaves a bit to be desired here...
- nsIRDFNode* propertyNode = nsnull;
- nsIRDFResource* property = nsnull;
- nsIRDFNode* titleNode = nsnull;
- nsIRDFLiteral* title = nsnull;
-
- rv = mDB->GetTarget(column, NC_Column, PR_TRUE, &propertyNode);
- PR_ASSERT(NS_SUCCEEDED(rv));
-
- rv = propertyNode->QueryInterface(kIRDFResourceIID, (void**) &property);
- PR_ASSERT(NS_SUCCEEDED(rv));
-
- rv = mDB->GetTarget(column, NC_Title, PR_TRUE, &titleNode);
- PR_ASSERT(NS_SUCCEEDED(rv));
-
- rv = titleNode->QueryInterface(kIRDFLiteralIID, (void**) &title);
- PR_ASSERT(NS_SUCCEEDED(rv));
-
- AddColumn(columnsElement, property, title);
-
- NS_IF_RELEASE(title);
- NS_IF_RELEASE(titleNode);
- NS_IF_RELEASE(property);
- NS_IF_RELEASE(propertyNode);
-
- NS_RELEASE(column);
- }
- NS_RELEASE(columnNode);
- }
-
- if (NS_FAILED(rv))
- break;
- }
-
- if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
- // This is a "normal" return code from nsIRDFCursor::Advance().
- rv = NS_OK;
-
-done:
- NS_IF_RELEASE(cursor);
- NS_IF_RELEASE(NC_Title);
- NS_IF_RELEASE(NC_Column);
- return rv;
-}
-
-/*
-
- When the columns are specified using multi-attributes, the data
- model assumed to look something like the following example:
-
-
-
-
- Date Last Visited
- URL
- Title
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- TODO: implement the NC:Order property on the column set. This is not
- exactly a slam dunk; it requires getting reification working
- properly in the RDF content sink.
-
- */
-nsresult
-RDFTreeDocumentImpl::AddColumnsFromMultiAttributes(nsIContent* parent,
- nsIRDFResource* columns)
-{
- nsresult rv;
-
- nsIContent* columnsElement;
- if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsTag, columnsElement)))
- return rv;
-
- nsIRDFArcsOutCursor* cursor = nsnull;
- if (NS_FAILED(rv = mDB->ArcLabelsOut(columns, &cursor)))
- goto done;
-
- while (NS_SUCCEEDED(rv = cursor->Advance())) {
- nsIRDFResource* property;
- if (NS_SUCCEEDED(rv = cursor->GetPredicate(&property))) {
- nsIRDFNode* titleNode;
- if (NS_SUCCEEDED(rv = mDB->GetTarget(columns, property, PR_TRUE, &titleNode))) {
- nsIRDFLiteral* title;
- if (NS_SUCCEEDED(rv = titleNode->QueryInterface(kIRDFLiteralIID,
- (void**) &title))) {
- rv = AddColumn(columnsElement, property, title);
- NS_RELEASE(title);
- }
- NS_RELEASE(titleNode);
- }
- NS_RELEASE(property);
- }
-
- if (NS_FAILED(rv))
- break;
- }
-
- if (rv == NS_ERROR_RDF_CURSOR_EMPTY)
- // This is a reasonable return code from nsIRDFCursor::Advance()
- rv = NS_OK;
-
- // XXX Now search for an "order" property and apply it to the
- // above to sort them...
-
-done:
- NS_IF_RELEASE(cursor);
- return rv;
-}
-
-nsresult
-RDFTreeDocumentImpl::AddColumns(nsIContent* parent,
- nsIRDFResource* columns)
-{
- nsresult rv;
-
- if (rdf_IsContainer(mRDFService, mDB, columns)) {
- rv = AddColumnsFromContainer(parent, columns);
- }
- else {
- rv = AddColumnsFromMultiAttributes(parent, columns);
- }
- return rv;
-}
-
-
-nsresult
-RDFTreeDocumentImpl::AddPropertyChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* 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.,
- //
- //
- //
- // value
- //
- // ...
- //
- nsresult rv;
- nsIContent* columnsElement = nsnull;
- nsIRDFContent* child = nsnull;
- const char* p;
- nsAutoString s;
-
- if (NS_FAILED(rv = EnsureChildElement(parent, kColumnsTag, columnsElement)))
- goto done;
-
- if (NS_FAILED(rv = property->GetValue(&p)))
- goto done;
-
- s = p;
-
- // XXX this should be a generic XML element, *not* an nsRDFElement.
- if (NS_FAILED(rv = NewChild(s, property, child, PR_FALSE)))
- goto done;
-
- if (NS_FAILED(rv = AttachTextNode(child, value)))
- goto done;
-
- rv = columnsElement->AppendChildTo(child, PR_TRUE);
-
-done:
- NS_IF_RELEASE(columnsElement);
- NS_IF_RELEASE(child);
- return rv;
-}
-
-
-nsresult
-RDFTreeDocumentImpl::AddChild(nsIRDFContent* parent,
- nsIRDFResource* property,
- nsIRDFNode* value)
-{
- nsresult rv;
- nsIRDFResource* resource;
- if (NS_SUCCEEDED(rv = value->QueryInterface(kIRDFResourceIID, (void**) &resource))) {
- PRBool isColumnsProperty;
-
- if (parent == mRootContent &&
- NS_SUCCEEDED(property->EqualsString(kURINC_Columns, &isColumnsProperty)) &&
- isColumnsProperty) {
- rv = AddColumns(parent, resource);
-
- NS_RELEASE(resource);
- return rv;
- }
- else if (IsTreeProperty(property) || rdf_IsContainer(mRDFService, mDB, resource)) {
- rv = AddTreeChild(parent, property, resource);
-
- NS_RELEASE(resource);
- return rv;
- }
-
- NS_RELEASE(resource);
- }
-
- return AddPropertyChild(parent, property, value);
-}
-
-
-////////////////////////////////////////////////////////////////////////
-
-nsresult NS_NewRDFTreeDocument(nsIRDFDocument** result)
-{
- nsIRDFDocument* doc = new RDFTreeDocumentImpl();
- if (! doc)
- return NS_ERROR_OUT_OF_MEMORY;
-
- NS_ADDREF(doc);
- *result = doc;
- return NS_OK;
-}
-
-
-
diff --git a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
index cfe9827a6d5..299501ca2e3 100644
--- a/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
+++ b/mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
@@ -224,7 +224,7 @@ BookmarkParser::NextToken(void)
return;
nsIRDFResource* parent = (nsIRDFResource*) mStack[mStack.Count() - 1];
- rdf_Assert(mRDFService, mDataSource, parent, kURINC_Folder, folder);
+ rdf_Assert(mDataSource, parent, kURINC_Folder, folder);
}
else {
// it's the root
@@ -244,21 +244,21 @@ BookmarkParser::NextToken(void)
//NS_RELEASE(folder);
if (mState != eBookmarkParserState_InTitle)
- rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Name, mLine);
+ rdf_Assert(mDataSource, mLastItem, kURINC_Name, mLine);
if (mLine.Find(kPersonalToolbar) == 0)
- rdf_Assert(mRDFService, mDataSource, mLastItem, kURIRDF_instanceOf, kURINC_PersonalToolbarFolderCategory);
+ rdf_Assert(mDataSource, mLastItem, kURIRDF_instanceOf, kURINC_PersonalToolbarFolderCategory);
}
else if (mState == eBookmarkParserState_InItemTitle) {
PR_ASSERT(mLastItem);
if (! mLastItem)
return;
- rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Name, mLine);
+ rdf_Assert(mDataSource, mLastItem, kURINC_Name, mLine);
NS_IF_RELEASE(mLastItem);
}
else if (mState == eBookmarkParserState_InItemDescription) {
- rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Description, mLine);
+ rdf_Assert(mDataSource, mLastItem, kURINC_Description, mLine);
}
}
@@ -312,7 +312,7 @@ BookmarkParser::DoStateTransition(void)
(mLine.Find(kBRString) == 0)) {
// XXX in the original bmk2rdf.c, we only added the
// description in the case that it wasn't set already...why?
- rdf_Assert(mRDFService, mDataSource, mLastItem, kURINC_Description, mLine);
+ rdf_Assert(mDataSource, mLastItem, kURINC_Description, mLine);
}
else {
mState = eBookmarkParserState_Initial;
@@ -364,7 +364,7 @@ BookmarkParser::CreateBookmark(void)
if (! parent)
return;
- rdf_Assert(mRDFService, mDataSource, parent, kURINC_child, bookmark);
+ rdf_Assert(mDataSource, parent, kURINC_child, bookmark);
if (values[eBmkAttribute_AddDate].Length() > 0)
AssertTime(bookmark, kURINC_BookmarkAddDate, values[eBmkAttribute_AddDate]);
@@ -389,7 +389,7 @@ BookmarkParser::AssertTime(nsIRDFResource* object,
const nsString& time)
{
// XXX
- return rdf_Assert(mRDFService, mDataSource, object, predicateURI, time);
+ return rdf_Assert(mDataSource, object, predicateURI, time);
}
////////////////////////////////////////////////////////////////////////
@@ -492,6 +492,13 @@ public:
}
NS_IMETHOD Flush(void);
+
+ NS_IMETHOD IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult);
+
+ NS_IMETHOD DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget);
};
////////////////////////////////////////////////////////////////////////
@@ -541,6 +548,23 @@ BookmarkDataSourceImpl::Flush(void)
}
+NS_IMETHODIMP
+BookmarkDataSourceImpl::IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult)
+{
+ PR_ASSERT(0);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+BookmarkDataSourceImpl::DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget)
+{
+ PR_ASSERT(0);
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
nsresult
BookmarkDataSourceImpl::ReadBookmarks(void)
diff --git a/mozilla/rdf/datasource/src/nsMailDataSource.cpp b/mozilla/rdf/datasource/src/nsMailDataSource.cpp
index b5dfae7477f..f287e6c9a6d 100644
--- a/mozilla/rdf/datasource/src/nsMailDataSource.cpp
+++ b/mozilla/rdf/datasource/src/nsMailDataSource.cpp
@@ -154,6 +154,18 @@ peq(nsIRDFResource* r1, nsIRDFResource* r2)
/********************************** MailDataSource **************************************
************************************************************************************/
+nsIRDFResource* MailDataSource::kNC_Child;
+nsIRDFResource* MailDataSource::kNC_Folder;
+nsIRDFResource* MailDataSource::kNC_From;
+nsIRDFResource* MailDataSource::kNC_subject;
+nsIRDFResource* MailDataSource::kNC_date;
+nsIRDFResource* MailDataSource::kNC_user;
+nsIRDFResource* MailDataSource::kNC_host;
+nsIRDFResource* MailDataSource::kNC_account;
+nsIRDFResource* MailDataSource::kNC_Name;
+nsIRDFResource* MailDataSource::kNC_MailRoot;
+nsIRDFResource* MailDataSource::kNC_Columns;
+
MailDataSource::MailDataSource(void)
: mURI(nsnull),
mMiscMailData(nsnull),
@@ -180,17 +192,18 @@ MailDataSource::~MailDataSource (void)
}
delete mObservers;
}
- NS_RELEASE(mResourceChild);
- NS_RELEASE(mResourceFolder);
- NS_RELEASE(mResourceFrom);
- NS_RELEASE(mResourceSubject);
- NS_RELEASE(mResourceDate);
- NS_RELEASE(mResourceUser);
- NS_RELEASE(mResourceHost);
- NS_RELEASE(mResourceAccount);
- NS_RELEASE(mResourceName);
- NS_RELEASE(mMailRoot);
- NS_RELEASE(mResourceColumns);
+ nsrefcnt refcnt;
+ NS_RELEASE2(kNC_Child, refcnt);
+ NS_RELEASE2(kNC_Folder, refcnt);
+ NS_RELEASE2(kNC_From, refcnt);
+ NS_RELEASE2(kNC_subject, refcnt);
+ NS_RELEASE2(kNC_date, refcnt);
+ NS_RELEASE2(kNC_user, refcnt);
+ NS_RELEASE2(kNC_host, refcnt);
+ NS_RELEASE2(kNC_account, refcnt);
+ NS_RELEASE2(kNC_Name, refcnt);
+ NS_RELEASE2(kNC_MailRoot, refcnt);
+ NS_RELEASE2(kNC_Columns, refcnt);
gMailDataSource = nsnull;
@@ -203,16 +216,16 @@ NS_IMPL_ISUPPORTS(MailDataSource, kIRDFMailDataSourceIID);
NS_IMETHODIMP
MailDataSource::AddAccount(nsIRDFMailAccount* folder)
{
- return gMailDataSource->mMiscMailData->Assert(gMailDataSource->mMailRoot,
- gMailDataSource->mResourceFolder,
+ return gMailDataSource->mMiscMailData->Assert(MailDataSource::kNC_MailRoot,
+ MailDataSource::kNC_Folder,
folder, PR_TRUE);
}
NS_IMETHODIMP
MailDataSource::RemoveAccount(nsIRDFMailAccount* folder)
{
- return gMailDataSource->mMiscMailData->Unassert(gMailDataSource->mMailRoot,
- gMailDataSource->mResourceFolder,
+ return gMailDataSource->mMiscMailData->Unassert(MailDataSource::kNC_MailRoot,
+ MailDataSource::kNC_Folder,
folder);
}
@@ -233,17 +246,19 @@ MailDataSource::Init(const char* uri)
(void**) &mMiscMailData)))
return rv;
- gRDFService->GetResource(kURINC_child, &mResourceChild);
- gRDFService->GetResource(kURINC_Folder, &mResourceFolder);
- gRDFService->GetResource(kURINC_from, &mResourceFrom);
- gRDFService->GetResource(kURINC_subject, &mResourceSubject);
- gRDFService->GetResource(kURINC_date, &mResourceDate);
- gRDFService->GetResource(kURINC_user, &mResourceUser);
- gRDFService->GetResource(kURINC_host, &mResourceHost);
- gRDFService->GetResource(kURINC_account, &mResourceAccount);
- gRDFService->GetResource(kURINC_Name, &mResourceName);
- gRDFService->GetResource(kURINC_Columns, &mResourceColumns);
- gRDFService->GetResource(kURINC_MailRoot, &mMailRoot);
+ if (! kNC_Child) {
+ gRDFService->GetResource(kURINC_child, &kNC_Child);
+ gRDFService->GetResource(kURINC_Folder, &kNC_Folder);
+ gRDFService->GetResource(kURINC_from, &kNC_From);
+ gRDFService->GetResource(kURINC_subject, &kNC_subject);
+ gRDFService->GetResource(kURINC_date, &kNC_date);
+ gRDFService->GetResource(kURINC_user, &kNC_user);
+ gRDFService->GetResource(kURINC_host, &kNC_host);
+ gRDFService->GetResource(kURINC_account, &kNC_account);
+ gRDFService->GetResource(kURINC_Name, &kNC_Name);
+ gRDFService->GetResource(kURINC_Columns, &kNC_Columns);
+ gRDFService->GetResource(kURINC_MailRoot, &kNC_MailRoot);
+ }
if (NS_FAILED(rv = InitAccountList()))
return rv;
@@ -269,13 +284,13 @@ MailDataSource::GetSource(nsIRDFResource* property,
nsresult rv = NS_ERROR_RDF_NO_VALUE;
if (!tv) return rv;
if (NS_OK == target->QueryInterface(kIRDFMailMessageIID, (void**)&msg)) {
- if (peq(mResourceChild, property)) {
+ if (peq(kNC_Child, property)) {
rv = msg->GetFolder((nsIRDFMailFolder**)source);
}
NS_RELEASE(msg);
return rv;
} else if (NS_OK == target->QueryInterface(kIRDFMailFolderIID, (void**)&fl)) {
- if (peq(mResourceAccount, property)) {
+ if (peq(kNC_account, property)) {
rv = fl->GetAccount((nsIRDFMailAccount**)source);
}
NS_RELEASE(fl);
@@ -301,13 +316,13 @@ MailDataSource::GetTarget(nsIRDFResource* source,
// XXX maybe something here to make sure that the folder corresponding to the message
// has been initialized?
- if (peq(mResourceFrom, property)) {
+ if (peq(kNC_From, property)) {
rv = msg->GetSender((nsIRDFResource**)target);
}
- else if (peq(mResourceSubject, property)) {
+ else if (peq(kNC_subject, property)) {
rv = msg->GetSubject((nsIRDFLiteral**)target);
}
- else if (peq(mResourceDate, property)) {
+ else if (peq(kNC_date, property)) {
rv = msg->GetDate((nsIRDFLiteral**)target);
}
else {
@@ -386,6 +401,22 @@ NS_IMETHODIMP MailDataSource::Flush()
return NS_ERROR_NOT_IMPLEMENTED;
}
+
+NS_IMETHODIMP
+MailDataSource::IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult)
+{
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+MailDataSource::DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget)
+{
+ return NS_OK;
+}
+
NS_IMETHODIMP
MailDataSource::GetSources(nsIRDFResource* property,
nsIRDFNode* target, PRBool tv,
@@ -407,16 +438,16 @@ MailDataSource::GetTargets(nsIRDFResource* source,
nsVoidArray* array = nsnull;
nsresult rv = NS_ERROR_FAILURE;
- if (peq(mResourceChild, property) &&
+ if (peq(kNC_Child, property) &&
(NS_OK == source->QueryInterface(kIRDFMailFolderIID, (void**)&fl))) {
rv = fl->GetMessageList(&array);
*targets = new ArrayMailCursor(source, property, array);
NS_ADDREF(*targets);
NS_IF_RELEASE(fl);
return rv;
- } else if ((peq(mResourceDate, property) ||
- peq(mResourceFrom, property) ||
- peq(mResourceSubject, property)) &&
+ } else if ((peq(kNC_date, property) ||
+ peq(kNC_From, property) ||
+ peq(kNC_subject, property)) &&
(NS_OK == source->QueryInterface(kIRDFMailMessageIID, (void**)&msg))) {
*targets = new SingletonMailCursor(source, property, PR_FALSE);
NS_IF_RELEASE(msg);
@@ -430,16 +461,56 @@ NS_IMETHODIMP
MailDataSource::ArcLabelsOut(nsIRDFResource* source,
nsIRDFArcsOutCursor** labels /* out */)
{
- nsVoidArray* temp = new nsVoidArray();
- temp->AppendElement(mResourceChild);
- temp->AppendElement(mResourceFolder);
- temp->AppendElement(mResourceName);
- temp->AppendElement(mResourceSubject);
- temp->AppendElement(mResourceFrom);
- temp->AppendElement(mResourceDate);
- temp->AppendElement(mResourceColumns);
- *labels = new ArrayMailCursor(source, mResourceChild, temp);
- return NS_OK;
+ nsIRDFMailMessage* message;
+ nsIRDFMailFolder* folder;
+ nsIRDFMailAccount* account;
+
+ if (NS_SUCCEEDED(source->QueryInterface(kIRDFMailMessageIID, (void**) &message))) {
+ nsVoidArray* temp = new nsVoidArray();
+ if (! temp)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ temp->AppendElement(kNC_Name); // XXX hack to get things to look right
+ temp->AppendElement(kNC_subject);
+ temp->AppendElement(kNC_From);
+ temp->AppendElement(kNC_date);
+ *labels = new ArrayMailCursor(source, kNC_Child, temp);
+ NS_ADDREF(*labels);
+
+ NS_RELEASE(message);
+ return NS_OK;
+ }
+ else if (NS_SUCCEEDED(source->QueryInterface(kIRDFMailFolderIID, (void**) &folder))) {
+ nsVoidArray* temp = new nsVoidArray();
+ if (! temp)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ temp->AppendElement(kNC_Name);
+ temp->AppendElement(kNC_subject); // XXX hack to get things to look right
+ temp->AppendElement(kNC_Child);
+ *labels = new ArrayMailCursor(source, kNC_Child, temp);
+ NS_ADDREF(*labels);
+
+ NS_RELEASE(folder);
+ return NS_OK;
+ }
+ else if (NS_SUCCEEDED(source->QueryInterface(kIRDFMailAccountIID, (void**) &account))) {
+ nsVoidArray* temp = new nsVoidArray();
+ if (! temp)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ temp->AppendElement(kNC_Name);
+ temp->AppendElement(kNC_subject); // XXX hack to get things to look right
+ temp->AppendElement(kNC_Folder);
+ *labels = new ArrayMailCursor(source, kNC_Child, temp);
+ NS_ADDREF(*labels);
+
+ NS_RELEASE(account);
+ return NS_OK;
+ }
+ else {
+ return mMiscMailData->ArcLabelsOut(source, labels);
+ }
}
nsresult
@@ -459,8 +530,8 @@ MailDataSource::InitAccountList(void)
if (strchr(de->name, '@')) {
PR_snprintf(fileurl, sizeof(fileurl), "mailaccount:%s", de->name);
gRDFService->GetResource(fileurl, (nsIRDFResource**)&account);
- rdf_Assert(gRDFService, mMiscMailData, account, mResourceName, de->name);
- rdf_Assert(gRDFService, mMiscMailData, account, mResourceSubject, de->name);
+ rdf_Assert(mMiscMailData, account, kNC_Name, de->name);
+ rdf_Assert(mMiscMailData, account, kNC_subject, de->name);
AddAccount(account);
}
}
@@ -502,7 +573,7 @@ NS_IMETHODIMP
MailAccount::GetUser(nsIRDFLiteral** result) const
{
return gMailDataSource->mMiscMailData->GetTarget((nsIRDFResource*)this,
- gMailDataSource->mResourceUser, PR_TRUE,
+ MailDataSource::kNC_user, PR_TRUE,
(nsIRDFNode**)result);
}
@@ -511,7 +582,7 @@ MailAccount::GetName(nsIRDFLiteral** result) const
{
// NS_ADDREF(mName);
return gMailDataSource->mMiscMailData->GetTarget(NS_CONST_CAST(MailAccount*, this),
- gMailDataSource->mResourceName,
+ MailDataSource::kNC_Name,
PR_TRUE,
(nsIRDFNode**)result);
}
@@ -521,7 +592,7 @@ NS_IMETHODIMP
MailAccount::GetHost(nsIRDFLiteral** result) const
{
return gMailDataSource->mMiscMailData->GetTarget(NS_CONST_CAST(MailAccount*, this),
- gMailDataSource->mResourceHost,
+ MailDataSource::kNC_host,
PR_TRUE,
(nsIRDFNode**)result);
}
@@ -531,7 +602,7 @@ NS_IMETHODIMP
MailAccount::AddFolder (nsIRDFMailFolder* folder)
{
return gMailDataSource->mMiscMailData->Assert(this,
- gMailDataSource->mResourceFolder,
+ MailDataSource::kNC_Folder,
folder, PR_TRUE);
}
@@ -539,7 +610,7 @@ NS_IMETHODIMP
MailAccount::RemoveFolder (nsIRDFMailFolder* folder)
{
return gMailDataSource->mMiscMailData->Unassert(this,
- gMailDataSource->mResourceFolder,
+ MailDataSource::kNC_Folder,
folder);
}
@@ -651,10 +722,10 @@ MailAccount::InitMailAccount (const char* url)
(!endsWith(".snm", de->name)) && (!endsWith("~", de->name))) {
PR_snprintf(fileurl, sizeof(fileurl), "mailbox://%s/%s/", &url[12], de->name);
gRDFService->GetResource(fileurl, (nsIRDFResource**)&folder);
- rdf_Assert(gRDFService, gMailDataSource->mMiscMailData, folder,
- gMailDataSource->mResourceName, de->name);
- rdf_Assert(gRDFService, gMailDataSource->mMiscMailData, folder,
- gMailDataSource->mResourceSubject, de->name);
+ rdf_Assert(gMailDataSource->mMiscMailData, folder,
+ MailDataSource::kNC_Name, de->name);
+ rdf_Assert(gMailDataSource->mMiscMailData, folder,
+ MailDataSource::kNC_subject, de->name);
AddFolder(folder);
}
}
@@ -674,7 +745,7 @@ NS_IMETHODIMP
MailFolder::GetAccount(nsIRDFMailAccount** account)
{
return gMailDataSource->mMiscMailData->GetTarget((nsIRDFResource*)this,
- gMailDataSource->mResourceAccount, PR_TRUE,
+ MailDataSource::kNC_account, PR_TRUE,
(nsIRDFNode**)account);
}
@@ -682,8 +753,8 @@ NS_IMETHODIMP
MailFolder::GetName(nsIRDFLiteral** result) const
{
return gMailDataSource->mMiscMailData->GetTarget((nsIRDFResource*)this,
- gMailDataSource->mResourceName, PR_TRUE,
- (nsIRDFNode**)result);
+ MailDataSource::kNC_Name, PR_TRUE,
+ (nsIRDFNode**)result);
}
NS_IMETHODIMP
@@ -1091,6 +1162,10 @@ MailMessage::QueryInterface(REFNSIID iid, void** result)
SingletonMailCursor::SingletonMailCursor(nsIRDFNode* u,
nsIRDFResource* s,
PRBool inversep)
+ : mValueReturnedp(PR_FALSE),
+ mProperty(s),
+ mInversep(inversep),
+ mValue(nsnull)
{
if (!inversep) {
mSource = (nsIRDFResource*)u;
@@ -1100,11 +1175,7 @@ SingletonMailCursor::SingletonMailCursor(nsIRDFNode* u,
mTarget = u;
}
NS_ADDREF(u);
- mProperty = s;
NS_ADDREF(mProperty);
- mValueReturnedp = PR_FALSE;
- mInversep = inversep;
- mValue = nsnull;
}
@@ -1132,16 +1203,14 @@ SingletonMailCursor::Advance(void)
if (mInversep) {
rv = gMailDataSource->GetSource(mProperty, mTarget, 1, (nsIRDFResource**)&mValue);
mSource = (nsIRDFResource*)mValue;
+ NS_IF_ADDREF(mSource);
} else {
rv = gMailDataSource->GetTarget(mSource, mProperty, 1, &mValue);
mTarget = mValue;
+ NS_IF_ADDREF(mTarget);
}
- if (mValue) {
- NS_ADDREF(mValue);
- NS_ADDREF(mValue);
- }
- // yes, its required twice, one for the value and one for the source/target
- if (rv == NS_ERROR_RDF_NO_VALUE) return NS_ERROR_RDF_CURSOR_EMPTY;
+ if (rv == NS_ERROR_RDF_NO_VALUE)
+ return NS_ERROR_RDF_CURSOR_EMPTY;
return rv;
}
@@ -1196,25 +1265,30 @@ SingletonMailCursor::GetTruthValue(PRBool* aTruthValue)
NS_IMPL_ISUPPORTS(SingletonMailCursor, kIRDFAssertionCursorIID);
+////////////////////////////////////////////////////////////////////////
+
ArrayMailCursor::ArrayMailCursor(nsIRDFResource* u, nsIRDFResource* s, nsVoidArray* array)
+ : mSource(u),
+ mProperty(s),
+ mArray(array),
+ mCount(0),
+ mTarget(nsnull),
+ mValue(nsnull)
{
// getsources and gettargets will call this with the array
- mSource = u;
- mProperty = s;
- mArray = array;
+ NS_INIT_REFCNT();
NS_ADDREF(mProperty);
NS_ADDREF(u);
- mCount = 0;
- mTarget = nsnull;
- mValue = nsnull;
}
ArrayMailCursor::~ArrayMailCursor(void)
{
+ // note that individual elements in the array are _not_ refcounted.
NS_IF_RELEASE(mSource);
NS_IF_RELEASE(mValue);
NS_IF_RELEASE(mProperty);
NS_IF_RELEASE(mTarget);
+ delete mArray;
}
@@ -1222,7 +1296,9 @@ ArrayMailCursor::~ArrayMailCursor(void)
NS_IMETHODIMP
ArrayMailCursor::Advance(void)
{
- if (mArray->Count() <= mCount) return NS_ERROR_RDF_CURSOR_EMPTY;
+ if (mArray->Count() <= mCount)
+ return NS_ERROR_RDF_CURSOR_EMPTY;
+
NS_IF_RELEASE(mValue);
mTarget = mValue = (nsIRDFNode*) mArray->ElementAt(mCount++);
NS_ADDREF(mValue);
@@ -1273,7 +1349,7 @@ ArrayMailCursor::GetObject(nsIRDFNode** aObject)
NS_IMETHODIMP
ArrayMailCursor::GetTruthValue(PRBool* aTruthValue)
{
- *aTruthValue = 1;
+ *aTruthValue = PR_TRUE;
return NS_OK;
}
diff --git a/mozilla/rdf/datasource/src/nsMailDataSource.h b/mozilla/rdf/datasource/src/nsMailDataSource.h
index 939d0259a78..d7f4aff1260 100644
--- a/mozilla/rdf/datasource/src/nsMailDataSource.h
+++ b/mozilla/rdf/datasource/src/nsMailDataSource.h
@@ -155,18 +155,25 @@ public:
NS_IMETHOD Flush();
+ NS_IMETHOD IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult);
+
+ NS_IMETHOD DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget);
+
// caching frequently used resources
- nsIRDFResource* mResourceChild;
- nsIRDFResource* mResourceFolder;
- nsIRDFResource* mResourceFrom;
- nsIRDFResource* mResourceSubject;
- nsIRDFResource* mResourceDate;
- nsIRDFResource* mResourceUser;
- nsIRDFResource* mResourceHost;
- nsIRDFResource* mResourceAccount;
- nsIRDFResource* mResourceName;
- nsIRDFResource* mMailRoot;
- nsIRDFResource* mResourceColumns;
+ static nsIRDFResource* kNC_Child;
+ static nsIRDFResource* kNC_Folder;
+ static nsIRDFResource* kNC_From;
+ static nsIRDFResource* kNC_subject;
+ static nsIRDFResource* kNC_date;
+ static nsIRDFResource* kNC_user;
+ static nsIRDFResource* kNC_host;
+ static nsIRDFResource* kNC_account;
+ static nsIRDFResource* kNC_Name;
+ static nsIRDFResource* kNC_Columns;
+ static nsIRDFResource* kNC_MailRoot;
nsIRDFDataSource* mMiscMailData;
};
diff --git a/mozilla/rdf/datasource/src/nsStreamDataSource.cpp b/mozilla/rdf/datasource/src/nsStreamDataSource.cpp
index db0610598a4..f7101a58166 100644
--- a/mozilla/rdf/datasource/src/nsStreamDataSource.cpp
+++ b/mozilla/rdf/datasource/src/nsStreamDataSource.cpp
@@ -205,6 +205,19 @@ public:
NS_IMETHOD Flush(void);
+ NS_IMETHOD IsCommandEnabled(const char* aCommand,
+ nsIRDFResource* aCommandTarget,
+ PRBool* aResult) {
+ return mInner->IsCommandEnabled(aCommand, aCommandTarget, aResult);
+ }
+
+ NS_IMETHOD DoCommand(const char* aCommand,
+ nsIRDFResource* aCommandTarget) {
+ // XXX Uh oh, this could cause problems wrt. the "dirty" flag
+ // if it changes the in-memory store's internal state.
+ return mInner->DoCommand(aCommand, aCommandTarget);
+ }
+
// nsIRDFXMLSource interface
NS_IMETHOD Serialize(nsIOutputStream* aStream);
};
diff --git a/mozilla/rdf/macbuild/rdf.mcp b/mozilla/rdf/macbuild/rdf.mcp
index a6f00db66fc..2704990dd45 100644
Binary files a/mozilla/rdf/macbuild/rdf.mcp and b/mozilla/rdf/macbuild/rdf.mcp differ
diff --git a/mozilla/rdf/macbuild/rdf.toc b/mozilla/rdf/macbuild/rdf.toc
index 87d41ec18eb..eaab609241d 100644
--- a/mozilla/rdf/macbuild/rdf.toc
+++ b/mozilla/rdf/macbuild/rdf.toc
@@ -7,12 +7,14 @@ mozilla/rdf/base/src/nsRDFService.cpp
mozilla/rdf/base/src/rdfutil.cpp
mozilla/rdf/build/nsRDFFactory.cpp
mozilla/rdf/content/src/nsRDFContentSink.cpp
+mozilla/rdf/content/src/nsRDFContentUtils.cpp
mozilla/rdf/content/src/nsRDFDocument.cpp
mozilla/rdf/content/src/nsRDFDocumentContentSink.cpp
-mozilla/rdf/content/src/nsRDFElement.cpp
-mozilla/rdf/content/src/nsRDFHTMLDocument.cpp
+mozilla/rdf/content/src/nsRDFGenericElement.cpp
+mozilla/rdf/content/src/nsRDFHTMLBuilder.cpp
+mozilla/rdf/content/src/nsRDFResourceElement.cpp
mozilla/rdf/content/src/nsRDFSimpleContentSink.cpp
-mozilla/rdf/content/src/nsRDFTreeDocument.cpp
+mozilla/rdf/content/src/nsRDFTreeBuilder.cpp
mozilla/rdf/datasource/src/nsBookmarkDataSource.cpp
mozilla/rdf/datasource/src/nsMailDataSource.cpp
mozilla/rdf/datasource/src/nsStreamDataSource.cpp
diff --git a/mozilla/rdf/resources/LocalStore.css b/mozilla/rdf/resources/LocalStore.css
new file mode 100644
index 00000000000..04e8dc86fec
--- /dev/null
+++ b/mozilla/rdf/resources/LocalStore.css
@@ -0,0 +1,52 @@
+DOCUMENT, BODY {
+ display: block;
+}
+
+FOLDER, CHILD {
+ display: block;
+ color: #FFFFFF;
+ background-color: #AAAAEE;
+ margin-left: 8px;
+}
+
+NAME {
+ font-weight: bold;
+ text-decoration: underline;
+ cursor: pointer;
+ padding: 2px;
+}
+
+SUBJECT {
+ display: none;
+}
+
+FOLDER FOLDER CHILD SUBJECT {
+ display: block;
+ float: left;
+ width: 300px;
+ font-family: Verdana, Sans-Serif;
+ font-size: 10pt;
+ font-weight: bold;
+ cursor: pointer;
+}
+
+FOLDER CHILD NAME {
+ text-decoration: none;
+ font-family: Verdana, Sans-Serif;
+ font-size: 10pt;
+ font-weight: bold;
+ cursor: pointer;
+}
+
+DATE {
+ margin-left: 12px;
+ font-family: Verdana, Sans-Serif;
+ font-size: 10pt;
+}
+
+LASTVISITDATE, BOOKMARKADDDATE, LASTMODIFIEDDATE {
+ font-family: monospace;
+ display: block;
+ float: right;
+ width: 100px;
+}
diff --git a/mozilla/rdf/resources/LocalStore.rdf b/mozilla/rdf/resources/LocalStore.rdf
index 696ff4ed378..7cdbf772015 100644
--- a/mozilla/rdf/resources/LocalStore.rdf
+++ b/mozilla/rdf/resources/LocalStore.rdf
@@ -6,8 +6,14 @@
-->
+
+
+
+
+
+ xmlns:nc="http://home.netscape.com/NC-rdf#"
+ xmlns:web="http://home.netscape.com/WEB-rdf#">
diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp
index 950e028bf49..4c9e9c4fd54 100644
--- a/mozilla/uriloader/base/nsDocLoader.cpp
+++ b/mozilla/uriloader/base/nsDocLoader.cpp
@@ -48,6 +48,9 @@
#include "nsICSSParser.h"
#include "nsICSSStyleSheet.h"
#include "nsLayoutCID.h"
+
+#include "nsIRDFContentModelBuilder.h"
+#include "nsIRDFDocument.h"
#include "nsRDFCID.h"
/* Forward declarations.... */
@@ -87,7 +90,8 @@ NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
/* Define CIDs... */
NS_DEFINE_IID(kCHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
NS_DEFINE_IID(kCXMLDocumentCID, NS_XMLDOCUMENT_CID);
-NS_DEFINE_IID(kCRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
+NS_DEFINE_IID(kCRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
+NS_DEFINE_IID(kCRDFDocumentCID, NS_RDFDOCUMENT_CID);
NS_DEFINE_IID(kCImageDocumentCID, NS_IMAGEDOCUMENT_CID);
NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
@@ -449,9 +453,14 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
+ static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
+ static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
+
nsresult rv = NS_ERROR_FAILURE;
nsIDocument* doc = nsnull;
+ nsIRDFDocument* rdfDoc = nsnull;
nsIDocumentViewer* docv = nsnull;
+ nsIRDFContentModelBuilder* builder = nsnull;
// Load the UA style sheet if we haven't already done that
if (nsnull == gUAStyleSheet) {
@@ -461,21 +470,30 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
/*
* Create the image document...
*/
- rv = nsRepository::CreateInstance(kCRDFHTMLDocumentCID,
- nsnull,
- kIDocumentIID,
- (void **)&doc);
- if (NS_OK != rv) {
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kCRDFDocumentCID,
+ nsnull,
+ kIRDFDocumentIID,
+ (void **)&rdfDoc)))
+ goto done;
+
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kCRDFHTMLBuilderCID,
+ nsnull,
+ kIRDFContentModelBuilderIID,
+ (void**) &builder)))
+ goto done;
+
+ if (NS_FAILED(rv = rdfDoc->Init(builder)))
+ goto done;
+
+ if (NS_FAILED(rv = rdfDoc->QueryInterface(kIDocumentIID, (void**) &doc)))
goto done;
- }
/*
* Create the image content viewer...
*/
- rv = NS_NewDocumentViewer(docv);
- if (NS_OK != rv) {
+ if (NS_FAILED(rv = NS_NewDocumentViewer(docv)))
goto done;
- }
+
docv->SetUAStyleSheet(gUAStyleSheet);
/*
@@ -484,9 +502,8 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
* An nsIStreamListener connected to the parser is returned in
* aDocListener.
*/
- rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand);
- if (NS_OK != rv) {
- NS_IF_RELEASE(docv);
+ if (NS_FAILED(rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand))) {
+ NS_RELEASE(docv);
goto done;
}
@@ -498,6 +515,8 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
done:
NS_IF_RELEASE(doc);
+ NS_IF_RELEASE(builder);
+ NS_IF_RELEASE(rdfDoc);
return rv;
}
diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp
index 950e028bf49..4c9e9c4fd54 100644
--- a/mozilla/webshell/src/nsDocLoader.cpp
+++ b/mozilla/webshell/src/nsDocLoader.cpp
@@ -48,6 +48,9 @@
#include "nsICSSParser.h"
#include "nsICSSStyleSheet.h"
#include "nsLayoutCID.h"
+
+#include "nsIRDFContentModelBuilder.h"
+#include "nsIRDFDocument.h"
#include "nsRDFCID.h"
/* Forward declarations.... */
@@ -87,7 +90,8 @@ NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
/* Define CIDs... */
NS_DEFINE_IID(kCHTMLDocumentCID, NS_HTMLDOCUMENT_CID);
NS_DEFINE_IID(kCXMLDocumentCID, NS_XMLDOCUMENT_CID);
-NS_DEFINE_IID(kCRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
+NS_DEFINE_IID(kCRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
+NS_DEFINE_IID(kCRDFDocumentCID, NS_RDFDOCUMENT_CID);
NS_DEFINE_IID(kCImageDocumentCID, NS_IMAGEDOCUMENT_CID);
NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
@@ -449,9 +453,14 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
nsIStreamListener** aDocListener,
nsIContentViewer** aDocViewer)
{
+ static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
+ static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
+
nsresult rv = NS_ERROR_FAILURE;
nsIDocument* doc = nsnull;
+ nsIRDFDocument* rdfDoc = nsnull;
nsIDocumentViewer* docv = nsnull;
+ nsIRDFContentModelBuilder* builder = nsnull;
// Load the UA style sheet if we haven't already done that
if (nsnull == gUAStyleSheet) {
@@ -461,21 +470,30 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
/*
* Create the image document...
*/
- rv = nsRepository::CreateInstance(kCRDFHTMLDocumentCID,
- nsnull,
- kIDocumentIID,
- (void **)&doc);
- if (NS_OK != rv) {
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kCRDFDocumentCID,
+ nsnull,
+ kIRDFDocumentIID,
+ (void **)&rdfDoc)))
+ goto done;
+
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kCRDFHTMLBuilderCID,
+ nsnull,
+ kIRDFContentModelBuilderIID,
+ (void**) &builder)))
+ goto done;
+
+ if (NS_FAILED(rv = rdfDoc->Init(builder)))
+ goto done;
+
+ if (NS_FAILED(rv = rdfDoc->QueryInterface(kIDocumentIID, (void**) &doc)))
goto done;
- }
/*
* Create the image content viewer...
*/
- rv = NS_NewDocumentViewer(docv);
- if (NS_OK != rv) {
+ if (NS_FAILED(rv = NS_NewDocumentViewer(docv)))
goto done;
- }
+
docv->SetUAStyleSheet(gUAStyleSheet);
/*
@@ -484,9 +502,8 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
* An nsIStreamListener connected to the parser is returned in
* aDocListener.
*/
- rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand);
- if (NS_OK != rv) {
- NS_IF_RELEASE(docv);
+ if (NS_FAILED(rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand))) {
+ NS_RELEASE(docv);
goto done;
}
@@ -498,6 +515,8 @@ nsDocFactoryImpl::CreateRDFDocument(nsIURL* aURL,
done:
NS_IF_RELEASE(doc);
+ NS_IF_RELEASE(builder);
+ NS_IF_RELEASE(rdfDoc);
return rv;
}
diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
index 634b6097370..42af126e6ec 100644
--- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
+++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp
@@ -840,6 +840,7 @@ HandleToolbarDemoWindowEvent(nsGUIEvent *aEvent)
// attaches it to an RDF document, and sets the document's root
// resource to be the top-level bookmark node.
#include "nsRDFCID.h"
+#include "nsIRDFContentModelBuilder.h"
#include "nsIRDFDataBase.h"
#include "nsIRDFDataSource.h"
#include "nsIRDFDocument.h"
@@ -853,18 +854,22 @@ rdf_CreateBookmarkDocument(nsIDocument*& result)
{
static NS_DEFINE_CID(kRDFBookmarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
-static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
-static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
-static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
-static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
-static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
-static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
+static NS_DEFINE_CID(kRDFDocumentCID, NS_RDFDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
+
+static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
+static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
+static NS_DEFINE_IID(kIRDFDataBaseIID, NS_IRDFDATABASE_IID);
+static NS_DEFINE_IID(kIRDFDataSourceIID, NS_IRDFDATASOURCE_IID);
+static NS_DEFINE_IID(kIRDFDocumentIID, NS_IRDFDOCUMENT_IID);
+static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
nsresult rv;
nsIRDFDataSource* ds = nsnull;
nsIRDFDataBase* db = nsnull;
nsIRDFDocument* doc = nsnull;
+ nsIRDFContentModelBuilder* builder = nsnull;
nsIRDFService* service = nsnull;
nsIRDFResource* root = nsnull;
@@ -875,13 +880,19 @@ static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
(nsISupports**) &service)))
goto done;
- if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFTreeDocumentCID,
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFDocumentCID,
nsnull,
kIRDFDocumentIID,
(void**) &doc)))
goto done;
- if (NS_FAILED(rv = doc->Init()))
+ if (NS_FAILED(rv = nsRepository::CreateInstance(kRDFTreeBuilderCID,
+ nsnull,
+ kIRDFContentModelBuilderIID,
+ (void**) &builder)))
+ goto done;
+
+ if (NS_FAILED(rv = doc->Init(builder)))
goto done;
if (NS_FAILED(rv = doc->GetDataBase(db)))
@@ -929,6 +940,7 @@ done:
nsServiceManager::ReleaseService(kRDFServiceCID, service);
service = nsnull;
}
+ NS_IF_RELEASE(builder);
NS_IF_RELEASE(doc);
NS_IF_RELEASE(db);
NS_IF_RELEASE(ds);
diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
index c95bdbe6860..c9c83229077 100644
--- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
+++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
@@ -143,10 +143,11 @@ static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
static NS_DEFINE_CID(kRDFBookMarkDataSourceCID, NS_RDFBOOKMARKDATASOURCE_CID);
static NS_DEFINE_CID(kRDFDataBaseCID, NS_RDFDATABASE_CID);
-static NS_DEFINE_CID(kRDFHTMLDocumentCID, NS_RDFHTMLDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFDocumentCID, NS_RDFDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFHTMLBuilderCID, NS_RDFHTMLBUILDER_CID);
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
-static NS_DEFINE_CID(kRDFTreeDocumentCID, NS_RDFTREEDOCUMENT_CID);
+static NS_DEFINE_CID(kRDFTreeBuilderCID, NS_RDFTREEBUILDER_CID);
static NS_DEFINE_CID(kRDFSimpleContentSinkCID, NS_RDFSIMPLECONTENTSINK_CID);
static NS_DEFINE_CID(kCSSParserCID, NS_CSSPARSER_CID);
@@ -211,10 +212,11 @@ NS_SetupRegistry()
nsRepository::RegisterFactory(kRDFBookMarkDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFDataBaseCID, RDF_DLL, PR_FALSE, PR_FALSE);
- nsRepository::RegisterFactory(kRDFHTMLDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
+ nsRepository::RegisterFactory(kRDFDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
+ nsRepository::RegisterFactory(kRDFHTMLBuilderCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFInMemoryDataSourceCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFServiceCID, RDF_DLL, PR_FALSE, PR_FALSE);
- nsRepository::RegisterFactory(kRDFTreeDocumentCID, RDF_DLL, PR_FALSE, PR_FALSE);
+ nsRepository::RegisterFactory(kRDFTreeBuilderCID, RDF_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kRDFSimpleContentSinkCID, RDF_DLL, PR_FALSE, PR_FALSE);