зеркало из https://github.com/mozilla/pjs.git
Clean up shared structures between nsRDFGenericBuilder.cpp and nsXULSortService.cpp; r=rjc
This commit is contained in:
Родитель
f0282b3110
Коммит
8e421b1013
|
@ -24,19 +24,54 @@
|
|||
#include "nsIRDFCompositeDataSource.idl"
|
||||
#include "nsIRDFResource.idl"
|
||||
|
||||
%{C++
|
||||
class nsRDFSortState;
|
||||
%}
|
||||
|
||||
[ptr] native nsIRDFDataSourceHandle( nsIRDFDataSource *);
|
||||
interface sortState;
|
||||
[ptr] native nsRDFSortState(nsRDFSortState);
|
||||
|
||||
interface nsIContent;
|
||||
interface nsIDOMNode;
|
||||
|
||||
/**
|
||||
* A service used to sort the contents of a XUL widget.
|
||||
*/
|
||||
[scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F371)]
|
||||
interface nsIXULSortService : nsISupports
|
||||
{
|
||||
void Sort(in nsIDOMNode node, in string sortResource, in string sortDirection);
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in sortState sortStatePtr, in nsIContent root, in nsIContent trueParent,
|
||||
in nsIContent container, in nsIContent node, in boolean aNotify);
|
||||
/**
|
||||
*
|
||||
* Sort the contents of the widget containing <code>aNode</code>
|
||||
* using <code>aSortResource</code> as the comparison key, and
|
||||
* <code>aSortDirection</code> as the direction.
|
||||
*
|
||||
* @param aNode A node in the XUL widget whose children are to be
|
||||
* sorted. <code>Sort</code> will traverse upwards to find the
|
||||
* root node at which to begin the actualy sorting. For optimal
|
||||
* results, pass in the root of the widget.
|
||||
*
|
||||
* @param aSortResource The RDF resource to be used as
|
||||
* the comparison key.
|
||||
*
|
||||
* @param aSortDirection May be either <b>natural</b> to return
|
||||
* the contents to their natural (unsorted) order,
|
||||
* <b>ascending</b> to sort the contents in ascending order, or
|
||||
* <b>descending</b> to sort the contents in descending order.
|
||||
*/
|
||||
void Sort(in nsIDOMNode aNode,
|
||||
in string aSortResource,
|
||||
in string aSortDirection);
|
||||
|
||||
/**
|
||||
* Used internally for insertion sorting.
|
||||
*/
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db,
|
||||
in nsRDFSortState sortStatePtr,
|
||||
in nsIContent root,
|
||||
in nsIContent trueParent,
|
||||
in nsIContent container,
|
||||
in nsIContent node,
|
||||
in boolean aNotify);
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- 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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla 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.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Shared structure for sort state.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef nsRDFSort_h__
|
||||
#define nsRDFSort_h__
|
||||
|
||||
#include "nsIRDFResource.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsString.h"
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsRDFSortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
};
|
||||
|
||||
|
||||
#endif // nsRDFSort_h__
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsRDFSort.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsIAtom.h"
|
||||
|
@ -1412,29 +1412,8 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo)
|
|||
}
|
||||
|
||||
|
||||
// rjc: yes, I'm lame. For the moment, "class sortState" is defined both here and in
|
||||
// nsRDFGenericBuilder.cpp so any changes made here must also (exactly) be made there also.
|
||||
|
||||
typedef class sortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
} sortStateClass;
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, sortStateClass *sortState, nsIContent *root,
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSortState *sortState, nsIContent *root,
|
||||
nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsIXULContentUtils.h"
|
||||
#include "nsRDFSort.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -88,55 +89,26 @@
|
|||
#define NS_RDF_ELEMENT_WAS_THERE NS_OK
|
||||
static PRLogModuleInfo* gLog;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// rjc: yes, I'm lame. For the moment, "class sortState" is defined both here and in
|
||||
// nsXULSortService.cpp so any changes made here must also (exactly) be made there also.
|
||||
|
||||
typedef class sortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
} sortStateClass;
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// RDFGenericBuilderImpl
|
||||
//
|
||||
|
||||
class RDFGenericBuilderImpl : public nsIRDFContentModelBuilder,
|
||||
public nsIRDFObserver
|
||||
|
@ -334,7 +306,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
sortStateClass sortState;
|
||||
nsRDFSortState sortState;
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
@ -387,7 +359,7 @@ protected:
|
|||
static nsString falseStr;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsrefcnt RDFGenericBuilderImpl::gRefCnt = 0;
|
||||
nsIXULSortService* RDFGenericBuilderImpl::gXULSortService = nsnull;
|
||||
|
@ -439,7 +411,7 @@ nsIRDFResource* RDFGenericBuilderImpl::kRDF_instanceOf;
|
|||
nsIRDFResource* RDFGenericBuilderImpl::kXUL_element;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
nsresult
|
||||
|
@ -603,7 +575,7 @@ RDFGenericBuilderImpl::Init()
|
|||
// Initialize the global shared reference to the service
|
||||
// manager and get some shared resource objects.
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -651,35 +623,12 @@ RDFGenericBuilderImpl::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NS_IMPL_ISUPPORTS2(RDFGenericBuilderImpl, nsIRDFContentModelBuilder, nsIRDFObserver);
|
||||
|
||||
NS_IMPL_ADDREF(RDFGenericBuilderImpl);
|
||||
NS_IMPL_RELEASE(RDFGenericBuilderImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFContentModelBuilderIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFContentModelBuilder*, this);
|
||||
}
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFContentModelBuilder methods
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
|
||||
|
@ -969,8 +918,10 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
|
|||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFObserver interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
|
@ -1377,8 +1328,10 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Implementation methods
|
||||
//
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::IsTemplateRuleMatch(nsIContent* aElement,
|
||||
|
@ -2948,17 +2901,13 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement)
|
|||
nsresult
|
||||
RDFGenericBuilderImpl::GetDOMNodeResource(nsIDOMNode* aNode, nsIRDFResource** aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Given an nsIDOMNode that presumably has been created as a proxy
|
||||
// for an RDF resource, pull the RDF resource information out of
|
||||
// it.
|
||||
|
||||
nsCOMPtr<nsIContent> element;
|
||||
if (NS_FAILED(rv = aNode->QueryInterface(kIContentIID, getter_AddRefs(element) ))) {
|
||||
NS_ERROR("DOM element doesn't support nsIContent");
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aNode);
|
||||
if (! element)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return gXULUtils->GetElementRefResource(element, aResource);
|
||||
}
|
||||
|
|
|
@ -1,45 +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.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIRDFCompositeDataSource.idl"
|
||||
#include "nsIRDFResource.idl"
|
||||
|
||||
|
||||
[ptr] native nsIRDFDataSourceHandle( nsIRDFDataSource *);
|
||||
interface sortState;
|
||||
|
||||
interface nsIContent;
|
||||
interface nsIDOMNode;
|
||||
|
||||
[scriptable, uuid(BFD05261-834C-11d2-8EAC-00805F29F371)]
|
||||
interface nsIXULSortService : nsISupports
|
||||
{
|
||||
void Sort(in nsIDOMNode node, in string sortResource, in string sortDirection);
|
||||
[noscript] void InsertContainerNode(in nsIRDFCompositeDataSource db, in sortState sortStatePtr, in nsIContent root, in nsIContent trueParent,
|
||||
in nsIContent container, in nsIContent node, in boolean aNotify);
|
||||
};
|
||||
|
||||
%{C++
|
||||
extern nsresult
|
||||
NS_NewXULSortService(nsIXULSortService **result);
|
||||
%}
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsIXULContentUtils.h"
|
||||
#include "nsRDFSort.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -88,55 +89,26 @@
|
|||
#define NS_RDF_ELEMENT_WAS_THERE NS_OK
|
||||
static PRLogModuleInfo* gLog;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// rjc: yes, I'm lame. For the moment, "class sortState" is defined both here and in
|
||||
// nsXULSortService.cpp so any changes made here must also (exactly) be made there also.
|
||||
|
||||
typedef class sortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
} sortStateClass;
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// RDFGenericBuilderImpl
|
||||
//
|
||||
|
||||
class RDFGenericBuilderImpl : public nsIRDFContentModelBuilder,
|
||||
public nsIRDFObserver
|
||||
|
@ -334,7 +306,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
sortStateClass sortState;
|
||||
nsRDFSortState sortState;
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
@ -387,7 +359,7 @@ protected:
|
|||
static nsString falseStr;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsrefcnt RDFGenericBuilderImpl::gRefCnt = 0;
|
||||
nsIXULSortService* RDFGenericBuilderImpl::gXULSortService = nsnull;
|
||||
|
@ -439,7 +411,7 @@ nsIRDFResource* RDFGenericBuilderImpl::kRDF_instanceOf;
|
|||
nsIRDFResource* RDFGenericBuilderImpl::kXUL_element;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
nsresult
|
||||
|
@ -603,7 +575,7 @@ RDFGenericBuilderImpl::Init()
|
|||
// Initialize the global shared reference to the service
|
||||
// manager and get some shared resource objects.
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -651,35 +623,12 @@ RDFGenericBuilderImpl::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NS_IMPL_ISUPPORTS2(RDFGenericBuilderImpl, nsIRDFContentModelBuilder, nsIRDFObserver);
|
||||
|
||||
NS_IMPL_ADDREF(RDFGenericBuilderImpl);
|
||||
NS_IMPL_RELEASE(RDFGenericBuilderImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFContentModelBuilderIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFContentModelBuilder*, this);
|
||||
}
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFContentModelBuilder methods
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
|
||||
|
@ -969,8 +918,10 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
|
|||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFObserver interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
|
@ -1377,8 +1328,10 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Implementation methods
|
||||
//
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::IsTemplateRuleMatch(nsIContent* aElement,
|
||||
|
@ -2948,17 +2901,13 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement)
|
|||
nsresult
|
||||
RDFGenericBuilderImpl::GetDOMNodeResource(nsIDOMNode* aNode, nsIRDFResource** aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Given an nsIDOMNode that presumably has been created as a proxy
|
||||
// for an RDF resource, pull the RDF resource information out of
|
||||
// it.
|
||||
|
||||
nsCOMPtr<nsIContent> element;
|
||||
if (NS_FAILED(rv = aNode->QueryInterface(kIContentIID, getter_AddRefs(element) ))) {
|
||||
NS_ERROR("DOM element doesn't support nsIContent");
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aNode);
|
||||
if (! element)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return gXULUtils->GetElementRefResource(element, aResource);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include "nsXPIDLString.h"
|
||||
#include "rdf.h"
|
||||
#include "rdfutil.h"
|
||||
|
||||
#include "nsRDFSort.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsQuickSort.h"
|
||||
#include "nsIAtom.h"
|
||||
|
@ -1412,29 +1412,8 @@ XULSortServiceImpl::SortTreeChildren(nsIContent *container, sortPtr sortInfo)
|
|||
}
|
||||
|
||||
|
||||
// rjc: yes, I'm lame. For the moment, "class sortState" is defined both here and in
|
||||
// nsRDFGenericBuilder.cpp so any changes made here must also (exactly) be made there also.
|
||||
|
||||
typedef class sortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
} sortStateClass;
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, sortStateClass *sortState, nsIContent *root,
|
||||
XULSortServiceImpl::InsertContainerNode(nsIRDFCompositeDataSource *db, nsRDFSortState *sortState, nsIContent *root,
|
||||
nsIContent *trueParent, nsIContent *container, nsIContent *node, PRBool aNotify)
|
||||
{
|
||||
nsresult rv;
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIXULContent.h"
|
||||
#include "nsIXULContentUtils.h"
|
||||
#include "nsRDFSort.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -88,55 +89,26 @@
|
|||
#define NS_RDF_ELEMENT_WAS_THERE NS_OK
|
||||
static PRLogModuleInfo* gLog;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINameSpaceManagerIID, NS_INAMESPACEMANAGER_IID);
|
||||
static NS_DEFINE_IID(kIRDFResourceIID, NS_IRDFRESOURCE_IID);
|
||||
static NS_DEFINE_IID(kIRDFLiteralIID, NS_IRDFLITERAL_IID);
|
||||
static NS_DEFINE_IID(kIRDFContentModelBuilderIID, NS_IRDFCONTENTMODELBUILDER_IID);
|
||||
static NS_DEFINE_IID(kIRDFObserverIID, NS_IRDFOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kRDFInMemoryDataSourceCID, NS_RDFINMEMORYDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXULContentUtilsCID, NS_XULCONTENTUTILS_CID);
|
||||
static NS_DEFINE_CID(kXULSortServiceCID, NS_XULSORTSERVICE_CID);
|
||||
|
||||
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
||||
static NS_DEFINE_CID(kXMLElementFactoryCID, NS_XML_ELEMENT_FACTORY_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
#define XUL_NAMESPACE_URI "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// rjc: yes, I'm lame. For the moment, "class sortState" is defined both here and in
|
||||
// nsXULSortService.cpp so any changes made here must also (exactly) be made there also.
|
||||
|
||||
typedef class sortState
|
||||
{
|
||||
public:
|
||||
// state match strings
|
||||
nsAutoString sortResource, sortResource2;
|
||||
|
||||
// state variables
|
||||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsIRDFResource> sortProperty, sortProperty2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertyColl, sortPropertyColl2;
|
||||
nsCOMPtr<nsIRDFResource> sortPropertySort, sortPropertySort2;
|
||||
|
||||
nsCOMPtr<nsIContent> lastContainer;
|
||||
PRBool lastWasFirst, lastWasLast;
|
||||
} sortStateClass;
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// RDFGenericBuilderImpl
|
||||
//
|
||||
|
||||
class RDFGenericBuilderImpl : public nsIRDFContentModelBuilder,
|
||||
public nsIRDFObserver
|
||||
|
@ -334,7 +306,7 @@ protected:
|
|||
nsCOMPtr<nsIRDFDataSource> mCache;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
sortStateClass sortState;
|
||||
nsRDFSortState sortState;
|
||||
|
||||
// pseudo-constants
|
||||
static nsrefcnt gRefCnt;
|
||||
|
@ -387,7 +359,7 @@ protected:
|
|||
static nsString falseStr;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
nsrefcnt RDFGenericBuilderImpl::gRefCnt = 0;
|
||||
nsIXULSortService* RDFGenericBuilderImpl::gXULSortService = nsnull;
|
||||
|
@ -439,7 +411,7 @@ nsIRDFResource* RDFGenericBuilderImpl::kRDF_instanceOf;
|
|||
nsIRDFResource* RDFGenericBuilderImpl::kXUL_element;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
||||
nsresult
|
||||
|
@ -603,7 +575,7 @@ RDFGenericBuilderImpl::Init()
|
|||
// Initialize the global shared reference to the service
|
||||
// manager and get some shared resource objects.
|
||||
rv = nsServiceManager::GetService(kRDFServiceCID,
|
||||
kIRDFServiceIID,
|
||||
NS_GET_IID(nsIRDFService),
|
||||
(nsISupports**) &gRDFService);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -651,35 +623,12 @@ RDFGenericBuilderImpl::Init()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
NS_IMPL_ISUPPORTS2(RDFGenericBuilderImpl, nsIRDFContentModelBuilder, nsIRDFObserver);
|
||||
|
||||
NS_IMPL_ADDREF(RDFGenericBuilderImpl);
|
||||
NS_IMPL_RELEASE(RDFGenericBuilderImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::QueryInterface(REFNSIID iid, void** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult != nsnull, "null ptr");
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (iid.Equals(kIRDFContentModelBuilderIID) ||
|
||||
iid.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFContentModelBuilder*, this);
|
||||
}
|
||||
else if (iid.Equals(kIRDFObserverIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIRDFObserver*, this);
|
||||
}
|
||||
else {
|
||||
*aResult = nsnull;
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFContentModelBuilder methods
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::SetDocument(nsIXULDocument* aDocument)
|
||||
|
@ -969,8 +918,10 @@ RDFGenericBuilderImpl::RebuildContainer(nsIContent* aElement)
|
|||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIRDFObserver interface
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFGenericBuilderImpl::OnAssert(nsIRDFResource* aSource,
|
||||
|
@ -1377,8 +1328,10 @@ RDFGenericBuilderImpl::OnMove(nsIRDFResource* aOldSource,
|
|||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// Implementation methods
|
||||
//
|
||||
|
||||
nsresult
|
||||
RDFGenericBuilderImpl::IsTemplateRuleMatch(nsIContent* aElement,
|
||||
|
@ -2948,17 +2901,13 @@ RDFGenericBuilderImpl::IsElementInWidget(nsIContent* aElement)
|
|||
nsresult
|
||||
RDFGenericBuilderImpl::GetDOMNodeResource(nsIDOMNode* aNode, nsIRDFResource** aResource)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Given an nsIDOMNode that presumably has been created as a proxy
|
||||
// for an RDF resource, pull the RDF resource information out of
|
||||
// it.
|
||||
|
||||
nsCOMPtr<nsIContent> element;
|
||||
if (NS_FAILED(rv = aNode->QueryInterface(kIContentIID, getter_AddRefs(element) ))) {
|
||||
NS_ERROR("DOM element doesn't support nsIContent");
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIContent> element = do_QueryInterface(aNode);
|
||||
if (! element)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
return gXULUtils->GetElementRefResource(element, aResource);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче