Compare commits

..

15 Commits

Author SHA1 Message Date
alecf%netscape.com
8df220c8fd update mac build for this branch
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@51101 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-19 02:42:45 +00:00
alecf%netscape.com
a5e40744ba fix support for HTML content broken by adding frame support
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@50091 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-07 07:56:15 +00:00
alecf%netscape.com
2bd9b7253c tweaks to get it to build on windows
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49232 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-28 19:47:10 +00:00
alecf%netscape.com
40ce189f8d add frame mode support
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49218 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-28 18:22:30 +00:00
alecf%netscape.com
20fb9d7520 add support for IFrames
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49204 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-28 07:57:35 +00:00
alecf%netscape.com
fc0694a7bf fix up style support.
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49124 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 07:39:00 +00:00
alecf%netscape.com
43a8b98cf8 add massive support for all 5 style classes
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49121 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 06:58:55 +00:00
alecf%netscape.com
20470d610f add more support for styles, etc
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49120 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 06:12:05 +00:00
alecf%netscape.com
e2f51a9da1 add support for content and leaf activation through checkboxes
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49119 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-27 06:11:43 +00:00
alecf%netscape.com
e3c644972b add support for nsIContent nodes and attributes
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49045 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 09:54:43 +00:00
alecf%netscape.com
38030e146b abstract object creation so that the resource nodes only contain nsISupports objects, and add a hashtable so we can map objects back to resources
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49039 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 07:54:46 +00:00
alecf%netscape.com
9fd9ce1ffd move tree into main view
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49036 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 06:47:37 +00:00
alecf%netscape.com
4e20235e47 factor out dom nodes, attributes, and children
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49035 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 06:47:05 +00:00
alecf%netscape.com
88a9d48667 first cleanup of DOMDatasource in prep for adding document observers
git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@49033 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-25 06:23:00 +00:00
(no author)
322c8626f1 This commit was manufactured by cvs2svn to create branch
'domviewer_observers_branch'.

git-svn-id: svn://10.0.0.236/branches/domviewer_observers_branch@48236 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-19 01:17:40 +00:00
26 changed files with 2298 additions and 105 deletions

View File

@@ -1,105 +0,0 @@
/*
The contents of this file are subject to the Mozilla 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/MPL/
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 Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMGlobals_h__
#define __JavaDOMGlobals_h__
#include "jni.h"
#include "prclist.h"
#include "nsError.h"
#ifdef ERROR
#undef ERROR
#endif
class nsISupports;
class nsIDOMNode;
struct PRLogModuleInfo;
struct PRLock;
class JavaDOMGlobals {
public:
static jclass attrClass;
static jclass cDataSectionClass;
static jclass commentClass;
static jclass documentClass;
static jclass documentFragmentClass;
static jclass documentTypeClass;
static jclass domImplementationClass;
static jclass elementClass;
static jclass entityClass;
static jclass entityReferenceClass;
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
static jclass notationClass;
static jclass processingInstructionClass;
static jclass textClass;
static jfieldID nodePtrFID;
static jfieldID nodeListPtrFID;
static jfieldID domImplementationPtrFID;
static jfieldID nodeTypeAttributeFID;
static jfieldID nodeTypeCDataSectionFID;
static jfieldID nodeTypeCommentFID;
static jfieldID nodeTypeDocumentFragmentFID;
static jfieldID nodeTypeDocumentFID;
static jfieldID nodeTypeDocumentTypeFID;
static jfieldID nodeTypeElementFID;
static jfieldID nodeTypeEntityFID;
static jfieldID nodeTypeEntityReferenceFID;
static jfieldID nodeTypeNotationFID;
static jfieldID nodeTypeProcessingInstructionFID;
static jfieldID nodeTypeTextFID;
static jclass domExceptionClass;
static jmethodID domExceptionInitMID;
static jclass runtimeExceptionClass;
static jmethodID runtimeExceptionInitMID;
static const char* const DOM_EXCEPTION_MESSAGE[];
typedef enum ExceptionType { EXCEPTION_RUNTIME,
EXCEPTION_DOM } ExceptionType;
static PRLogModuleInfo* log;
static PRCList garbage;
static PRLock* garbageLock;
static PRInt32 javaMaxInt;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node);
static void AddToGarbage(nsISupports* domObject);
static void TakeOutGarbage();
static void ThrowException(JNIEnv *env,
const char * message = NULL,
nsresult rv = NS_OK,
ExceptionType exceptionType = EXCEPTION_RUNTIME);
};
#endif /* __JavaDOMGlobals_h__ */

View File

@@ -0,0 +1,2 @@
nsIDOMDataSource.idl
nsIDOMViewerElement.idl

View File

@@ -0,0 +1,53 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = rdfdomds
LIBRARY_NAME = rdfdomds
IS_COMPONENT = 1
DIRS = resources
CPPSRCS = \
nsRDFDOMDataSource.cpp \
nsRDFDOMDataSourceFactory.cpp \
nsRDFDOMResourceFactory.cpp \
nsRDFDOMViewerUtils.cpp \
$(NULL)
XPIDLSRCS = \
nsIDOMDataSource.idl \
nsIDOMViewerElement.idl \
nsIRDFDOMViewerObject.idl \
$(NULL)
EXTRA_DSO_LDOPTS = \
-L$(DIST)/bin \
-L$(DIST)/lib \
-lxpcom \
-lrdfutil_s \
$(NSPR_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
#include "MacPrefix.h"

View File

@@ -0,0 +1,2 @@
#define DEBUG 1
#include "MacPrefix_debug.h"

View File

@@ -0,0 +1,50 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ..\..\..
include <$(DEPTH)/config/config.mak>
MODULE=rdfdomds
LIBNAME=.\$(OBJDIR)\$(MODULE)
DLL=$(LIBNAME).dll
XPIDLSRCS= .\nsIDOMViewerElement.idl \
.\nsIDOMDataSource.idl \
.\nsIRDFDOMViewerObject.idl \
$(NULL)
DIRS=resources
OBJS= .\$(OBJDIR)\nsRDFDOMDataSource.obj \
.\$(OBJDIR)\nsRDFDOMDataSourceFactory.obj \
.\$(OBJDIR)\nsRDFDOMResourceFactory.obj \
.\$(OBJDIR)\nsRDFDOMViewerUtils.obj \
$(NULL)
LLIBS= \
$(DIST)\lib\rdfutil_s.lib \
$(DIST)\lib\xpcom.lib \
$(LIBNSPR)
include <$(DEPTH)\config\rules.mak>
install:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin\components
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib
clobber::
rm -rf $(DIST)\bin\components\$(LIBNAME).$(DLL_SUFFIX)
rm -rf $(DIST)\lib\$(LIBNAME).$(LIB_SUFFIX)

View File

@@ -0,0 +1,37 @@
/* -*- Mode: IDL; 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 "nsISupports.idl"
#include "domstubs.idl"
%{C++
#include "nsIDOMWindow.h"
#include "nsIDOMNode.h"
%}
[scriptable, uuid(0b96297e-2459-11d3-8aad-006008948010)]
interface nsIDOMDataSource : nsISupports {
void setMode(in string mode, in boolean active);
boolean getMode(in string mode);
void setWindow(in nsIDOMWindow window);
};

View 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 nsISupports object;
};

View File

@@ -0,0 +1,35 @@
/* -*- Mode: idl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsISupports.idl"
#include "nsIRDFResource.idl"
%{C++
#include "nsString.h"
%}
[ref] native nsStringRef(nsString);
[scriptable, uuid(1ff615aa-7328-11d3-90a0-00a0c900d445)]
interface nsIRDFDOMViewerObject : nsISupports {
void setTarget(in nsIRDFResource property, in nsIRDFNode value);
[noscript] void setTargetLiteral(in nsIRDFResource property,
in nsStringRef str);
nsIRDFNode getTarget(in nsIRDFResource property);
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,198 @@
/* -*- 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 __nsRDFDOMDataSource_h
#define __nsRDFDOMDataSource_h
#include "nsIRDFDataSource.h"
#include "nsIDOMDataSource.h"
#include "nsIRDFService.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIDOMDocument.h"
//
#include "nsIDOMNode.h"
#include "nsIContent.h"
#include "nsIStyledContent.h"
#include "nsIDOMCSSRule.h"
#include "nsIDOMCSSStyleRule.h"
#include "nsIDOMHTMLElement.h"
#include "nsICSSStyleRule.h"
#include "nsIStyleRule.h"
#include "nsIFrame.h"
/* {c7cf77e8-245a-11d3-80f0-006008948010} */
#define NS_RDF_DOMDATASOURCE_CID \
{0xc7cf77e8, 0x245a, 0x11d3, \
{0x80, 0xf0, 0x00, 0x60, 0x08, 0x94, 0x80, 0x10}}
class nsRDFDOMDataSource : public nsIRDFDataSource,
public nsIDOMDataSource
{
public:
nsRDFDOMDataSource();
virtual ~nsRDFDOMDataSource();
NS_DECL_ISUPPORTS
NS_DECL_NSIRDFDATASOURCE
NS_DECL_NSIDOMDATASOURCE
static NS_METHOD Create(nsISupports* aOuter,
const nsIID& iid,
void **result);
protected:
char *mURI;
nsIRDFService *getRDFService();
static PRBool assertEnumFunc(void *aElement, void *aData);
static PRBool unassertEnumFunc(void *aElement, void *aData);
nsresult NotifyObservers(nsIRDFResource *subject, nsIRDFResource *property,
nsIRDFNode *object, PRBool assert);
private:
// HTML stuff
nsresult createHTMLElementArcs(nsIDOMHTMLElement *element,
nsISupportsArray *arcs);
nsresult createFrameArcs(nsIFrame *frame,
nsISupportsArray *arcs);
// DOM stuff
nsresult createDOMNodeArcs(nsIDOMNode *node,
nsISupportsArray *arcs);
nsresult createDOMAttributeArcs(nsIDOMNode *node,
nsISupportsArray *arcs);
nsresult createDOMChildArcs(nsIDOMNode *node,
nsISupportsArray *arcs);
nsresult createDOMNodeListArcs(nsIDOMNodeList *nodelist,
nsISupportsArray *arcs);
nsresult createDOMNamedNodeMapArcs(nsIDOMNamedNodeMap *nodelist,
nsISupportsArray *arcs);
nsresult createFrameTarget(nsIFrame *frame,
nsIRDFResource *property,
nsIRDFNode **aResult);
nsresult createDOMNodeTarget(nsIDOMNode *node,
nsIRDFResource *property,
nsIRDFNode **aResult);
// nsIContent stuff
nsresult createContentArcs(nsIContent *content,
nsISupportsArray *arcs);
nsresult createContentChildArcs(nsIContent *content,
nsISupportsArray *arcs);
nsresult createContentAttributeArcs(nsIContent *content,
nsISupportsArray *arcs);
nsresult createContentMiscArcs(nsIContent* content,
nsISupportsArray *arcs);
nsresult createContentTarget(nsIContent *content,
nsIRDFResource *property,
nsIRDFNode **aResult);
// nsIStyledContent stuff
nsresult createStyledContentArcs(nsIStyledContent *content,
nsISupportsArray *arcs);
nsresult createStyledContentClassArcs(nsIStyledContent *content,
nsISupportsArray *arcs);
nsresult createStyledContentTarget(nsIStyledContent *content,
nsIRDFResource *property,
nsIRDFNode **aResult);
// nsIDOMCSSStyleDeclaration
nsresult getDOMCSSStyleDeclTarget(nsIDOMCSSStyleDeclaration *decl,
nsIRDFResource *property,
nsIRDFNode **aResult);
// nsIDOMCSSStyleRule
// nsIDOMCSSRule
nsresult getDOMCSSStyleRuleTarget(nsIDOMCSSStyleRule *rule,
nsIRDFResource *property,
nsIRDFNode **result);
nsresult getDOMCSSRuleTarget(nsIDOMCSSRule *rule,
nsIRDFResource *property,
nsIRDFNode **result);
// nsICSSStyleRule
// nsICSSRule
// nsIStyleRule
nsresult getCSSStyleRuleTarget(nsICSSStyleRule *rule,
nsIRDFResource *property,
nsIRDFNode **result);
nsresult getCSSRuleTarget(nsICSSRule *rule,
nsIRDFResource *property,
nsIRDFNode **result);
nsresult getStyleRuleTarget(nsIStyleRule *rule,
nsIRDFResource *property,
nsIRDFNode **result);
// helper routines
nsresult createArcsFromSupportsArray(nsISupportsArray *rules,
nsISupportsArray *arcs);
nsresult getResourceForObject(nsISupports *object,
nsIRDFResource **resource);
nsresult appendLeafObject(nsString& name,
nsString& value,
nsISupportsArray *arcs);
nsresult getTargetForKnownObject(nsISupports *object,
nsIRDFResource* aProperty,
nsIRDFNode **result);
nsresult getTargetsForKnownObject(nsISupports *object,
nsIRDFResource *aProperty,
PRBool useDOM,
nsISupportsArray *arcs);
nsresult createLiteral(nsString& str, nsIRDFNode **result);
// member variables
PRBool init;
nsIRDFService *mRDFService;
PRInt32 mMode;
nsVoidArray *mObservers;
nsSupportsHashtable objectTable;
nsHashtable mModeTable;
nsCOMPtr<nsIDOMDocument> mDocument;
nsIFrame *mRootFrame;
nsIRDFResource* kNC_Name;
nsIRDFResource* kNC_Value;
nsIRDFResource* kNC_Type;
nsIRDFResource* kNC_Child;
nsIRDFResource* kNC_DOMRoot;
};
#endif

View File

@@ -0,0 +1,101 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsIGenericFactory.h"
#include "nsRDFDOMDataSource.h"
#include "nsRDFDOMResourceFactory.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "rdf.h"
#ifdef NS_DEBUG
#include <stdio.h>
#endif
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);
// return the proper factory to the caller
extern "C" PR_IMPLEMENT(nsresult)
NSGetFactory(nsISupports* aServMgr,
const nsCID &aClass,
const char* aClassName,
const char* aProgID,
nsIFactory **aFactory)
{
nsresult rv=NS_OK;
nsIGenericFactory* fact;
if (aClass.Equals(kRDFDOMDataSourceCID)) {
rv = NS_NewGenericFactory(&fact, nsRDFDOMDataSource::Create);
printf("Creating datasource: %s\n", NS_SUCCEEDED(rv) ? "succeed" : "failed");
} else
if (aClass.Equals(kRDFDOMResourceFactoryCID)) {
rv = NS_NewGenericFactory(&fact, nsRDFDOMViewerElement::Create);
printf("Creating resource: %s\n", NS_SUCCEEDED(rv) ? "succeed" : "failed");
}
else
rv = NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv))
*aFactory = fact;
#ifdef DEBUG_alecf
printf("nsRDFDOMDataSource's NSGetFactory!\n");
#endif
return rv;
}
extern "C" PR_IMPLEMENT(nsresult)
NSRegisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
NS_WITH_SERVICE1(nsIComponentManager,
compMgr,
aServMgr,
kComponentManagerCID,
&rv);
if (NS_FAILED(rv)) return rv;
printf("Registering DOM Viewer\n");
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 "object",
aPath, PR_TRUE, PR_TRUE);
return rv;
}
extern "C" PR_IMPLEMENT(nsresult)
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
{
nsresult rv;
NS_WITH_SERVICE1(nsIComponentManager, compMgr,
aServMgr, kComponentManagerCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = compMgr->UnregisterComponent(kRDFDOMDataSourceCID, aPath);
rv = compMgr->UnregisterComponent(kRDFDOMResourceFactoryCID, aPath);
return rv;
}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* The contents of this file are subject to the Netscape Public
* License Version 1.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 "nsRDFDOMResourceFactory.h"
nsRDFDOMViewerElement::nsRDFDOMViewerElement()
{
}
nsRDFDOMViewerElement::~nsRDFDOMViewerElement()
{
}
NS_IMPL_ISUPPORTS_INHERITED(nsRDFDOMViewerElement, nsRDFResource, nsIDOMViewerElement)
NS_IMETHODIMP
nsRDFDOMViewerElement::SetObject(nsISupports* object)
{
mObject = do_QueryInterface(object);
return NS_OK;
}
NS_IMETHODIMP
nsRDFDOMViewerElement::GetObject(nsISupports** object)
{
if (!object) return NS_ERROR_NULL_POINTER;
*object = mObject;
NS_IF_ADDREF(*object);
return NS_OK;
}
NS_METHOD
nsRDFDOMViewerElement::Create(nsISupports* aOuter,
const nsIID& iid,
void **result) {
nsRDFDOMViewerElement* ve = new nsRDFDOMViewerElement();
if (!ve) return NS_ERROR_NULL_POINTER;
NS_ADDREF(ve);
nsresult rv = ve->QueryInterface(iid, result);
NS_RELEASE(ve);
return rv;
}

View File

@@ -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, 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"
#include "nscore.h"
#include "nsCOMPtr.h"
#include "nsWeakPtr.h"
#include "rdf.h"
#include "nsRDFResource.h"
#include "nsIDOMViewerElement.h"
class nsRDFDOMViewerElement : nsRDFResource,
nsIDOMViewerElement
{
public:
nsRDFDOMViewerElement();
virtual ~nsRDFDOMViewerElement();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMVIEWERELEMENT
static NS_METHOD
Create(nsISupports* aOuter,const nsIID& iid, void **result);
private:
//nsWeakPtr mObject;
nsCOMPtr<nsISupports> mObject;
};
/* {84a87046-57f4-11d3-9061-00a0c900d445} */
#define NS_RDF_DOMRESOURCEFACTORY_CID \
{0x84a87046, 0x57f4, 0x11d3, \
{ 0x90, 0x61, 0x0, 0xa0, 0xc9, 0x0, 0xd4, 0x45 }}
#endif

View File

@@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "rdf.h"
#include "nsIRDFService.h"
#include "nsRDFDOMViewerUtils.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
nsDOMViewerObject::nsDOMViewerObject() {}
nsDOMViewerObject::~nsDOMViewerObject()
{
targets.Reset();
}
NS_IMPL_ISUPPORTS1(nsDOMViewerObject,
nsIRDFDOMViewerObject)
NS_IMETHODIMP
nsDOMViewerObject::SetTarget(nsIRDFResource *aProperty,
nsIRDFNode *aValue)
{
nsISupportsKey propKey(aProperty);
targets.Put(&propKey, (void *)aValue);
return NS_OK;
}
NS_IMETHODIMP
nsDOMViewerObject::SetTargetLiteral(nsIRDFResource *aProperty,
nsString& str)
{
nsresult rv;
NS_WITH_SERVICE(nsIRDFService, rdf, NS_RDF_PROGID "/rdf-service", &rv);
PRUnichar* uniStr = str.ToNewUnicode();
nsCOMPtr<nsIRDFLiteral> literal;
rv = rdf->GetLiteral(uniStr, getter_AddRefs(literal));
nsAllocator::Free(uniStr);
SetTarget(aProperty, literal);
return NS_OK;
}
nsresult
nsDOMViewerObject::GetTarget(nsIRDFResource *aProperty,
nsIRDFNode **aValue)
{
nsISupportsKey propKey(aProperty);
*aValue = (nsIRDFResource*)targets.Get(&propKey);
return NS_OK;
}
nsresult
NS_NewDOMViewerObject(const nsIID& iid, void ** aResult) {
nsresult rv;
nsDOMViewerObject* obj = new nsDOMViewerObject;
NS_ADDREF(obj);
rv = obj->QueryInterface(iid, aResult);
NS_RELEASE(obj);
return rv;
}

View File

@@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* a really lame-ass last resort for putting objects in the tree
* use only if there really is no object */
#include "nsIRDFDOMViewerObject.h"
#include "nsHashtable.h"
class nsDOMViewerObject : nsIRDFDOMViewerObject {
public:
nsDOMViewerObject();
virtual ~nsDOMViewerObject();
NS_DECL_ISUPPORTS
NS_DECL_NSIRDFDOMVIEWEROBJECT
private:
nsSupportsHashtable targets;
};
nsresult
NS_NewDOMViewerObject(const nsIID& iid, void ** result);

View File

@@ -0,0 +1,42 @@
treeitem[Type="1"] {
color: green;
}
treeitem[Type="2"] {
color: red;
}
treeitem[Type="3"] {
color: blue;
}
treeitem[Type="leaf"] {
color: black;
}
treeitem[Type~="content"] {
color: green;
font-style: italic;
}
treeitem[Type="contentAttribute"] {
color: red;
font-style: italic;
}
treeitem[Type="contentStyleRule"] {
color: orange;
font-style: italic;
}
treeitem[Type="style"] {
color: brown;
font-style: italic;
}
treeitem[Type="contentMisc"] {
color:black;
font-style: italic;
}

View File

@@ -0,0 +1,61 @@
/* -*- 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.
*/
var RDF = Components.classes['component://netscape/rdf/rdf-service'].getService();
RDF = RDF.QueryInterface(Components.interfaces.nsIRDFService);
var domds;
function loadUrl() {
var urlwidget = document.getElementById("url");
if (!urlwidget)
url = "resource:/res/samples/rdf/domviewer.html";
else
url = urlwidget.value;
dump("Loading " + url + " into " + parent.window.frames["srcdoc"] +"\n");
var win = window.frames["srcdoc"];
win.location=url;
}
function setMode(mode, active) {
domds.setMode(mode, active);
}
function refreshTree() {
dump("refresh..\n");
var win = window.frames["srcdoc"];
domds.setWindow(win);
var tree = document.getElementById("dataSourceTree");
tree.clearItemSelection();
tree.setAttribute("ref","NC:DOMRoot");
}
function onSrcLoaded() {
var ds = RDF.GetDataSource("rdf:domds");
domds = ds.QueryInterface(Components.interfaces.nsIDOMDataSource);
}

View File

@@ -0,0 +1,67 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="DOMDataSourceViewer.css" type="text/css"?>
<window
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="onSrcLoaded();"
alignment="horizontal"
title="DOM Viewer">
<html:script language="JavaScript" src="DOMDataSourceViewer.js"/>
<box align="vertical" flex="30%">
<html:input value="resource:/res/samples/rdf/domviewer.html" type="text" name="url" id="url" onkeyup="if (event.which == 13) loadUrl();"/>
<html:div>
Show:
<html:input type="checkbox" onclick="setMode('content', !event.target.checked);"/>
Content
<html:input type="checkbox" onclick="setMode('dom', !event.target.checked);"/>
DOM
<html:input type="checkbox" onclick="setMode('frame', !event.target.checked);"/> Frames
<html:input type="checkbox" onclick="setMode('leaf', !event.target.checked);"/>
OOB data
</html:div>
<box align="horizontal">
<titledbutton onclick="loadUrl();" value="Load"/>
<titledbutton onclick="refreshTree();" value="Refresh"/>
</box>
<html:div flex="100%">
<tree style="height:100%"
rdf:datasources="rdf:domds"
id="dataSourceTree">
<template>
<rule>
<treechildren>
<treeitem uri="..."
Type="rdf:http://home.netscape.com/NC-rdf#Type">
<treerow>
<treecell indent="true" value="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Value"/>
</treerow>
</treeitem>
</treechildren>
</rule>
<treechildren>
<treeitem id="NC:DOMRoot"/>
</treechildren>
</template>
<treecol style="width: 50%" id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
<treecol style="width: 50%" id="ValueColumn" rdf:resource="http://home.netscape.com/NC-rdf#Value"/>
<treehead>
<treerow>
<treecell value="Name"/>
<treecell value="Value"/>
</treerow>
</treehead>
</tree>
</html:div>
</box>
<splitter collapse="before" persist="state hidden" chromeclass="extrachrome"/>
<html:iframe onload="onSrcLoaded();" name="srcdoc" src="resource:/res/samples/rdf/domviewer.html" flex="73%"/>
</window>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="DOMDataSourceViewer.css" type="text/css"?>
<!DOCTYPE window>
<window
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
</window>

View File

@@ -0,0 +1,5 @@
DOMDataSourceViewer.xul
DOMDataSourceViewer.css
DOMTree.xul
domviewer.html
DOMDataSourceViewer.js

View File

@@ -0,0 +1,43 @@
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = rdfdomds
SAMPLES_DIR = $(DIST)/bin/res/samples/rdf
RESOURCE_SAMPLES = \
DOMDataSourceViewer.xul \
DOMDataSourceViewer.css \
DOMDataSourceViewer.js \
DOMTree.xul \
domviewer.html \
$(NULL)
include $(topsrcdir)/config/rules.mk
GARBAGE += $(addprefix $(SAMPLES_DIR)/, $(RESOURCE_SAMPLES))
install::
$(INSTALL) $(addprefix $(srcdir)/,$(RESOURCE_SAMPLES)) $(SAMPLES_DIR)

View File

@@ -0,0 +1,21 @@
<html>
<title>How to use the DOM Viewer</title>
<body>
<h2>
How to use the DOM Viewer
</h2>
<hr>
<p>
click the <b>Refresh</b> button to view the dom for the page loaded in this frame.
</p>
<b>(try it now on this page!)</b></p>
<p>
to load a new page, enter it in the text area. hit enter or click the <b>Load</b> button.</p>
<p>
Then browse the DOM!</p>
<p>questions / comments to <a href=mailto:alecf@netscape.com>alecf</a><p>
</body>
</html>

View File

@@ -0,0 +1,37 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..\..
MODULE=rdfdomds
SAMPLES_DIR = $(DIST)/bin/res/samples/rdf
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) DOMDataSourceViewer.css $(SAMPLES_DIR)
$(MAKE_INSTALL) DOMDataSourceViewer.js $(SAMPLES_DIR)
$(MAKE_INSTALL) DOMDataSourceViewer.xul $(SAMPLES_DIR)
$(MAKE_INSTALL) DOMTree.xul $(SAMPLES_DIR)
$(MAKE_INSTALL) domviewer.html $(SAMPLES_DIR)
clobber::
rm -f $(SAMPLES_DIR)\DOMDataSourceViewer.css
rm -f $(SAMPLES_DIR)\DOMDataSourceViewer.js
rm -f $(SAMPLES_DIR)\DOMDataSourceViewer.xul
rm -f $(SAMPLES_DIR)\DOMTree.xul
rm -f $(SAMPLES_DIR)\domviewer.html