updating DOM Viewer
- start creating DOM elements using the PROGID system for creating elements git-svn-id: svn://10.0.0.236/trunk@44031 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -27,11 +27,15 @@ LIBRARY_NAME=rdfdomds
|
||||
IS_COMPONENT=1
|
||||
DIRS = resources
|
||||
|
||||
XPIDLSRCS = nsIDOMDataSource.idl
|
||||
XPIDLSRCS = \
|
||||
nsIDOMDataSource.idl \
|
||||
nsIDOMViewerElement.idl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsRDFDOMDataSource.cpp \
|
||||
nsRDFDOMDataSourceFactory.cpp \
|
||||
nsRDFDOMResourceFactory.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
|
||||
@@ -31,8 +31,3 @@ interface nsIDOMDataSource : nsISupports {
|
||||
void SetWindow(in nsIDOMWindow window);
|
||||
};
|
||||
|
||||
[scriptable, uuid(2842a0ba-4bd8-11d3-ac84-00a0c900d445)]
|
||||
interface nsIDOMViewerElement : nsISupports {
|
||||
attribute nsIDOMNode node;
|
||||
};
|
||||
|
||||
|
||||
13
mozilla/rdf/tests/domds/nsIDOMViewerElement.idl
Normal file
13
mozilla/rdf/tests/domds/nsIDOMViewerElement.idl
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "domstubs.idl"
|
||||
%{C++
|
||||
#include "nsIDOMNode.h"
|
||||
%}
|
||||
|
||||
|
||||
[scriptable, uuid(2842a0ba-4bd8-11d3-ac84-00a0c900d445)]
|
||||
interface nsIDOMViewerElement : nsISupports {
|
||||
attribute nsIDOMNode node;
|
||||
};
|
||||
|
||||
@@ -639,13 +639,13 @@ nsRDFDOMDataSource::getURIForNode(nsIDOMNode *node, char **uri)
|
||||
char *idstr = PR_smprintf("%8.8X", gCurrentId++);
|
||||
id = idstr;
|
||||
printf("Element has no ID. Assigning it %s\n", idstr);
|
||||
|
||||
|
||||
element->SetAttribute(nsAutoString("id"), id);
|
||||
}
|
||||
else {
|
||||
printf("ID of this element is %s\n", id.ToNewCString());
|
||||
}
|
||||
|
||||
|
||||
// leaks id.ToNewCString()
|
||||
*uri = PR_smprintf("dom://%s", id.ToNewCString());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsRDFDOMDataSource.h"
|
||||
#include "nsRDFDOMResourceFactory.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "rdf.h"
|
||||
@@ -26,7 +27,8 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_CID(kRDFDataSourceCID, NS_RDF_DOMDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFDOMDataSourceCID, NS_RDF_DOMDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFDOMResourceFactoryCID, NS_RDF_DOMRESOURCEFACTORY_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
nsresult
|
||||
@@ -38,8 +40,10 @@ NSGetFactory(nsISupports* aServMgr,
|
||||
{
|
||||
nsresult rv=NS_OK;
|
||||
nsIGenericFactory* fact;
|
||||
if (aClass.Equals(kRDFDataSourceCID))
|
||||
if (aClass.Equals(kRDFDOMDataSourceCID))
|
||||
rv = NS_NewGenericFactory(&fact, NS_NewRDFDOMDataSource);
|
||||
if (aClass.Equals(kRDFDOMDataSourceCID))
|
||||
rv = NS_NewGenericFactory(&fact, NS_NewRDFDOMResourceFactory);
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
||||
@@ -64,11 +68,15 @@ NSRegisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kRDFDataSourceCID,
|
||||
rv = compMgr->RegisterComponent(kRDFDOMDataSourceCID,
|
||||
"Generic DataSource DataSource",
|
||||
NS_RDF_DATASOURCE_PROGID_PREFIX "domds",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
rv = compMgr->RegisterComponent(kRDFDOMResourceFactoryCID,
|
||||
"DOM element resource factory",
|
||||
NS_RDF_RESOURCE_FACTORY_PROGID_PREFIX "dom",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
return rv;
|
||||
|
||||
}
|
||||
@@ -81,7 +89,8 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
aServMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kRDFDataSourceCID, aPath);
|
||||
rv = compMgr->UnregisterComponent(kRDFDOMDataSourceCID, aPath);
|
||||
rv = compMgr->UnregisterComponent(kRDFDOMResourceFactoryCID, aPath);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
88
mozilla/rdf/tests/domds/nsRDFDOMResourceFactory.cpp
Normal file
88
mozilla/rdf/tests/domds/nsRDFDOMResourceFactory.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- 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, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsRDFResource.h"
|
||||
#include "nsRDFDOMResourceFactory.h"
|
||||
#include "nsIDOMViewerElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
|
||||
class nsRDFDOMViewerElement : nsRDFResource,
|
||||
nsIDOMViewerElement {
|
||||
public:
|
||||
nsRDFDOMViewerElement();
|
||||
virtual ~nsRDFDOMViewerElement();
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_DECL_NSIDOMVIEWERELEMENT
|
||||
|
||||
private:
|
||||
|
||||
nsIDOMNode *mNode;
|
||||
|
||||
|
||||
};
|
||||
|
||||
nsRDFDOMViewerElement::nsRDFDOMViewerElement() :
|
||||
mNode(nsnull)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
nsRDFDOMViewerElement::~nsRDFDOMViewerElement()
|
||||
{
|
||||
if (mNode) NS_RELEASE(mNode);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsRDFDOMViewerElement, nsRDFResource, nsIDOMViewerElement)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMViewerElement::SetNode(nsIDOMNode* node)
|
||||
{
|
||||
if (mNode) NS_RELEASE(mNode);
|
||||
mNode = node;
|
||||
NS_ADDREF(mNode);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRDFDOMViewerElement::GetNode(nsIDOMNode** node)
|
||||
{
|
||||
if (!node) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*node = mNode;
|
||||
NS_ADDREF(*node);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDOMResourceFactory(nsISupports* aOuter,
|
||||
const nsIID& iid,
|
||||
void **result) {
|
||||
|
||||
nsRDFDOMViewerElement* ve = new nsRDFDOMViewerElement();
|
||||
if (!ve) return NS_ERROR_NULL_POINTER;
|
||||
return ve->QueryInterface(iid, result);
|
||||
}
|
||||
|
||||
37
mozilla/rdf/tests/domds/nsRDFDOMResourceFactory.h
Normal file
37
mozilla/rdf/tests/domds/nsRDFDOMResourceFactory.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- 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, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef __nsRDFDOMResourceFactory_h
|
||||
#define __nsRDFDOMResourceFactory_h
|
||||
|
||||
#include "nsIRDFService.h"
|
||||
|
||||
/* {84a87046-57f4-11d3-9061-00a0c900d445} */
|
||||
#define NS_RDF_DOMRESOURCEFACTORY_CID \
|
||||
{0x84a87046, 0x57f4, 0x11d3, \
|
||||
{ 0x90, 0x61, 0x0, 0xa0, 0xc9, 0x0, 0xd4, 0x45 }}
|
||||
|
||||
|
||||
nsresult
|
||||
NS_NewRDFDOMResourceFactory(nsISupports* aOuter,
|
||||
const nsIID& iid,
|
||||
void **result);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user