land new DOMViewer branch

no reviewer, not part of product, just a test
This commit is contained in:
alecf%netscape.com 1999-10-19 02:46:45 +00:00
parent 8d1afc2f92
commit 9253dd3ab3
14 changed files with 1096 additions and 341 deletions

View File

@ -32,11 +32,13 @@ CPPSRCS = \
nsRDFDOMDataSource.cpp \
nsRDFDOMDataSourceFactory.cpp \
nsRDFDOMResourceFactory.cpp \
nsRDFDOMViewerUtils.cpp \
$(NULL)
XPIDLSRCS = \
nsIDOMDataSource.idl \
nsIDOMViewerElement.idl \
nsIRDFDOMViewerObject.idl \
$(NULL)
EXTRA_DSO_LDOPTS = \

View File

@ -24,12 +24,14 @@ 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= \

View File

@ -28,6 +28,10 @@
[scriptable, uuid(0b96297e-2459-11d3-8aad-006008948010)]
interface nsIDOMDataSource : nsISupports {
void SetWindow(in nsIDOMWindow window);
void setMode(in string mode, in boolean active);
boolean getMode(in string mode);
void setWindow(in nsIDOMWindow window);
};

View File

@ -8,6 +8,6 @@
[scriptable, uuid(2842a0ba-4bd8-11d3-ac84-00a0c900d445)]
interface nsIDOMViewerElement : nsISupports {
attribute nsIDOMNode node;
attribute nsISupports object;
};

File diff suppressed because it is too large Load Diff

View File

@ -27,9 +27,20 @@
#include "nsIRDFService.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsIDOMNode.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 \
@ -44,123 +55,10 @@ class nsRDFDOMDataSource : public nsIRDFDataSource,
virtual ~nsRDFDOMDataSource();
NS_DECL_ISUPPORTS
/* void Init (in string uri); */
NS_IMETHOD Init(const char *uri);
/* readonly attribute string URI; */
NS_IMETHOD GetURI(char * *aURI);
NS_DECL_NSIRDFDATASOURCE
/* nsIRDFResource GetSource (in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD GetSource(nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
nsIRDFResource **_retval);
/* nsISimpleEnumerator GetSources (in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD GetSources(nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
nsISimpleEnumerator **_retval);
/* nsIRDFNode GetTarget (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue); */
NS_IMETHOD GetTarget(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
PRBool aTruthValue,
nsIRDFNode **_retval);
/* nsISimpleEnumerator GetTargets (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in boolean aTruthValue); */
NS_IMETHOD GetTargets(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
PRBool aTruthValue,
nsISimpleEnumerator **_retval);
/* void Assert (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD Assert(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue);
/* void Unassert (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget); */
NS_IMETHOD Unassert(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget);
/* boolean HasAssertion (in nsIRDFResource aSource,
in nsIRDFResource aProperty,
in nsIRDFNode aTarget,
in boolean aTruthValue); */
NS_IMETHOD HasAssertion(nsIRDFResource *aSource,
nsIRDFResource *aProperty,
nsIRDFNode *aTarget,
PRBool aTruthValue,
PRBool *_retval);
/* void AddObserver (in nsIRDFObserver aObserver); */
NS_IMETHOD AddObserver(nsIRDFObserver *aObserver);
/* void RemoveObserver (in nsIRDFObserver aObserver); */
NS_IMETHOD RemoveObserver(nsIRDFObserver *aObserver);
/* nsISimpleEnumerator ArcLabelsIn (in nsIRDFNode aNode); */
NS_IMETHOD ArcLabelsIn(nsIRDFNode *aNode,
nsISimpleEnumerator **_retval);
/* nsISimpleEnumerator ArcLabelsOut (in nsIRDFResource aSource); */
NS_IMETHOD ArcLabelsOut(nsIRDFResource *aSource,
nsISimpleEnumerator **_retval);
/* nsISimpleEnumerator GetAllResources (); */
NS_IMETHOD GetAllResources(nsISimpleEnumerator **_retval);
/* void Flush (); */
NS_IMETHOD Flush();
/* nsIEnumerator GetAllCommands (in nsIRDFResource aSource); */
NS_IMETHOD GetAllCommands(nsIRDFResource *aSource,
nsIEnumerator **_retval);
/* nsISimpleEnumerator GetAllCmds (in nsIRDFResource aSource); */
NS_IMETHOD GetAllCmds(nsIRDFResource *aSource,
nsISimpleEnumerator **_retval);
/* boolean IsCommandEnabled (in nsISupportsArray aSources,
in nsIRDFResource aCommand,
in nsISupportsArray aArguments); */
NS_IMETHOD IsCommandEnabled(nsISupportsArray *aSources,
nsIRDFResource *aCommand,
nsISupportsArray *aArguments,
PRBool *_retval);
/* void DoCommand (in nsISupportsArray aSources,
in nsIRDFResource aCommand,
in nsISupportsArray aArguments); */
NS_IMETHOD DoCommand(nsISupportsArray *aSources,
nsIRDFResource *aCommand,
nsISupportsArray *aArguments);
NS_IMETHOD SetWindow(nsIDOMWindow *window);
NS_IMETHOD Change(nsIRDFResource*, nsIRDFResource*,
nsIRDFNode*, nsIRDFNode*)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD Move(nsIRDFResource*, nsIRDFResource*,
nsIRDFResource*, nsIRDFNode*)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_DECL_NSIDOMDATASOURCE
static NS_METHOD Create(nsISupports* aOuter,
const nsIID& iid,
@ -177,17 +75,124 @@ class nsRDFDOMDataSource : public nsIRDFDataSource,
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

@ -31,26 +31,21 @@ nsRDFDOMViewerElement::~nsRDFDOMViewerElement()
NS_IMPL_ISUPPORTS_INHERITED(nsRDFDOMViewerElement, nsRDFResource, nsIDOMViewerElement)
NS_IMETHODIMP
nsRDFDOMViewerElement::SetNode(nsIDOMNode* node)
nsRDFDOMViewerElement::SetObject(nsISupports* object)
{
mNode = node;
mObject = do_QueryInterface(object);
return NS_OK;
}
NS_IMETHODIMP
nsRDFDOMViewerElement::GetNode(nsIDOMNode** node)
nsRDFDOMViewerElement::GetObject(nsISupports** object)
{
if (!node) return NS_ERROR_NULL_POINTER;
if (!object) return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
if (mNode) {
*node = mNode;
NS_ADDREF(*node);
}
else {
*node = nsnull;
}
return rv;
*object = mObject;
NS_IF_ADDREF(*object);
return NS_OK;
}
NS_METHOD

View File

@ -29,7 +29,6 @@
#include "rdf.h"
#include "nsRDFResource.h"
#include "nsIDOMViewerElement.h"
#include "nsIDOMNode.h"
class nsRDFDOMViewerElement : nsRDFResource,
nsIDOMViewerElement
@ -46,9 +45,8 @@ public:
Create(nsISupports* aOuter,const nsIID& iid, void **result);
private:
// weak reference to DOM node
//nsWeakPtr mNode;
nsCOMPtr<nsIDOMNode> mNode;
//nsWeakPtr mObject;
nsCOMPtr<nsISupports> mObject;
};
/* {84a87046-57f4-11d3-9061-00a0c900d445} */

View File

@ -7,6 +7,36 @@ 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

@ -21,6 +21,8 @@
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");
@ -36,25 +38,24 @@ function loadUrl() {
}
function refreshTree() {
var ds = RDF.GetDataSource("rdf:domds");
var domds = ds.QueryInterface(Components.interfaces.nsIDOMDataSource);
var win = window.frames["srcdoc"];
domds.SetWindow(win);
var treeframe = window.frames["treeframe"];
var tree = treeframe.document.getElementById("dataSourceTree");
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");
var domds = ds.QueryInterface(Components.interfaces.nsIDOMDataSource);
var win = window.frames["srcdoc"];
domds.SetWindow(win);
dump("window done loading.\n");
domds = ds.QueryInterface(Components.interfaces.nsIDOMDataSource);
}

View File

@ -12,12 +12,55 @@
<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:iframe flex="100%" src="DOMTree.xul" name="treeframe"/>
<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

@ -7,39 +7,4 @@
xmlns:html="http://www.w3.org/TR/REC-html40"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<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"/>
<treecell value="rdf:http://home.netscape.com/NC-rdf#Type"/>
</treerow>
</treeitem>
</treechildren>
</rule>
<treechildren>
<treeitem id="NC:DOMRoot"/>
</treechildren>
</template>
<treecol style="width: 40%" 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"/>
<treecol style="width: 10%" id="TypeColumn" rdf:resource="http://home.netscape.com/NC-rdf#Type"/>
<treehead>
<treerow>
<treecell value="Name"/>
<treecell value="Value"/>
<treecell value="Type"/>
</treerow>
</treehead>
</tree>
</html:div>
</window>