зеркало из https://github.com/mozilla/gecko-dev.git
Use nsCString instead of nsString for anonymous content nodes. Get rid of use of rdf_Isa().
This commit is contained in:
Родитель
e113a6f5f1
Коммит
59f822c9a6
|
@ -60,6 +60,8 @@ private:
|
|||
nsIRDFResource* aType,
|
||||
nsIRDFContainer** aResult);
|
||||
|
||||
PRBool IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
|
||||
|
||||
// pseudo constants
|
||||
static PRInt32 gRefCnt;
|
||||
static nsIRDFService* gRDFService;
|
||||
|
@ -210,9 +212,9 @@ RDFContainerUtilsImpl::IsContainer(nsIRDFDataSource *aDataSource, nsIRDFResource
|
|||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (rdf_IsA(aDataSource, aResource, kRDF_Bag) ||
|
||||
rdf_IsA(aDataSource, aResource, kRDF_Seq) ||
|
||||
rdf_IsA(aDataSource, aResource, kRDF_Alt)) {
|
||||
if (IsA(aDataSource, aResource, kRDF_Bag) ||
|
||||
IsA(aDataSource, aResource, kRDF_Seq) ||
|
||||
IsA(aDataSource, aResource, kRDF_Alt)) {
|
||||
*_retval = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
|
@ -237,7 +239,7 @@ RDFContainerUtilsImpl::IsBag(nsIRDFDataSource *aDataSource, nsIRDFResource *aRes
|
|||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_IsA(aDataSource, aResource, kRDF_Bag);
|
||||
*_retval = IsA(aDataSource, aResource, kRDF_Bag);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -257,7 +259,7 @@ RDFContainerUtilsImpl::IsSeq(nsIRDFDataSource *aDataSource, nsIRDFResource *aRes
|
|||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_IsA(aDataSource, aResource, kRDF_Seq);
|
||||
*_retval = IsA(aDataSource, aResource, kRDF_Seq);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -277,7 +279,7 @@ RDFContainerUtilsImpl::IsAlt(nsIRDFDataSource *aDataSource, nsIRDFResource *aRes
|
|||
if (! _retval)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*_retval = rdf_IsA(aDataSource, aResource, kRDF_Alt);
|
||||
*_retval = IsA(aDataSource, aResource, kRDF_Alt);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -409,3 +411,14 @@ RDFContainerUtilsImpl::MakeContainer(nsIRDFDataSource* aDataSource, nsIRDFResour
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
RDFContainerUtilsImpl::IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRBool result;
|
||||
rv = aDataSource->HasAssertion(aResource, kRDF_instanceOf, aType, PR_TRUE, &result);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -964,12 +964,9 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
|||
PRInt32 ac = aNode.GetAttributeCount();
|
||||
nsresult rv;
|
||||
|
||||
#ifdef NECKO
|
||||
char* docURI;
|
||||
#else
|
||||
const char* docURI;
|
||||
#endif
|
||||
mDocumentURL->GetSpec(&docURI);
|
||||
nsXPIDLCString docURI;
|
||||
rv = mDocumentURL->GetSpec(getter_Copies(docURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
for (PRInt32 i = 0; i < ac; i++) {
|
||||
// Get upper-cased key
|
||||
|
@ -991,10 +988,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
|||
nsAutoString uri = aNode.GetValueAt(i);
|
||||
nsRDFParserUtils::StripAndConvert(uri);
|
||||
|
||||
rdf_MakeAbsoluteURI(docURI, uri);
|
||||
#ifdef NECKO
|
||||
nsCRT::free(docURI);
|
||||
#endif
|
||||
rdf_MakeAbsoluteURI(nsCAutoString(docURI), uri);
|
||||
|
||||
return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource);
|
||||
}
|
||||
|
@ -1024,10 +1018,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
|||
// attribute.
|
||||
name.Insert('#', 0);
|
||||
|
||||
rdf_MakeAbsoluteURI(docURI, name);
|
||||
#ifdef NECKO
|
||||
nsCRT::free(docURI);
|
||||
#endif
|
||||
rdf_MakeAbsoluteURI(nsCAutoString(docURI), name);
|
||||
|
||||
return gRDFService->GetUnicodeResource(name.GetUnicode(), aResource);
|
||||
}
|
||||
|
@ -1040,10 +1031,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode,
|
|||
}
|
||||
|
||||
// Otherwise, we couldn't find anything, so just gensym one...
|
||||
rv = rdf_CreateAnonymousResource(docURI, aResource);
|
||||
#ifdef NECKO
|
||||
nsCRT::free(docURI);
|
||||
#endif
|
||||
rv = rdf_CreateAnonymousResource(nsCAutoString(docURI), aResource);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -365,6 +365,9 @@ public:
|
|||
|
||||
nsresult
|
||||
SerializeEpilogue(nsIOutputStream* aStream);
|
||||
|
||||
PRBool
|
||||
IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType);
|
||||
};
|
||||
|
||||
PRInt32 RDFXMLDataSourceImpl::gRefCnt = 0;
|
||||
|
@ -1401,13 +1404,13 @@ static const char kRDFAlt[] = "RDF:Alt";
|
|||
// Decide if it's a sequence, bag, or alternation, and print the
|
||||
// appropriate tag-open sequence
|
||||
|
||||
if (rdf_IsA(mInner, aContainer, kRDF_Bag)) {
|
||||
if (IsA(mInner, aContainer, kRDF_Bag)) {
|
||||
tag = kRDFBag;
|
||||
}
|
||||
else if (rdf_IsA(mInner, aContainer, kRDF_Seq)) {
|
||||
else if (IsA(mInner, aContainer, kRDF_Seq)) {
|
||||
tag = kRDFSeq;
|
||||
}
|
||||
else if (rdf_IsA(mInner, aContainer, kRDF_Alt)) {
|
||||
else if (IsA(mInner, aContainer, kRDF_Alt)) {
|
||||
tag = kRDFAlt;
|
||||
}
|
||||
else {
|
||||
|
@ -1588,9 +1591,9 @@ RDFXMLDataSourceImpl::Serialize(nsIOutputStream* aStream)
|
|||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
if (rdf_IsA(mInner, resource, kRDF_Bag) ||
|
||||
rdf_IsA(mInner, resource, kRDF_Seq) ||
|
||||
rdf_IsA(mInner, resource, kRDF_Alt)) {
|
||||
if (IsA(mInner, resource, kRDF_Bag) ||
|
||||
IsA(mInner, resource, kRDF_Seq) ||
|
||||
IsA(mInner, resource, kRDF_Alt)) {
|
||||
rv = SerializeContainer(aStream, resource);
|
||||
}
|
||||
else {
|
||||
|
@ -1607,3 +1610,14 @@ RDFXMLDataSourceImpl::Serialize(nsIOutputStream* aStream)
|
|||
}
|
||||
|
||||
|
||||
PRBool
|
||||
RDFXMLDataSourceImpl::IsA(nsIRDFDataSource* aDataSource, nsIRDFResource* aResource, nsIRDFResource* aType)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
PRBool result;
|
||||
rv = aDataSource->HasAssertion(aResource, kRDF_instanceOf, aType, PR_TRUE, &result);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче